diff options
author | tkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7> | 2013-04-10 19:05:15 +0000 |
---|---|---|
committer | tkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7> | 2013-04-10 19:05:15 +0000 |
commit | 74577792ca14945ad08d2d8edd5d79c585d416ce (patch) | |
tree | 78affb294db31b627343c8c7c91785d352610c08 /pdf-over-gui/src/main/java/at/asit | |
parent | 345a74e64c4ab22ef9482c0d04c13ac9e8b63e00 (diff) | |
download | pdf-over-74577792ca14945ad08d2d8edd5d79c585d416ce.tar.gz pdf-over-74577792ca14945ad08d2d8edd5d79c585d416ce.tar.bz2 pdf-over-74577792ca14945ad08d2d8edd5d79c585d416ce.zip |
Make sig placeholder transparent
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@122 174cde9d-5d70-4d2a-aa98-46368bc2aaf7
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit')
-rw-r--r-- | pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java index f4e4f240..7fee3021 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java +++ b/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 { |