From de5b6551176b63d930db8fbd62efe3434de0a420 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Wed, 19 Dec 2018 15:11:05 +0000 Subject: [PATCH] JAL-2621 Overview uses hand cursor in drag box, crosshair outside box --- resources/images/dragcursor.png | Bin 264 -> 0 bytes src/jalview/appletgui/OverviewPanel.java | 45 ++++------------------------ src/jalview/gui/OverviewPanel.java | 47 ++++++------------------------ 3 files changed, 15 insertions(+), 77 deletions(-) delete mode 100644 resources/images/dragcursor.png diff --git a/resources/images/dragcursor.png b/resources/images/dragcursor.png deleted file mode 100644 index 914bb15296b76105b3cbaab7a6b7f1f75c792ba5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 264 zcmeAS@N?(olHy`uVBq!ia0vp^av;pX1|+Qw)-3{3Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmPdBNw-!@rKxd9YCR}o-U3d9>?EK+sM~oz~RzpVe#_O z|Nkov?_3eBtlQqZOg}Mu=Ql4drDjLTITu^lT%0SXDBPOj?YZdc&oevoO82R|q$G=8 zyc7^)yt*p8RdA~mCwrZU+oEXKL=OIn)AKc>t{A;+VcX{tvSZmj^J{NTM>;VVJ~cRg z?C;Za<;Gus8R@4#=&?M^7Zv^IjDmx7?JnNx=KsYE3pF&oImF6%fevKwboFyt=akR{ E0JG&^5&!@I diff --git a/src/jalview/appletgui/OverviewPanel.java b/src/jalview/appletgui/OverviewPanel.java index 334310f..0c0bf37 100755 --- a/src/jalview/appletgui/OverviewPanel.java +++ b/src/jalview/appletgui/OverviewPanel.java @@ -32,11 +32,8 @@ import java.awt.CheckboxMenuItem; import java.awt.Cursor; import java.awt.Dimension; import java.awt.Frame; -import java.awt.Image; import java.awt.Panel; -import java.awt.Point; import java.awt.PopupMenu; -import java.awt.Toolkit; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; import java.awt.event.InputEvent; @@ -47,14 +44,9 @@ import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import java.beans.PropertyChangeEvent; -import javax.swing.ImageIcon; - public class OverviewPanel extends Panel implements Runnable, MouseMotionListener, MouseListener, ViewportListenerI { - protected Image dragImage = new ImageIcon( - getClass().getResource("/images/dragcursor.png")).getImage(); - private OverviewDimensions od; private OverviewCanvas oviewCanvas; @@ -69,8 +61,6 @@ public class OverviewPanel extends Panel implements Runnable, private boolean draggingBox = false; - private Cursor dragCursor; - public OverviewPanel(AlignmentPanel alPanel) { this.av = alPanel.av; @@ -89,19 +79,6 @@ public class OverviewPanel extends Panel implements Runnable, av.getRanges().addPropertyChangeListener(this); - Toolkit toolkit = Toolkit.getDefaultToolkit(); - Image image = toolkit.getImage("images/dragcursor.png"); - - if (Platform.isAMac()) - { - dragCursor = toolkit.createCustomCursor(image, new Point(15, 15), - "drag cursor"); - } - else - { - dragCursor = Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR); - } - addComponentListener(new ComponentAdapter() { @@ -142,33 +119,21 @@ public class OverviewPanel extends Panel implements Runnable, { showPopupMenu(evt); } - else if (od.isPositionInBox(evt.getX(), evt.getY())) - { - // display drag cursor at mouse position - this.getParent().setCursor(dragCursor); - } - else - { - // reset cursor - this.getParent() - .setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - } } @Override public void mouseMoved(MouseEvent evt) { - System.out.println(evt.getY()); if (od.isPositionInBox(evt.getX(), evt.getY())) { - // display drag cursor at mouse position - this.getParent().setCursor(dragCursor); + this.getParent() + .setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } else { - // reset cursor this.getParent() - .setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + .setCursor( + Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); } } @@ -194,6 +159,8 @@ public class OverviewPanel extends Panel implements Runnable, od.updateViewportFromMouse(evt.getX(), evt.getY(), av.getAlignment().getHiddenSequences(), av.getAlignment().getHiddenColumns()); + getParent() + .setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } else { diff --git a/src/jalview/gui/OverviewPanel.java b/src/jalview/gui/OverviewPanel.java index 567a121..ee478a5 100755 --- a/src/jalview/gui/OverviewPanel.java +++ b/src/jalview/gui/OverviewPanel.java @@ -32,8 +32,6 @@ import jalview.viewmodel.ViewportListenerI; import java.awt.BorderLayout; import java.awt.Cursor; import java.awt.Dimension; -import java.awt.Image; -import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ComponentAdapter; @@ -44,7 +42,6 @@ import java.awt.event.MouseMotionAdapter; import java.beans.PropertyChangeEvent; import java.beans.PropertyVetoException; -import javax.swing.ImageIcon; import javax.swing.JCheckBoxMenuItem; import javax.swing.JInternalFrame; import javax.swing.JPanel; @@ -61,10 +58,6 @@ import javax.swing.SwingUtilities; public class OverviewPanel extends JPanel implements Runnable, ViewportListenerI { - protected Image dragImage = new ImageIcon( - getClass().getResource("/images/dragcursor.png")) - .getImage(); - private OverviewDimensions od; private OverviewCanvas oviewCanvas; @@ -119,22 +112,6 @@ public class OverviewPanel extends JPanel // without this the overview window does not size to fit the overview canvas setPreferredSize(new Dimension(od.getWidth(), od.getHeight())); - - // set up custom cursor for use on Mac... - Point hotSpot = new Point(16, 16); - String cursorName = "Custom drag cursor"; - - Cursor tempCursor; - if (Platform.isAMac()) - { - tempCursor = getToolkit().createCustomCursor(dragImage, hotSpot, - cursorName); - } - else - { - tempCursor = Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR); - } - final Cursor dragCursor = tempCursor; addComponentListener(new ComponentAdapter() { @@ -195,14 +172,18 @@ public class OverviewPanel extends JPanel { if (od.isPositionInBox(evt.getX(), evt.getY())) { - // display drag cursor at mouse position - getParent().setCursor(dragCursor); + /* + * using HAND_CURSOR rather than DRAG_CURSOR + * as the latter is not supported on Mac + */ + getParent().setCursor( + Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } else { // reset cursor getParent().setCursor( - Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); } } @@ -231,6 +212,8 @@ public class OverviewPanel extends JPanel od.updateViewportFromMouse(evt.getX(), evt.getY(), av.getAlignment().getHiddenSequences(), av.getAlignment().getHiddenColumns()); + getParent().setCursor( + Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } else { @@ -249,18 +232,6 @@ public class OverviewPanel extends JPanel { showPopupMenu(evt); } - // click in box should also reset the cursor - else if (od.isPositionInBox(evt.getX(), evt.getY())) - { - // display drag cursor at mouse position - getParent().setCursor(dragCursor); - } - else - { - // reset cursor - getParent().setCursor( - Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - } } }); } -- 1.7.10.2