X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FOverviewPanel.java;h=71b3ac77a67940fce98b11c2d068f102407b7a5b;hb=57738a1f3c19b1c3a00bd3ac5108f8cd0af32f99;hp=76c4e862e4332f871df12b646c6d3e699d0eb8c2;hpb=24b3db7a46158fe7bf82c208472740f8b7c76448;p=jalview.git diff --git a/src/jalview/appletgui/OverviewPanel.java b/src/jalview/appletgui/OverviewPanel.java index 76c4e86..71b3ac7 100755 --- a/src/jalview/appletgui/OverviewPanel.java +++ b/src/jalview/appletgui/OverviewPanel.java @@ -31,6 +31,7 @@ import java.awt.BorderLayout; import java.awt.CheckboxMenuItem; import java.awt.Cursor; import java.awt.Dimension; +import java.awt.Frame; import java.awt.Panel; import java.awt.PopupMenu; import java.awt.event.ComponentAdapter; @@ -43,6 +44,8 @@ import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import java.beans.PropertyChangeEvent; +import javax.swing.SwingUtilities; + public class OverviewPanel extends Panel implements Runnable, MouseMotionListener, MouseListener, ViewportListenerI { @@ -67,7 +70,8 @@ public class OverviewPanel extends Panel implements Runnable, setLayout(null); od = new OverviewDimensionsShowHidden(av.getRanges(), - (av.isShowAnnotation() && av.getSequenceConsensusHash() != null)); + (av.isShowAnnotation() + && av.getSequenceConsensusHash() != null)); oviewCanvas = new OverviewCanvas(od, av); setLayout(new BorderLayout()); @@ -112,7 +116,8 @@ public class OverviewPanel extends Panel implements Runnable, @Override public void mouseClicked(MouseEvent evt) { - if ((evt.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) + if ((evt.getModifiersEx() + & InputEvent.BUTTON3_DOWN_MASK) == InputEvent.BUTTON3_DOWN_MASK) { showPopupMenu(evt); } @@ -123,37 +128,44 @@ public class OverviewPanel extends Panel implements Runnable, { if (od.isPositionInBox(evt.getX(), evt.getY())) { - // display drag cursor at mouse position - setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); + this.getParent() + .setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } else { - // reset cursor - setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + this.getParent().setCursor( + Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); } } @Override public void mousePressed(MouseEvent evt) { - if ((evt.getModifiers() - & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) + if ((evt.getModifiersEx() + & InputEvent.BUTTON3_DOWN_MASK) == InputEvent.BUTTON3_DOWN_MASK) { - if (!Platform.isAMac()) + if (!Platform.isMac()) // BH was excluding JavaScript { showPopupMenu(evt); } } 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())) { - // 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 + 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 { @@ -168,40 +180,38 @@ public class OverviewPanel extends Panel implements Runnable, @Override public void mouseReleased(MouseEvent evt) { - if (draggingBox) - { - draggingBox = false; - } + draggingBox = false; } @Override public void mouseDragged(MouseEvent evt) { - if ((evt.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) + if (Platform.isWinRightButton(evt)) { - if (!Platform.isAMac()) - { - showPopupMenu(evt); - } + showPopupMenu(evt); + return; + } + + if (SwingUtilities.isRightMouseButton(evt)) + { + return; + } + + if (draggingBox) + { + // set the mouse position as a fixed point in the box + // and drag relative to that position + od.adjustViewportFromMouse(evt.getX(), evt.getY(), + av.getAlignment().getHiddenSequences(), + av.getAlignment().getHiddenColumns()); } else { - if (draggingBox) - { - // set the mouse position as a fixed point in the box - // and drag relative to that position - od.adjustViewportFromMouse(evt.getX(), evt.getY(), - av.getAlignment().getHiddenSequences(), - av.getAlignment().getHiddenColumns()); - } - else - { - od.updateViewportFromMouse(evt.getX(), evt.getY(), - av.getAlignment().getHiddenSequences(), - av.getAlignment().getHiddenColumns()); - } - ap.paintAlignment(false); + od.updateViewportFromMouse(evt.getX(), evt.getY(), + av.getAlignment().getHiddenSequences(), + av.getAlignment().getHiddenColumns()); } + ap.paintAlignment(false, false); } /** @@ -209,6 +219,14 @@ public class OverviewPanel extends Panel implements Runnable, */ public void updateOverviewImage() { + if (oviewCanvas == null) + { + /* + * panel has been disposed + */ + return; + } + if ((getSize().width > 0) && (getSize().height > 0)) { od.setWidth(getSize().width); @@ -236,8 +254,8 @@ public class OverviewPanel extends Panel implements Runnable, public void run() { oviewCanvas.draw(av.isShowSequenceFeatures(), - (av.isShowAnnotation() && av - .getAlignmentConservationAnnotation() != null), + (av.isShowAnnotation() + && av.getAlignmentConservationAnnotation() != null), ap.seqPanel.seqCanvas.getFeatureRenderer()); setBoxPosition(); } @@ -249,9 +267,8 @@ public class OverviewPanel extends Panel implements Runnable, */ private void setBoxPosition() { - od.setBoxPosition(av.getAlignment() -.getHiddenSequences(), av - .getAlignment().getHiddenColumns()); + od.setBoxPosition(av.getAlignment().getHiddenSequences(), + av.getAlignment().getHiddenColumns()); repaint(); } @@ -293,17 +310,41 @@ public class OverviewPanel extends Panel implements Runnable, { showHidden = false; od = new OverviewDimensionsHideHidden(av.getRanges(), - (av.isShowAnnotation() && av - .getAlignmentConservationAnnotation() != null)); + (av.isShowAnnotation() + && av.getAlignmentConservationAnnotation() != null)); } else { showHidden = true; od = new OverviewDimensionsShowHidden(av.getRanges(), - (av.isShowAnnotation() && av - .getAlignmentConservationAnnotation() != null)); + (av.isShowAnnotation() + && av.getAlignmentConservationAnnotation() != null)); } oviewCanvas.resetOviewDims(od); updateOverviewImage(); } + + /** + * Removes this object as a property change listener, and nulls references + */ + protected void dispose() + { + try + { + av.getRanges().removePropertyChangeListener(this); + Frame parent = (Frame) getParent(); + parent.dispose(); + parent.setVisible(false); + } finally + { + av = null; + if (oviewCanvas != null) + { + oviewCanvas.dispose(); + } + oviewCanvas = null; + ap = null; + od = null; + } + } }