diff options
author | tkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7> | 2013-04-10 19:06:00 +0000 |
---|---|---|
committer | tkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7> | 2013-04-10 19:06:00 +0000 |
commit | 0b716028cb197d4bebfbb88b317b3a0600f82d6a (patch) | |
tree | 64d7e3f1b8c05fb90cbf32bdd6faa97f8d621ca3 /pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites | |
parent | 06e896f3578e9a527e4e80940e88342ea6dad24f (diff) | |
download | pdf-over-0b716028cb197d4bebfbb88b317b3a0600f82d6a.tar.gz pdf-over-0b716028cb197d4bebfbb88b317b3a0600f82d6a.tar.bz2 pdf-over-0b716028cb197d4bebfbb88b317b3a0600f82d6a.zip |
Make signature placeholder transparency configurable
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@128 174cde9d-5d70-4d2a-aa98-46368bc2aaf7
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites')
4 files changed, 99 insertions, 53 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java index b82150aa..e9383747 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java @@ -16,40 +16,53 @@ package at.asit.pdfover.gui.composites; // Imports -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.TabItem; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import at.asit.pdfover.gui.Messages; -import at.asit.pdfover.gui.controls.ErrorDialog; -import at.asit.pdfover.gui.workflow.ConfigurationContainer; -import at.asit.pdfover.gui.workflow.states.State; -import at.asit.pdfover.signator.BKUs; - -import org.eclipse.swt.widgets.Label; import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.TabFolder; import org.eclipse.swt.events.FocusAdapter; import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.layout.FormLayout; -import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.layout.FormLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.DirectoryDialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Scale; +import org.eclipse.swt.widgets.TabFolder; +import org.eclipse.swt.widgets.TabItem; import org.eclipse.swt.widgets.Text; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.asit.pdfover.gui.Messages; +import at.asit.pdfover.gui.controls.ErrorDialog; +import at.asit.pdfover.gui.workflow.ConfigurationContainer; +import at.asit.pdfover.gui.workflow.states.State; +import at.asit.pdfover.signator.BKUs; /** * Composite for advanced configuration */ public class AdvancedConfigurationComposite extends BaseConfigurationComposite { + + /** + * SLF4J Logger instance + **/ + private static final Logger log = LoggerFactory + .getLogger(AdvancedConfigurationComposite.class); + SimpleConfigurationComposite simpleComposite; + Text txtOutputFolder; + Combo cmbBKUAuswahl; + String[] bkuStrings; + Button btnAutomatischePositionierung; + Scale sclTransparenz; + /** * @param parent * @param style @@ -89,21 +102,21 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite { advancedTabItem.setControl(advancedComposite); advancedComposite.setLayout(new FormLayout()); - Group grpSignaturPosition = new Group(advancedComposite, SWT.NONE); - grpSignaturPosition.setText(Messages.getString("advanced_config.AutoPosition_Title")); //$NON-NLS-1$ - grpSignaturPosition.setLayout(new FormLayout()); - FormData fd_grpSignaturPosition = new FormData(); - fd_grpSignaturPosition.top = new FormAttachment(0, 5); - fd_grpSignaturPosition.bottom = new FormAttachment(33, -5); - fd_grpSignaturPosition.right = new FormAttachment(100, -5); - fd_grpSignaturPosition.left = new FormAttachment(0, 5); - grpSignaturPosition.setLayoutData(fd_grpSignaturPosition); - - FontData[] fD_grpSignaturPosition = grpSignaturPosition.getFont().getFontData(); + Group grpSignatur = new Group(advancedComposite, SWT.NONE); + grpSignatur.setText(Messages.getString("advanced_config.Signature_Title")); //$NON-NLS-1$ + grpSignatur.setLayout(new FormLayout()); + FormData fd_grpSignatur = new FormData(); + fd_grpSignatur.top = new FormAttachment(0, 5); + fd_grpSignatur.bottom = new FormAttachment(33, -5); + fd_grpSignatur.right = new FormAttachment(100, -5); + fd_grpSignatur.left = new FormAttachment(0, 5); + grpSignatur.setLayoutData(fd_grpSignatur); + + FontData[] fD_grpSignaturPosition = grpSignatur.getFont().getFontData(); fD_grpSignaturPosition[0].setHeight(TEXT_SIZE_NORMAL); - grpSignaturPosition.setFont(new Font(Display.getCurrent(), fD_grpSignaturPosition[0])); + grpSignatur.setFont(new Font(Display.getCurrent(), fD_grpSignaturPosition[0])); - this.btnAutomatischePositionierung = new Button(grpSignaturPosition, + this.btnAutomatischePositionierung = new Button(grpSignatur, SWT.CHECK); FormData fd_btnAutomatischePositionierung = new FormData(); fd_btnAutomatischePositionierung.right = new FormAttachment(100, -5); @@ -125,6 +138,24 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite { AdvancedConfigurationComposite.this.btnAutomatischePositionierung.getSelection()); } }); + log.debug(this.btnAutomatischePositionierung.getBounds().toString()); + + this.sclTransparenz = new Scale(grpSignatur, SWT.HORIZONTAL); + FormData fd_sldTransparenz = new FormData(); + fd_sldTransparenz.right = new FormAttachment(100, -5); + fd_sldTransparenz.top = new FormAttachment(this.btnAutomatischePositionierung, 5); + fd_sldTransparenz.left = new FormAttachment(0, 5); + this.sclTransparenz.setLayoutData(fd_sldTransparenz); + this.sclTransparenz.setMinimum(0); + this.sclTransparenz.setMaximum(255); + this.sclTransparenz.setIncrement(1); + this.sclTransparenz.setPageIncrement(10); + this.sclTransparenz.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + performPlaceholderTransparency(AdvancedConfigurationComposite.this.sclTransparenz.getSelection()); + } + }); Group grpBkuAuswahl = new Group(advancedComposite, SWT.NONE); grpBkuAuswahl.setText(Messages.getString("advanced_config.BKUSelection_Title")); //$NON-NLS-1$ @@ -328,16 +359,10 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite { this.btnAutomatischePositionierung.setSelection(automatic); } - /** - * SLF4J Logger instance - **/ - private static final Logger log = LoggerFactory - .getLogger(AdvancedConfigurationComposite.class); - SimpleConfigurationComposite simpleComposite; - Text txtOutputFolder; - Combo cmbBKUAuswahl; - String[] bkuStrings; - Button btnAutomatischePositionierung; + void performPlaceholderTransparency(int transparency) { + log.debug("Transparency: " + transparency); //$NON-NLS-1$ + this.configurationContainer.setPlaceholderTransparency(transparency); + } /* * (non-Javadoc) @@ -367,6 +392,7 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite { this.performOutputFolderChanged(outputFolder); } this.performPositionSelection(this.configurationContainer.getAutomaticPosition()); + this.sclTransparenz.setSelection(this.configurationContainer.getPlaceholderTransparency()); } /* (non-Javadoc) diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java index 105fcd54..e19cdfa6 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java @@ -201,6 +201,9 @@ public class ConfigurationComposite extends StateComposite { .useAutoPositioning()); } + this.configurationContainer.setPlaceholderTransparency( + this.configProvider.getPlaceholderTransparency()); + this.configurationContainer.setBKUSelection(this.configProvider .getDefaultBKU()); try { @@ -332,6 +335,9 @@ public class ConfigurationComposite extends StateComposite { this.configManipulator.setDefaultSignaturePosition(null); } + this.configManipulator.setPlaceholderTransparency( + this.configurationContainer.getPlaceholderTransparency()); + this.configManipulator .setDefaultOutputFolder(this.configurationContainer .getOutputFolder()); diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java index 86ccbe9b..f841ae6f 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java @@ -92,6 +92,13 @@ public class PositioningComposite extends StateComposite { this.numPages = this.pdf.getNumPages(); this.scrollbar.setValues(1, 1, this.numPages + 1, 1, 1, 1); showPage(this.numPages); + } + + /** + * Request focus (to enable keyboard input) + */ + public void requestFocus() + { this.setFocus(); this.frame.requestFocus(); } @@ -102,11 +109,12 @@ public class PositioningComposite extends StateComposite { * @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 setPlaceholder(Image placeholder, int width, int height) { + public void setPlaceholder(Image placeholder, int width, int height, int transparency) { if (this.viewer == null) return; - this.viewer.setSignaturePlaceholder(placeholder, width, height); + this.viewer.setSignaturePlaceholder(placeholder, width, height, transparency); } /** @@ -124,8 +132,6 @@ public class PositioningComposite extends StateComposite { this.addKeyListener(this.keyListener); this.frame.addMouseWheelListener(this.mouseListener); this.scrollbar.addSelectionListener(this.selectionListener); - this.setFocus(); - this.frame.requestFocus(); } private KeyListener keyListener = new KeyAdapter() { @@ -222,7 +228,10 @@ public class PositioningComposite extends StateComposite { */ void setFinalPosition() { // TODO: check if this is the real position - this.position = new SignaturePosition(this.viewer.getSignaturePositionX(), this.viewer.getSignaturePositionY(), this.currentPage); + this.position = new SignaturePosition( + this.viewer.getSignaturePositionX(), + this.viewer.getSignaturePositionY(), + this.currentPage); PositioningComposite.this.state.updateStateMachine(); } 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 f2c2c798..b2f5270f 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 @@ -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); |