X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FIdCanvas.java;h=0731bf3fa1cbe219d4420126228f7acc4d1cfbb4;hb=02e2fe79e8c9c2e5e751c33cf6aec4ae25e3c993;hp=951db786136f8634d7fb6ab649d77fe446348b63;hpb=985fd5ff517f3eb5221a7aefec88138341514779;p=jalview.git diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index 951db78..0731bf3 100755 --- a/src/jalview/gui/IdCanvas.java +++ b/src/jalview/gui/IdCanvas.java @@ -55,11 +55,11 @@ public class IdCanvas extends JPanel implements ViewportListenerI BufferedImage image; - Graphics2D gg; +// Graphics2D gg; int imgHeight = 0; - boolean fastPaint = false; + private boolean fastPaint = false; List searchResults; @@ -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); } @@ -576,20 +580,34 @@ public class IdCanvas extends JPanel implements ViewportListenerI public void propertyChange(PropertyChangeEvent evt) { 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)) - { + break; + case ViewportRanges.STARTRES: + if (av.getWrapAlignment()) + { + fastPaint((int) evt.getNewValue() - (int) evt.getOldValue()); + } + break; + case ViewportRanges.STARTRESANDSEQ: fastPaint(((int[]) evt.getNewValue())[1] - ((int[]) evt.getOldValue())[1]); - } - else if (propertyName.equals(ViewportRanges.MOVE_VIEWPORT)) - { + break; + case ViewportRanges.MOVE_VIEWPORT: repaint(); + break; + default: } } + + /** + * Clears the flag that allows a 'fast paint' on the next repaint, so + * requiring a full repaint + */ + public void setNoFastPaint() + { + fastPaint = false; + } }