X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FOverviewPanel.java;h=a5aaf7c51c615b691686881eefbbf41ad73a388e;hb=7a5cac232c59bba9964ec32ecdd787b8028cde48;hp=9ddb7519893fdb2a2a08c97c0077a91952c9b44d;hpb=7544cc610aa35fd10e975598cc8fb2c97abe6bd9;p=jalview.git diff --git a/src/jalview/gui/OverviewPanel.java b/src/jalview/gui/OverviewPanel.java index 9ddb751..a5aaf7c 100755 --- a/src/jalview/gui/OverviewPanel.java +++ b/src/jalview/gui/OverviewPanel.java @@ -55,24 +55,25 @@ import javax.swing.SwingUtilities; * @author $author$ * @version $Revision$ */ +@SuppressWarnings("serial") public class OverviewPanel extends JPanel implements Runnable, ViewportListenerI { - private OverviewDimensions od; + protected OverviewDimensions od; private OverviewCanvas oviewCanvas; - private AlignViewport av; + protected AlignViewport av; private AlignmentPanel ap; - private JCheckBoxMenuItem displayToggle; + protected JCheckBoxMenuItem displayToggle; - private boolean showHidden = true; + protected boolean showHidden = true; - private boolean draggingBox = false; + protected boolean draggingBox = false; - private ProgressPanel progressPanel; + protected ProgressPanel progressPanel; /** * Creates a new OverviewPanel object. @@ -86,7 +87,7 @@ public class OverviewPanel extends JPanel this.ap = alPanel; showHidden = Cache.getDefault(Preferences.SHOW_OV_HIDDEN_AT_START, - true); + false); if (showHidden) { od = new OverviewDimensionsShowHidden(av.getRanges(), @@ -112,7 +113,7 @@ 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())); - + addComponentListener(new ComponentAdapter() { @Override @@ -172,15 +173,21 @@ public class OverviewPanel extends JPanel { if (od.isPositionInBox(evt.getX(), evt.getY())) { - // display drag cursor at mouse position - setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); + /* + * 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 - setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + getParent().setCursor( + Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); } } + }); addMouseListener(new MouseAdapter() @@ -188,24 +195,29 @@ public class OverviewPanel extends JPanel @Override public void mousePressed(MouseEvent evt) { - if (SwingUtilities.isRightMouseButton(evt)) - { - if (!Platform.isAMac()) - { - showPopupMenu(evt); - } + + if (Platform.isWinRightButton(evt)) { + showPopupMenu(evt); + return; + } + if (SwingUtilities.isRightMouseButton(evt)) { + return; } - else - { // don't do anything if the mouse press is in the overview's box // (wait to see if it's a drag instead) // otherwise update the viewport if (!od.isPositionInBox(evt.getX(), evt.getY())) { draggingBox = false; + + // display drag cursor at mouse position + setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); + od.updateViewportFromMouse(evt.getX(), evt.getY(), av.getAlignment().getHiddenSequences(), av.getAlignment().getHiddenColumns()); + getParent().setCursor( + Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } else { @@ -214,7 +226,6 @@ public class OverviewPanel extends JPanel av.getAlignment().getHiddenSequences(), av.getAlignment().getHiddenColumns()); } - } } @Override @@ -225,13 +236,29 @@ public class OverviewPanel extends JPanel showPopupMenu(evt); } } + + @Override + public void mouseReleased(MouseEvent evt) + { + draggingBox = false; + } + }); + + /* + * Javascript does not call componentResized on initial display, + * so do the update here + */ + if (Platform.isJS()) + { + updateOverviewImage(); + } } /* * Displays the popup menu and acts on user input */ - private void showPopupMenu(MouseEvent e) + protected void showPopupMenu(MouseEvent e) { JPopupMenu popup = new JPopupMenu(); ActionListener menuListener = new ActionListener() @@ -256,7 +283,7 @@ public class OverviewPanel extends JPanel /* * Toggle overview display between showing hidden columns and hiding hidden columns */ - private void toggleHiddenColumns() + protected void toggleHiddenColumns() { if (showHidden) { @@ -329,6 +356,22 @@ public class OverviewPanel extends JPanel * changed * */ + private void setBoxPositionOnly() + { + if (od != null) + { + int oldX = od.getBoxX(); + int oldY = od.getBoxY(); + int oldWidth = od.getBoxWidth(); + int oldHeight = od.getBoxHeight(); + od.setBoxPosition(av.getAlignment().getHiddenSequences(), + av.getAlignment().getHiddenColumns()); + repaint(oldX - 1, oldY - 1, oldWidth + 2, oldHeight + 2); + repaint(od.getBoxX(), od.getBoxY(), od.getBoxWidth(), + od.getBoxHeight()); + } + } + private void setBoxPosition() { if (od != null) @@ -342,7 +385,7 @@ public class OverviewPanel extends JPanel @Override public void propertyChange(PropertyChangeEvent evt) { - setBoxPosition(); + setBoxPositionOnly(); } /**