import jalview.schemes.*;\r
\r
import java.awt.*;\r
+import java.awt.image.BufferedImage;\r
\r
\r
/**\r
return resBoxColour;\r
}\r
\r
+ BufferedImage bi;\r
+ public Color findSequenceColour(Color initialCol, SequenceI seq, int i)\r
+ {\r
+ if (bi == null)\r
+ bi = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);\r
+\r
+ bi.getGraphics().setColor(initialCol);\r
+ bi.getGraphics().fillRect(0, 0, 1, 1);\r
+ allGroups = av.alignment.findAllGroups(seq);\r
+ graphics = bi.getGraphics();\r
+\r
+ drawBoxes(seq, i,i, 0, 0, 1,1);\r
+\r
+ return new Color(bi.getRGB(0, 0));\r
+ }\r
+\r
+\r
/**\r
* DOCUMENT ME!\r
*\r
public void drawBoxes(SequenceI seq, int start, int end, int x1, int y1,\r
int width, int height)\r
{\r
- int i = start;\r
- int length = seq.getLength();\r
+ int i = start;\r
+ int length = seq.getLength();\r
+\r
+ int curStart = -1;\r
+ int curWidth = width;\r
\r
- int curStart = -1;\r
- int curWidth = width;\r
+ Color tempColour = null;\r
\r
- Color tempColour = null;\r
+ while (i <= end)\r
+ {\r
+ resBoxColour = Color.white;\r
\r
- while ((i <= end) && (i < length))\r
+ if (i < length)\r
{\r
- if (inCurrentSequenceGroup(i))\r
- {\r
- if (currentSequenceGroup.getDisplayBoxes())\r
- {\r
- getBoxColour(currentSequenceGroup.cs, seq, i);\r
- }\r
- else\r
- {\r
- resBoxColour = Color.white;\r
- }\r
- }\r
- else if (av.getShowBoxes())\r
+ if (inCurrentSequenceGroup(i))\r
+ {\r
+ if (currentSequenceGroup.getDisplayBoxes())\r
{\r
- getBoxColour(av.getGlobalColourScheme(), seq, i);\r
- }\r
- else\r
- {\r
- resBoxColour = Color.white;\r
+ getBoxColour(currentSequenceGroup.cs, seq, i);\r
}\r
+ }\r
+ else if (av.getShowBoxes())\r
+ {\r
+ getBoxColour(av.getGlobalColourScheme(), seq, i);\r
+ }\r
\r
- if (resBoxColour != tempColour)\r
- {\r
- if (tempColour != null)\r
- {\r
- graphics.fillRect(x1 + (width * (curStart - start)), y1,\r
- curWidth, height);\r
- }\r
+ }\r
\r
- graphics.setColor(resBoxColour);\r
+ if (resBoxColour != tempColour)\r
+ {\r
+ if (tempColour != null)\r
+ {\r
+ graphics.fillRect(x1 + (width * (curStart - start)), y1,\r
+ curWidth, height);\r
+ }\r
\r
- curStart = i;\r
- curWidth = width;\r
- tempColour = resBoxColour;\r
- }\r
- else\r
- {\r
- curWidth += width;\r
- }\r
+ graphics.setColor(resBoxColour);\r
\r
- i++;\r
- }\r
+ curStart = i;\r
+ curWidth = width;\r
+ tempColour = resBoxColour;\r
+ }\r
+ else\r
+ {\r
+ curWidth += width;\r
+ }\r
+\r
+ i++;\r
+ }\r
+\r
+ graphics.fillRect(x1 + (width * (curStart - start)), y1, curWidth,\r
+ height);\r
\r
- graphics.fillRect(x1 + (width * (curStart - start)), y1, curWidth,\r
- height);\r
}\r
\r
/**\r
int charOffset = 0;\r
char s;\r
\r
+\r
// Need to find the sequence position here.\r
String sequence = seq.getSequence();\r
\r
+ if(end+1>=seq.getLength())\r
+ end = seq.getLength()-1;\r
+\r
for (int i = start; i <= end; i++)\r
{\r
graphics.setColor(Color.black);\r
\r
- if (i < sequence.length())\r
- {\r
- s = sequence.charAt(i);\r
- }\r
- else\r
- {\r
- s = ' ';\r
- }\r
+ s = sequence.charAt(i);\r
\r
if (!renderGaps && jalview.util.Comparison.isGap(s))\r
{\r
\r
charOffset = (width - fm.charWidth(s)) / 2;\r
graphics.drawString(String.valueOf(s),\r
- charOffset + x1 + (width * (i - start)), (y1 + height) - pady);\r
+ charOffset + x1 + (int)(width * (i - start)), (y1 + height) - pady);\r
+\r
}\r
}\r
\r