static Color HELIX_COLOUR = Color.red.darker();\r
static Color SHEET_COLOUR = Color.green.darker().darker();\r
\r
- BufferedImage bi;\r
+\r
+ BufferedImage image;\r
+ Graphics2D gg;\r
+ FontMetrics fm;\r
+ int imgWidth=0;\r
+\r
\r
\r
\r
\r
public void paintComponent(Graphics g)\r
{\r
- if(bi==null\r
- || bi.getWidth()!=ap.annotationPanel.getWidth()\r
- || bi.getHeight()!=ap.annotationPanel.getHeight())\r
- {\r
- bi = new BufferedImage(ap.annotationPanel.getWidth(),\r
- ap.annotationPanel.getHeight(),\r
- BufferedImage.TYPE_INT_RGB);\r
- }\r
+ g.setColor(Color.white);\r
+ g.fillRect(0,0,getWidth(), getHeight());\r
+\r
+ imgWidth = (av.endRes-av.startRes+1) *av.charWidth;\r
+\r
+ image = new BufferedImage(imgWidth,\r
+ ap.annotationPanel.getHeight(),\r
+ BufferedImage.TYPE_INT_RGB);\r
+ gg = (Graphics2D) image.getGraphics();\r
+ gg.setColor(Color.white);\r
+ gg.fillRect(0, 0, imgWidth, getHeight());\r
+ gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,\r
+ RenderingHints.VALUE_ANTIALIAS_ON);\r
+ fm = gg.getFontMetrics();\r
+ gg.setFont(av.getFont());\r
\r
- drawComponent( (Graphics2D)bi.getGraphics() );\r
- g.drawImage( bi, 0, 0, this);\r
+\r
+ drawComponent( gg, av.startRes, av.endRes+1);\r
+ g.drawImage( image, 0, 0, this);\r
}\r
\r
- public void drawComponent(Graphics2D g)\r
+ public void fastPaint(int horizontal)\r
+{\r
+ if(image==null || horizontal ==0)\r
{\r
- g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);\r
- FontMetrics fm = g.getFontMetrics();\r
- g.setFont(av.getFont());\r
- g.setColor(Color.white);\r
- g.fillRect(0,0,getWidth(),getHeight());\r
+ repaint();\r
+ return;\r
+ }\r
+\r
+ gg.copyArea( 0,0, imgWidth, getHeight(), -horizontal*av.charWidth, 0 );\r
+ int sr=av.startRes, er=av.endRes+1, transX=0;\r
\r
+ if(horizontal>0) // scrollbar pulled right, image to the left\r
+ {\r
+ transX = (er-sr-horizontal)*av.charWidth;\r
+ sr = er - horizontal ;\r
+ }\r
+ else if(horizontal<0)\r
+ {\r
+ er = sr-horizontal;\r
+ }\r
+\r
+\r
+ gg.translate(transX, 0);\r
+\r
+ drawComponent(gg, sr, er);\r
+\r
+ gg.translate( -transX, 0 );\r
+\r
+ getGraphics().drawImage(image, 0, 0, this);\r
+}\r
+\r
+\r
+ public void drawComponent(Graphics2D g, int startRes, int endRes)\r
+ {\r
+ g.setColor(Color.white);\r
+ g.fillRect(0,0,(endRes-startRes) *av.charWidth, getHeight());\r
if(av.alignment.getAlignmentAnnotation()==null || av.alignment.getAlignmentAnnotation().length<1)\r
{\r
g.setColor(Color.black);\r
else\r
iconOffset = 0;\r
\r
- for(j=av.startRes; j<av.endRes+1; j++)\r
+ for(j=startRes; j<endRes; j++)\r
{\r
validRes = row.annotations[j]==null?false:true;\r
\r
- x = (j-av.getStartRes())*av.charWidth;\r
+ x = (j-startRes)*av.charWidth;\r
\r
\r
if(activeRow==i)\r
{\r
int v = Integer.parseInt(activeRes.get(n).toString()) ;\r
if (v == j)\r
- g.fillRect( (j-av.getStartRes()) * av.charWidth, y, av.charWidth, row.height);\r
+ g.fillRect( (j-startRes) * av.charWidth, y, av.charWidth, row.height);\r
}\r
}\r
\r