import java.awt.image.*;\r
\r
import javax.swing.*;\r
-import jalview.schemes.*;\r
\r
\r
/**\r
*/\r
public void fastPaint(int horizontal, int vertical)\r
{\r
- if (gg == null)\r
+ if (fastPaint || gg == null)\r
{\r
return;\r
}\r
\r
+ fastPaint = true;\r
+\r
gg.copyArea(horizontal * av.charWidth,\r
vertical * av.charHeight,\r
imgWidth,\r
drawPanel(gg, sr, er, ss, es, sr, ss, 0);\r
gg.translate(-transX, -transY);\r
\r
- fastPaint = true;\r
repaint();\r
}\r
\r
img = new BufferedImage(imgWidth, imgHeight, BufferedImage.TYPE_INT_RGB);\r
gg = (Graphics2D) img.getGraphics();\r
gg.setFont(av.getFont());\r
- gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,\r
- RenderingHints.VALUE_ANTIALIAS_ON);\r
+\r
+ if (av.antiAlias)\r
+ gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,\r
+ RenderingHints.VALUE_ANTIALIAS_ON);\r
\r
gg.setColor(Color.white);\r
gg.fillRect(0, 0, imgWidth, imgHeight);\r
}\r
\r
\r
- synchronized public void drawPanel(Graphics g1, int x1, int x2, int y1,\r
- int y2, int startx, int starty, int offset)\r
+ 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
\r
- SequenceI nextSeq, dna = null;\r
- int aaHeight = av.charHeight, dnaHeight = av.charHeight;\r
- Font dnafont = null, aafont = av.getFont();\r
+ SequenceI nextSeq;\r
+ // int aaHeight = av.charHeight;\r
+ // Font aafont = av.getFont();\r
\r
- /* if (av.getShowTranslation())\r
+ /* dnafont = null, , dna = null, dnaHeight = av.charHeight\r
+ if (av.getShowTranslation())\r
{\r
aaHeight = (int) (av.getCharHeight() * aaRatio);\r
dnaHeight = (int) (av.getCharHeight() * (1 - aaRatio));\r
}\r
*/\r
\r
- ColourSchemeI cs = av.getGlobalColourScheme();\r
\r
/// First draw the sequences\r
/////////////////////////////\r
for (int i = y1; i < y2; i++)\r
{\r
nextSeq = av.alignment.getSequenceAt(i);\r
- g.setFont(aafont);\r
+\r
/* if(av.getShowTranslation())\r
{\r
dna = nextSeq;\r
sr.drawSequence(g, nextSeq, av.alignment.findAllGroups(nextSeq),\r
x1, x2, (x1 - startx) * av.charWidth,\r
offset + ( (i - starty) * av.charHeight), av.charWidth,\r
- aaHeight);\r
+ av.charHeight);\r
\r
/* if(av.getShowTranslation())\r
{\r
SequenceGroup[] allGroups = null;\r
Color resBoxColour;\r
Graphics graphics;\r
+ boolean monospacedFont;\r
\r
/**\r
* Creates a new SequenceRenderer object.\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 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
-\r
-\r
- // Need to find the sequence position here.\r
- String sequence = seq.getSequence();\r
+ y1 += height - height / 5; // height/5 replaces pady\r
+ int charOffset = 0;\r
+ char s;\r
\r
if(end+1>=seq.getLength())\r
end = seq.getLength()-1;\r
+ graphics.setColor(Color.black);\r
\r
- for (int i = start; i <= end; i++)\r
+\r
+ if(monospacedFont && av.showText && allGroups.length==0 && !av.getColourText())\r
{\r
+ graphics.drawString(seq.getSequence(start, end + 1), x1, y1);\r
+ }\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.globalColourScheme, 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)(width * (i - start)), (y1 + height) - pady);\r
+ charOffset + x1 + width * (i - start),\r
+ y1);\r
\r
+ }\r
}\r
}\r
\r