summaryrefslogtreecommitdiff
path: root/pdf-over-gui
diff options
context:
space:
mode:
authortkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 19:30:04 +0000
committertkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 19:30:04 +0000
commitbd7459723b832c7d5c7d22fc9d837094b43861e8 (patch)
tree403ee0d0c82db2cf640838e83d16704172f3fc60 /pdf-over-gui
parent9a5a6257994c0554ff27f3e5874a4555465f6153 (diff)
downloadmocca-bd7459723b832c7d5c7d22fc9d837094b43861e8.tar.gz
mocca-bd7459723b832c7d5c7d22fc9d837094b43861e8.tar.bz2
mocca-bd7459723b832c7d5c7d22fc9d837094b43861e8.zip
Use mouse cursors during positioning
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@350 174cde9d-5d70-4d2a-aa98-46368bc2aaf7
Diffstat (limited to 'pdf-over-gui')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java3
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java45
2 files changed, 47 insertions, 1 deletions
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 43575e45..8294c004 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
@@ -16,6 +16,7 @@
package at.asit.pdfover.gui.composites;
// Imports
+import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Frame;
import java.awt.Image;
@@ -184,7 +185,7 @@ public class PositioningComposite extends StateComposite {
}
if (this.viewer == null) {
this.viewer = new SignaturePanel(this.pdf);
- this.frame.add(this.viewer);
+ this.frame.add(this.viewer, BorderLayout.CENTER);
this.viewer.setSignaturePlaceholderBorderColor(new Color(
Constants.MAINBAR_ACTIVE_BACK_DARK.getRed(),
Constants.MAINBAR_ACTIVE_BACK_DARK.getGreen(),
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 3c8888f7..df375367 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
@@ -18,6 +18,7 @@ package at.asit.pdfover.gui.composites;
// Imports
import java.awt.BorderLayout;
import java.awt.Color;
+import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
@@ -97,6 +98,16 @@ public class SignaturePanel extends JPanel {
int page = 0;
/** Number of pages in the document */
int numPages = 0;
+ /** Cursor types */
+ static enum Cursors {DEFAULT, HAND, MOVE};
+ /** Default arrow cursor */
+ final Cursor defaultCursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
+ /** Hand cursor */
+ final Cursor handCursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);
+ /** Move cursor */
+ final Cursor moveCursor = Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR);
+ /** Current cursor */
+ Cursors currentCursor = Cursors.DEFAULT;
/**
* Create a new PagePanel.
@@ -403,6 +414,13 @@ public class SignaturePanel extends JPanel {
sigy - SignaturePanel.this.offY);
}
+ /** Handles a mouseMoved event */
+ @Override
+ public void mouseMoved(MouseEvent evt) {
+ boolean onSig = isOnSignature(evt.getX(), evt.getY());
+ setCursor(onSig ? Cursors.HAND : Cursors.DEFAULT);
+ }
+
/** Handles a mousePressed event */
@Override
public void mousePressed(MouseEvent evt) {
@@ -422,6 +440,7 @@ public class SignaturePanel extends JPanel {
this.dragYOffset = 0;
}
updateSigPos(evt.getX() + this.dragXOffset, evt.getY() + this.dragYOffset);
+ setCursor(Cursors.MOVE);
}
}
@@ -429,6 +448,8 @@ public class SignaturePanel extends JPanel {
@Override
public void mouseReleased(MouseEvent evt) {
this.doDrag = false;
+ boolean onSig = isOnSignature(evt.getX(), evt.getY());
+ setCursor(onSig ? Cursors.HAND : Cursors.DEFAULT);
}
/**
@@ -442,6 +463,30 @@ public class SignaturePanel extends JPanel {
};
/**
+ * Sets the mouse cursor
+ * @param cursor cursor to set
+ */
+ void setCursor(Cursors cursor)
+ {
+ if (this.currentCursor == cursor)
+ return;
+ this.currentCursor = cursor;
+ Cursor cur = null;
+ switch (cursor) {
+ case DEFAULT:
+ cur = this.defaultCursor;
+ break;
+ case HAND:
+ cur = this.handCursor;
+ break;
+ case MOVE:
+ cur = this.moveCursor;
+ break;
+ }
+ this.getParent().setCursor(cur);
+ }
+
+ /**
* Check whether given point is on signature placeholder
* @param x x coordinate
* @param y y coordinate