diff options
author | tkellner <tkellner@3a0b52a2-8410-0410-bc02-ff6273a87459> | 2012-10-31 16:37:07 +0000 |
---|---|---|
committer | tkellner <tkellner@3a0b52a2-8410-0410-bc02-ff6273a87459> | 2012-10-31 16:37:07 +0000 |
commit | 227dad8b1a4be54f69c15c1a329a004890ab8e78 (patch) | |
tree | ea2b02fbab8fc8b74ff6c0ee452aeee614af4549 | |
parent | 20c15ef5565b98798767373077da946bb9cd7216 (diff) | |
download | pdf-over-227dad8b1a4be54f69c15c1a329a004890ab8e78.tar.gz pdf-over-227dad8b1a4be54f69c15c1a329a004890ab8e78.tar.bz2 pdf-over-227dad8b1a4be54f69c15c1a329a004890ab8e78.zip |
Draw signature overlay string
git-svn-id: https://svn.iaik.tugraz.at/svn/egiz/prj/current/12PDF-OVER-4.0@12781 3a0b52a2-8410-0410-bc02-ff6273a87459
-rw-r--r-- | trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java | 24 | ||||
-rw-r--r-- | trunk/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties | 1 |
2 files changed, 22 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 353b2b66..a259d3e1 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 @@ -21,6 +21,7 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Image; +import java.awt.Rectangle; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.geom.AffineTransform; @@ -330,10 +331,27 @@ public class SignaturePanel extends JPanel { this.prevSigPlaceholderTransparency = this.sigPlaceholderTransparency; Image placeholder = this.sigPlaceholder.getScaledInstance( this.sigScreenWidth, this.sigScreenHeight, Image.SCALE_SMOOTH); + + //Make placeholder transparent this.sigPlaceholderScaled = new BufferedImage(this.sigScreenWidth, this.sigScreenHeight, BufferedImage.TYPE_INT_ARGB); - Graphics g2 = this.sigPlaceholderScaled.getGraphics(); - g2.drawImage(placeholder, 0, 0, null); - g2.dispose(); + Graphics g_phs = this.sigPlaceholderScaled.getGraphics(); + g_phs.drawImage(placeholder, 0, 0, null); + + // Draw grey "Signature" overlay + String overlay = Messages.getString("positioning.signature"); //$NON-NLS-1$ + // Voodoo to get overlay font scale + float scale = (((float) this.sigScreenWidth) / this.sigPlaceholder.getWidth(null)) * 150; + log.debug(Float.toString(scale)); + g_phs.setFont(getFont().deriveFont(scale)); + g_phs.setColor(Color.GRAY); + Rectangle2D overlay_size = g_phs.getFontMetrics().getStringBounds(overlay, g_phs); + int width = (int) overlay_size.getWidth(); + int height = (int) overlay_size.getHeight(); + int x = this.sigScreenWidth / 2 - width / 2; + int y = this.sigScreenHeight / 2 - height / 2 + g_phs.getFontMetrics().getAscent(); + g_phs.drawString(overlay, x, y); + + g_phs.dispose(); 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) { diff --git a/trunk/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties b/trunk/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties index 957364d6..2904e9c4 100644 --- a/trunk/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties +++ b/trunk/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties @@ -97,6 +97,7 @@ positioning.newPage=Create &new Page positioning.page=Page %d of %d positioning.removeNewPage=&Undo new Page positioning.sign=&Sign +positioning.signature=Signature simple_config.EmblemEmpty=Drag and Drop an image here\nor use the browse button \nto select a signature logo. simple_config.Emblem_Title=Signature &logo simple_config.ExampleNumber=+43676123456789 |