2 * Jalview - A Sequence Alignment Editor and Viewer
3 * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 import java.awt.event.*;
23 import java.awt.image.*;
26 import jalview.datamodel.*;
34 public class AnnotationPanel
35 extends JPanel implements MouseListener,
36 MouseMotionListener, ActionListener, AdjustmentListener
38 final String HELIX = "Helix";
39 final String SHEET = "Sheet";
40 final String LABEL = "Label";
41 final String REMOVE = "Remove Annotation";
42 final String COLOUR = "Colour";
43 final Color HELIX_COLOUR = Color.red.darker();
44 final Color SHEET_COLOUR = Color.green.darker().darker();
51 BufferedImage fadedImage;
55 boolean fastPaint = false;
57 //Used For mouse Dragging and resizing graphs
58 int graphStretch = -1;
59 int graphStretchY = -1;
60 int min; //used by mouseDragged to see if user
61 int max; //used by mouseDragged to see if user
62 boolean mouseDragging = false;
67 * Creates a new AnnotationPanel object.
69 * @param ap DOCUMENT ME!
71 public AnnotationPanel(AlignmentPanel ap)
74 MAC = new jalview.util.Platform().isAMac();
76 ToolTipManager.sharedInstance().registerComponent(this);
77 ToolTipManager.sharedInstance().setInitialDelay(0);
78 ToolTipManager.sharedInstance().setDismissDelay(10000);
82 addMouseListener(this);
83 addMouseMotionListener(this);
84 ap.annotationScroller.getVerticalScrollBar().addAdjustmentListener(this);
87 public AnnotationPanel(AlignViewport av)
95 * @param evt DOCUMENT ME!
97 public void adjustmentValueChanged(AdjustmentEvent evt)
99 ap.alabels.setScrollOffset( -evt.getValue());
105 public int adjustPanelHeight()
107 // setHeight of panels
108 AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
113 for (int i = 0; i < aa.length; i++)
124 aa[i].height += av.charHeight;
134 aa[i].height += aa[i].graphHeight;
137 if (aa[i].height == 0)
142 height += aa[i].height;
150 this.setPreferredSize(new Dimension(1, height));
158 * @param evt DOCUMENT ME!
160 public void actionPerformed(ActionEvent evt)
162 AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
163 Annotation[] anot = aa[activeRow].annotations;
165 if (anot.length < av.getColumnSelection().getMax())
167 Annotation[] temp = new Annotation[av.getColumnSelection().getMax() + 2];
168 System.arraycopy(anot, 0, temp, 0, anot.length);
170 aa[activeRow].annotations = anot;
173 if (evt.getActionCommand().equals(REMOVE))
175 for (int i = 0; i < av.getColumnSelection().size(); i++)
177 anot[av.getColumnSelection().columnAt(i)] = null;
180 else if (evt.getActionCommand().equals(LABEL))
182 String exMesg = collectAnnotVals(anot, av.getColumnSelection(), LABEL);
183 String label = JOptionPane.showInputDialog(this,"Enter label",exMesg);
190 if ( (label.length() > 0) && !aa[activeRow].hasText)
192 aa[activeRow].hasText = true;
195 for (int i = 0; i < av.getColumnSelection().size(); i++)
197 int index = av.getColumnSelection().columnAt(i);
199 if(!av.colSel.isVisible(index))
202 if (anot[index] == null)
204 anot[index] = new Annotation(label, "", ' ', 0); // TODO: verify that null exceptions aren't raised elsewhere.
206 anot[index].displayCharacter = label;
210 else if (evt.getActionCommand().equals(COLOUR))
212 Color col = JColorChooser.showDialog(this,
213 "Choose foreground colour",
216 for (int i = 0; i < av.getColumnSelection().size(); i++)
218 int index = av.getColumnSelection().columnAt(i);
220 if(!av.colSel.isVisible(index))
223 if (anot[index] == null)
225 anot[index] = new Annotation("", "", ' ', 0);
228 anot[index].colour = col;
231 else // HELIX OR SHEET
234 String symbol = "\u03B1";
236 if (evt.getActionCommand().equals(HELIX))
240 else if (evt.getActionCommand().equals(SHEET))
246 if (!aa[activeRow].hasIcons)
248 aa[activeRow].hasIcons = true;
251 String label = JOptionPane.showInputDialog(
252 "Enter a label for the structure?",
260 if ( (label.length() > 0) && !aa[activeRow].hasText)
262 aa[activeRow].hasText = true;
265 for (int i = 0; i < av.getColumnSelection().size(); i++)
267 int index = av.getColumnSelection().columnAt(i);
269 if(!av.colSel.isVisible(index))
272 if (anot[index] == null)
274 anot[index] = new Annotation(label, "", type, 0);
277 anot[index].secondaryStructure = type;
278 anot[index].displayCharacter = label;
288 private String collectAnnotVals(Annotation[] anot, ColumnSelection columnSelection,
291 String collatedInput="";
293 for (int i = 0; i < columnSelection.size(); i++)
295 int index = columnSelection.columnAt(i);
296 // always check for current display state - just in case
297 if(!av.colSel.isVisible(index))
300 if (anot[index] != null)
302 if (label2.equals(HELIX) || label2.equals(SHEET) || label2.equals(LABEL))
304 tlabel = anot[index].description;
307 if (label2.equals(HELIX) || label2.equals(SHEET))
309 tlabel = ""+anot[index].secondaryStructure;
311 tlabel = ""+anot[index].displayCharacter;
315 if (tlabel!=null && !tlabel.equals(last))
321 collatedInput+=tlabel;
325 return collatedInput;
331 * @param evt DOCUMENT ME!
333 public void mousePressed(MouseEvent evt)
336 AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
345 for (int i = 0; i < aa.length; i++)
349 height += aa[i].height;
352 if (evt.getY() < height)
358 else if (aa[i].graph > 0)
362 graphStretchY = evt.getY();
369 if (SwingUtilities.isRightMouseButton(evt) && activeRow != -1)
371 if (av.getColumnSelection() == null)
376 JPopupMenu pop = new JPopupMenu("Structure type");
377 JMenuItem item = new JMenuItem(HELIX);
378 item.addActionListener(this);
380 item = new JMenuItem(SHEET);
381 item.addActionListener(this);
383 item = new JMenuItem(LABEL);
384 item.addActionListener(this);
386 item = new JMenuItem(COLOUR);
387 item.addActionListener(this);
389 item = new JMenuItem(REMOVE);
390 item.addActionListener(this);
392 pop.show(this, evt.getX(), evt.getY());
402 ap.scalePanel.mousePressed(evt);
409 * @param evt DOCUMENT ME!
411 public void mouseReleased(MouseEvent evt)
415 mouseDragging = false;
416 ap.scalePanel.mouseReleased(evt);
422 * @param evt DOCUMENT ME!
424 public void mouseEntered(MouseEvent evt)
426 ap.scalePanel.mouseEntered(evt);
432 * @param evt DOCUMENT ME!
434 public void mouseExited(MouseEvent evt)
436 ap.scalePanel.mouseExited(evt);
442 * @param evt DOCUMENT ME!
444 public void mouseDragged(MouseEvent evt)
446 if (graphStretch > -1)
448 av.alignment.getAlignmentAnnotation()[graphStretch].graphHeight +=
449 graphStretchY - evt.getY();
450 if (av.alignment.getAlignmentAnnotation()[graphStretch].graphHeight < 0)
452 av.alignment.getAlignmentAnnotation()[graphStretch].graphHeight = 0;
454 graphStretchY = evt.getY();
456 ap.paintAlignment(true);
460 ap.scalePanel.mouseDragged(evt);
467 * @param evt DOCUMENT ME!
469 public void mouseMoved(MouseEvent evt)
471 AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
475 this.setToolTipText(null);
482 for (int i = 0; i < aa.length; i++)
486 height += aa[i].height;
489 if (evt.getY() < height)
499 this.setToolTipText(null);
503 int res = (evt.getX() / av.getCharWidth()) + av.getStartRes();
505 if (av.hasHiddenColumns)
507 res = av.getColumnSelection().adjustForHiddenColumns(res);
510 if (aa[row].annotations != null
512 && res < (int) aa[row].annotations.length)
514 if (aa[row].graphGroup > -1)
516 StringBuffer tip = new StringBuffer("<html>");
517 for (int gg = 0; gg < aa.length; gg++)
519 if (aa[gg].graphGroup == aa[row].graphGroup && aa[gg].annotations[res] != null)
521 tip.append(aa[gg].label + " " + aa[gg].annotations[res].description +
525 if (tip.length() != 6)
527 tip.setLength(tip.length() - 4);
528 this.setToolTipText(tip.toString() + "</html>");
531 else if (aa[row].annotations[res] != null
532 && aa[row].annotations[res].description != null)
534 this.setToolTipText(aa[row].annotations[res].description);
537 if (aa[row].annotations[res] != null)
539 StringBuffer text = new StringBuffer("Sequence position " +
542 if (aa[row].annotations[res].description != null)
544 text.append(" " + aa[row].annotations[res].description);
547 ap.alignFrame.statusBar.setText(text.toString());
552 this.setToolTipText(null);
559 * @param evt DOCUMENT ME!
561 public void mouseClicked(MouseEvent evt)
568 * @param g DOCUMENT ME!
570 public void paintComponent(Graphics g)
572 g.setColor(Color.white);
573 g.fillRect(0, 0, getWidth(), getHeight());
578 || (getVisibleRect().width != g.getClipBounds().width)
579 || (getVisibleRect().height != g.getClipBounds().height))
581 g.drawImage(image, 0, 0, this);
586 imgWidth = (av.endRes - av.startRes + 1) * av.charWidth;
589 if (image == null || imgWidth != image.getWidth()
590 || image.getHeight(this) != getHeight())
592 image = new BufferedImage(imgWidth, ap.annotationPanel.getHeight(),
593 BufferedImage.TYPE_INT_RGB);
594 gg = (Graphics2D) image.getGraphics();
598 gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
599 RenderingHints.VALUE_ANTIALIAS_ON);
602 gg.setFont(av.getFont());
603 fm = gg.getFontMetrics();
604 gg.setColor(Color.white);
605 gg.fillRect(0, 0, imgWidth, image.getHeight());
608 drawComponent(gg, av.startRes, av.endRes + 1);
609 g.drawImage(image, 0, 0, this);
611 boolean fpainting=false;
613 * Thread safe repaint
615 * @param horizontal repaint with horizontal shift in alignment
617 public void fastPaint(int horizontal)
624 if ( (horizontal == 0)
626 || av.alignment.getAlignmentAnnotation() == null
627 || av.alignment.getAlignmentAnnotation().length < 1
628 || av.updatingConsensus
629 || av.updatingConservation
635 gg.copyArea(0, 0, imgWidth, getHeight(), -horizontal * av.charWidth, 0);
637 int sr = av.startRes;
638 int er = av.endRes + 1;
641 if (horizontal > 0) // scrollbar pulled right, image to the left
643 transX = (er - sr - horizontal) * av.charWidth;
644 sr = er - horizontal;
646 else if (horizontal < 0)
648 er = sr - horizontal;
651 gg.translate(transX, 0);
653 drawComponent(gg, sr, er);
655 gg.translate( -transX, 0);
665 * @param g DOCUMENT ME!
666 * @param startRes DOCUMENT ME!
667 * @param endRes DOCUMENT ME!
669 public void drawComponent(Graphics g, int startRes, int endRes)
671 if (av.updatingConsensus || av.updatingConservation)
677 //We'll keep a record of the old image,
678 //and draw a faded image until the calculation
680 if (fadedImage == null
681 || fadedImage.getWidth() != imgWidth
682 || fadedImage.getHeight() != image.getHeight())
684 fadedImage = new BufferedImage(
685 imgWidth, image.getHeight(),
686 BufferedImage.TYPE_INT_RGB);
688 Graphics2D fadedG = (Graphics2D) fadedImage.getGraphics();
690 fadedG.setColor(Color.white);
691 fadedG.fillRect(0, 0, imgWidth, image.getHeight());
694 AlphaComposite.getInstance(
695 AlphaComposite.SRC_OVER, .3f));
696 fadedG.drawImage(image, 0, 0, this);
706 g.setColor(Color.white);
707 g.fillRect(0, 0, (endRes - startRes) * av.charWidth, getHeight());
709 g.setFont(av.getFont());
712 fm = g.getFontMetrics();
715 if ( (av.alignment.getAlignmentAnnotation() == null) ||
716 (av.alignment.getAlignmentAnnotation().length < 1))
718 g.setColor(Color.white);
719 g.fillRect(0, 0, getWidth(), getHeight());
720 g.setColor(Color.black);
721 if (av.validCharWidth)
723 g.drawString("Alignment has no annotations", 20, 15);
729 AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
736 boolean validRes = false;
738 boolean[] graphGroupDrawn = new boolean[aa.length];
741 for (int i = 0; i < aa.length; i++)
743 AlignmentAnnotation row = aa[i];
755 if (row.graphGroup > -1 && graphGroupDrawn[row.graphGroup])
760 // this is so that we draw the characters below the graph
765 iconOffset =av.charHeight -fm.getDescent();
769 else if (row.hasText)
771 iconOffset = av.charHeight -fm.getDescent();
780 if (av.updatingConsensus && aa[i] == av.consensus)
784 g.drawImage(fadedImage,
785 0, y - row.height, imgWidth, y,
786 0, y - row.height, imgWidth, y, this);
787 g.setColor(Color.black);
788 // g.drawString("Calculating Consensus....",20, y-row.height/2);
792 else if (av.updatingConservation && aa[i].label.equals("Conservation"))
796 g.drawImage(fadedImage,
797 0, y - row.height, imgWidth, y,
798 0, y - row.height, imgWidth, y, this);
800 g.setColor(Color.black);
801 // g.drawString("Calculating Conservation.....",20, y-row.height/2);
805 else if (av.updatingConservation && aa[i].label.equals("Quality"))
809 g.drawImage(fadedImage,
810 0, y - row.height, imgWidth, y,
811 0, y - row.height, imgWidth, y, this);
812 g.setColor(Color.black);
813 /// g.drawString("Calculating Quality....",20, y-row.height/2);
821 while (x < endRes - startRes)
823 if (av.hasHiddenColumns)
825 column = av.getColumnSelection().adjustForHiddenColumns(startRes + x);
826 if (column > row.annotations.length - 1)
833 column = startRes + x;
836 if ( (row.annotations==null)
837 || (row.annotations.length <= column)
838 || (row.annotations[column] == null))
849 g.setColor(Color.red);
851 if (av.getColumnSelection() != null)
853 for (int n = 0; n < av.getColumnSelection().size(); n++)
855 int v = av.getColumnSelection().columnAt(n);
859 g.fillRect(x * av.charWidth, y,
860 av.charWidth, av.charHeight);
866 if (av.validCharWidth && validRes
867 && row.annotations[column].displayCharacter != null
868 && (row.annotations[column].displayCharacter.length() > 0))
871 int charOffset = (av.charWidth -
872 fm.charWidth(row.annotations[column].
873 displayCharacter.charAt(
876 if (row.annotations[column].colour == null)
877 g.setColor(Color.black);
879 g.setColor(row.annotations[column].colour);
881 if (column == 0 || row.graph > 0)
883 g.drawString(row.annotations[column].displayCharacter,
884 (x * av.charWidth) + charOffset,
888 row.annotations[column - 1] == null
889 || (!row.annotations[column].displayCharacter.equals(
890 row.annotations[column - 1].displayCharacter)
892 (row.annotations[column].displayCharacter.length() < 2 &&
893 row.annotations[column].secondaryStructure == ' ')))
895 g.drawString(row.annotations[column].displayCharacter,
896 x * av.charWidth + charOffset,
904 (row.annotations[column].secondaryStructure != lastSS))
909 g.setColor(HELIX_COLOUR);
912 //Off by 1 offset when drawing rects and ovals
913 //to offscreen image on the MAC
914 g.fillRoundRect(lastSSX, y + 4 + iconOffset,
915 (x * av.charWidth) - lastSSX, 7, 8, 8);
919 int sCol = (lastSSX / av.charWidth) + startRes;
921 int x2 = (x * av.charWidth);
924 row.annotations[sCol - 1] == null ||
925 row.annotations[sCol - 1].secondaryStructure != 'H')
927 g.fillArc(lastSSX, y + 4 + iconOffset, av.charWidth, 8, 90,
929 x1 += av.charWidth / 2;
932 if (row.annotations[column] == null ||
933 row.annotations[column].secondaryStructure != 'H')
935 g.fillArc( (x * av.charWidth) - av.charWidth,
936 y + 4 + iconOffset, av.charWidth, 8, 270, 180);
937 x2 -= av.charWidth / 2;
940 g.fillRect(x1, y + 4 + iconOffset, x2 - x1, 8);
944 g.setColor(SHEET_COLOUR);
945 g.fillRect(lastSSX, y + 4 + iconOffset,
946 (x * av.charWidth) - lastSSX - 4, 7);
947 g.fillPolygon(new int[]
948 { (x * av.charWidth) - 4,
949 (x * av.charWidth) - 4,
953 y + iconOffset, y + 14 + iconOffset,
960 g.setColor(Color.gray);
961 g.fillRect(lastSSX, y + 6 + iconOffset,
962 (x * av.charWidth) - lastSSX, 2);
969 lastSS = row.annotations[column].secondaryStructure;
976 lastSSX = (x * av.charWidth);
984 if (column >= row.annotations.length)
986 column = row.annotations.length - 1;
996 g.setColor(HELIX_COLOUR);
999 //Off by 1 offset when drawing rects and ovals
1000 //to offscreen image on the MAC
1001 g.fillRoundRect(lastSSX, y + 4 + iconOffset,
1002 (x * av.charWidth) - lastSSX, 7, 8, 8);
1006 int sCol = (lastSSX / av.charWidth) + startRes;
1008 int x2 = (x * av.charWidth);
1011 row.annotations[sCol - 1] == null ||
1012 row.annotations[sCol - 1].secondaryStructure != 'H')
1014 g.fillArc(lastSSX, y + 4 + iconOffset, av.charWidth, 8, 90, 180);
1015 x1 += av.charWidth / 2;
1018 if (row.annotations[column] == null ||
1019 row.annotations[column].secondaryStructure != 'H')
1021 g.fillArc( (x * av.charWidth) - av.charWidth,
1022 y + 4 + iconOffset, av.charWidth, 8, 270,
1024 x2 -= av.charWidth / 2;
1027 g.fillRect(x1, y + 4 + iconOffset, x2 - x1, 8);
1032 g.setColor(SHEET_COLOUR);
1034 if (row.annotations[endRes] == null
1035 || row.annotations[endRes].secondaryStructure != 'E')
1037 g.fillRect(lastSSX, y + 4 + iconOffset,
1038 (x * av.charWidth) - lastSSX - 4, 7);
1039 g.fillPolygon(new int[]
1040 { (x * av.charWidth) - 4,
1041 (x * av.charWidth) - 4,
1042 (x * av.charWidth)},
1045 y + iconOffset, y + 14 + iconOffset,
1051 g.fillRect(lastSSX, y + 4 + iconOffset,
1052 (x + 1) * av.charWidth - lastSSX, 7);
1057 g.setColor(Color.gray);
1058 g.fillRect(lastSSX, y + 6 + iconOffset,
1059 (x * av.charWidth) - lastSSX, 2);
1065 if (row.graph > 0 && row.graphHeight > 0)
1067 if (row.graph == AlignmentAnnotation.LINE_GRAPH)
1069 if (row.graphGroup > -1 && !graphGroupDrawn[row.graphGroup])
1071 float groupmax = -999999, groupmin = 9999999;
1072 for (int gg = 0; gg < aa.length; gg++)
1074 if (aa[gg].graphGroup != row.graphGroup)
1081 aa[gg].visible = false;
1084 if (aa[gg].graphMax > groupmax)
1086 groupmax = aa[gg].graphMax;
1088 if (aa[gg].graphMin < groupmin)
1090 groupmin = aa[gg].graphMin;
1094 for (int gg = 0; gg < aa.length; gg++)
1096 if (aa[gg].graphGroup == row.graphGroup)
1098 drawLineGraph(g, aa[gg], startRes, endRes, y,
1104 graphGroupDrawn[row.graphGroup] = true;
1108 drawLineGraph(g, row, startRes, endRes,
1109 y, row.graphMin, row.graphMax, row.graphHeight);
1112 else if (row.graph == AlignmentAnnotation.BAR_GRAPH)
1114 drawBarGraph(g, row, startRes, endRes,
1115 row.graphMin, row.graphMax, y);
1119 if (row.graph > 0 && row.hasText)
1131 public void drawLineGraph(Graphics g, AlignmentAnnotation aa,
1134 float min, float max,
1137 if (sRes > aa.annotations.length)
1144 //Adjustment for fastpaint to left
1145 if (eRes < av.endRes)
1150 eRes = Math.min(eRes, aa.annotations.length);
1158 float range = max - min;
1163 y2 = y - (int) ( (0 - min / range) * graphHeight);
1166 g.setColor(Color.gray);
1167 g.drawLine(x - av.charWidth, y2, (eRes - sRes + 1) * av.charWidth, y2);
1169 eRes = Math.min(eRes, aa.annotations.length);
1172 int aaMax = aa.annotations.length - 1;
1174 while (x < eRes - sRes)
1177 if (av.hasHiddenColumns)
1179 column = av.getColumnSelection().adjustForHiddenColumns(column);
1187 if (aa.annotations[column] == null || aa.annotations[column - 1] == null)
1193 if (aa.annotations[column].colour == null)
1194 g.setColor(Color.black);
1196 g.setColor(aa.annotations[column].colour);
1199 (int) ( ( (aa.annotations[column - 1].value - min) / range) * graphHeight);
1201 (int) ( ( (aa.annotations[column].value - min) / range) * graphHeight);
1203 g.drawLine(x * av.charWidth - av.charWidth / 2, y1,
1204 x * av.charWidth + av.charWidth / 2, y2);
1208 if (aa.threshold != null)
1210 g.setColor(aa.threshold.colour);
1211 Graphics2D g2 = (Graphics2D) g;
1212 g2.setStroke(new BasicStroke(1,
1213 BasicStroke.CAP_SQUARE,
1214 BasicStroke.JOIN_ROUND, 3f,
1218 y2 = (int) (y - ( (aa.threshold.value - min) / range) * graphHeight);
1219 g.drawLine(0, y2, (eRes - sRes) * av.charWidth, y2);
1220 g2.setStroke(new BasicStroke());
1224 public void drawBarGraph(Graphics g, AlignmentAnnotation aa,
1226 float min, float max,
1229 if (sRes > aa.annotations.length)
1234 eRes = Math.min(eRes, aa.annotations.length);
1236 int x = 0, y1 = y, y2 = y;
1238 float range = max - min;
1242 y2 = y - (int) ( (0 - min / (range)) * aa.graphHeight);
1245 g.setColor(Color.gray);
1247 g.drawLine(x, y2, (eRes - sRes) * av.charWidth, y2);
1250 int aaMax = aa.annotations.length - 1;
1252 while (x < eRes - sRes)
1255 if (av.hasHiddenColumns)
1257 column = av.getColumnSelection().adjustForHiddenColumns(column);
1265 if (aa.annotations[column] == null)
1271 if (aa.annotations[column].colour == null)
1272 g.setColor(Color.black);
1274 g.setColor(aa.annotations[column].colour);
1277 (int) ( ( (aa.annotations[column].value - min) / (range)) * aa.graphHeight);
1281 g.fillRect(x * av.charWidth, y2, av.charWidth, y1 - y2);
1285 g.fillRect(x * av.charWidth, y1, av.charWidth, y2 - y1);
1291 if (aa.threshold != null)
1293 g.setColor(aa.threshold.colour);
1294 Graphics2D g2 = (Graphics2D) g;
1295 g2.setStroke(new BasicStroke(1,
1296 BasicStroke.CAP_SQUARE,
1297 BasicStroke.JOIN_ROUND, 3f,
1301 y2 = (int) (y - ( (aa.threshold.value - min) / range) * aa.graphHeight);
1302 g.drawLine(0, y2, (eRes - sRes) * av.charWidth, y2);
1303 g2.setStroke(new BasicStroke());
1307 // used by overview window
1308 public void drawGraph(Graphics g, AlignmentAnnotation aa, int width, int y,
1311 eRes = Math.min(eRes, aa.annotations.length);
1312 g.setColor(Color.white);
1313 g.fillRect(0, 0, width, y);
1314 g.setColor(new Color(0, 0, 180));
1318 for (int j = sRes; j < eRes; j++)
1320 if (aa.annotations[j] != null)
1322 if (aa.annotations[j].colour == null)
1323 g.setColor(Color.black);
1325 g.setColor(aa.annotations[j].colour);
1327 height = (int) ( (aa.annotations[j].value / aa.graphMax) * y);
1333 g.fillRect(x, y - height, av.charWidth, height);