From: amwaterhouse Date: Thu, 7 Apr 2005 11:34:45 +0000 (+0000) Subject: fastPaint flag added X-Git-Tag: Release_2_0~474 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=c3162a6dd5f226c743bce629cf125a17c9b67711;p=jalview.git fastPaint flag added --- diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 5c6bcf4..f14b199 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -29,6 +29,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, MouseMotio FontMetrics fm; int imgWidth=0; + boolean fastPaint = false; @@ -320,6 +321,13 @@ public class AnnotationPanel extends JPanel implements MouseListener, MouseMotio g.setColor(Color.white); g.fillRect(0,0,getWidth(), getHeight()); + if(fastPaint) + { + g.drawImage(image, 0, 0, this); + fastPaint = false; + return; + } + imgWidth = (av.endRes-av.startRes+1) *av.charWidth; image = new BufferedImage(imgWidth, @@ -366,7 +374,8 @@ public class AnnotationPanel extends JPanel implements MouseListener, MouseMotio gg.translate( -transX, 0 ); - getGraphics().drawImage(image, 0, 0, this); + fastPaint = true; + repaint(); } diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index cb7fddf..959c83c 100755 --- a/src/jalview/gui/IdCanvas.java +++ b/src/jalview/gui/IdCanvas.java @@ -17,6 +17,7 @@ public class IdCanvas extends JPanel BufferedImage image; Graphics2D gg; int imgHeight=0; + boolean fastPaint = false; public IdCanvas(AlignViewport av) { @@ -49,11 +50,8 @@ public class IdCanvas extends JPanel public void fastPaint(int vertical) { - if(image==null) - { - repaint(); - return; - } + if(gg==null) + { repaint(); return;} gg.copyArea( 0,0, getWidth(), imgHeight, 0, -vertical*av.charHeight ); @@ -75,11 +73,22 @@ public class IdCanvas extends JPanel gg.translate( 0, -transY ); - getGraphics().drawImage(image, 0, 0, this); + fastPaint = true; + repaint(); } public void paintComponent(Graphics g) { + g.setColor(Color.white); + g.fillRect(0, 0, getWidth(), getHeight()); + + if (fastPaint) + { + g.drawImage(image, 0, 0, this); + fastPaint = false; + return; + } + imgHeight = getHeight(); imgHeight -= imgHeight % av.charHeight; image = new BufferedImage(getWidth(), imgHeight, BufferedImage.TYPE_INT_RGB); @@ -93,10 +102,6 @@ public class IdCanvas extends JPanel av.getFont().getSize()); gg.setFont(italic); - - g.setColor(Color.white); - g.fillRect(0,0,getWidth(),getHeight()); - drawIds( av.getStartSeq(), av.endSeq); g.drawImage(image, 0, 0, this); diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index ff9488e..c6ecff2 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -16,7 +16,7 @@ public class SeqCanvas extends JPanel AlignViewport av; - public boolean paintFlag = false; + // public boolean paintFlag = false; boolean showScores = false; boolean displaySearch = false; @@ -25,6 +25,8 @@ public class SeqCanvas extends JPanel int chunkHeight; int chunkWidth; + boolean fastPaint = false; + public SeqCanvas(AlignViewport av) { @@ -58,12 +60,6 @@ public void fastPaint(int horizontal, int vertical) if (horizontal == 0 && vertical == 0) return; - if (img == null || paintFlag) - { - repaint(); - return; - } - gg.copyArea(0, 0, imgWidth, imgHeight, -horizontal * av.charWidth, -vertical * av.charHeight); @@ -90,7 +86,9 @@ public void fastPaint(int horizontal, int vertical) drawPanel(gg, sr, er, ss, es, sr, ss, 0); gg.translate( -transX, -transY); - getGraphics().drawImage(img, 0, 0, this); + + fastPaint = true; + repaint(); } @@ -107,6 +105,16 @@ public void fastPaint(int horizontal, int vertical) public void paintComponent(Graphics g) { + g.setColor(Color.white); + g.fillRect(0, 0, getWidth(), getHeight()); + + if (fastPaint) + { + g.drawImage(img, 0, 0, this); + fastPaint = false; + return; + } + // this draws the whole of the alignment imgWidth = getWidth(); imgHeight = getHeight(); @@ -118,7 +126,6 @@ public void fastPaint(int horizontal, int vertical) gg = (Graphics2D)img.getGraphics(); gg.setFont(av.getFont()); gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); - paintFlag = false; gg.setColor(Color.white); gg.fillRect(0,0,imgWidth,imgHeight); @@ -135,9 +142,7 @@ public void fastPaint(int horizontal, int vertical) else drawPanel(gg, av.startRes, av.endRes, av.startSeq, av.endSeq, av.startRes, av.startSeq, 0); - g.setColor(Color.white); - g.fillRect(0,0,getWidth(),getHeight()); - g.drawImage(img,0,0,this); + g.drawImage(img, 0, 0, this); } @@ -259,7 +264,7 @@ public void fastPaint(int horizontal, int vertical) if (bottom == -1 && !group.sequences.contains(av.alignment.getSequenceAt(i + 1))) - bottom = sy + av.charHeight - 1; + bottom = sy + av.charHeight -1; if (!inGroup) { @@ -364,7 +369,6 @@ public void fastPaint(int horizontal, int vertical) searchResults = results; - paintFlag = true; repaint(); }