{\r
FeatureRenderer fr;\r
Image img;\r
- Graphics gg;\r
+ Graphics2D gg;\r
int imgWidth;\r
int imgHeight;\r
\r
AlignViewport av;\r
\r
- public boolean paintFlag = false;\r
-\r
boolean showScores = false;\r
boolean displaySearch = false;\r
int [] searchResults = null;\r
int chunkHeight;\r
int chunkWidth;\r
\r
+ boolean fastPaint = false;\r
+\r
\r
public SeqCanvas(AlignViewport av)\r
{\r
}\r
\r
\r
+public void fastPaint(int horizontal, int vertical)\r
+{\r
+ if (horizontal == 0 && vertical == 0)\r
+ return;\r
+\r
+ gg.copyArea(0, 0, imgWidth, imgHeight, -horizontal * av.charWidth,\r
+ -vertical * av.charHeight);\r
+\r
+ int sr = av.startRes, er = av.endRes + 1, ss = av.startSeq, es = av.endSeq,\r
+ transX = 0, transY = 0;\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
+ er = sr - horizontal;\r
+\r
+ else if (vertical > 0) // scroll down\r
+ {\r
+ transY = imgHeight - vertical * av.charHeight;\r
+ ss = es - vertical;\r
+ }\r
+ else if (vertical < 0)\r
+ es = ss - vertical;\r
+\r
+ gg.translate(transX, transY);\r
+\r
+\r
+ drawPanel(gg, sr, er, ss, es, sr, ss, 0);\r
+ gg.translate( -transX, -transY);\r
+\r
+ fastPaint = true;\r
+ repaint();\r
+\r
+}\r
+\r
/**\r
* Definitions of startx and endx (hopefully):\r
* SMJS This is what I'm working towards!\r
\r
public void paintComponent(Graphics g)\r
{\r
+ g.setColor(Color.white);\r
+ g.fillRect(0, 0, getWidth(), getHeight());\r
\r
- if (img==null || imgWidth!=getWidth() || imgHeight!=getHeight() || paintFlag)\r
+ if (fastPaint)\r
{\r
+ g.drawImage(img, 0, 0, this);\r
+ fastPaint = false;\r
+ return;\r
+ }\r
+\r
+ // this draws the whole of the alignment\r
imgWidth = getWidth();\r
imgHeight = getHeight();\r
+\r
+ imgWidth -= imgWidth%av.charWidth;\r
+ imgHeight-= imgHeight%av.charHeight;\r
+\r
img = createImage(imgWidth,imgHeight);\r
- gg = img.getGraphics();\r
+ gg = (Graphics2D)img.getGraphics();\r
gg.setFont(av.getFont());\r
- paintFlag = false;\r
- }\r
+ gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);\r
\r
+ gg.setColor(Color.white);\r
+ gg.fillRect(0,0,imgWidth,imgHeight);\r
\r
chunkWidth = getWidth()/av.charWidth;\r
chunkHeight = (av.getAlignment().getHeight() + 2)*av.charHeight;\r
av.setChunkHeight(chunkHeight);\r
av.setChunkWidth(chunkWidth);\r
\r
- fillBackground(gg,Color.WHITE,0,0,imgWidth,imgHeight);\r
\r
if (av.getWrapAlignment())\r
drawWrappedPanel(gg, getWidth(), getHeight(), av.startRes);\r
else\r
drawPanel(gg, av.startRes, av.endRes, av.startSeq, av.endSeq, av.startRes, av.startSeq, 0);\r
\r
-\r
- g.drawImage(img,0,0,this);\r
+ g.drawImage(img, 0, 0, this);\r
\r
}\r
\r
}\r
\r
\r
- public void drawPanel(Graphics g,int x1,int x2, int y1, int y2,int startx, int starty,int offset) {\r
-\r
+ public void drawPanel(Graphics g1,int x1,int x2, int y1, int y2,int startx, int starty,int offset) {\r
\r
+ Graphics2D g = (Graphics2D)g1;\r
g.setFont(av.getFont());\r
RendererI sr = av.getRenderer();\r
\r
/////////////////////////////\r
for (int i = y1 ; i < y2 ;i++)\r
{\r
- nextSeq = av.getAlignment().getSequenceAt(i);\r
+ nextSeq = av.alignment.getSequenceAt(i);\r
\r
sr.drawSequence(g, nextSeq, av.alignment.findAllGroups( nextSeq ),x1,x2,\r
(x1 - startx) * av.charWidth,\r
int oldY = -1;\r
int i = 0;\r
boolean inGroup = false;\r
+ int top=-1, bottom =-1;\r
for (i = y1; i < y2; i++)\r
{\r
sx = (group.getStartRes() - startx) * av.charWidth;\r
sy = offset + AlignmentUtil.getPixelHeight(starty, i, av.charHeight);\r
ex = (group.getEndRes() + 1 - group.getStartRes()) * av.charWidth;\r
\r
- if (group.sequences.contains(av.alignment.getSequenceAt(i))\r
- && sx < getWidth()\r
- && ex > 0)\r
+\r
+ if (sx < getWidth()\r
+ && ex > 0\r
+ && group.sequences.contains(av.alignment.getSequenceAt(i)))\r
{\r
+\r
+ if (bottom == -1 &&\r
+ !group.sequences.contains(av.alignment.getSequenceAt(i + 1)))\r
+ bottom = sy + av.charHeight ;\r
+\r
if (!inGroup)\r
{\r
+ if (top == -1 && i==0 ||\r
+ !group.sequences.contains(av.alignment.getSequenceAt(i - 1)))\r
+ top = sy;\r
+\r
+\r
oldY = sy;\r
inGroup = true;\r
if (group == av.getSelectionGroup())\r
- g.setColor(Color.RED.brighter());\r
+ {\r
+ g.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 3f, new float[]{5f,3f}, 0f ));\r
+ g.setColor(Color.RED);\r
+ }\r
else\r
+ {\r
+ g.setStroke(new BasicStroke());\r
g.setColor(group.getOutlineColour());\r
+ }\r
}\r
}\r
else\r
{\r
if (inGroup)\r
{\r
- g.drawRect(sx, oldY, ex, (sy - oldY));\r
+ g.drawLine(sx, oldY, sx, sy );\r
+ g.drawLine(sx+ex, oldY, sx+ex, sy );\r
+\r
+ if (top != -1)\r
+ {\r
+ g.drawLine(sx, top, sx + ex, top);\r
+ top =-1;\r
+ }\r
+ if (bottom != -1)\r
+ {\r
+ g.drawLine(sx, bottom, sx + ex, bottom);\r
+ bottom = -1;\r
+ }\r
+\r
+\r
inGroup = false;\r
}\r
}\r
}\r
+\r
if (inGroup)\r
{\r
+\r
+ if(top!=-1)\r
+ {\r
+ g.drawLine(sx, top, sx + ex, top);\r
+ top =-1;\r
+ }\r
+ if(bottom!=-1)\r
+ {\r
+ g.drawLine(sx, bottom-1, sx + ex, bottom-1);\r
+ bottom = -1;\r
+\r
+ }\r
sy = offset + AlignmentUtil.getPixelHeight(starty, i, av.charHeight);\r
- g.drawRect(sx, oldY, ex, (sy - oldY));\r
+ g.drawLine(sx, oldY, sx, sy );\r
+ g.drawLine(sx+ex, oldY, sx+ex, sy );\r
inGroup = false;\r
}\r
-\r
groupIndex++;\r
if (groupIndex >= groups.size())\r
break;\r
\r
}\r
\r
- public void fillBackground(Graphics g,Color c, int x1,int y1,int width,int height) {\r
- g.setColor(c);\r
- g.fillRect(x1,y1,width,height);\r
- }\r
\r
public int getChunkWidth() {\r
return chunkWidth;\r
\r
searchResults = results;\r
\r
- paintFlag = true;\r
repaint();\r
}\r
\r