2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
19 package jalview.gui;
\r
21 import jalview.datamodel.*;
\r
24 import java.awt.event.*;
\r
25 import java.awt.image.*;
\r
27 import javax.swing.*;
\r
34 * @version $Revision$
\r
36 public class AnnotationPanel extends JPanel implements MouseListener,
\r
37 MouseMotionListener, ActionListener, AdjustmentListener
\r
39 final String HELIX = "Helix";
\r
40 final String SHEET = "Sheet";
\r
41 final String LABEL = "Label";
\r
42 final String REMOVE = "Remove Annotation";
\r
43 final String COLOUR = "Colour";
\r
44 final Color HELIX_COLOUR = Color.red.darker();
\r
45 final Color SHEET_COLOUR = Color.green.darker().darker();
\r
47 /** DOCUMENT ME!! */
\r
51 BufferedImage image;
\r
52 BufferedImage fadedImage;
\r
56 boolean fastPaint = false;
\r
58 //Used For mouse Dragging and resizing graphs
\r
59 int graphStretch = -1;
\r
60 int graphStretchY = -1;
\r
61 int min; //used by mouseDragged to see if user
\r
62 int max; //used by mouseDragged to see if user
\r
63 boolean mouseDragging = false;
\r
65 boolean MAC = false;
\r
68 * Creates a new AnnotationPanel object.
\r
70 * @param ap DOCUMENT ME!
\r
72 public AnnotationPanel(AlignmentPanel ap)
\r
75 if(System.getProperty("os.name").startsWith("Mac"))
\r
78 ToolTipManager.sharedInstance().registerComponent(this);
\r
79 ToolTipManager.sharedInstance().setInitialDelay(0);
\r
80 ToolTipManager.sharedInstance().setDismissDelay(10000);
\r
83 this.setLayout(null);
\r
84 addMouseListener(this);
\r
85 addMouseMotionListener(this);
\r
86 ap.annotationScroller.getVerticalScrollBar().addAdjustmentListener(this);
\r
89 public AnnotationPanel(AlignViewport av)
\r
98 * @param evt DOCUMENT ME!
\r
100 public void adjustmentValueChanged(AdjustmentEvent evt)
\r
102 ap.alabels.setScrollOffset(-evt.getValue());
\r
108 public int adjustPanelHeight()
\r
110 // setHeight of panels
\r
111 AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
\r
116 for (int i = 0; i < aa.length; i++)
\r
118 if (!aa[i].visible)
\r
127 aa[i].height += av.charHeight;
\r
130 if (aa[i].hasIcons)
\r
132 aa[i].height += 16;
\r
137 aa[i].height += aa[i].graphHeight;
\r
140 if (aa[i].height == 0)
\r
145 height += aa[i].height;
\r
153 this.setPreferredSize(new Dimension(1, height));
\r
163 * @param evt DOCUMENT ME!
\r
165 public void actionPerformed(ActionEvent evt)
\r
167 AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
\r
168 Annotation[] anot = aa[activeRow].annotations;
\r
170 if (evt.getActionCommand().equals(REMOVE))
\r
172 for (int i = 0; i < av.getColumnSelection().size(); i++)
\r
174 anot[av.getColumnSelection().columnAt(i)] = null;
\r
177 else if (evt.getActionCommand().equals(LABEL))
\r
179 String label = JOptionPane.showInputDialog(this, "Enter Label ",
\r
180 "Enter label", JOptionPane.QUESTION_MESSAGE);
\r
187 if ((label.length() > 0) && !aa[activeRow].hasText)
\r
189 aa[activeRow].hasText = true;
\r
192 for (int i = 0; i < av.getColumnSelection().size(); i++)
\r
194 int index = av.getColumnSelection().columnAt(i);
\r
196 if (anot[index] == null)
\r
198 anot[index] = new Annotation(label, "", ' ', 0);
\r
201 anot[index].displayCharacter = label;
\r
204 else if (evt.getActionCommand().equals(COLOUR))
\r
206 Color col = JColorChooser.showDialog(this,
\r
207 "Choose foreground colour", Color.black);
\r
209 for (int i = 0; i < av.getColumnSelection().size(); i++)
\r
211 int index = av.getColumnSelection().columnAt(i);
\r
213 if (anot[index] == null)
\r
215 anot[index] = new Annotation("", "", ' ', 0);
\r
218 anot[index].colour = col;
\r
221 else // HELIX OR SHEET
\r
224 String symbol = "\u03B1";
\r
226 if (evt.getActionCommand().equals(HELIX))
\r
230 else if (evt.getActionCommand().equals(SHEET))
\r
236 if (!aa[activeRow].hasIcons)
\r
238 aa[activeRow].hasIcons = true;
\r
241 String label = JOptionPane.showInputDialog("Enter a label for the structure?",
\r
249 if ((label.length() > 0) && !aa[activeRow].hasText)
\r
251 aa[activeRow].hasText = true;
\r
254 for (int i = 0; i < av.getColumnSelection().size(); i++)
\r
256 int index = av.getColumnSelection().columnAt(i);
\r
258 if (anot[index] == null)
\r
260 anot[index] = new Annotation(label, "", type, 0);
\r
263 anot[index].secondaryStructure = type;
\r
264 anot[index].displayCharacter = label;
\r
268 adjustPanelHeight();
\r
277 * @param evt DOCUMENT ME!
\r
279 public void mousePressed(MouseEvent evt)
\r
283 AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
\r
292 for (int i = 0; i < aa.length; i++)
\r
296 height += aa[i].height;
\r
299 if (evt.getY() < height)
\r
301 if (aa[i].editable)
\r
305 else if(aa[i].graph>0)
\r
309 graphStretchY = evt.getY();
\r
317 if (SwingUtilities.isRightMouseButton(evt) && activeRow!=-1)
\r
319 if (av.getColumnSelection() == null)
\r
324 JPopupMenu pop = new JPopupMenu("Structure type");
\r
325 JMenuItem item = new JMenuItem(HELIX);
\r
326 item.addActionListener(this);
\r
328 item = new JMenuItem(SHEET);
\r
329 item.addActionListener(this);
\r
331 item = new JMenuItem(LABEL);
\r
332 item.addActionListener(this);
\r
334 item = new JMenuItem(COLOUR);
\r
335 item.addActionListener(this);
\r
337 item = new JMenuItem(REMOVE);
\r
338 item.addActionListener(this);
\r
340 pop.show(this, evt.getX(), evt.getY());
\r
350 int res = (evt.getX() / av.getCharWidth()) + av.getStartRes();
\r
355 if (av.getColumnSelection().contains(res))
\r
356 av.getColumnSelection().removeElement(res);
\r
359 av.getColumnSelection().addElement(res);
\r
360 SequenceGroup sg = new SequenceGroup();
\r
362 for (int i = 0; i < av.alignment.getSequences().size(); i++)
\r
364 sg.addSequence(av.alignment.getSequenceAt(i), false);
\r
367 sg.setStartRes(res);
\r
369 av.setSelectionGroup(sg);
\r
379 * @param evt DOCUMENT ME!
\r
381 public void mouseReleased(MouseEvent evt)
\r
384 graphStretchY = -1;
\r
385 mouseDragging = false;
\r
391 * @param evt DOCUMENT ME!
\r
393 public void mouseEntered(MouseEvent evt)
\r
396 ap.seqPanel.scrollCanvas(null);
\r
402 * @param evt DOCUMENT ME!
\r
404 public void mouseExited(MouseEvent evt)
\r
407 ap.seqPanel.scrollCanvas(evt);
\r
414 * @param evt DOCUMENT ME!
\r
416 public void mouseDragged(MouseEvent evt)
\r
418 if(graphStretch>-1)
\r
420 av.alignment.getAlignmentAnnotation()[graphStretch].graphHeight += graphStretchY - evt.getY();
\r
421 if(av.alignment.getAlignmentAnnotation()[graphStretch].graphHeight <0)
\r
422 av.alignment.getAlignmentAnnotation()[graphStretch].graphHeight = 0;
\r
423 graphStretchY = evt.getY();
\r
424 adjustPanelHeight();
\r
429 mouseDragging = true;
\r
431 int res = (evt.getX() / av.getCharWidth()) + av.getStartRes();
\r
433 SequenceGroup sg = av.getSelectionGroup();
\r
447 if (!av.getColumnSelection().contains(res))
\r
449 av.getColumnSelection().addElement(res);
\r
452 if (res > sg.getStartRes())
\r
456 else if (res < sg.getStartRes())
\r
458 sg.setStartRes(res);
\r
461 for (int i = min; i <= max; i++)
\r
463 if ((i < sg.getStartRes()) || (i > sg.getEndRes()))
\r
465 av.getColumnSelection().removeElement(i);
\r
469 av.getColumnSelection().addElement(i);
\r
482 * @param evt DOCUMENT ME!
\r
484 public void mouseMoved(MouseEvent evt)
\r
486 AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
\r
496 for (int i = 0; i < aa.length; i++)
\r
500 height += aa[i].height;
\r
503 if (evt.getY() < height)
\r
514 int res = (evt.getX() / av.getCharWidth()) + av.getStartRes();
\r
516 if(av.hasHiddenColumns)
\r
517 res = av.getColumnSelection().adjustForHiddenColumns(res);
\r
519 if ( aa[row].annotations!=null
\r
521 && res < (int) aa[row].annotations.length)
\r
523 if(aa[row].graphGroup>-1)
\r
525 StringBuffer tip = new StringBuffer("<html>");
\r
526 for (int gg = 0; gg < aa.length; gg++)
\r
528 if (aa[gg].graphGroup == aa[row].graphGroup && aa[gg].annotations[res]!=null)
\r
529 tip.append(aa[gg].label+" "+aa[gg].annotations[res].description+"<br>" );
\r
531 if(tip.length()!=6)
\r
533 tip.setLength(tip.length() - 4);
\r
534 this.setToolTipText(tip.toString() + "</html>");
\r
537 else if(aa[row].annotations[res] != null)
\r
538 this.setToolTipText(aa[row].annotations[res].description);
\r
540 if(aa[row].annotations[res]!=null)
\r
542 StringBuffer text = new StringBuffer("Sequence position " +
\r
544 aa[row].annotations[res].description);
\r
546 ap.alignFrame.statusBar.setText(text.toString());
\r
554 * @param evt DOCUMENT ME!
\r
556 public void mouseClicked(MouseEvent evt)
\r
563 * @param g DOCUMENT ME!
\r
565 public void paintComponent(Graphics g)
\r
567 g.setColor(Color.white);
\r
568 g.fillRect(0, 0, getWidth(), getHeight());
\r
572 || (getVisibleRect().width != g.getClipBounds().width)
\r
573 || (getVisibleRect().height != g.getClipBounds().height))
\r
575 g.drawImage(image, 0, 0, this);
\r
580 imgWidth = (av.endRes - av.startRes + 1) * av.charWidth;
\r
582 if (image == null || imgWidth != image.getWidth()
\r
583 || image.getHeight(this) != getHeight())
\r
585 image = new BufferedImage(imgWidth, ap.annotationPanel.getHeight(),
\r
586 BufferedImage.TYPE_INT_RGB);
\r
587 gg = (Graphics2D) image.getGraphics();
\r
590 gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
\r
591 RenderingHints.VALUE_ANTIALIAS_ON);
\r
593 gg.setFont(av.getFont());
\r
594 fm = gg.getFontMetrics();
\r
595 gg.setColor(Color.white);
\r
596 gg.fillRect(0, 0, imgWidth, image.getHeight());
\r
600 drawComponent(gg, av.startRes, av.endRes + 1);
\r
601 g.drawImage(image, 0, 0, this);
\r
607 * @param horizontal DOCUMENT ME!
\r
609 public void fastPaint(int horizontal)
\r
611 if ((horizontal == 0)
\r
613 || av.alignment.getAlignmentAnnotation()==null
\r
614 || av.alignment.getAlignmentAnnotation().length < 1
\r
615 || av.updatingConsensus
\r
616 || av.updatingConservation)
\r
622 gg.copyArea(0, 0, imgWidth, getHeight(), -horizontal * av.charWidth, 0);
\r
624 int sr = av.startRes;
\r
625 int er = av.endRes + 1;
\r
628 if (horizontal > 0) // scrollbar pulled right, image to the left
\r
630 transX = (er - sr - horizontal) * av.charWidth;
\r
631 sr = er - horizontal;
\r
633 else if (horizontal < 0)
\r
635 er = sr - horizontal;
\r
638 gg.translate(transX, 0);
\r
640 drawComponent(gg, sr, er);
\r
642 gg.translate(-transX, 0);
\r
653 * @param g DOCUMENT ME!
\r
654 * @param startRes DOCUMENT ME!
\r
655 * @param endRes DOCUMENT ME!
\r
657 public void drawComponent(Graphics g, int startRes, int endRes)
\r
659 if(av.updatingConsensus || av.updatingConservation)
\r
665 //We'll keep a record of the old image,
\r
666 //and draw a faded image until the calculation
\r
668 if(fadedImage==null
\r
669 || fadedImage.getWidth()!=imgWidth
\r
670 || fadedImage.getHeight()!=image.getHeight())
\r
672 fadedImage = new BufferedImage(
\r
673 imgWidth, image.getHeight(),
\r
674 BufferedImage.TYPE_INT_RGB);
\r
676 Graphics2D fadedG = (Graphics2D) fadedImage.getGraphics();
\r
678 fadedG.setColor(Color.white);
\r
679 fadedG.fillRect(0, 0, imgWidth, image.getHeight());
\r
681 fadedG.setComposite(
\r
682 AlphaComposite.getInstance(
\r
683 AlphaComposite.SRC_OVER, .3f));
\r
684 fadedG.drawImage(image, 0, 0, this);
\r
693 g.setColor(Color.white);
\r
694 g.fillRect(0, 0, (endRes - startRes) * av.charWidth, getHeight());
\r
696 g.setFont(av.getFont());
\r
698 fm = g.getFontMetrics();
\r
703 if ( (av.alignment.getAlignmentAnnotation() == null) ||
\r
704 (av.alignment.getAlignmentAnnotation().length < 1))
\r
706 g.setColor(Color.white);
\r
707 g.fillRect(0, 0, getWidth(), getHeight());
\r
708 g.setColor(Color.black);
\r
709 if(av.validCharWidth)
\r
710 g.drawString("Alignment has no annotations", 20, 15);
\r
716 AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
\r
722 int iconOffset = av.charHeight / 2;
\r
723 boolean validRes = false;
\r
725 boolean [] graphGroupDrawn = new boolean[aa.length];
\r
729 for (int i = 0; i < aa.length; i++)
\r
731 AlignmentAnnotation row = aa[i];
\r
744 if(row.graphGroup>-1 && graphGroupDrawn[ row.graphGroup ] )
\r
747 // this is so that we draw the characters below the graph
\r
752 y -= av.charHeight;
\r
756 if (av.updatingConsensus && aa[i].label.equals("Consensus"))
\r
758 y += av.charHeight;
\r
760 g.drawImage(fadedImage,
\r
761 0,y-row.height,imgWidth, y,
\r
762 0,y-row.height,imgWidth, y, this);
\r
763 g.setColor(Color.black);
\r
764 // g.drawString("Calculating Consensus....",20, y-row.height/2);
\r
768 else if (av.updatingConservation && aa[i].label.equals("Conservation"))
\r
771 y += av.charHeight;
\r
772 g.drawImage(fadedImage,
\r
773 0, y - row.height, imgWidth, y,
\r
774 0, y - row.height, imgWidth, y, this);
\r
776 g.setColor(Color.black);
\r
777 // g.drawString("Calculating Conservation.....",20, y-row.height/2);
\r
781 else if (av.updatingConservation && aa[i].label.equals("Quality"))
\r
784 y += av.charHeight;
\r
785 g.drawImage(fadedImage,
\r
786 0, y - row.height, imgWidth, y,
\r
787 0, y - row.height, imgWidth, y, this);
\r
788 g.setColor(Color.black);
\r
789 /// g.drawString("Calculating Quality....",20, y-row.height/2);
\r
797 iconOffset = av.charHeight / 2 + 4;
\r
805 while (x < endRes-startRes)
\r
807 if (av.hasHiddenColumns)
\r
809 column = av.getColumnSelection().adjustForHiddenColumns(startRes+x);
\r
810 if (column > row.annotations.length-1)
\r
816 column = startRes+x;
\r
819 if ((row.annotations.length <= column) ||
\r
820 (row.annotations[column] == null))
\r
830 if (activeRow == i)
\r
832 g.setColor(Color.red);
\r
834 if (av.getColumnSelection() != null)
\r
836 for (int n = 0; n < av.getColumnSelection().size(); n++)
\r
838 int v = av.getColumnSelection().columnAt(n);
\r
842 g.fillRect(x * av.charWidth, y,
\r
843 av.charWidth, av.charHeight);
\r
849 if (av.validCharWidth && validRes &&
\r
850 (row.annotations[column].displayCharacter.length() > 0))
\r
853 int charOffset = (av.charWidth -
\r
854 fm.charWidth(row.annotations[column].displayCharacter.charAt(
\r
856 g.setColor(row.annotations[column].colour);
\r
858 if (column == 0 || row.graph>0)
\r
860 g.drawString(row.annotations[column].displayCharacter,
\r
861 (x*av.charWidth)+charOffset,
\r
865 row.annotations[column - 1] == null
\r
866 ||(!row.annotations[column].displayCharacter.equals(
\r
867 row.annotations[column - 1].displayCharacter)
\r
869 (row.annotations[column].displayCharacter.length() <2 &&
\r
870 row.annotations[column].secondaryStructure==' ')))
\r
872 g.drawString(row.annotations[column].displayCharacter,
\r
873 x*av.charWidth+charOffset,
\r
881 (row.annotations[column].secondaryStructure != lastSS))
\r
886 g.setColor(HELIX_COLOUR);
\r
889 //Off by 1 offset when drawing rects and ovals
\r
890 //to offscreen image on the MAC
\r
891 g.fillRoundRect(lastSSX, y + 4 + iconOffset,
\r
892 (x*av.charWidth) - lastSSX, 7, 8, 8);
\r
896 int sCol = (lastSSX / av.charWidth) + startRes;
\r
898 int x2 = (x*av.charWidth);
\r
901 row.annotations[sCol-1]==null ||
\r
902 row.annotations[sCol-1].secondaryStructure!='H')
\r
904 g.fillArc(lastSSX, y+4+iconOffset, av.charWidth, 8, 90,180) ;
\r
905 x1 += av.charWidth/2;
\r
908 if(row.annotations[column]==null ||
\r
909 row.annotations[column].secondaryStructure!='H')
\r
911 g.fillArc((x*av.charWidth)-av.charWidth,
\r
912 y+4+iconOffset, av.charWidth, 8, 270,180);
\r
913 x2 -= av.charWidth/2;
\r
916 g.fillRect(x1, y+4+iconOffset, x2-x1, 8);
\r
920 g.setColor(SHEET_COLOUR);
\r
921 g.fillRect(lastSSX, y + 4 + iconOffset,
\r
922 (x*av.charWidth) - lastSSX - 4, 7);
\r
923 g.fillPolygon(new int[] { (x*av.charWidth) - 4,
\r
924 (x*av.charWidth) - 4,
\r
925 (x*av.charWidth) },
\r
928 y + iconOffset, y + 14 + iconOffset,
\r
936 g.setColor(Color.gray);
\r
937 g.fillRect(lastSSX, y + 6 + iconOffset,
\r
938 (x*av.charWidth) - lastSSX, 2);
\r
945 lastSS = row.annotations[column].secondaryStructure;
\r
952 lastSSX = (x*av.charWidth);
\r
961 if(column>=row.annotations.length)
\r
962 column = row.annotations.length-1;
\r
971 g.setColor(HELIX_COLOUR);
\r
974 //Off by 1 offset when drawing rects and ovals
\r
975 //to offscreen image on the MAC
\r
976 g.fillRoundRect(lastSSX, y + 4 + iconOffset,
\r
977 (x*av.charWidth) - lastSSX, 7, 8, 8);
\r
981 int sCol = (lastSSX / av.charWidth) + startRes;
\r
983 int x2 = (x*av.charWidth);
\r
986 row.annotations[sCol - 1] == null ||
\r
987 row.annotations[sCol - 1].secondaryStructure != 'H')
\r
989 g.fillArc(lastSSX, y + 4 + iconOffset, av.charWidth, 8, 90, 180);
\r
990 x1 += av.charWidth / 2;
\r
993 if (row.annotations[column] == null ||
\r
994 row.annotations[column].secondaryStructure != 'H')
\r
996 g.fillArc((x*av.charWidth) - av.charWidth,
\r
997 y + 4 + iconOffset, av.charWidth, 8, 270,
\r
999 x2 -= av.charWidth / 2;
\r
1002 g.fillRect(x1, y + 4 + iconOffset, x2 - x1, 8);
\r
1007 g.setColor(SHEET_COLOUR);
\r
1009 if (row.annotations[endRes] == null
\r
1010 || row.annotations[endRes].secondaryStructure != 'E')
\r
1012 g.fillRect(lastSSX, y + 4 + iconOffset,
\r
1013 (x*av.charWidth) - lastSSX - 4, 7);
\r
1014 g.fillPolygon(new int[]
\r
1015 {(x*av.charWidth) - 4,
\r
1016 (x*av.charWidth) - 4,
\r
1017 (x*av.charWidth)},
\r
1020 y + iconOffset, y + 14 + iconOffset,
\r
1021 y + 7 + iconOffset
\r
1026 g.fillRect(lastSSX, y + 4 + iconOffset,
\r
1027 (x+1) * av.charWidth - lastSSX, 7);
\r
1032 g.setColor(Color.gray);
\r
1033 if(!av.wrapAlignment || endRes==av.endRes)
\r
1034 g.fillRect(lastSSX, y + 6 + iconOffset,
\r
1035 (x*av.charWidth) - lastSSX, 2);
\r
1041 if (row.graph>0 && row.graphHeight>0)
\r
1043 if(row.graph == AlignmentAnnotation.LINE_GRAPH )
\r
1045 if(row.graphGroup>-1 && !graphGroupDrawn[row.graphGroup])
\r
1047 float groupmax=-999999, groupmin=9999999;
\r
1048 for(int gg=0; gg<aa.length; gg++)
\r
1050 if(aa[gg].graphGroup!=row.graphGroup)
\r
1054 aa[gg].visible = false;
\r
1056 if(aa[gg].graphMax>groupmax)
\r
1057 groupmax = aa[gg].graphMax;
\r
1058 if(aa[gg].graphMin<groupmin)
\r
1059 groupmin = aa[gg].graphMin;
\r
1062 for (int gg = 0; gg < aa.length; gg++)
\r
1064 if (aa[gg].graphGroup == row.graphGroup)
\r
1066 drawLineGraph(g, aa[gg], startRes, endRes, y,
\r
1067 groupmin, groupmax,
\r
1072 graphGroupDrawn[ row.graphGroup ] = true;
\r
1075 drawLineGraph(g, row, startRes, endRes,
\r
1076 y, row.graphMin, row.graphMax, row.graphHeight );
\r
1078 else if(row.graph == AlignmentAnnotation.BAR_GRAPH )
\r
1079 drawBarGraph(g, row, startRes, endRes,
\r
1080 row.graphMin, row.graphMax, y);
\r
1083 if (row.graph>0 && row.hasText)
\r
1085 y += av.charHeight;
\r
1090 y += aa[i].height;
\r
1095 public void drawLineGraph(Graphics g, AlignmentAnnotation aa,
\r
1096 int sRes, int eRes,
\r
1098 float min, float max,
\r
1101 if(sRes>aa.annotations.length)
\r
1107 //Adjustment for fastpaint to left
\r
1108 if(eRes<av.endRes)
\r
1111 eRes = Math.min(eRes, aa.annotations.length);
\r
1119 float range = max - min;
\r
1123 y2 = y - (int)((0-min / range)*graphHeight);
\r
1125 g.setColor(Color.gray);
\r
1126 g.drawLine(x-av.charWidth,y2,(eRes-sRes+1)*av.charWidth,y2);
\r
1128 eRes = Math.min(eRes, aa.annotations.length);
\r
1131 int aaMax = aa.annotations.length-1;
\r
1133 while( x < eRes - sRes )
\r
1135 column = sRes + x;
\r
1136 if(av.hasHiddenColumns)
\r
1138 column = av.getColumnSelection().adjustForHiddenColumns(column);
\r
1141 if (column > aaMax)
\r
1146 if(aa.annotations[column]==null || aa.annotations[column-1]==null)
\r
1153 g.setColor(aa.annotations[column].colour);
\r
1154 y1 = y - (int) (((aa.annotations[column-1].value-min) / range) * graphHeight);
\r
1155 y2 = y - (int) (((aa.annotations[column].value-min) / range) * graphHeight);
\r
1157 g.drawLine(x*av.charWidth-av.charWidth/2, y1, x*av.charWidth+av.charWidth/2, y2);
\r
1161 if(aa.threshold!=null)
\r
1163 g.setColor(aa.threshold.colour);
\r
1164 Graphics2D g2 = (Graphics2D)g;
\r
1165 g2.setStroke(new BasicStroke(1,
\r
1166 BasicStroke.CAP_SQUARE,
\r
1167 BasicStroke.JOIN_ROUND, 3f,
\r
1168 new float[] { 5f, 3f }, 0f));
\r
1170 y2 = (int)(y - ((aa.threshold.value-min) / range)*graphHeight);
\r
1171 g.drawLine(0,y2,(eRes-sRes)*av.charWidth,y2);
\r
1172 g2.setStroke(new BasicStroke());
\r
1176 public void drawBarGraph(Graphics g, AlignmentAnnotation aa,
\r
1177 int sRes, int eRes,
\r
1178 float min, float max,
\r
1181 if(sRes>aa.annotations.length)
\r
1184 eRes = Math.min(eRes, aa.annotations.length);
\r
1186 int x=0, y1=y, y2=y;
\r
1188 float range = max - min;
\r
1191 y2 = y - (int)((0-min / (range))*aa.graphHeight);
\r
1193 g.setColor(Color.gray);
\r
1195 g.drawLine(x,y2,(eRes-sRes)*av.charWidth,y2);
\r
1198 int aaMax = aa.annotations.length-1;
\r
1200 while( x < eRes-sRes )
\r
1202 column = sRes + x;
\r
1203 if(av.hasHiddenColumns)
\r
1205 column = av.getColumnSelection().adjustForHiddenColumns(column);
\r
1208 if(column > aaMax)
\r
1213 if (aa.annotations[column] == null)
\r
1219 g.setColor(aa.annotations[column].colour);
\r
1220 y1 = y - (int) (((aa.annotations[column].value-min) / (range)) * aa.graphHeight);
\r
1223 g.fillRect(x*av.charWidth, y2, av.charWidth, y1-y2 );
\r
1225 g.fillRect(x*av.charWidth, y1, av.charWidth, y2-y1 );
\r
1230 if(aa.threshold!=null)
\r
1232 g.setColor(aa.threshold.colour);
\r
1233 Graphics2D g2 = (Graphics2D)g;
\r
1234 g2.setStroke(new BasicStroke(1,
\r
1235 BasicStroke.CAP_SQUARE,
\r
1236 BasicStroke.JOIN_ROUND, 3f,
\r
1237 new float[] { 5f, 3f }, 0f));
\r
1239 y2 = (int)(y - ((aa.threshold.value-min) / range)*aa.graphHeight);
\r
1240 g.drawLine(0,y2,(eRes-sRes)*av.charWidth,y2);
\r
1241 g2.setStroke(new BasicStroke());
\r
1245 // used by overview window
\r
1246 public void drawGraph(Graphics g, AlignmentAnnotation aa, int width, int y, int sRes, int eRes)
\r
1248 eRes = Math.min(eRes, aa.annotations.length);
\r
1249 g.setColor(Color.white);
\r
1250 g.fillRect(0, 0, width, y);
\r
1251 g.setColor(new Color(0, 0, 180));
\r
1253 int x = 0, height;
\r
1255 for (int j = sRes; j < eRes; j++)
\r
1257 if (aa.annotations[j] != null)
\r
1259 g.setColor(aa.annotations[j].colour);
\r
1261 height = (int) ( (aa.annotations[j].value / aa.graphMax) * y);
\r
1265 g.fillRect(x, y - height, av.charWidth, height);
\r
1267 x += av.charWidth;
\r