X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FOverviewPanel.java;h=96138bfdc5b500af4834945a9aecc4cce17cb03d;hb=5010b95e8e250e744eefc5a1c976d70c044be32f;hp=76c4e862e4332f871df12b646c6d3e699d0eb8c2;hpb=24b3db7a46158fe7bf82c208472740f8b7c76448;p=jalview.git diff --git a/src/jalview/appletgui/OverviewPanel.java b/src/jalview/appletgui/OverviewPanel.java index 76c4e86..96138bf 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; @@ -67,7 +68,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 +114,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.getModifiers() + & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) { showPopupMenu(evt); } @@ -123,13 +126,14 @@ 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)); } } @@ -146,14 +150,21 @@ public class OverviewPanel extends Panel implements Runnable, } 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,16 +179,14 @@ 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 ((evt.getModifiers() + & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) { if (!Platform.isAMac()) { @@ -200,7 +209,7 @@ public class OverviewPanel extends Panel implements Runnable, av.getAlignment().getHiddenSequences(), av.getAlignment().getHiddenColumns()); } - ap.paintAlignment(false); + ap.paintAlignment(false, false); } } @@ -209,6 +218,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 +253,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 +266,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 +309,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; + } + } }