\r
}\r
\r
- public void drawScale(Graphics g, int startx, int endx,int ypos) {\r
- int scalestartx = startx - startx%10 + 10;\r
+ void drawNorthScale(Graphics g, int startx, int endx,int ypos) {\r
+ int scalestartx = startx - startx % 10 + 10;\r
\r
- g.setColor(Color.black);\r
+ g.setColor(Color.black);\r
\r
- for (int i=scalestartx;i < endx;i+= 10)\r
+ // NORTH SCALE\r
+ for (int i = scalestartx; i < endx; i += 10)\r
+ {\r
+ String string = String.valueOf(i);\r
+ g.drawString(string, (i - startx - 1) * av.charWidth,\r
+ ypos - av.charHeight / 2);\r
+\r
+ g.drawLine( (i - startx - 1) * av.charWidth + av.charWidth / 2,\r
+ ypos + 2 - av.charHeight / 2,\r
+ (i - startx - 1) * av.charWidth + av.charWidth / 2, ypos - 2);\r
+\r
+ }\r
+ }\r
+\r
+ void drawWestScale(Graphics g, int startx, int endx, int ypos)\r
+ {\r
+ FontMetrics fm = getFontMetrics(av.getFont());\r
+ ypos+= av.charHeight;\r
+ // EAST SCALE\r
+ for (int i = 0; i < av.alignment.getHeight(); i++)\r
+ {\r
+ SequenceI seq = av.alignment.getSequenceAt(i);\r
+ int index = startx;\r
+ int value = -1;\r
+ while (index < endx)\r
{\r
- String string = String.valueOf(i);\r
- g.drawString(string,(i-startx-1)*av.charWidth,ypos - av.charHeight/2);\r
+ if (jalview.util.Comparison.isGap(seq.getCharAt(index)))\r
+ {\r
+ index++;\r
+ continue;\r
+ }\r
\r
- g.drawLine( (i-startx-1)*av.charWidth +av.charWidth/2, ypos+2 - av.charHeight/2,\r
- (i-startx-1)*av.charWidth +av.charWidth/2, ypos-2 );\r
+ value = av.alignment.getSequenceAt(i).findPosition(index);\r
+ break;\r
+ }\r
+ if(value!=-1)\r
+ {\r
+ int x = fm.stringWidth("000") - fm.stringWidth(value+"");\r
+ g.drawString(value + "", x, ypos + i*av.charHeight - av.charHeight/5);\r
+ }\r
+ }\r
+ }\r
\r
+ void drawEastScale(Graphics g, int startx, int endx, int ypos)\r
+{\r
+ ypos+= av.charHeight;\r
+ // EAST SCALE\r
+ for (int i = 0; i < av.alignment.getHeight(); i++)\r
+ {\r
+ SequenceI seq = av.alignment.getSequenceAt(i);\r
+ int index = endx;\r
+ int value = -1;\r
+ while (index > startx)\r
+ {\r
+ if (jalview.util.Comparison.isGap(seq.getCharAt(index)))\r
+ {\r
+ index--;\r
+ continue;\r
}\r
\r
+ value = av.alignment.getSequenceAt(i).findPosition(index);\r
+ break;\r
+ }\r
+ if(value!=-1)\r
+ g.drawString(value + "", 0, ypos + i*av.charHeight - av.charHeight/5);\r
}\r
\r
+}\r
+\r
+\r
+\r
+\r
\r
public void fastPaint(int horizontal, int vertical)\r
{\r
\r
gg.translate(transX, transY);\r
\r
-\r
+ gg.setColor(Color.white);\r
+ gg.fillRect(0,0, (er-sr)*av.charWidth, (es-ss)*av.charHeight);\r
drawPanel(gg, sr, er, ss, es, sr, ss, 0);\r
gg.translate( -transX, -transY);\r
\r
gg.setColor(Color.white);\r
gg.fillRect(0,0,imgWidth,imgHeight);\r
\r
- chunkWidth = getWidth()/av.charWidth;\r
+ chunkWidth = getWrappedCanvasWidth( getWidth() );\r
chunkHeight = (av.getAlignment().getHeight() + 2)*av.charHeight;\r
\r
av.setChunkHeight(chunkHeight);\r
\r
}\r
\r
+ public int getWrappedCanvasWidth(int cwidth)\r
+ {\r
+ FontMetrics fm = getFontMetrics(av.getFont());\r
+\r
+ int LABEL_EAST = 0;\r
+ if(av.scaleRightWrapped)\r
+ LABEL_EAST = fm.stringWidth( av.alignment.getWidth()+"000" );\r
+ int LABEL_WEST = 0;\r
+ if(av.scaleLeftWrapped)\r
+ LABEL_WEST = fm.stringWidth( av.alignment.getWidth()+"0" );\r
+\r
+ return (cwidth - LABEL_EAST -LABEL_WEST)/av.charWidth;\r
+ }\r
+\r
public void drawWrappedPanel(Graphics g, int canvasWidth, int canvasHeight, int startRes)\r
{\r
- AlignmentI da = av.getAlignment();\r
+ AlignmentI al = av.getAlignment();\r
+\r
+ FontMetrics fm = getFontMetrics(av.getFont());\r
\r
- int cWidth = canvasWidth/av.charWidth;\r
+ int LABEL_EAST = 0;\r
+ if(av.scaleRightWrapped)\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
+\r
+ int cWidth = (canvasWidth - LABEL_EAST -LABEL_WEST)/av.charWidth;\r
int cHeight = (av.getAlignment().getHeight() + 2)*av.charHeight;\r
\r
int endx = startRes+cWidth-1;\r
- int ypos = 2*av.charHeight;\r
+ int ypos = 2*av.charHeight;\r
+\r
\r
- while (ypos <= canvasHeight)\r
+ while (ypos <= canvasHeight && endx <al.getWidth())\r
{\r
- drawScale(g, startRes, endx, ypos);\r
- drawPanel(g, startRes, endx, 0, da.getHeight(), startRes, 0, ypos);\r
+ g.setColor(Color.black);\r
+\r
+ if(av.scaleLeftWrapped)\r
+ drawWestScale(g, startRes, endx, ypos);\r
+\r
+ if(av.scaleRightWrapped)\r
+ {\r
+ g.translate(canvasWidth - LABEL_EAST +av.charWidth, 0);\r
+ drawEastScale(g, startRes, endx, ypos);\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
+ drawPanel(g, startRes, endx, 0, al.getHeight(), startRes, 0, ypos);\r
+ g.translate(-LABEL_WEST,0);\r
\r
ypos += cHeight;\r
startRes += cWidth;\r
endx = startRes + cWidth - 1;\r
\r
- if (endx > da.getWidth())\r
- endx = da.getWidth();\r
+ if (endx > al.getWidth())\r
+ endx = al.getWidth();\r
}\r
\r
}\r
\r
public 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
+ Graphics2D g = (Graphics2D)g1;\r
g.setFont(av.getFont());\r
RendererI sr = av.getRenderer();\r
\r
sy = offset + AlignmentUtil.getPixelHeight(starty, i, av.charHeight);\r
ex = (group.getEndRes() + 1 - group.getStartRes()) * av.charWidth;\r
\r
+ if (av.getWrapAlignment())\r
+ {\r
+ if (sx < 0)\r
+ sx = 0;\r
+\r
+ if (ex > getWidth())\r
+ {\r
+ if (av.getWrapAlignment())\r
+ ex = getWrappedCanvasWidth(getWidth()) * av.charWidth;\r
+\r
+ }\r
+ }\r
+ else if(ex>getWidth())\r
+ ex -= av.charWidth;\r
+\r
\r
if (sx < getWidth()\r
&& ex > 0\r
&& group.sequences.contains(av.alignment.getSequenceAt(i)))\r
{\r
-\r
if (bottom == -1 &&\r
!group.sequences.contains(av.alignment.getSequenceAt(i + 1)))\r
bottom = sy + av.charHeight ;\r
}\r
\r
\r
- public int getChunkWidth() {\r
- return chunkWidth;\r
- }\r
\r
public void highlightSearchResults(int [] results)\r
{\r