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();
50 BufferedImage fadedImage;
54 boolean fastPaint = false;
56 //Used For mouse Dragging and resizing graphs
57 int graphStretch = -1;
58 int graphStretchY = -1;
59 int min; //used by mouseDragged to see if user
60 int max; //used by mouseDragged to see if user
61 boolean mouseDragging = false;
66 * Creates a new AnnotationPanel object.
68 * @param ap DOCUMENT ME!
70 public AnnotationPanel(AlignmentPanel ap)
73 MAC = new jalview.util.Platform().isAMac();
75 ToolTipManager.sharedInstance().registerComponent(this);
76 ToolTipManager.sharedInstance().setInitialDelay(0);
77 ToolTipManager.sharedInstance().setDismissDelay(10000);
81 addMouseListener(this);
82 addMouseMotionListener(this);
83 ap.annotationScroller.getVerticalScrollBar().addAdjustmentListener(this);
86 public AnnotationPanel(AlignViewport av)
94 * @param evt DOCUMENT ME!
96 public void adjustmentValueChanged(AdjustmentEvent evt)
98 ap.alabels.setScrollOffset( -evt.getValue());
104 public int adjustPanelHeight()
106 // setHeight of panels
107 AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
112 for (int i = 0; i < aa.length; i++)
123 aa[i].height += av.charHeight;
133 aa[i].height += aa[i].graphHeight;
136 if (aa[i].height == 0)
141 height += aa[i].height;
149 this.setPreferredSize(new Dimension(1, height));
157 * @param evt DOCUMENT ME!
159 public void actionPerformed(ActionEvent evt)
161 AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
162 Annotation[] anot = aa[activeRow].annotations;
164 if (anot.length < av.getColumnSelection().getMax())
166 Annotation[] temp = new Annotation[av.getColumnSelection().getMax() + 2];
167 System.arraycopy(anot, 0, temp, 0, anot.length);
169 aa[activeRow].annotations = anot;
172 if (evt.getActionCommand().equals(REMOVE))
174 for (int i = 0; i < av.getColumnSelection().size(); i++)
176 anot[av.getColumnSelection().columnAt(i)] = null;
179 else if (evt.getActionCommand().equals(LABEL))
181 String exMesg = collectAnnotVals(anot, av.getColumnSelection(), LABEL);
182 String label = JOptionPane.showInputDialog(this,"Enter label",exMesg);
189 if ( (label.length() > 0) && !aa[activeRow].hasText)
191 aa[activeRow].hasText = true;
194 for (int i = 0; i < av.getColumnSelection().size(); i++)
196 int index = av.getColumnSelection().columnAt(i);
198 if(!av.colSel.isVisible(index))
201 if (anot[index] == null)
203 anot[index] = new Annotation(label, "", ' ', 0); // TODO: verify that null exceptions aren't raised elsewhere.
205 anot[index].displayCharacter = label;
209 else if (evt.getActionCommand().equals(COLOUR))
211 Color col = JColorChooser.showDialog(this,
212 "Choose foreground colour",
215 for (int i = 0; i < av.getColumnSelection().size(); i++)
217 int index = av.getColumnSelection().columnAt(i);
219 if(!av.colSel.isVisible(index))
222 if (anot[index] == null)
224 anot[index] = new Annotation("", "", ' ', 0);
227 anot[index].colour = col;
230 else // HELIX OR SHEET
233 String symbol = "\u03B1";
235 if (evt.getActionCommand().equals(HELIX))
239 else if (evt.getActionCommand().equals(SHEET))
245 if (!aa[activeRow].hasIcons)
247 aa[activeRow].hasIcons = true;
250 String label = JOptionPane.showInputDialog(
251 "Enter a label for the structure?",
259 if ( (label.length() > 0) && !aa[activeRow].hasText)
261 aa[activeRow].hasText = true;
264 for (int i = 0; i < av.getColumnSelection().size(); i++)
266 int index = av.getColumnSelection().columnAt(i);
268 if(!av.colSel.isVisible(index))
271 if (anot[index] == null)
273 anot[index] = new Annotation(label, "", type, 0);
276 anot[index].secondaryStructure = type;
277 anot[index].displayCharacter = label;
287 private String collectAnnotVals(Annotation[] anot, ColumnSelection columnSelection,
290 String collatedInput="";
292 for (int i = 0; i < columnSelection.size(); i++)
294 int index = columnSelection.columnAt(i);
295 // always check for current display state - just in case
296 if(!av.colSel.isVisible(index))
299 if (anot[index] != null)
301 if (label2.equals(HELIX) || label2.equals(SHEET) || label2.equals(LABEL))
303 tlabel = anot[index].description;
306 if (label2.equals(HELIX) || label2.equals(SHEET))
308 tlabel = ""+anot[index].secondaryStructure;
310 tlabel = ""+anot[index].displayCharacter;
314 if (tlabel!=null && !tlabel.equals(last))
320 collatedInput+=tlabel;
324 return collatedInput;
330 * @param evt DOCUMENT ME!
332 public void mousePressed(MouseEvent evt)
335 AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
344 for (int i = 0; i < aa.length; i++)
348 height += aa[i].height;
351 if (evt.getY() < height)
357 else if (aa[i].graph > 0)
361 graphStretchY = evt.getY();
368 if (SwingUtilities.isRightMouseButton(evt) && activeRow != -1)
370 if (av.getColumnSelection() == null)
375 JPopupMenu pop = new JPopupMenu("Structure type");
376 JMenuItem item = new JMenuItem(HELIX);
377 item.addActionListener(this);
379 item = new JMenuItem(SHEET);
380 item.addActionListener(this);
382 item = new JMenuItem(LABEL);
383 item.addActionListener(this);
385 item = new JMenuItem(COLOUR);
386 item.addActionListener(this);
388 item = new JMenuItem(REMOVE);
389 item.addActionListener(this);
391 pop.show(this, evt.getX(), evt.getY());
401 ap.scalePanel.mousePressed(evt);
408 * @param evt DOCUMENT ME!
410 public void mouseReleased(MouseEvent evt)
414 mouseDragging = false;
415 ap.scalePanel.mouseReleased(evt);
421 * @param evt DOCUMENT ME!
423 public void mouseEntered(MouseEvent evt)
425 ap.scalePanel.mouseEntered(evt);
431 * @param evt DOCUMENT ME!
433 public void mouseExited(MouseEvent evt)
435 ap.scalePanel.mouseExited(evt);
441 * @param evt DOCUMENT ME!
443 public void mouseDragged(MouseEvent evt)
445 if (graphStretch > -1)
447 av.alignment.getAlignmentAnnotation()[graphStretch].graphHeight +=
448 graphStretchY - evt.getY();
449 if (av.alignment.getAlignmentAnnotation()[graphStretch].graphHeight < 0)
451 av.alignment.getAlignmentAnnotation()[graphStretch].graphHeight = 0;
453 graphStretchY = evt.getY();
455 ap.paintAlignment(true);
459 ap.scalePanel.mouseDragged(evt);
466 * @param evt DOCUMENT ME!
468 public void mouseMoved(MouseEvent evt)
470 AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
474 this.setToolTipText(null);
481 for (int i = 0; i < aa.length; i++)
485 height += aa[i].height;
488 if (evt.getY() < height)
498 this.setToolTipText(null);
502 int res = (evt.getX() / av.getCharWidth()) + av.getStartRes();
504 if (av.hasHiddenColumns)
506 res = av.getColumnSelection().adjustForHiddenColumns(res);
509 if (aa[row].annotations != null
511 && res < (int) aa[row].annotations.length)
513 if (aa[row].graphGroup > -1)
515 StringBuffer tip = new StringBuffer("<html>");
516 for (int gg = 0; gg < aa.length; gg++)
518 if (aa[gg].graphGroup == aa[row].graphGroup && aa[gg].annotations[res] != null)
520 tip.append(aa[gg].label + " " + aa[gg].annotations[res].description +
524 if (tip.length() != 6)
526 tip.setLength(tip.length() - 4);
527 this.setToolTipText(tip.toString() + "</html>");
530 else if (aa[row].annotations[res] != null
531 && aa[row].annotations[res].description != null)
533 this.setToolTipText(aa[row].annotations[res].description);
536 if (aa[row].annotations[res] != null)
538 StringBuffer text = new StringBuffer("Sequence position " +
541 if (aa[row].annotations[res].description != null)
543 text.append(" " + aa[row].annotations[res].description);
546 ap.alignFrame.statusBar.setText(text.toString());
551 this.setToolTipText(null);
558 * @param evt DOCUMENT ME!
560 public void mouseClicked(MouseEvent evt)
567 * @param g DOCUMENT ME!
569 public void paintComponent(Graphics g)
571 g.setColor(Color.white);
572 g.fillRect(0, 0, getWidth(), getHeight());
577 || (getVisibleRect().width != g.getClipBounds().width)
578 || (getVisibleRect().height != g.getClipBounds().height))
580 g.drawImage(image, 0, 0, this);
585 imgWidth = (av.endRes - av.startRes + 1) * av.charWidth;
588 if (image == null || imgWidth != image.getWidth()
589 || image.getHeight(this) != getHeight())
591 image = new BufferedImage(imgWidth, ap.annotationPanel.getHeight(),
592 BufferedImage.TYPE_INT_RGB);
593 gg = (Graphics2D) image.getGraphics();
597 gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
598 RenderingHints.VALUE_ANTIALIAS_ON);
601 gg.setFont(av.getFont());
602 fm = gg.getFontMetrics();
603 gg.setColor(Color.white);
604 gg.fillRect(0, 0, imgWidth, image.getHeight());
607 drawComponent(gg, av.startRes, av.endRes + 1);
608 g.drawImage(image, 0, 0, this);
611 * non-Thread safe repaint
613 * @param horizontal repaint with horizontal shift in alignment
615 public void fastPaint(int horizontal)
618 if ( (horizontal == 0)
620 || av.alignment.getAlignmentAnnotation() == null
621 || av.alignment.getAlignmentAnnotation().length < 1
622 || av.updatingConsensus
623 || av.updatingConservation)
628 gg.copyArea(0, 0, imgWidth, getHeight(), -horizontal * av.charWidth, 0);
630 int sr = av.startRes;
631 int er = av.endRes + 1;
634 if (horizontal > 0) // scrollbar pulled right, image to the left
636 transX = (er - sr - horizontal) * av.charWidth;
637 sr = er - horizontal;
639 else if (horizontal < 0)
641 er = sr - horizontal;
644 gg.translate(transX, 0);
646 drawComponent(gg, sr, er);
648 gg.translate( -transX, 0);
658 * @param g DOCUMENT ME!
659 * @param startRes DOCUMENT ME!
660 * @param endRes DOCUMENT ME!
662 public void drawComponent(Graphics g, int startRes, int endRes)
664 if (av.updatingConsensus || av.updatingConservation)
670 //We'll keep a record of the old image,
671 //and draw a faded image until the calculation
673 if (fadedImage == null
674 || fadedImage.getWidth() != imgWidth
675 || fadedImage.getHeight() != image.getHeight())
677 fadedImage = new BufferedImage(
678 imgWidth, image.getHeight(),
679 BufferedImage.TYPE_INT_RGB);
681 Graphics2D fadedG = (Graphics2D) fadedImage.getGraphics();
683 fadedG.setColor(Color.white);
684 fadedG.fillRect(0, 0, imgWidth, image.getHeight());
687 AlphaComposite.getInstance(
688 AlphaComposite.SRC_OVER, .3f));
689 fadedG.drawImage(image, 0, 0, this);
699 g.setColor(Color.white);
700 g.fillRect(0, 0, (endRes - startRes) * av.charWidth, getHeight());
702 g.setFont(av.getFont());
705 fm = g.getFontMetrics();
708 if ( (av.alignment.getAlignmentAnnotation() == null) ||
709 (av.alignment.getAlignmentAnnotation().length < 1))
711 g.setColor(Color.white);
712 g.fillRect(0, 0, getWidth(), getHeight());
713 g.setColor(Color.black);
714 if (av.validCharWidth)
716 g.drawString("Alignment has no annotations", 20, 15);
722 AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
729 boolean validRes = false;
731 boolean[] graphGroupDrawn = new boolean[aa.length];
734 for (int i = 0; i < aa.length; i++)
736 AlignmentAnnotation row = aa[i];
748 if (row.graphGroup > -1 && graphGroupDrawn[row.graphGroup])
753 // this is so that we draw the characters below the graph
758 iconOffset =av.charHeight -fm.getDescent();
762 else if (row.hasText)
764 iconOffset = av.charHeight -fm.getDescent();
773 if (av.updatingConsensus && aa[i] == av.consensus)
777 g.drawImage(fadedImage,
778 0, y - row.height, imgWidth, y,
779 0, y - row.height, imgWidth, y, this);
780 g.setColor(Color.black);
781 // g.drawString("Calculating Consensus....",20, y-row.height/2);
785 else if (av.updatingConservation && aa[i].label.equals("Conservation"))
789 g.drawImage(fadedImage,
790 0, y - row.height, imgWidth, y,
791 0, y - row.height, imgWidth, y, this);
793 g.setColor(Color.black);
794 // g.drawString("Calculating Conservation.....",20, y-row.height/2);
798 else if (av.updatingConservation && aa[i].label.equals("Quality"))
802 g.drawImage(fadedImage,
803 0, y - row.height, imgWidth, y,
804 0, y - row.height, imgWidth, y, this);
805 g.setColor(Color.black);
806 /// g.drawString("Calculating Quality....",20, y-row.height/2);
814 while (x < endRes - startRes)
816 if (av.hasHiddenColumns)
818 column = av.getColumnSelection().adjustForHiddenColumns(startRes + x);
819 if (column > row.annotations.length - 1)
826 column = startRes + x;
829 if ( (row.annotations==null)
830 || (row.annotations.length <= column)
831 || (row.annotations[column] == null))
842 g.setColor(Color.red);
844 if (av.getColumnSelection() != null)
846 for (int n = 0; n < av.getColumnSelection().size(); n++)
848 int v = av.getColumnSelection().columnAt(n);
852 g.fillRect(x * av.charWidth, y,
853 av.charWidth, av.charHeight);
859 if (av.validCharWidth && validRes
860 && row.annotations[column].displayCharacter != null
861 && (row.annotations[column].displayCharacter.length() > 0))
864 int charOffset = (av.getCentreColumnLabels()) ? ((av.charWidth -
865 fm.charsWidth(row.annotations[column].
866 displayCharacter.toCharArray(),0,
867 row.annotations[column].
868 displayCharacter.length())) / 2)
869 : (av.charWidth - fm.charWidth(row.annotations[column].
870 displayCharacter.charAt(0))) / 2;
872 if (row.annotations[column].colour == null)
873 g.setColor(Color.black);
875 g.setColor(row.annotations[column].colour);
877 if (column == 0 || row.graph > 0)
879 g.drawString(row.annotations[column].displayCharacter,
880 (x * av.charWidth) + charOffset,
884 row.annotations[column - 1] == null
885 || (!row.annotations[column].displayCharacter.equals(
886 row.annotations[column - 1].displayCharacter)
888 (row.annotations[column].displayCharacter.length() < 2 &&
889 row.annotations[column].secondaryStructure == ' ')))
891 g.drawString(row.annotations[column].displayCharacter,
892 x * av.charWidth + charOffset,
900 (row.annotations[column].secondaryStructure != lastSS))
905 g.setColor(HELIX_COLOUR);
908 //Off by 1 offset when drawing rects and ovals
909 //to offscreen image on the MAC
910 g.fillRoundRect(lastSSX, y + 4 + iconOffset,
911 (x * av.charWidth) - lastSSX, 7, 8, 8);
915 int sCol = (lastSSX / av.charWidth) + startRes;
917 int x2 = (x * av.charWidth);
920 row.annotations[sCol - 1] == null ||
921 row.annotations[sCol - 1].secondaryStructure != 'H')
923 g.fillArc(lastSSX, y + 4 + iconOffset, av.charWidth, 8, 90,
925 x1 += av.charWidth / 2;
928 if (row.annotations[column] == null ||
929 row.annotations[column].secondaryStructure != 'H')
931 g.fillArc( (x * av.charWidth) - av.charWidth,
932 y + 4 + iconOffset, av.charWidth, 8, 270, 180);
933 x2 -= av.charWidth / 2;
936 g.fillRect(x1, y + 4 + iconOffset, x2 - x1, 8);
940 g.setColor(SHEET_COLOUR);
941 g.fillRect(lastSSX, y + 4 + iconOffset,
942 (x * av.charWidth) - lastSSX - 4, 7);
943 g.fillPolygon(new int[]
944 { (x * av.charWidth) - 4,
945 (x * av.charWidth) - 4,
949 y + iconOffset, y + 14 + iconOffset,
956 g.setColor(Color.gray);
957 g.fillRect(lastSSX, y + 6 + iconOffset,
958 (x * av.charWidth) - lastSSX, 2);
965 lastSS = row.annotations[column].secondaryStructure;
972 lastSSX = (x * av.charWidth);
980 if (column >= row.annotations.length)
982 column = row.annotations.length - 1;
992 g.setColor(HELIX_COLOUR);
995 //Off by 1 offset when drawing rects and ovals
996 //to offscreen image on the MAC
997 g.fillRoundRect(lastSSX, y + 4 + iconOffset,
998 (x * av.charWidth) - lastSSX, 7, 8, 8);
1002 int sCol = (lastSSX / av.charWidth) + startRes;
1004 int x2 = (x * av.charWidth);
1007 row.annotations[sCol - 1] == null ||
1008 row.annotations[sCol - 1].secondaryStructure != 'H')
1010 g.fillArc(lastSSX, y + 4 + iconOffset, av.charWidth, 8, 90, 180);
1011 x1 += av.charWidth / 2;
1014 if (row.annotations[column] == null ||
1015 row.annotations[column].secondaryStructure != 'H')
1017 g.fillArc( (x * av.charWidth) - av.charWidth,
1018 y + 4 + iconOffset, av.charWidth, 8, 270,
1020 x2 -= av.charWidth / 2;
1023 g.fillRect(x1, y + 4 + iconOffset, x2 - x1, 8);
1028 g.setColor(SHEET_COLOUR);
1030 if (row.annotations[endRes] == null
1031 || row.annotations[endRes].secondaryStructure != 'E')
1033 g.fillRect(lastSSX, y + 4 + iconOffset,
1034 (x * av.charWidth) - lastSSX - 4, 7);
1035 g.fillPolygon(new int[]
1036 { (x * av.charWidth) - 4,
1037 (x * av.charWidth) - 4,
1038 (x * av.charWidth)},
1041 y + iconOffset, y + 14 + iconOffset,
1047 g.fillRect(lastSSX, y + 4 + iconOffset,
1048 (x + 1) * av.charWidth - lastSSX, 7);
1053 g.setColor(Color.gray);
1054 g.fillRect(lastSSX, y + 6 + iconOffset,
1055 (x * av.charWidth) - lastSSX, 2);
1061 if (row.graph > 0 && row.graphHeight > 0)
1063 if (row.graph == AlignmentAnnotation.LINE_GRAPH)
1065 if (row.graphGroup > -1 && !graphGroupDrawn[row.graphGroup])
1067 float groupmax = -999999, groupmin = 9999999;
1068 for (int gg = 0; gg < aa.length; gg++)
1070 if (aa[gg].graphGroup != row.graphGroup)
1077 aa[gg].visible = false;
1080 if (aa[gg].graphMax > groupmax)
1082 groupmax = aa[gg].graphMax;
1084 if (aa[gg].graphMin < groupmin)
1086 groupmin = aa[gg].graphMin;
1090 for (int gg = 0; gg < aa.length; gg++)
1092 if (aa[gg].graphGroup == row.graphGroup)
1094 drawLineGraph(g, aa[gg], startRes, endRes, y,
1100 graphGroupDrawn[row.graphGroup] = true;
1104 drawLineGraph(g, row, startRes, endRes,
1105 y, row.graphMin, row.graphMax, row.graphHeight);
1108 else if (row.graph == AlignmentAnnotation.BAR_GRAPH)
1110 drawBarGraph(g, row, startRes, endRes,
1111 row.graphMin, row.graphMax, y);
1115 if (row.graph > 0 && row.hasText)
1127 public void drawLineGraph(Graphics g, AlignmentAnnotation aa,
1130 float min, float max,
1133 if (sRes > aa.annotations.length)
1140 //Adjustment for fastpaint to left
1141 if (eRes < av.endRes)
1146 eRes = Math.min(eRes, aa.annotations.length);
1154 float range = max - min;
1159 y2 = y - (int) ( (0 - min / range) * graphHeight);
1162 g.setColor(Color.gray);
1163 g.drawLine(x - av.charWidth, y2, (eRes - sRes + 1) * av.charWidth, y2);
1165 eRes = Math.min(eRes, aa.annotations.length);
1168 int aaMax = aa.annotations.length - 1;
1170 while (x < eRes - sRes)
1173 if (av.hasHiddenColumns)
1175 column = av.getColumnSelection().adjustForHiddenColumns(column);
1183 if (aa.annotations[column] == null || aa.annotations[column - 1] == null)
1189 if (aa.annotations[column].colour == null)
1190 g.setColor(Color.black);
1192 g.setColor(aa.annotations[column].colour);
1195 (int) ( ( (aa.annotations[column - 1].value - min) / range) * graphHeight);
1197 (int) ( ( (aa.annotations[column].value - min) / range) * graphHeight);
1199 g.drawLine(x * av.charWidth - av.charWidth / 2, y1,
1200 x * av.charWidth + av.charWidth / 2, y2);
1204 if (aa.threshold != null)
1206 g.setColor(aa.threshold.colour);
1207 Graphics2D g2 = (Graphics2D) g;
1208 g2.setStroke(new BasicStroke(1,
1209 BasicStroke.CAP_SQUARE,
1210 BasicStroke.JOIN_ROUND, 3f,
1214 y2 = (int) (y - ( (aa.threshold.value - min) / range) * graphHeight);
1215 g.drawLine(0, y2, (eRes - sRes) * av.charWidth, y2);
1216 g2.setStroke(new BasicStroke());
1220 public void drawBarGraph(Graphics g, AlignmentAnnotation aa,
1222 float min, float max,
1225 if (sRes > aa.annotations.length)
1230 eRes = Math.min(eRes, aa.annotations.length);
1232 int x = 0, y1 = y, y2 = y;
1234 float range = max - min;
1238 y2 = y - (int) ( (0 - min / (range)) * aa.graphHeight);
1241 g.setColor(Color.gray);
1243 g.drawLine(x, y2, (eRes - sRes) * av.charWidth, y2);
1246 int aaMax = aa.annotations.length - 1;
1248 while (x < eRes - sRes)
1251 if (av.hasHiddenColumns)
1253 column = av.getColumnSelection().adjustForHiddenColumns(column);
1261 if (aa.annotations[column] == null)
1267 if (aa.annotations[column].colour == null)
1268 g.setColor(Color.black);
1270 g.setColor(aa.annotations[column].colour);
1273 (int) ( ( (aa.annotations[column].value - min) / (range)) * aa.graphHeight);
1277 g.fillRect(x * av.charWidth, y2, av.charWidth, y1 - y2);
1281 g.fillRect(x * av.charWidth, y1, av.charWidth, y2 - y1);
1287 if (aa.threshold != null)
1289 g.setColor(aa.threshold.colour);
1290 Graphics2D g2 = (Graphics2D) g;
1291 g2.setStroke(new BasicStroke(1,
1292 BasicStroke.CAP_SQUARE,
1293 BasicStroke.JOIN_ROUND, 3f,
1297 y2 = (int) (y - ( (aa.threshold.value - min) / range) * aa.graphHeight);
1298 g.drawLine(0, y2, (eRes - sRes) * av.charWidth, y2);
1299 g2.setStroke(new BasicStroke());
1303 // used by overview window
1304 public void drawGraph(Graphics g, AlignmentAnnotation aa, int width, int y,
1307 eRes = Math.min(eRes, aa.annotations.length);
1308 g.setColor(Color.white);
1309 g.fillRect(0, 0, width, y);
1310 g.setColor(new Color(0, 0, 180));
1314 for (int j = sRes; j < eRes; j++)
1316 if (aa.annotations[j] != null)
1318 if (aa.annotations[j].colour == null)
1319 g.setColor(Color.black);
1321 g.setColor(aa.annotations[j].colour);
1323 height = (int) ( (aa.annotations[j].value / aa.graphMax) * y);
1329 g.fillRect(x, y - height, av.charWidth, height);