X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FOverviewCanvas.java;h=de55996b1bf7f0249f647ab9b799c8db8e247448;hb=be7bf233b7e6af4f824613b1dbd3d5338498b4c8;hp=aafac388284d2c5d45915f86e7f1bd03261b518c;hpb=04e88679fd837e9fe36d186e5eacdd5f13a89927;p=jalview.git diff --git a/src/jalview/gui/OverviewCanvas.java b/src/jalview/gui/OverviewCanvas.java index aafac38..de55996 100644 --- a/src/jalview/gui/OverviewCanvas.java +++ b/src/jalview/gui/OverviewCanvas.java @@ -47,7 +47,7 @@ public class OverviewCanvas extends JPanel private boolean disposed = false; - private BufferedImage lastMiniMe = null; + BufferedImage lastMiniMe = null; // Can set different properties in this seqCanvas than // main visible SeqCanvas @@ -73,15 +73,18 @@ public class OverviewCanvas extends JPanel private OverviewPanel panel; + private boolean showProgress; + public OverviewCanvas(OverviewPanel panel, OverviewDimensions overviewDims, AlignViewportI alignvp, ProgressPanel pp) { this.panel = panel; od = overviewDims; + lastMiniMe = null; av = alignvp; progressPanel = pp; - + showProgress = (pp != null); sr = new SequenceRenderer(av); sr.renderGaps = false; fr = new jalview.renderer.seqfeatures.FeatureRenderer(av); @@ -106,6 +109,7 @@ public class OverviewCanvas extends JPanel public void resetOviewDims(OverviewDimensions overviewDims) { od = overviewDims; + lastMiniMe = null; } /** @@ -123,6 +127,7 @@ public class OverviewCanvas extends JPanel else { updaterunning = true; + restart = false; } return restart; } @@ -154,46 +159,31 @@ public class OverviewCanvas extends JPanel this.showSequenceFeatures = showSequenceFeatures; this.showAnnotation = showAnnotation; this.featureRenderer = featureRenderer; - - // System.out.println("OC draw " + ++ndraw + " showseqf=" - // + showSequenceFeatures + " showAnno=" + showAnnotation); - if (showSequenceFeatures) { fr.transferSettings(featureRenderer); } - setPreferredSize(new Dimension(od.getWidth(), od.getHeight())); - AlignmentI al = av.getAlignment(); - or = new OverviewRenderer(panel.ap, fr, od, al, - av.getResidueShading(), cf, - progressPanel != null); - if (progressPanel != null) + or = new OverviewRenderer(panel.ap, fr, od, al, av.getResidueShading(), + cf, showProgress); + if (showProgress) { or.addPropertyChangeListener(progressPanel); } - or.draw(od.getRows(al), od.getColumns(al)); + or.drawMiniMe(); } - void finalizeDraw(BufferedImage miniMe) + synchronized void finalizeDraw(BufferedImage miniMe) { - Graphics mg = miniMe.getGraphics(); - if (showAnnotation) - { - mg.translate(0, od.getSequencesHeight()); - or.drawGraph(mg, av.getAlignmentConservationAnnotation(), - od.getGraphHeight(), od.getColumns(av.getAlignment())); - mg.translate(0, -od.getSequencesHeight()); - } - mg.dispose(); // BH 2019 - if (progressPanel != null) + + if (showProgress && or != null) { or.removePropertyChangeListener(progressPanel); } - or = null; if (restart) { + or = null; restart = false; if (!disposed) { @@ -202,12 +192,17 @@ public class OverviewCanvas extends JPanel } else { + if (showAnnotation && or != null) + { + or.drawGraph(av.getAlignmentConservationAnnotation()); + } + or = null; updaterunning = false; lastMiniMe = miniMe; repaint(); } - } + @Override public void paintComponent(Graphics g) { @@ -240,40 +235,56 @@ public class OverviewCanvas extends JPanel else if (drawMe) { // is this a resize? - if (w != od.getWidth() || h != od.getHeight()) { - // if there is annotation, scale the alignment and annotation - // separately - if (od.getGraphHeight() <= 0 && od.getSequencesHeight() <= 0) + if (w != od.getWidth() || h != od.getHeight()) { - od.setWidth(w); - od.setHeight(h); + + lastMiniMe = null; return; - } - // System.out.println("OC new subimages"); - BufferedImage topImage = lastMiniMe.getSubimage(0, 0, od.getWidth(), - od.getSequencesHeight()); - BufferedImage bottomImage = lastMiniMe.getSubimage(0, - od.getSequencesHeight(), od.getWidth(), od.getGraphHeight()); - - // must be done at this point as we rely on using old width/height - // above, and new width/height below - od.setWidth(w); - od.setHeight(h); - - // stick the images back together so lastMiniMe is consistent in the - // event of a repaint - BUT probably not thread safe - // System.out.println("OC new lastminime " + w + " " + h); - lastMiniMe = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); - Graphics lg = lastMiniMe.getGraphics(); - lg.drawImage(topImage, 0, 0, w, od.getSequencesHeight(), null); - lg.drawImage(bottomImage, 0, od.getSequencesHeight(), w, - od.getGraphHeight(), this); - lg.dispose(); - // BH 2019: removed -- this is now taken care of using vpbox in - // OverviewDimension - // // make sure the box is in the right place - // od.setBoxPosition(av.getAlignment().getHiddenSequences(), - // av.getAlignment().getHiddenColumns()); + // // if there is annotation, scale the alignment and annotation + // // separately + // if (od.getGraphHeight() <= 0 && od.getSequencesHeight() <= 0) + // { + // od.setWidth(w); + // od.setHeight(h); + // return; + // } + // try + // { + // BufferedImage topImage = lastMiniMe.getSubimage(0, 0, + // od.getWidth(), od.getSequencesHeight()); + // + // BufferedImage bottomImage = lastMiniMe.getSubimage(0, + // od.getSequencesHeight(), od.getWidth(), + // od.getGraphHeight()); + // + // // must be done at this point as we rely on using old width/height + // // above, and new width/height below + // od.setWidth(w); + // od.setHeight(h); + // + // // stick the images back together so lastMiniMe is consistent in the + // // event of a repaint - BUT probably not thread safe + // + // // right -- this fails with fast user action. + // + // lastMiniMe = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); + // Graphics lg = lastMiniMe.getGraphics(); + // lg.drawImage(topImage, 0, 0, w, od.getSequencesHeight(), null); + // lg.drawImage(bottomImage, 0, od.getSequencesHeight(), w, + // od.getGraphHeight(), this); + // lg.dispose(); + // + // } catch (RasterFormatException e) + // { + // System.out.println("OC Raster Exception " + lastMiniMe.getWidth() + // + "/" + w + "," + lastMiniMe.getHeight() + "/" + h + " " + // + od.getSequencesHeight() + " " + od.getGraphHeight()); + // } + // BH 2019: removed -- this is now taken care of using vpbox in + // OverviewDimension + // // make sure the box is in the right place + // od.setBoxPosition(av.getAlignment().getHiddenSequences(), + // av.getAlignment().getHiddenColumns()); } } @@ -288,7 +299,7 @@ public class OverviewCanvas extends JPanel od.drawBox(g); } - private int ndraw, npaint, nrepaint; + // private int ndraw, npaint, nrepaint; // @Override // public void repaint() @@ -301,6 +312,7 @@ public class OverviewCanvas extends JPanel { disposed = true; od = null; + lastMiniMe = null; synchronized (this) { setRestart("dispose");