From: amwaterhouse Date: Fri, 3 Feb 2006 17:39:03 +0000 (+0000) Subject: Applet draws line graphs X-Git-Tag: Root_VamJalview_2_07b+~184 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=9f7b5126265a85454dae0987f617771ed9b8f138;hp=59183747dbffe3ab6b141c5440d2f70799ae360b;p=jalview.git Applet draws line graphs --- diff --git a/src/jalview/appletgui/AnnotationPanel.java b/src/jalview/appletgui/AnnotationPanel.java index a71e439..bcc2866 100755 --- a/src/jalview/appletgui/AnnotationPanel.java +++ b/src/jalview/appletgui/AnnotationPanel.java @@ -264,6 +264,13 @@ public class AnnotationPanel repaint(); } + /** + * DOCUMENT ME! + * + * @param g DOCUMENT ME! + * @param startRes DOCUMENT ME! + * @param endRes DOCUMENT ME! + */ public void drawComponent(Graphics g, int startRes, int endRes) { g.setFont(av.getFont()); @@ -296,6 +303,9 @@ public class AnnotationPanel int iconOffset = av.charHeight / 2; boolean validRes = false; + boolean [] graphGroupDrawn = new boolean[aa.length]; + + //\u03B2 \u03B1 for (int i = 0; i < aa.length; i++) { @@ -307,8 +317,12 @@ public class AnnotationPanel } + if (row.graph>0) { + if(row.graphGroup>-1 && graphGroupDrawn[ row.graphGroup ] ) + continue; + // this is so that we draw the characters below the graph y += row.height; @@ -341,6 +355,24 @@ public class AnnotationPanel x = (j - startRes) * av.charWidth; + if (activeRow == i) + { + g.setColor(Color.red); + + if (activeRes != null) + { + for (int n = 0; n < activeRes.size(); n++) + { + int v = Integer.parseInt(activeRes.elementAt(n).toString()); + + if (v == j) + { + g.fillRect((j - startRes) * av.charWidth, y, + av.charWidth, row.height); + } + } + } + } if (validRes && (row.annotations[j].displayCharacter.length() > 0)) @@ -392,8 +424,6 @@ public class AnnotationPanel break; - case 'C': - break; default: g.setColor(Color.gray); @@ -415,16 +445,6 @@ public class AnnotationPanel lastSSX[i] = x; } } - - if (validRes && row.graph>0) - { - g.setColor(new Color(0, 0, 180)); - - int height = (int) ((row.annotations[j].value / row.graphMax) * GRAPH_HEIGHT); - - g.setColor(row.annotations[j].colour); - g.fillRect(x, y - height, av.charWidth, height); - } } x += av.charWidth; @@ -442,14 +462,23 @@ public class AnnotationPanel case 'E': g.setColor(SHEET_COLOUR); - g.fillRect(lastSSX[i], y + 4 + iconOffset, - x - lastSSX[i] - 4, 7); - g.fillPolygon(new int[] { x - 4, x - 4, x }, - new int[] - { - y + iconOffset, y + 14 + iconOffset, - y + 7 + iconOffset - }, 3); + + if (row.annotations.length > endRes + && row.annotations[endRes].secondaryStructure != 'E') + { + g.fillRect(lastSSX[i], y + 4 + iconOffset, + x - lastSSX[i] - 4, 7); + g.fillPolygon(new int[] + {x - 4, x - 4, x}, + new int[] + { + y + iconOffset, y + 14 + iconOffset, + y + 7 + iconOffset + }, 3); + } + else + g.fillRect(lastSSX[i], y + 4 + iconOffset, + x - lastSSX[i], 7); break; @@ -464,6 +493,48 @@ public class AnnotationPanel } } + if (row.graph>0) + { + if(row.graph == AlignmentAnnotation.LINE_GRAPH ) + { + if(row.graphGroup>-1 && !graphGroupDrawn[row.graphGroup]) + { + float groupmax=-999999, groupmin=9999999; + for(int gg=0; gggroupmax) + groupmax = aa[gg].graphMax; + if(aa[gg].graphMin0 && row.hasText) { y += av.charHeight; @@ -473,7 +544,121 @@ public class AnnotationPanel { y += aa[i].height; } - } + } + } + + public void drawLineGraph(Graphics g, AlignmentAnnotation aa, + int sRes, int eRes, + int y, + float min, float max, + int graphHeight) + { + if(sRes>aa.annotations.length) + return; + + int x = 0; + + //Adjustment for fastpaint to left + if(eResaa.annotations.length) + return; + + int x=0, y1, y2; + + float range = max - min; + + if(aa.graphLines!=null) + { + for(int l=0; l0) + g.fillRect(x, y2, av.charWidth, y1-y2 ); + else + g.fillRect(x, y1, av.charWidth, y2-y1 ); + + x += av.charWidth; + } + } // used by overview window