+ if (column >= row.annotations.length)\r
+ {\r
+ column = row.annotations.length - 1;\r
+ }\r
+\r
+ // x ++;\r
+\r
+ if (row.hasIcons)\r
+ {\r
+ switch (lastSS)\r
+ {\r
+ case 'H':\r
+ g.setColor(HELIX_COLOUR);\r
+ if (MAC)\r
+ {\r
+ //Off by 1 offset when drawing rects and ovals\r
+ //to offscreen image on the MAC\r
+ g.fillRoundRect(lastSSX, y + 4 + iconOffset,\r
+ (x * av.charWidth) - lastSSX, 7, 8, 8);\r
+ break;\r
+ }\r
+\r
+ int sCol = (lastSSX / av.charWidth) + startRes;\r
+ int x1 = lastSSX;\r
+ int x2 = (x * av.charWidth);\r
+\r
+ if (sCol == 0 ||\r
+ row.annotations[sCol - 1] == null ||\r
+ row.annotations[sCol - 1].secondaryStructure != 'H')\r
+ {\r
+ g.fillArc(lastSSX, y + 4 + iconOffset, av.charWidth, 8, 90, 180);\r
+ x1 += av.charWidth / 2;\r
+ }\r
+\r
+ if (row.annotations[column] == null ||\r
+ row.annotations[column].secondaryStructure != 'H')\r
+ {\r
+ g.fillArc( (x * av.charWidth) - av.charWidth,\r
+ y + 4 + iconOffset, av.charWidth, 8, 270,\r
+ 180);\r
+ x2 -= av.charWidth / 2;\r
+ }\r
+\r
+ g.fillRect(x1, y + 4 + iconOffset, x2 - x1, 8);\r
+\r
+ break;\r
+\r
+ case 'E':\r
+ g.setColor(SHEET_COLOUR);\r
+\r
+ if (row.annotations[endRes] == null\r
+ || row.annotations[endRes].secondaryStructure != 'E')\r
+ {\r
+ g.fillRect(lastSSX, y + 4 + iconOffset,\r
+ (x * av.charWidth) - lastSSX - 4, 7);\r
+ g.fillPolygon(new int[]\r
+ { (x * av.charWidth) - 4,\r
+ (x * av.charWidth) - 4,\r
+ (x * av.charWidth)},\r
+ new int[]\r
+ {\r
+ y + iconOffset, y + 14 + iconOffset,\r
+ y + 7 + iconOffset\r
+ }, 3);\r
+ }\r
+ else\r
+ {\r
+ g.fillRect(lastSSX, y + 4 + iconOffset,\r
+ (x + 1) * av.charWidth - lastSSX, 7);\r
+ }\r
+ break;\r
+\r
+ default:\r
+ g.setColor(Color.gray);\r
+ g.fillRect(lastSSX, y + 6 + iconOffset,\r
+ (x * av.charWidth) - lastSSX, 2);\r
+\r
+ break;\r
+ }\r
+ }\r
+\r
+ if (row.graph > 0 && row.graphHeight > 0)\r
+ {\r
+ if (row.graph == AlignmentAnnotation.LINE_GRAPH)\r
+ {\r
+ if (row.graphGroup > -1 && !graphGroupDrawn[row.graphGroup])\r
+ {\r
+ float groupmax = -999999, groupmin = 9999999;\r
+ for (int gg = 0; gg < aa.length; gg++)\r
+ {\r
+ if (aa[gg].graphGroup != row.graphGroup)\r
+ {\r
+ continue;\r
+ }\r
+\r
+ if (aa[gg] != row)\r
+ {\r
+ aa[gg].visible = false;\r
+ }\r
+\r
+ if (aa[gg].graphMax > groupmax)\r
+ {\r
+ groupmax = aa[gg].graphMax;\r
+ }\r
+ if (aa[gg].graphMin < groupmin)\r
+ {\r
+ groupmin = aa[gg].graphMin;\r
+ }\r
+ }\r
+\r
+ for (int gg = 0; gg < aa.length; gg++)\r
+ {\r
+ if (aa[gg].graphGroup == row.graphGroup)\r
+ {\r
+ drawLineGraph(g, aa[gg], startRes, endRes, y,\r
+ groupmin, groupmax,\r
+ row.graphHeight);\r
+ }\r
+ }\r
+\r
+ graphGroupDrawn[row.graphGroup] = true;\r
+ }\r
+ else\r
+ {\r
+ drawLineGraph(g, row, startRes, endRes,\r
+ y, row.graphMin, row.graphMax, row.graphHeight);\r
+ }\r
+ }\r
+ else if (row.graph == AlignmentAnnotation.BAR_GRAPH)\r
+ {\r
+ drawBarGraph(g, row, startRes, endRes,\r
+ row.graphMin, row.graphMax, y);\r
+ }\r
+ }\r
+\r
+ if (row.graph > 0 && row.hasText)\r
+ {\r
+ y += av.charHeight;\r
+ }\r
+\r
+ if (row.graph == 0)\r
+ {\r
+ y += aa[i].height;\r
+ }\r
+ }\r
+ }\r
+\r
+ public void drawLineGraph(Graphics g, AlignmentAnnotation aa,\r
+ int sRes, int eRes,\r
+ int y,\r
+ float min, float max,\r
+ int graphHeight)\r
+ {\r
+ if (sRes > aa.annotations.length)\r
+ {\r
+ return;\r
+ }\r
+\r
+ int x = 0;\r
+\r
+ //Adjustment for fastpaint to left\r
+ if (eRes < av.endRes)\r
+ {\r
+ eRes++;\r
+ }\r
+\r
+ eRes = Math.min(eRes, aa.annotations.length);\r
+\r
+ if (sRes == 0)\r
+ {\r
+ x++;\r
+ }\r
+\r
+ int y1 = y, y2 = y;\r
+ float range = max - min;\r
+\r
+ ////Draw origin\r
+ if (min < 0)\r
+ {\r
+ y2 = y - (int) ( (0 - min / range) * graphHeight);\r
+ }\r
+\r
+ g.setColor(Color.gray);\r
+ g.drawLine(x - av.charWidth, y2, (eRes - sRes + 1) * av.charWidth, y2);\r
+\r
+ eRes = Math.min(eRes, aa.annotations.length);\r
+\r
+ int column;\r
+ int aaMax = aa.annotations.length - 1;\r
+\r
+ while (x < eRes - sRes)\r
+ {\r
+ column = sRes + x;\r
+ if (av.hasHiddenColumns)\r
+ {\r
+ column = av.getColumnSelection().adjustForHiddenColumns(column);\r
+ }\r
+\r
+ if (column > aaMax)\r
+ {\r
+ break;\r
+ }\r
+\r
+ if (aa.annotations[column] == null || aa.annotations[column - 1] == null)\r
+ {\r
+ x++;\r
+ continue;\r
+ }\r
+\r
+ if (aa.annotations[column].colour == null)\r
+ g.setColor(Color.black);\r
+ else\r
+ g.setColor(aa.annotations[column].colour);\r
+\r
+ y1 = y -\r
+ (int) ( ( (aa.annotations[column - 1].value - min) / range) * graphHeight);\r
+ y2 = y -\r
+ (int) ( ( (aa.annotations[column].value - min) / range) * graphHeight);\r
+\r
+ g.drawLine(x * av.charWidth - av.charWidth / 2, y1,\r
+ x * av.charWidth + av.charWidth / 2, y2);\r
+ x++;\r
+ }\r
+\r
+ if (aa.threshold != null)\r
+ {\r
+ g.setColor(aa.threshold.colour);\r
+ Graphics2D g2 = (Graphics2D) g;\r
+ g2.setStroke(new BasicStroke(1,\r
+ BasicStroke.CAP_SQUARE,\r
+ BasicStroke.JOIN_ROUND, 3f,\r
+ new float[]\r
+ {5f, 3f}, 0f));\r
+\r
+ y2 = (int) (y - ( (aa.threshold.value - min) / range) * graphHeight);\r
+ g.drawLine(0, y2, (eRes - sRes) * av.charWidth, y2);\r
+ g2.setStroke(new BasicStroke());\r
+ }\r
+ }\r
+\r
+ public void drawBarGraph(Graphics g, AlignmentAnnotation aa,\r
+ int sRes, int eRes,\r
+ float min, float max,\r
+ int y)\r
+ {\r
+ if (sRes > aa.annotations.length)\r
+ {\r
+ return;\r
+ }\r
+\r
+ eRes = Math.min(eRes, aa.annotations.length);\r
+\r
+ int x = 0, y1 = y, y2 = y;\r
+\r
+ float range = max - min;\r
+\r
+ if (min < 0)\r
+ {\r
+ y2 = y - (int) ( (0 - min / (range)) * aa.graphHeight);\r
+ }\r