package jalview.gui;\r
\r
import java.awt.*;\r
+import java.awt.image.*;\r
import javax.swing.*;\r
import jalview.datamodel.*;\r
import jalview.analysis.*;\r
public class SeqCanvas extends JPanel\r
{\r
FeatureRenderer fr;\r
- Image img;\r
+ BufferedImage img;\r
Graphics2D gg;\r
int imgWidth;\r
int imgHeight;\r
}\r
if(value!=-1)\r
{\r
- int x = fm.stringWidth("000") - fm.stringWidth(value+"");\r
+ int x = LABEL_WEST - fm.stringWidth(value+"");\r
g.drawString(value + "", x, ypos + i*av.charHeight - av.charHeight/5);\r
}\r
}\r
imgWidth -= imgWidth%av.charWidth;\r
imgHeight-= imgHeight%av.charHeight;\r
\r
- img = createImage(imgWidth,imgHeight);\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,RenderingHints.VALUE_ANTIALIAS_ON);\r
\r
}\r
\r
+ int LABEL_WEST, LABEL_EAST;\r
public int getWrappedCanvasWidth(int cwidth)\r
{\r
FontMetrics fm = getFontMetrics(av.getFont());\r
\r
- int LABEL_EAST = 0;\r
+ LABEL_EAST = 0;\r
+ LABEL_WEST = 0;\r
+\r
if(av.scaleRightWrapped)\r
LABEL_EAST = fm.stringWidth( av.alignment.getWidth()+"000" );\r
- int LABEL_WEST = 0;\r
+\r
if(av.scaleLeftWrapped)\r
- LABEL_WEST = fm.stringWidth( av.alignment.getWidth()+"0" );\r
+ LABEL_WEST = fm.stringWidth( av.alignment.getWidth()+"" );\r
\r
return (cwidth - LABEL_EAST -LABEL_WEST)/av.charWidth;\r
}\r
LABEL_EAST = fm.stringWidth( al.getWidth()+"000" );\r
int LABEL_WEST = 0;\r
if(av.scaleLeftWrapped)\r
- LABEL_WEST = fm.stringWidth( al.getWidth()+"0" );\r
+ LABEL_WEST = fm.stringWidth(al.getWidth()+"0");\r
+\r
\r
int cWidth = (canvasWidth - LABEL_EAST -LABEL_WEST)/av.charWidth;\r
int cHeight = (av.getAlignment().getHeight() + 2)*av.charHeight;\r
int ypos = 2*av.charHeight;\r
\r
\r
- while (ypos <= canvasHeight)\r
+ while (ypos <= canvasHeight && startRes<av.alignment.getWidth() )\r
{\r
g.setColor(Color.black);\r
\r
g.translate( - (canvasWidth - LABEL_EAST+av.charWidth), 0);\r
}\r
\r
-\r
g.translate(LABEL_WEST,0);\r
if(av.scaleAboveWrapped)\r
drawNorthScale(g, startRes, endx, ypos);\r
\r
+ g.setClip(0, 0, cWidth*av.charWidth, getHeight());\r
drawPanel(g, startRes, endx, 0, al.getHeight(), startRes, 0, ypos);\r
+ g.setClip(null);\r
g.translate(-LABEL_WEST,0);\r
\r
ypos += cHeight;\r
g.setFont(av.getFont());\r
RendererI sr = av.getRenderer();\r
\r
- /*Vector pid = av.getConsensus(false);\r
- Vector tmpseq = new Vector();\r
- for (int i = 0; i < av.getAlignment().getHeight(); i++)\r
- if (!av.getSelection().contains(av.getAlignment().getSequenceAt(i)))\r
- tmpseq.addElement(av.getAlignment().getSequenceAt(i));\r
-\r
- if (sr instanceof SequenceRenderer)\r
- pid = AAFrequency.calculate(tmpseq,x1,x2);\r
-\r
- else if (sr instanceof GraphRenderer)\r
- pid = AAFrequency.calculatePID(av.getAlignment().getSequenceAt(0),\r
- av.getAlignment().getSequences(),\r
- av.getPIDWindow(),x1,x2);\r
-\r
-*/\r
-\r
- /* if (y2 > starty && y1 < av.getEndSeq())\r
- {\r
- fillBackground(g,\r
- Color.red,\r
- (x1-startx)*charWidth,\r
- offset + AlignmentUtil.getPixelHeight(starty,y1,av.getCharHeight()),\r
- (x2-x1+1)*charWidth,\r
- offset + AlignmentUtil.getPixelHeight(y1,y2,av.getCharHeight()));\r
- }*/\r
-\r
SequenceI nextSeq;\r
\r
/// First draw the sequences\r
sy = offset + AlignmentUtil.getPixelHeight(starty, i, av.charHeight);\r
ex = (group.getEndRes() + 1 - group.getStartRes()) * av.charWidth -1;\r
\r
- if (av.getWrapAlignment())\r
- {\r
- if (sx < 0)\r
- sx = 0;\r
-\r
- if (ex > getWidth())\r
- ex = getWrappedCanvasWidth(getWidth()) * av.charWidth;\r
- }\r
-\r
if (sx < getWidth()\r
&& ex > 0\r
&& group.sequences.contains(av.alignment.getSequenceAt(i)))\r