BufferedImage image;\r
Graphics2D gg;\r
int imgHeight=0;\r
+ boolean fastPaint = false;\r
\r
public IdCanvas(AlignViewport av)\r
{\r
\r
public void fastPaint(int vertical)\r
{\r
- if(image==null)\r
- {\r
- repaint();\r
- return;\r
- }\r
+ if(gg==null)\r
+ { repaint(); return;}\r
\r
gg.copyArea( 0,0, getWidth(), imgHeight, 0, -vertical*av.charHeight );\r
\r
int ss=av.startSeq, es=av.endSeq, transY = 0;\r
- if(vertical>0) // scroll down\r
+ if (vertical > 0) // scroll down\r
{\r
- transY = imgHeight - vertical*av.charHeight;\r
ss = es - vertical;\r
+ if(ss<av.startSeq) // ie scrolling too fast, more than a page at a time\r
+ ss = av.startSeq;\r
+ else\r
+ transY = imgHeight - vertical * av.charHeight;\r
}\r
- else if(vertical<0)\r
+ else if (vertical < 0)\r
{\r
- es = ss-vertical;\r
+ es = ss - vertical;\r
+ if(es > av.endSeq)\r
+ es = av.endSeq;\r
}\r
\r
+\r
+\r
gg.translate(0, transY);\r
\r
drawIds(ss, es);\r
gg.translate( 0, -transY );\r
\r
\r
- getGraphics().drawImage(image, 0, 0, this);\r
+ fastPaint = true;\r
+ repaint();\r
}\r
\r
public void paintComponent(Graphics g)\r
{\r
+ g.setColor(Color.white);\r
+ g.fillRect(0, 0, getWidth(), getHeight());\r
+\r
+ if (fastPaint)\r
+ {\r
+ fastPaint = false;\r
+ g.drawImage(image, 0, 0, this);\r
+ return;\r
+ }\r
+\r
imgHeight = getHeight();\r
imgHeight -= imgHeight % av.charHeight;\r
image = new BufferedImage(getWidth(), imgHeight, BufferedImage.TYPE_INT_RGB);\r
av.getFont().getSize());\r
gg.setFont(italic);\r
\r
-\r
- g.setColor(Color.white);\r
- g.fillRect(0,0,getWidth(),getHeight());\r
-\r
drawIds( av.getStartSeq(), av.endSeq);\r
\r
g.drawImage(image, 0, 0, this);\r
\r
void drawIds(int starty, int endy)\r
{\r
-\r
Color currentColor = Color.white;\r
Color currentTextColor = Color.black;\r
\r
if (av.getWrapAlignment())\r
{\r
+\r
+ int rowSize = av.getEndRes() - av.getStartRes();\r
// Draw the rest of the panels\r
- int chunkHeight = (av.alignment.getHeight() + 2)*av.charHeight;\r
- int row = av.getStartRes() / av.chunkWidth ;\r
- for(int ypos=2*av.charHeight;\r
- ypos <= getHeight() && row*av.chunkWidth<av.alignment.getWidth();\r
- ypos += chunkHeight, row++ )\r
+\r
+ for(int ypos=2*av.charHeight, row=av.getEndRes()-rowSize;\r
+ ypos <= getHeight() && row<av.alignment.getWidth();\r
+ ypos += av.chunkHeight, row+=rowSize )\r
{\r
for (int i = starty; i < av.alignment.getHeight(); i++)\r
{\r