X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FIdCanvas.java;h=882ed7ae2aa060d5451a8c9674d0d93965008f03;hb=1d8e0e97d2c2ab180a51756be7413364908d15b7;hp=cb7fddfd70e891075c7971d20aa4c152245a2abb;hpb=4532dfefeac026198bfea1b9dbe84186e870bfc8;p=jalview.git diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index cb7fddf..882ed7a 100755 --- a/src/jalview/gui/IdCanvas.java +++ b/src/jalview/gui/IdCanvas.java @@ -17,6 +17,9 @@ public class IdCanvas extends JPanel BufferedImage image; Graphics2D gg; int imgHeight=0; + boolean fastPaint = false; + + java.util.Vector searchResults; public IdCanvas(AlignViewport av) { @@ -28,8 +31,13 @@ public class IdCanvas extends JPanel public void drawIdString(Graphics2D gg,SequenceI s,int i, int starty, int ypos) { int charHeight = av.getCharHeight(); - - if (av.getSelectionGroup()!=null && av.getSelectionGroup().sequences.contains(s)) { + if(searchResults!=null && searchResults.contains(s)) + { + gg.setColor(Color.black); + gg.fillRect(0,AlignmentUtil.getPixelHeight(starty,i,charHeight)+ ypos,getWidth(),charHeight); + gg.setColor(Color.white); + } + else if (av.getSelectionGroup()!=null && av.getSelectionGroup().sequences.contains(s)) { gg.setColor(Color.lightGray); gg.fillRect(0,AlignmentUtil.getPixelHeight(starty,i,charHeight)+ ypos,getWidth(),charHeight); gg.setColor(Color.white); @@ -49,25 +57,29 @@ 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 ); int ss=av.startSeq, es=av.endSeq, transY = 0; - if(vertical>0) // scroll down + if (vertical > 0) // scroll down { - transY = imgHeight - vertical*av.charHeight; ss = es - vertical; + if(ss av.endSeq) + es = av.endSeq; } + + gg.translate(0, transY); drawIds(ss, es); @@ -75,11 +87,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) + { + fastPaint = false; + g.drawImage(image, 0, 0, this); + return; + } + imgHeight = getHeight(); imgHeight -= imgHeight % av.charHeight; image = new BufferedImage(getWidth(), imgHeight, BufferedImage.TYPE_INT_RGB); @@ -93,10 +116,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); @@ -104,18 +123,18 @@ public class IdCanvas extends JPanel void drawIds(int starty, int endy) { - Color currentColor = Color.white; Color currentTextColor = Color.black; if (av.getWrapAlignment()) { + + int rowSize = av.getEndRes() - av.getStartRes(); // Draw the rest of the panels - int chunkHeight = (av.alignment.getHeight() + 2)*av.charHeight; - int row = av.getStartRes() / av.chunkWidth ; - for(int ypos=2*av.charHeight; - ypos <= getHeight() && row*av.chunkWidth