X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FOverviewPanel.java;h=e74e1cd5f7e1985a1e5fa4884a198056208ced06;hb=8e640547def8e151db1fafafe93a2a0bb8078369;hp=76c4e862e4332f871df12b646c6d3e699d0eb8c2;hpb=24b3db7a46158fe7bf82c208472740f8b7c76448;p=jalview.git diff --git a/src/jalview/appletgui/OverviewPanel.java b/src/jalview/appletgui/OverviewPanel.java index 76c4e86..e74e1cd 100755 --- a/src/jalview/appletgui/OverviewPanel.java +++ b/src/jalview/appletgui/OverviewPanel.java @@ -67,7 +67,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 +113,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); } @@ -146,11 +148,12 @@ 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; od.updateViewportFromMouse(evt.getX(), evt.getY(), av.getAlignment().getHiddenSequences(), av.getAlignment().getHiddenColumns()); @@ -168,16 +171,13 @@ public class OverviewPanel extends Panel implements Runnable, @Override public void mouseReleased(MouseEvent evt) { - if (draggingBox) - { - 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()) { @@ -209,6 +209,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 +244,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 +257,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 +300,34 @@ 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); + } finally + { + av = null; + oviewCanvas = null; + ap = null; + od = null; + } + } }