X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FIdCanvas.java;h=6c50f31c69535d35b5afd94f84564253b9c16794;hb=1d1a30610226ffdb296e6ceb986b3fe0298f2158;hp=a526fb182a3f1487a0ecc046102fd07049a3cb54;hpb=185f40ac45106467bad7a58d1b0f6fd389f0d54c;p=jalview.git diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index a526fb1..6c50f31 100755 --- a/src/jalview/gui/IdCanvas.java +++ b/src/jalview/gui/IdCanvas.java @@ -2,7 +2,7 @@ package jalview.gui; import java.awt.*; import java.awt.Graphics2D.*; - +import java.awt.image.*; import javax.swing.*; import jalview.datamodel.*; import jalview.analysis.*; @@ -14,6 +14,10 @@ public class IdCanvas extends JPanel protected int maxIdLength = -1; protected String maxIdStr = null; + BufferedImage image; + Graphics2D gg; + int imgHeight=0; + boolean fastPaint = false; public IdCanvas(AlignViewport av) { @@ -22,7 +26,7 @@ public class IdCanvas extends JPanel PaintRefresher.Register(this); } - public void drawIdString(Graphics gg,SequenceI s,int i, int starty, int ypos) { + public void drawIdString(Graphics2D gg,SequenceI s,int i, int starty, int ypos) { int charHeight = av.getCharHeight(); @@ -44,37 +48,90 @@ public class IdCanvas extends JPanel } - public void paintComponent(Graphics gg) { - AlignmentI al = av.alignment; - int charHeight = av.charHeight; - Font italic = new Font(av.getFont().getName(), Font.ITALIC, av.getFont().getSize()); + public void fastPaint(int vertical) + { + if(gg==null) + { repaint(); return;} + + gg.copyArea( 0,0, getWidth(), imgHeight, 0, -vertical*av.charHeight ); - gg.setFont(italic); + int ss=av.startSeq, es=av.endSeq, transY = 0; + if (vertical > 0) // scroll down + { + ss = es - vertical; + if(ss av.endSeq) + es = av.endSeq; + } + + + + gg.translate(0, transY); + drawIds(ss, es); + + gg.translate( 0, -transY ); + + + 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); + gg = (Graphics2D) image.getGraphics(); //Fill in the background gg.setColor(Color.white); - gg.fillRect(0,0,getWidth(),getHeight()); + gg.fillRect(0, 0, getWidth(), imgHeight); + gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + Font italic = new Font(av.getFont().getName(), Font.ITALIC, + av.getFont().getSize()); + gg.setFont(italic); + + drawIds( av.getStartSeq(), av.endSeq); + + g.drawImage(image, 0, 0, this); + } + void drawIds(int starty, int endy) + { Color currentColor = Color.white; Color currentTextColor = Color.black; - //Which ids are we printing - int starty = av.getStartSeq(); - int endy = av.endSeq; - if (av.getWrapAlignment()) { + + int rowSize = av.getEndRes() - av.getStartRes(); // Draw the rest of the panels - int chunkHeight = (al.getHeight() + 2)*av.charHeight; - int row = av.getStartRes() / av.chunkWidth ; - for(int ypos=2*av.charHeight; - ypos <= getHeight() && row*av.chunkWidth