int imgHeight=0;\r
boolean fastPaint = false;\r
\r
+ java.util.Vector searchResults;\r
+\r
public IdCanvas(AlignViewport av)\r
{\r
setLayout(new BorderLayout());\r
public void drawIdString(Graphics2D gg,SequenceI s,int i, int starty, int ypos) {\r
int charHeight = av.getCharHeight();\r
\r
-\r
- if (av.getSelectionGroup()!=null && av.getSelectionGroup().sequences.contains(s)) {\r
+ if(searchResults!=null && searchResults.contains(s))\r
+ {\r
+ gg.setColor(Color.black);\r
+ gg.fillRect(0,AlignmentUtil.getPixelHeight(starty,i,charHeight)+ ypos,getWidth(),charHeight);\r
+ gg.setColor(Color.white);\r
+ }\r
+ else if (av.getSelectionGroup()!=null && av.getSelectionGroup().sequences.contains(s)) {\r
gg.setColor(Color.lightGray);\r
gg.fillRect(0,AlignmentUtil.getPixelHeight(starty,i,charHeight)+ ypos,getWidth(),charHeight);\r
gg.setColor(Color.white);\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
\r
if (fastPaint)\r
{\r
- g.drawImage(image, 0, 0, this);\r
fastPaint = false;\r
+ g.drawImage(image, 0, 0, this);\r
return;\r
}\r
\r
imgHeight = getHeight();\r
imgHeight -= imgHeight % av.charHeight;\r
+\r
+ if (imgHeight<1)\r
+ return;\r
+\r
image = new BufferedImage(getWidth(), imgHeight, BufferedImage.TYPE_INT_RGB);\r
gg = (Graphics2D) image.getGraphics();\r
//Fill in the background\r
\r
void drawIds(int starty, int endy)\r
{\r
-\r
Color currentColor = Color.white;\r
Color currentTextColor = Color.black;\r
\r
-\r
if (av.getWrapAlignment())\r
{\r
\r
int rowSize = av.getEndRes() - av.getStartRes();\r
// Draw the rest of the panels\r
\r
- for(int ypos=2*av.charHeight, row=av.getEndRes()-rowSize;\r
+ for(int ypos=2*av.charHeight, row=av.startRes;\r
ypos <= getHeight() && row<av.alignment.getWidth();\r
ypos += av.chunkHeight, row+=rowSize )\r
{\r
{\r
// Selected sequence colours\r
\r
- if (av.getSelectionGroup()!= null\r
+ if(searchResults!=null && searchResults.contains(av.alignment.getSequenceAt(i)))\r
+ {\r
+ gg.setColor(Color.black);\r
+ currentColor = Color.black;\r
+ currentTextColor = Color.white;\r
+ }\r
+ else if (av.getSelectionGroup()!= null\r
&& av.getSelectionGroup().sequences.contains(av.alignment.getSequenceAt(i)))\r
{\r
- // if(av.alignment.findGroup(al.getSequenceAt(i)).getEndRes()==\r
currentColor = Color.lightGray;\r
currentTextColor = Color.black;\r
}\r
}\r
\r
}\r
+\r
+ public void setHighlighted(java.util.Vector found)\r
+ {\r
+ searchResults = found;\r
+ repaint();\r
+ }\r
}\r