summaryrefslogtreecommitdiff
path: root/trunk/pdf-over-gui/src/main/java/at
diff options
context:
space:
mode:
authortkellner <tkellner@3a0b52a2-8410-0410-bc02-ff6273a87459>2012-10-31 16:36:41 +0000
committertkellner <tkellner@3a0b52a2-8410-0410-bc02-ff6273a87459>2012-10-31 16:36:41 +0000
commitb0b3d5e20859073097d95cefa92da52f7e620d8d (patch)
treec3b509218b9e53ff85850fa075af73f88063fbe7 /trunk/pdf-over-gui/src/main/java/at
parent72697fcaf89382ac5fd3568ffac4ec37d4c40b7a (diff)
downloadpdf-over-b0b3d5e20859073097d95cefa92da52f7e620d8d.tar.gz
pdf-over-b0b3d5e20859073097d95cefa92da52f7e620d8d.tar.bz2
pdf-over-b0b3d5e20859073097d95cefa92da52f7e620d8d.zip
Make sig placeholder transparent
git-svn-id: https://svn.iaik.tugraz.at/svn/egiz/prj/current/12PDF-OVER-4.0@12708 3a0b52a2-8410-0410-bc02-ff6273a87459
Diffstat (limited to 'trunk/pdf-over-gui/src/main/java/at')
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java35
1 files changed, 32 insertions, 3 deletions
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java
index f4e4f240..7fee3021 100644
--- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java
+++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java
@@ -27,6 +27,7 @@ import java.awt.geom.AffineTransform;
import java.awt.geom.NoninvertibleTransformException;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
import javax.swing.JPanel;
@@ -49,6 +50,9 @@ public class SignaturePanel extends JPanel {
/** Default serial version ID */
private static final long serialVersionUID = 1L;
+ /** Signature transparency (0-255) */
+ private static final int SIG_TRANSPARENCY = 170;
+
/** The PDF file being displayed */
private PDFFile pdf = null;
/** The image of the rendered PDF page being displayed */
@@ -69,6 +73,8 @@ public class SignaturePanel extends JPanel {
Point2D sigScreenPos = null;
/** The signature placeholder image */
private Image sigPlaceholder = null;
+ /** Current scaled signature placeholder image */
+ BufferedImage sigPlaceholderScaled = null;
/** Width of the signature placeholder in page space */
private int sigPageWidth = 0;
/** Height of the signature placeholder in page space */
@@ -77,6 +83,10 @@ public class SignaturePanel extends JPanel {
int sigScreenWidth = 0;
/** Height of the signature placeholder in screen space */
int sigScreenHeight = 0;
+ /** Previous Width of the signature placeholder in screen space */
+ int prevSigScreenWidth = 0;
+ /** Previous Height of the signature placeholder in screen space */
+ int prevSigScreenHeight = 0;
/**
* Create a new PagePanel, with a default size of 800 by 600 pixels.
@@ -242,9 +252,28 @@ public class SignaturePanel extends JPanel {
g.drawRect(sigX, sigY, 100, 40);
}
else {
- Image placeholder = this.sigPlaceholder.getScaledInstance(
- this.sigScreenWidth, this.sigScreenHeight, Image.SCALE_SMOOTH);
- g.drawImage(placeholder, sigX, sigY, null);
+ if ((this.sigScreenWidth != this.prevSigScreenWidth)
+ || (this.sigScreenHeight != this.prevSigScreenHeight))
+ {
+ this.prevSigScreenWidth = this.sigScreenWidth;
+ this.prevSigScreenHeight = this.sigScreenHeight;
+ Image placeholder = this.sigPlaceholder.getScaledInstance(
+ this.sigScreenWidth, this.sigScreenHeight, Image.SCALE_SMOOTH);
+ this.sigPlaceholderScaled = new BufferedImage(this.sigScreenWidth, this.sigScreenHeight, BufferedImage.TYPE_INT_ARGB);
+ Graphics g2 = this.sigPlaceholderScaled.getGraphics();
+ g2.drawImage(placeholder, 0, 0, null);
+ int[] phpixels = new int[this.sigScreenWidth * this.sigScreenHeight];
+ phpixels = this.sigPlaceholderScaled.getRGB(0, 0, this.sigScreenWidth, this.sigScreenHeight, phpixels, 0, this.sigScreenWidth);
+ for (int i = 0; i < phpixels.length; ++i) {
+ Color c = new Color(phpixels[i]);
+ c = new Color(c.getRed(), c.getGreen(), c.getBlue(), SIG_TRANSPARENCY);
+ phpixels[i] = c.getRGB();
+ }
+ this.sigPlaceholderScaled.setRGB(0, 0, this.sigScreenWidth, this.sigScreenHeight, phpixels, 0, this.sigScreenWidth);
+ }
+ g.drawImage(this.sigPlaceholderScaled, sigX, sigY, null);
+ g.setColor(Color.BLUE);
+ g.drawRect(sigX, sigY, this.sigScreenWidth, this.sigScreenHeight);
}
} else {