gg.setColor(Color.white);\r
gg.fillRect(0, 0, imgWidth, imgHeight);\r
\r
- chunkWidth = getWrappedCanvasWidth(getSize().width);\r
- chunkHeight = (av.getAlignment().getHeight() + 2) * av.charHeight;\r
-\r
- av.setChunkHeight(chunkHeight);\r
- av.setChunkWidth(chunkWidth);\r
\r
if (av.getWrapAlignment())\r
{\r
\r
FontMetrics fm = getFontMetrics(av.getFont());\r
\r
+ int LABEL_EAST = 0;\r
+\r
if (av.scaleRightWrapped)\r
{\r
LABEL_EAST = fm.stringWidth(getMask()+"0");\r
LABEL_WEST = fm.stringWidth(getMask());\r
}\r
\r
+ int hgap = av.charHeight;\r
+ if(av.scaleAboveWrapped)\r
+ hgap += av.charHeight;\r
+\r
int cWidth = (canvasWidth - LABEL_EAST - LABEL_WEST) / av.charWidth;\r
- int cHeight = (av.getAlignment().getHeight() + 2) * av.charHeight;\r
+ int cHeight = av.getAlignment().getHeight() * av.charHeight;\r
+\r
+ av.setWrappedWidth(cWidth);\r
\r
av.endRes = av.startRes + cWidth;\r
\r
- int endx = startRes + cWidth - 1;\r
- int ypos = 2 * av.charHeight;\r
\r
- while (ypos <= canvasHeight && startRes < av.alignment.getWidth())\r
+ int endx = (startRes + cWidth) - 1;\r
+ int ypos = hgap;\r
+\r
+\r
+ while ((ypos <= canvasHeight) && (startRes < av.alignment.getWidth()))\r
{\r
- g.setColor(Color.black);\r
+ g.setColor(Color.black);\r
\r
- if (av.scaleLeftWrapped)\r
- {\r
- drawWestScale(g, startRes, endx, ypos);\r
- }\r
+ if (av.scaleLeftWrapped)\r
+ {\r
+ drawWestScale(g, startRes, endx, ypos);\r
+ }\r
\r
- if (av.scaleRightWrapped)\r
- {\r
- g.translate(canvasWidth - LABEL_EAST, 0);\r
- drawEastScale(g, startRes, endx, ypos);\r
- g.translate( - (canvasWidth - LABEL_EAST), 0);\r
- }\r
+ if (av.scaleRightWrapped)\r
+ {\r
+ g.translate(canvasWidth - LABEL_EAST, 0);\r
+ drawEastScale(g, startRes, endx, ypos);\r
+ g.translate(-(canvasWidth - LABEL_EAST), 0);\r
+ }\r
\r
- g.translate(LABEL_WEST, 0);\r
- if (av.scaleAboveWrapped)\r
- {\r
- drawNorthScale(g, startRes, endx, ypos);\r
- }\r
+ g.translate(LABEL_WEST, 0);\r
\r
+ if (av.scaleAboveWrapped)\r
+ {\r
+ drawNorthScale(g, startRes, endx, ypos);\r
+ }\r
\r
- if(g.getClip()==null)\r
- g.setClip(0, 0, cWidth * av.charWidth, canvasHeight);\r
\r
- if (av.alignment.getWidth() >= av.vconsensus.size())\r
- {\r
- endx = av.vconsensus.size() - 2;\r
- }\r
- drawPanel(g, startRes, endx, 0, al.getHeight(), startRes, 0, ypos);\r
- g.setClip(null);\r
- g.translate( -LABEL_WEST, 0);\r
+ if (av.vconsensus!=null && av.alignment.getWidth() >= av.vconsensus.size())\r
+ {\r
+ endx = av.vconsensus.size() - 2;\r
+ }\r
\r
- ypos += cHeight;\r
- startRes += cWidth;\r
- endx = startRes + cWidth - 1;\r
\r
- if (endx > al.getWidth())\r
- {\r
- endx = al.getWidth();\r
- }\r
- }\r
+ drawPanel(g, startRes, endx, 0, al.getHeight(), startRes, 0, ypos);\r
+\r
+ if(av.showAnnotation)\r
+ {\r
+ g.translate(0, cHeight + ypos);\r
+ if(annotations==null)\r
+ annotations = new AnnotationPanel(av);\r
+\r
+ annotations.drawComponent( g, startRes, endx + 1);\r
+ g.translate(0, -cHeight - ypos);\r
+ }\r
+ g.translate(-LABEL_WEST, 0);\r
+\r
+ ypos += cHeight+getAnnotationHeight()+hgap;\r
+\r
+\r
+ startRes += cWidth;\r
+ endx = (startRes + cWidth) - 1;\r
+\r
+ if (endx > al.getWidth())\r
+ {\r
+ endx = al.getWidth();\r
+ }\r
+ }\r
\r
}\r
\r
+ AnnotationPanel annotations;\r
+ int getAnnotationHeight()\r
+ {\r
+ if(!av.showAnnotation)\r
+ return 0;\r
+\r
+ if(annotations==null)\r
+ annotations = new AnnotationPanel(av);\r
+\r
+ return annotations.adjustPanelHeight();\r
+ }\r
+\r
synchronized public void drawPanel(Graphics g, int x1, int x2, int y1, int y2,\r
int startx, int starty, int offset)\r
{\r
sr.renderGaps(av.renderGaps);\r
\r
SequenceI nextSeq;\r
-\r
/// First draw the sequences\r
- /////////////////////////////\r
- for (int i = y1; i < y2; i++)\r
- {\r
- nextSeq = av.alignment.getSequenceAt(i);\r
+ /////////////////////////////\r
+ for (int i = y1; i < y2; i++)\r
+ {\r
+ nextSeq = av.alignment.getSequenceAt(i);\r
\r
- sr.drawSequence(g, nextSeq, av.alignment.findAllGroups(nextSeq), x1, x2,\r
+ sr.drawSequence(g, nextSeq, av.alignment.findAllGroups(nextSeq), x1, x2,\r
+ (x1 - startx) * av.charWidth,\r
+ offset +\r
+ (i - starty) * av.charHeight,\r
+ av.charWidth, av.charHeight);\r
+\r
+ if (av.showSequenceFeatures)\r
+ {\r
+ fr.drawSequence(g, nextSeq, av.alignment.findAllGroups(nextSeq), x1, x2,\r
(x1 - startx) * av.charWidth,\r
offset +\r
- (i-starty)*av.charHeight,\r
+ (i - starty) * av.charHeight,\r
av.charWidth, av.charHeight);\r
-\r
- if (av.showSequenceFeatures)\r
- {\r
- fr.drawSequence(g, nextSeq, av.alignment.findAllGroups(nextSeq), x1, x2,\r
- (x1 - startx) * av.charWidth,\r
- offset +\r
- (i-starty)*av.charHeight,\r
- av.charWidth, av.charHeight);\r
- }\r
}\r
- //\r
+ }\r
+\r
/////////////////////////////////////\r
\r
// Now outline any areas if necessary\r
group = (SequenceGroup) groups.elementAt(0);\r
groupIndex = 0;\r
}\r
-\r
if (group != null && !isOverview)\r
{\r
- do\r
- {\r
- int oldY = -1;\r
- int i = 0;\r
- boolean inGroup = false;\r
- int top = -1;\r
- int bottom = -1;\r
-\r
- for (i = y1; i < y2; i++)\r
- {\r
- sx = (group.getStartRes() - startx) * av.charWidth;\r
- sy = offset + ((i - starty) * av.charHeight);\r
- ex = (((group.getEndRes() + 1) - group.getStartRes()) * av.charWidth) -\r
- 1;\r
-\r
- if(sx+ex<0 || sx>imgWidth)\r
- {\r
- continue;\r
- }\r
+ do\r
+ {\r
+ int oldY = -1;\r
+ int i = 0;\r
+ boolean inGroup = false;\r
+ int top = -1;\r
+ int bottom = -1;\r
\r
- if ( (sx <= (x2-x1)*av.charWidth) &&\r
- group.sequences.contains(av.alignment.getSequenceAt(\r
- i)))\r
- {\r
- if ((bottom == -1) &&\r
- !group.sequences.contains(\r
- av.alignment.getSequenceAt(i + 1)))\r
- {\r
- bottom = sy + av.charHeight;\r
- }\r
+ for (i = y1; i < y2; i++)\r
+ {\r
+ sx = (group.getStartRes() - startx) * av.charWidth;\r
+ sy = offset + ((i - starty) * av.charHeight);\r
+ ex = (((group.getEndRes() + 1) - group.getStartRes()) * av.charWidth) -\r
+ 1;\r
\r
- if (!inGroup)\r
- {\r
- if (((top == -1) && (i == 0)) ||\r
- !group.sequences.contains(\r
- av.alignment.getSequenceAt(i - 1)))\r
- {\r
- top = sy;\r
- }\r
-\r
- oldY = sy;\r
- inGroup = true;\r
-\r
- if (group == av.getSelectionGroup())\r
- {\r
- g.setColor(Color.red);\r
- }\r
- else\r
- {\r
- g.setColor(group.getOutlineColour());\r
- }\r
- }\r
- }\r
- else\r
- {\r
- if (inGroup)\r
+ if(sx+ex<0 || sx>imgWidth)\r
{\r
- if (sx >= 0 && sx < imgWidth)\r
- g.drawLine(sx, oldY, sx, sy);\r
-\r
- if (sx + ex < imgWidth)\r
- g.drawLine(sx + ex, oldY, sx + ex, sy);\r
+ continue;\r
+ }\r
\r
- if (sx < 0)\r
+ if ( (sx <= (x2-x1)*av.charWidth) &&\r
+ group.sequences.contains(av.alignment.getSequenceAt(\r
+ i)))\r
+ {\r
+ if ((bottom == -1) &&\r
+ !group.sequences.contains(\r
+ av.alignment.getSequenceAt(i + 1)))\r
+ {\r
+ bottom = sy + av.charHeight;\r
+ }\r
+\r
+ if (!inGroup)\r
+ {\r
+ if (((top == -1) && (i == 0)) ||\r
+ !group.sequences.contains(\r
+ av.alignment.getSequenceAt(i - 1)))\r
+ {\r
+ top = sy;\r
+ }\r
+\r
+ oldY = sy;\r
+ inGroup = true;\r
+\r
+ if (group == av.getSelectionGroup())\r
+ {\r
+\r
+ g.setColor(Color.red);\r
+ }\r
+ else\r
+ {\r
+ g.setColor(group.getOutlineColour());\r
+ }\r
+ }\r
+ }\r
+ else\r
+ {\r
+ if (inGroup)\r
{\r
- ex += sx;\r
- sx = 0;\r
- }\r
+ if (sx >= 0 && sx < imgWidth)\r
+ g.drawLine(sx, oldY, sx, sy);\r
+\r
+ if (sx + ex < imgWidth)\r
+ g.drawLine(sx + ex, oldY, sx + ex, sy);\r
+\r
+ if (sx < 0)\r
+ {\r
+ ex += sx;\r
+ sx = 0;\r
+ }\r
+\r
+ if (sx + ex > imgWidth)\r
+ ex = imgWidth;\r
+\r
+ else if (sx + ex >= (x2 - x1 + 1) * av.charWidth)\r
+ ex = (x2 - x1 + 1) * av.charWidth;\r
+\r
+ if (top != -1)\r
+ {\r
+ g.drawLine(sx, top, sx + ex, top);\r
+ top = -1;\r
+ }\r
+\r
+ if (bottom != -1)\r
+ {\r
+ g.drawLine(sx, bottom, sx + ex, bottom);\r
+ bottom = -1;\r
+ }\r
+\r
+ inGroup = false;\r
+ }\r
+ }\r
+ }\r
\r
- if (sx + ex > imgWidth)\r
- ex = imgWidth;\r
+ if (inGroup)\r
+ {\r
+ sy = offset + ( (i - starty) * av.charHeight);\r
+ if (sx >= 0 && sx < imgWidth)\r
+ g.drawLine(sx, oldY, sx, sy);\r
\r
- else if (sx + ex >= (x2 - x1 + 1) * av.charWidth)\r
- ex = (x2 - x1 + 1) * av.charWidth;\r
+ if (sx + ex < imgWidth)\r
+ g.drawLine(sx + ex, oldY, sx + ex, sy);\r
\r
- if (top != -1)\r
- {\r
- g.drawLine(sx, top, sx + ex, top);\r
- top = -1;\r
- }\r
+ if (sx < 0)\r
+ {\r
+ ex += sx;\r
+ sx = 0;\r
+ }\r
\r
- if (bottom != -1)\r
- {\r
- g.drawLine(sx, bottom, sx + ex, bottom);\r
- bottom = -1;\r
- }\r
+ if (sx + ex > imgWidth)\r
+ ex = imgWidth;\r
+ else if (sx + ex >= (x2 - x1 + 1) * av.charWidth)\r
+ ex = (x2 - x1 + 1) * av.charWidth;\r
\r
- inGroup = false;\r
- }\r
+ if (top != -1)\r
+ {\r
+ g.drawLine(sx, top, sx + ex, top);\r
+ top = -1;\r
}\r
- }\r
-\r
- if (inGroup)\r
- {\r
- sy = offset + ( (i - starty) * av.charHeight);\r
- if (sx >= 0 && sx < imgWidth)\r
- g.drawLine(sx, oldY, sx, sy);\r
\r
- if (sx + ex < imgWidth)\r
- g.drawLine(sx + ex, oldY, sx + ex, sy);\r
+ if (bottom != -1)\r
+ {\r
+ g.drawLine(sx, bottom - 1, sx + ex, bottom - 1);\r
+ bottom = -1;\r
+ }\r
\r
- if (sx < 0)\r
- {\r
- ex += sx;\r
- sx = 0;\r
+ inGroup = false;\r
}\r
\r
- if (sx + ex > imgWidth)\r
- ex = imgWidth;\r
- else if (sx + ex >= (x2 - x1 + 1) * av.charWidth)\r
- ex = (x2 - x1 + 1) * av.charWidth;\r
+ groupIndex++;\r
\r
- if (top != -1)\r
+ if (groupIndex >= groups.size())\r
{\r
- g.drawLine(sx, top, sx + ex, top);\r
- top = -1;\r
+ break;\r
}\r
\r
- if (bottom != -1)\r
- {\r
- g.drawLine(sx, bottom - 1, sx + ex, bottom - 1);\r
- bottom = -1;\r
- }\r
-\r
- inGroup = false;\r
- }\r
-\r
- groupIndex++;\r
-\r
- if (groupIndex >= groups.size())\r
- {\r
- break;\r
- }\r
-\r
- group = (SequenceGroup) groups.elementAt(groupIndex);\r
- }\r
- while (groupIndex < groups.size());\r
+ group = (SequenceGroup) groups.elementAt(groupIndex);\r
+ }\r
+ while (groupIndex < groups.size());\r
}\r
\r
/// Highlight search Results once all sequences have been drawn\r