\r
import java.awt.*;\r
\r
-\r
/**\r
* DOCUMENT ME!\r
*\r
SequenceGroup[] allGroups = null;\r
Color resBoxColour;\r
Graphics graphics;\r
+ boolean monospacedFont;\r
\r
/**\r
* Creates a new SequenceRenderer object.\r
renderGaps = b;\r
}\r
\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param cs DOCUMENT ME!\r
- * @param seq DOCUMENT ME!\r
- * @param i DOCUMENT ME!\r
- *\r
- * @return DOCUMENT ME!\r
- */\r
- public Color getResidueBoxColour(ColourSchemeI cs, SequenceI seq, int i)\r
+\r
+ public Color getResidueBoxColour(SequenceI seq, int i)\r
{\r
- getBoxColour(cs, seq, i);\r
+ allGroups = av.alignment.findAllGroups(seq);\r
\r
- return resBoxColour;\r
+ if (inCurrentSequenceGroup(i))\r
+ {\r
+ if (currentSequenceGroup.getDisplayBoxes())\r
+ {\r
+ getBoxColour(currentSequenceGroup.cs, seq, i);\r
+ }\r
+ }\r
+ else if (av.getShowBoxes())\r
+ {\r
+ getBoxColour(av.globalColourScheme, seq, i);\r
+ }\r
+\r
+ return resBoxColour;\r
}\r
\r
+\r
/**\r
* DOCUMENT ME!\r
*\r
drawBoxes(seq, start, end, x1, y1, (int) width, height);\r
\r
fm = g.getFontMetrics();\r
+\r
+ monospacedFont = fm.getStringBounds("M",g).getWidth()==fm.getStringBounds("|",g).getWidth();\r
+\r
drawText(seq, start, end, x1, y1, (int) width, height);\r
}\r
\r
* @param width DOCUMENT ME!\r
* @param height DOCUMENT ME!\r
*/\r
- public void drawBoxes(SequenceI seq, int start, int end, int x1, int y1,\r
+ public synchronized 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
+ int curStart = -1;\r
+ int curWidth = width;\r
\r
- Color tempColour = null;\r
+ Color tempColour = null;\r
\r
- while (i <= end)\r
- {\r
- resBoxColour = Color.white;\r
+ while (i <= end)\r
+ {\r
+ resBoxColour = Color.white;\r
\r
- if (i < length)\r
+ if (i < length)\r
+ {\r
+ if (inCurrentSequenceGroup(i))\r
{\r
- if (inCurrentSequenceGroup(i))\r
- {\r
- if (currentSequenceGroup.getDisplayBoxes())\r
- {\r
- getBoxColour(currentSequenceGroup.cs, seq, i);\r
- }\r
- }\r
- else if (av.getShowBoxes())\r
+ if (currentSequenceGroup.getDisplayBoxes())\r
{\r
- getBoxColour(av.getGlobalColourScheme(), seq, i);\r
+ getBoxColour(currentSequenceGroup.cs, seq, i);\r
}\r
-\r
+ }\r
+ else if (av.getShowBoxes())\r
+ {\r
+ getBoxColour(av.globalColourScheme, 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
* @param height DOCUMENT ME!\r
*/\r
public void drawText(SequenceI seq, int start, int end, int x1, int y1,\r
- int width, int height)\r
+ int width, int height)\r
{\r
- int pady = height / 5;\r
- int charOffset = 0;\r
- char s;\r
+ y1 += height - height / 5; // height/5 replaces pady\r
+ int charOffset = 0;\r
+ char s;\r
\r
- float fwidth = width + ((float)av.charWidth/(float)width)/width;\r
+ if(end+1>=seq.getLength())\r
+ end = seq.getLength()-1;\r
+ graphics.setColor(Color.black);\r
\r
\r
- if(av.charWidth != (av.charWidth/width)*width)\r
+ if(monospacedFont && av.showText && allGroups.length==0 && !av.getColourText())\r
{\r
-\r
+ graphics.drawString(seq.getSequence(start, end + 1), x1, y1);\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
+ else\r
{\r
+ for (int i = start; i <= end; i++)\r
+ {\r
graphics.setColor(Color.black);\r
-\r
- s = sequence.charAt(i);\r
-\r
+ s = seq.getCharAt(i);\r
if (!renderGaps && jalview.util.Comparison.isGap(s))\r
{\r
- continue;\r
+ continue;\r
}\r
\r
if (inCurrentSequenceGroup(i))\r
{\r
- if (!currentSequenceGroup.getDisplayText())\r
- {\r
- continue;\r
- }\r
+ if (!currentSequenceGroup.getDisplayText())\r
+ {\r
+ continue;\r
+ }\r
\r
- if (currentSequenceGroup.getColourText())\r
- {\r
- getBoxColour(currentSequenceGroup.cs, seq, i);\r
- graphics.setColor(resBoxColour.darker());\r
- }\r
+ if (currentSequenceGroup.getColourText())\r
+ {\r
+ getBoxColour(currentSequenceGroup.cs, seq, i);\r
+ graphics.setColor(resBoxColour.darker());\r
+ }\r
}\r
else\r
{\r
- if (!av.getShowText())\r
+ if (!av.getShowText())\r
+ {\r
+ continue;\r
+ }\r
+\r
+ if (av.getColourText())\r
+ {\r
+ getBoxColour(av.globalColourScheme, seq, i);\r
+\r
+ if (av.getShowBoxes())\r
{\r
- continue;\r
+ graphics.setColor(resBoxColour.darker());\r
}\r
-\r
- if (av.getColourText())\r
+ else\r
{\r
- getBoxColour(av.getGlobalColourScheme(), seq, i);\r
-\r
- if (av.getShowBoxes())\r
- {\r
- graphics.setColor(resBoxColour.darker());\r
- }\r
- else\r
- {\r
- graphics.setColor(resBoxColour);\r
- }\r
+ graphics.setColor(resBoxColour);\r
}\r
+ }\r
}\r
\r
charOffset = (width - fm.charWidth(s)) / 2;\r
graphics.drawString(String.valueOf(s),\r
- charOffset + x1 + (int)(fwidth * (i - start)), (y1 + height) - pady);\r
+ charOffset + x1 + width * (i - start),\r
+ y1);\r
+\r
+ }\r
}\r
}\r
\r