From 2ab0add6e4ea56ab12e69a48b758cd0861625185 Mon Sep 17 00:00:00 2001 From: tkellner Date: Wed, 31 Oct 2012 16:36:43 +0000 Subject: Make signature placeholder transparency configurable git-svn-id: https://svn.iaik.tugraz.at/svn/egiz/prj/current/12PDF-OVER-4.0@12714 3a0b52a2-8410-0410-bc02-ff6273a87459 --- .../asit/pdfover/gui/composites/SignaturePanel.java | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java') 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 f2c2c798..b2f5270f 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 @@ -50,9 +50,6 @@ 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 */ @@ -75,6 +72,10 @@ public class SignaturePanel extends JPanel { private Image sigPlaceholder = null; /** Current scaled signature placeholder image */ BufferedImage sigPlaceholderScaled = null; + /** Transparency of the signature placeholder (0-255) */ + private int sigPlaceholderTransparency = 170; + /** Previous Transparency of the signature placeholder */ + private int prevSigPlaceholderTransparency = 0; /** Width of the signature placeholder in page space */ private int sigPageWidth = 0; /** Height of the signature placeholder in page space */ @@ -116,12 +117,13 @@ public class SignaturePanel extends JPanel { * @param placeholder signature placeholder * @param width width of the placeholder in page space * @param height height of the placeholder in page space + * @param transparency transparency of the signature placeholder (0 - 255) */ - public void setSignaturePlaceholder(Image placeholder, int width, int height) - { + public void setSignaturePlaceholder(Image placeholder, int width, int height, int transparency) { this.sigPlaceholder = placeholder; this.sigPageWidth = width; this.sigPageHeight = height; + this.sigPlaceholderTransparency = transparency; } /** @@ -253,12 +255,15 @@ public class SignaturePanel extends JPanel { g.drawRect(sigX, sigY, 100, 40); } else { - if ((this.sigScreenWidth != this.prevSigScreenWidth) - || (this.sigScreenHeight != this.prevSigScreenHeight)) + if ( + (this.sigScreenWidth != this.prevSigScreenWidth) || + (this.sigScreenHeight != this.prevSigScreenHeight) || + (this.sigPlaceholderTransparency != this.prevSigPlaceholderTransparency)) { // redraw scaled transparent placeholder this.prevSigScreenWidth = this.sigScreenWidth; this.prevSigScreenHeight = this.sigScreenHeight; + this.prevSigPlaceholderTransparency = this.sigPlaceholderTransparency; Image placeholder = this.sigPlaceholder.getScaledInstance( this.sigScreenWidth, this.sigScreenHeight, Image.SCALE_SMOOTH); this.sigPlaceholderScaled = new BufferedImage(this.sigScreenWidth, this.sigScreenHeight, BufferedImage.TYPE_INT_ARGB); @@ -269,7 +274,7 @@ public class SignaturePanel extends JPanel { 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); + c = new Color(c.getRed(), c.getGreen(), c.getBlue(), this.sigPlaceholderTransparency); phpixels[i] = c.getRGB(); } this.sigPlaceholderScaled.setRGB(0, 0, this.sigScreenWidth, this.sigScreenHeight, phpixels, 0, this.sigScreenWidth); -- cgit v1.2.3