summaryrefslogtreecommitdiff
path: root/altosuilib/GrabNDrag.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2014-05-27 15:39:13 -0700
committerKeith Packard <keithp@keithp.com>2014-05-27 15:39:13 -0700
commit8e44580cbe978f1570d4d2ac13d3dd7cd470ecf7 (patch)
tree8540ca01103c1d1a73e91b2ab83f221274b4619e /altosuilib/GrabNDrag.java
parentc674a20432c2cb97e5bc2a3de891f78b9e172fe9 (diff)
altosuilib: Add distance measuring line to site map.
Use any modifier or button other than the left one to draw a line on the map. The length of the line is shown at the start of the line. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altosuilib/GrabNDrag.java')
-rw-r--r--altosuilib/GrabNDrag.java21
1 files changed, 14 insertions, 7 deletions
diff --git a/altosuilib/GrabNDrag.java b/altosuilib/GrabNDrag.java
index 5e5fdd52..4426f7a3 100644
--- a/altosuilib/GrabNDrag.java
+++ b/altosuilib/GrabNDrag.java
@@ -33,16 +33,23 @@ class GrabNDrag extends MouseInputAdapter {
scroll.setAutoscrolls(true);
}
+ public static boolean grab_n_drag(MouseEvent e) {
+ return e.getModifiers() == InputEvent.BUTTON1_MASK;
+ }
+
public void mousePressed(MouseEvent e) {
- startPt.setLocation(e.getPoint());
+ if (grab_n_drag(e))
+ startPt.setLocation(e.getPoint());
}
public void mouseDragged(MouseEvent e) {
- int xd = e.getX() - startPt.x;
- int yd = e.getY() - startPt.y;
+ if (grab_n_drag(e)) {
+ int xd = e.getX() - startPt.x;
+ int yd = e.getY() - startPt.y;
- Rectangle r = scroll.getVisibleRect();
- r.x -= xd;
- r.y -= yd;
- scroll.scrollRectToVisible(r);
+ Rectangle r = scroll.getVisibleRect();
+ r.x -= xd;
+ r.y -= yd;
+ scroll.scrollRectToVisible(r);
+ }
}
}