From: gmungoc Date: Fri, 2 Feb 2018 11:33:39 +0000 (+0000) Subject: JAL-984 use cursor for drag regions to adjust annotation height or id width X-Git-Tag: Release_2_10_4~56^2~5 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=c1abd9108f6a78bc4e900746ba2a4f3307a218fc;p=jalview.git JAL-984 use cursor for drag regions to adjust annotation height or id width --- diff --git a/src/jalview/appletgui/AnnotationLabels.java b/src/jalview/appletgui/AnnotationLabels.java index d8f65a5..c049326 100755 --- a/src/jalview/appletgui/AnnotationLabels.java +++ b/src/jalview/appletgui/AnnotationLabels.java @@ -31,6 +31,7 @@ import jalview.util.ParseHtmlBodyAndLinks; import java.awt.Checkbox; import java.awt.CheckboxMenuItem; import java.awt.Color; +import java.awt.Cursor; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.FontMetrics; @@ -269,6 +270,8 @@ public class AnnotationLabels extends Panel public void mouseMoved(MouseEvent evt) { resizePanel = evt.getY() < 10 && evt.getX() < 14; + setCursor(Cursor.getPredefinedCursor( + resizePanel ? Cursor.S_RESIZE_CURSOR : Cursor.DEFAULT_CURSOR)); int row = getSelectedRow(evt.getY() + scrollOffset); if (row > -1) @@ -406,6 +409,7 @@ public class AnnotationLabels extends Panel resizePanel = false; dragEvent = null; dragCancelled = false; + setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); repaint(); ap.annotationPanel.repaint(); } @@ -418,6 +422,8 @@ public class AnnotationLabels extends Panel resizePanel = true; repaint(); } + setCursor(Cursor.getPredefinedCursor( + resizePanel ? Cursor.S_RESIZE_CURSOR : Cursor.DEFAULT_CURSOR)); } @Override @@ -905,10 +911,10 @@ public class AnnotationLabels extends Panel g.translate(0, +scrollOffset); if (resizePanel) { - g.setColor(Color.red); - g.setPaintMode(); - g.drawLine(2, 8, 5, 2); - g.drawLine(5, 2, 8, 8); + // g.setColor(Color.red); + // g.setPaintMode(); + // g.drawLine(2, 8, 5, 2); + // g.drawLine(5, 2, 8, 8); } else if (!dragCancelled && dragEvent != null && aa != null) { diff --git a/src/jalview/appletgui/IdwidthAdjuster.java b/src/jalview/appletgui/IdwidthAdjuster.java index 75e3243..e9722fe 100755 --- a/src/jalview/appletgui/IdwidthAdjuster.java +++ b/src/jalview/appletgui/IdwidthAdjuster.java @@ -20,7 +20,7 @@ */ package jalview.appletgui; -import java.awt.Color; +import java.awt.Cursor; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Image; @@ -54,11 +54,13 @@ public class IdwidthAdjuster extends Panel addMouseMotionListener(this); } + @Override public void mousePressed(MouseEvent evt) { oldX = evt.getX(); } + @Override public void mouseReleased(MouseEvent evt) { active = false; @@ -85,18 +87,24 @@ public class IdwidthAdjuster extends Panel // } } + @Override public void mouseEntered(MouseEvent evt) { active = true; + setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR)); + repaint(); } + @Override public void mouseExited(MouseEvent evt) { active = false; + setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); repaint(); } + @Override public void mouseDragged(MouseEvent evt) { active = true; @@ -112,25 +120,28 @@ public class IdwidthAdjuster extends Panel } } + @Override public void mouseMoved(MouseEvent evt) { } + @Override public void mouseClicked(MouseEvent evt) { } + @Override public void paint(Graphics g) { - g.setColor(Color.white); - g.fillRect(0, 0, getSize().width, getSize().height); - if (active) - { - if (image != null) - { - g.drawImage(image, getSize().width - 20, 2, this); - } - } + // g.setColor(Color.white); + // g.fillRect(0, 0, getSize().width, getSize().height); + // if (active) + // { + // if (image != null) + // { + // g.drawImage(image, getSize().width - 20, 2, this); + // } + // } } } diff --git a/src/jalview/gui/AnnotationLabels.java b/src/jalview/gui/AnnotationLabels.java index b00e341..77b4ea9 100755 --- a/src/jalview/gui/AnnotationLabels.java +++ b/src/jalview/gui/AnnotationLabels.java @@ -35,6 +35,7 @@ import jalview.util.MessageManager; import jalview.util.Platform; import java.awt.Color; +import java.awt.Cursor; import java.awt.Dimension; import java.awt.Font; import java.awt.FontMetrics; @@ -818,8 +819,12 @@ public class AnnotationLabels extends JPanel { boolean was = resizePanel; resizePanel = evt.getY() < adjusterImageHeight && evt.getX() < HEIGHT_ADJUSTER_WIDTH; + if (resizePanel != was) { + setCursor(Cursor.getPredefinedCursor( + resizePanel ? Cursor.S_RESIZE_CURSOR + : Cursor.DEFAULT_CURSOR)); repaint(); } } @@ -1224,7 +1229,7 @@ public class AnnotationLabels extends JPanel if (resizePanel) { - g.drawImage(adjusterImage, 2, 0 - getScrollOffset(), this); + // g.drawImage(adjusterImage, 2, 0 - getScrollOffset(), this); } else if (dragEvent != null && aa != null) { diff --git a/src/jalview/gui/IdwidthAdjuster.java b/src/jalview/gui/IdwidthAdjuster.java index 8400543..99792c6 100755 --- a/src/jalview/gui/IdwidthAdjuster.java +++ b/src/jalview/gui/IdwidthAdjuster.java @@ -23,6 +23,7 @@ package jalview.gui; import jalview.api.AlignViewportI; import java.awt.Color; +import java.awt.Cursor; import java.awt.Graphics; import java.awt.Image; import java.awt.event.MouseEvent; @@ -198,7 +199,12 @@ public class IdwidthAdjuster extends JPanel { if (image != null) { - g.drawImage(image, getWidth() - 20, 2, this); + // g.drawImage(image, getWidth() - 20, 2, this); + setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR)); + } + else + { + setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } }