summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java
diff options
context:
space:
mode:
authortkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 19:12:29 +0000
committertkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 19:12:29 +0000
commite49ce3a63113c8bae09c4a31447251caf98492c8 (patch)
treef1abddb07ef10285935fc33064e4f6acb670f1ce /pdf-over-gui/src/main/java
parent9f35aefd7826767824a24bd76b5932e2182121d0 (diff)
downloadmocca-e49ce3a63113c8bae09c4a31447251caf98492c8.tar.gz
mocca-e49ce3a63113c8bae09c4a31447251caf98492c8.tar.bz2
mocca-e49ce3a63113c8bae09c4a31447251caf98492c8.zip
Draw signature overlay string
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@195 174cde9d-5d70-4d2a-aa98-46368bc2aaf7
Diffstat (limited to 'pdf-over-gui/src/main/java')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java24
1 files changed, 21 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 353b2b66..a259d3e1 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
@@ -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) {