X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FIdCanvas.java;h=e5a594695c7637c79b9399b94cce76525c4ee73a;hb=51ca42a8c4525c6871e3c8ea529b6cb8a59bb10f;hp=cf88c904add63efd0a7553608b7a6df45ef17031;hpb=6a18ba9e7e4bd4deee0337dfd072b959596ca4b5;p=jalview.git diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index cf88c90..e5a5946 100755 --- a/src/jalview/gui/IdCanvas.java +++ b/src/jalview/gui/IdCanvas.java @@ -55,7 +55,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI BufferedImage image; - Graphics2D gg; +// Graphics2D gg; int imgHeight = 0; @@ -152,10 +152,11 @@ public class IdCanvas extends JPanel implements ViewportListenerI */ public void fastPaint(int vertical) { + /* * for now, not attempting fast paint of wrapped ids... */ - if (gg == null || av.getWrapAlignment()) + if (image == null || av.getWrapAlignment()) { repaint(); @@ -164,6 +165,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI ViewportRanges ranges = av.getRanges(); + Graphics2D gg = image.createGraphics(); gg.copyArea(0, 0, getWidth(), imgHeight, 0, -vertical * av.getCharHeight()); @@ -200,6 +202,8 @@ public class IdCanvas extends JPanel implements ViewportListenerI gg.translate(0, -transY); + gg.dispose(); + fastPaint = true; // Call repaint on alignment panel so that repaints from other alignment @@ -217,8 +221,6 @@ public class IdCanvas extends JPanel implements ViewportListenerI @Override public void paintComponent(Graphics g) { - super.paintComponent(g); - g.setColor(Color.white); g.fillRect(0, 0, getWidth(), getHeight()); @@ -246,13 +248,15 @@ public class IdCanvas extends JPanel implements ViewportListenerI BufferedImage.TYPE_INT_RGB); } - gg = (Graphics2D) image.getGraphics(); + Graphics2D gg = image.createGraphics(); // Fill in the background gg.setColor(Color.white); gg.fillRect(0, 0, getWidth(), imgHeight); drawIds(gg, av, av.getRanges().getStartSeq(), av.getRanges().getEndSeq(), searchResults); + + gg.dispose(); g.drawImage(image, 0, 0, this); } @@ -380,12 +384,6 @@ public class IdCanvas extends JPanel implements ViewportListenerI int alignmentWidth = alignViewport.getAlignment().getWidth(); final int alheight = alignViewport.getAlignment().getHeight(); - if (alignViewport.hasHiddenColumns()) - { - alignmentWidth = alignViewport.getAlignment().getHiddenColumns() - .absoluteToVisibleColumn(alignmentWidth) - 1; - } - int annotationHeight = 0; AnnotationLabels labels = null; @@ -581,21 +579,45 @@ public class IdCanvas extends JPanel implements ViewportListenerI @Override public void propertyChange(PropertyChangeEvent evt) { + // BH just clarifying logic String propertyName = evt.getPropertyName(); - if (propertyName.equals(ViewportRanges.STARTSEQ) - || (av.getWrapAlignment() - && propertyName.equals(ViewportRanges.STARTRES))) - { + switch (propertyName) { + case ViewportRanges.STARTSEQ: fastPaint((int) evt.getNewValue() - (int) evt.getOldValue()); - } - else if (propertyName.equals(ViewportRanges.STARTRESANDSEQ)) - { + return; + case ViewportRanges.STARTRES: + if (av.getWrapAlignment()) + { + fastPaint((int) evt.getNewValue() - (int) evt.getOldValue()); + } + return; + case ViewportRanges.STARTRESANDSEQ: fastPaint(((int[]) evt.getNewValue())[1] - ((int[]) evt.getOldValue())[1]); - } - else if (propertyName.equals(ViewportRanges.MOVE_VIEWPORT)) - { + return; + case ViewportRanges.MOVE_VIEWPORT: repaint(); + return; + case ViewportRanges.ENDRES: + case ViewportRanges.ENDSEQ: + // ignore ?? + return; } +// BH 2019.07.27 was: +// if (propertyName.equals(ViewportRanges.STARTSEQ) +// || (av.getWrapAlignment() +// && propertyName.equals(ViewportRanges.STARTRES))) +// { +// fastPaint((int) evt.getNewValue() - (int) evt.getOldValue()); +// } +// else if (propertyName.equals(ViewportRanges.STARTRESANDSEQ)) +// { +// fastPaint(((int[]) evt.getNewValue())[1] +// - ((int[]) evt.getOldValue())[1]); +// } +// else if (propertyName.equals(ViewportRanges.MOVE_VIEWPORT)) +// { +// repaint(); + // } } }