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
112 AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
\r
117 for (int i = 0; i < aa.length; i++)
\r
119 if (!aa[i].visible)
\r
128 aa[i].height += av.charHeight;
\r
131 if (aa[i].hasIcons)
\r
133 aa[i].height += 16;
\r
138 aa[i].height += aa[i].graphHeight;
\r
141 if (aa[i].height == 0)
\r
146 height += aa[i].height;
\r
154 this.setPreferredSize(new Dimension(1, height));
\r
164 * @param evt DOCUMENT ME!
\r
166 public void actionPerformed(ActionEvent evt)
\r
168 AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
\r
169 Annotation[] anot = aa[activeRow].annotations;
\r
171 if (evt.getActionCommand().equals(REMOVE))
\r
173 for (int i = 0; i < av.getColumnSelection().size(); i++)
\r
175 anot[av.getColumnSelection().columnAt(i)] = null;
\r
178 else if (evt.getActionCommand().equals(LABEL))
\r
180 String label = JOptionPane.showInputDialog(this, "Enter Label ",
\r
181 "Enter label", JOptionPane.QUESTION_MESSAGE);
\r
188 if ((label.length() > 0) && !aa[activeRow].hasText)
\r
190 aa[activeRow].hasText = true;
\r
193 for (int i = 0; i < av.getColumnSelection().size(); i++)
\r
195 int index = av.getColumnSelection().columnAt(i);
\r
197 if (anot[index] == null)
\r
199 anot[index] = new Annotation(label, "", ' ', 0);
\r
202 anot[index].displayCharacter = label;
\r
205 else if (evt.getActionCommand().equals(COLOUR))
\r
207 Color col = JColorChooser.showDialog(this,
\r
208 "Choose foreground colour", Color.black);
\r
210 for (int i = 0; i < av.getColumnSelection().size(); i++)
\r
212 int index = av.getColumnSelection().columnAt(i);
\r
214 if (anot[index] == null)
\r
216 anot[index] = new Annotation("", "", ' ', 0);
\r
219 anot[index].colour = col;
\r
222 else // HELIX OR SHEET
\r
225 String symbol = "\u03B1";
\r
227 if (evt.getActionCommand().equals(HELIX))
\r
231 else if (evt.getActionCommand().equals(SHEET))
\r
237 if (!aa[activeRow].hasIcons)
\r
239 aa[activeRow].hasIcons = true;
\r
242 String label = JOptionPane.showInputDialog("Enter a label for the structure?",
\r
250 if ((label.length() > 0) && !aa[activeRow].hasText)
\r
252 aa[activeRow].hasText = true;
\r
255 for (int i = 0; i < av.getColumnSelection().size(); i++)
\r
257 int index = av.getColumnSelection().columnAt(i);
\r
259 if (anot[index] == null)
\r
261 anot[index] = new Annotation(label, "", type, 0);
\r
264 anot[index].secondaryStructure = type;
\r
265 anot[index].displayCharacter = label;
\r
269 adjustPanelHeight();
\r
278 * @param evt DOCUMENT ME!
\r
280 public void mousePressed(MouseEvent evt)
\r
284 AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
\r
293 for (int i = 0; i < aa.length; i++)
\r
297 height += aa[i].height;
\r
300 if (evt.getY() < height)
\r
302 if (aa[i].editable)
\r
306 else if(aa[i].graph>0)
\r
310 graphStretchY = evt.getY();
\r
318 if (SwingUtilities.isRightMouseButton(evt) && activeRow!=-1)
\r
320 if (av.getColumnSelection() == null)
\r
325 JPopupMenu pop = new JPopupMenu("Structure type");
\r
326 JMenuItem item = new JMenuItem(HELIX);
\r
327 item.addActionListener(this);
\r
329 item = new JMenuItem(SHEET);
\r
330 item.addActionListener(this);
\r
332 item = new JMenuItem(LABEL);
\r
333 item.addActionListener(this);
\r
335 item = new JMenuItem(COLOUR);
\r
336 item.addActionListener(this);
\r
338 item = new JMenuItem(REMOVE);
\r
339 item.addActionListener(this);
\r
341 pop.show(this, evt.getX(), evt.getY());
\r
351 int res = (evt.getX() / av.getCharWidth()) + av.getStartRes();
\r
356 if (av.getColumnSelection().contains(res))
\r
357 av.getColumnSelection().removeElement(res);
\r
360 av.getColumnSelection().addElement(res);
\r
361 SequenceGroup sg = new SequenceGroup();
\r
363 for (int i = 0; i < av.alignment.getSequences().size(); i++)
\r
365 sg.addSequence(av.alignment.getSequenceAt(i), false);
\r
368 sg.setStartRes(res);
\r
370 av.setSelectionGroup(sg);
\r
380 * @param evt DOCUMENT ME!
\r
382 public void mouseReleased(MouseEvent evt)
\r
385 graphStretchY = -1;
\r
386 mouseDragging = false;
\r
392 * @param evt DOCUMENT ME!
\r
394 public void mouseEntered(MouseEvent evt)
\r
397 ap.seqPanel.scrollCanvas(null);
\r
403 * @param evt DOCUMENT ME!
\r
405 public void mouseExited(MouseEvent evt)
\r
408 ap.seqPanel.scrollCanvas(evt);
\r
415 * @param evt DOCUMENT ME!
\r
417 public void mouseDragged(MouseEvent evt)
\r
419 if(graphStretch>-1)
\r
421 av.alignment.getAlignmentAnnotation()[graphStretch].graphHeight += graphStretchY - evt.getY();
\r
422 if(av.alignment.getAlignmentAnnotation()[graphStretch].graphHeight <0)
\r
423 av.alignment.getAlignmentAnnotation()[graphStretch].graphHeight = 0;
\r
424 graphStretchY = evt.getY();
\r
425 adjustPanelHeight();
\r
430 mouseDragging = true;
\r
432 int res = (evt.getX() / av.getCharWidth()) + av.getStartRes();
\r
434 SequenceGroup sg = av.getSelectionGroup();
\r
448 if (!av.getColumnSelection().contains(res))
\r
450 av.getColumnSelection().addElement(res);
\r
453 if (res > sg.getStartRes())
\r
457 else if (res < sg.getStartRes())
\r
459 sg.setStartRes(res);
\r
462 for (int i = min; i <= max; i++)
\r
464 if ((i < sg.getStartRes()) || (i > sg.getEndRes()))
\r
466 av.getColumnSelection().removeElement(i);
\r
470 av.getColumnSelection().addElement(i);
\r
483 * @param evt DOCUMENT ME!
\r
485 public void mouseMoved(MouseEvent evt)
\r
487 AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
\r
497 for (int i = 0; i < aa.length; i++)
\r
501 height += aa[i].height;
\r
504 if (evt.getY() < height)
\r
512 int res = (evt.getX() / av.getCharWidth()) + av.getStartRes();
\r
514 if(av.hasHiddenColumns)
\r
515 res = av.getColumnSelection().adjustForHiddenColumns(res);
\r
517 if (row > -1 && res<aa[row].annotations.length)
\r
519 if(aa[row].graphGroup>-1)
\r
521 StringBuffer tip = new StringBuffer("<html>");
\r
522 for (int gg = 0; gg < aa.length; gg++)
\r
524 if (aa[gg].graphGroup == aa[row].graphGroup && aa[gg].annotations[res]!=null)
\r
525 tip.append(aa[gg].label+" "+aa[gg].annotations[res].description+"<br>" );
\r
527 if(tip.length()!=6)
\r
529 tip.setLength(tip.length() - 4);
\r
530 this.setToolTipText(tip.toString() + "</html>");
\r
533 else if(aa[row].annotations[res] != null)
\r
534 this.setToolTipText(aa[row].annotations[res].description);
\r
536 if(aa[row].annotations[res]!=null)
\r
538 StringBuffer text = new StringBuffer("Sequence position " +
\r
540 aa[row].annotations[res].description);
\r
542 ap.alignFrame.statusBar.setText(text.toString());
\r
550 * @param evt DOCUMENT ME!
\r
552 public void mouseClicked(MouseEvent evt)
\r
559 * @param g DOCUMENT ME!
\r
561 public void paintComponent(Graphics g)
\r
563 g.setColor(Color.white);
\r
564 g.fillRect(0, 0, getWidth(), getHeight());
\r
568 || (getVisibleRect().width != g.getClipBounds().width)
\r
569 || (getVisibleRect().height != g.getClipBounds().height))
\r
571 g.drawImage(image, 0, 0, this);
\r
576 imgWidth = (av.endRes - av.startRes + 1) * av.charWidth;
\r
578 if (image == null || imgWidth != image.getWidth()
\r
579 || image.getHeight(this) != getHeight())
\r
581 image = new BufferedImage(imgWidth, ap.annotationPanel.getHeight(),
\r
582 BufferedImage.TYPE_INT_RGB);
\r
583 gg = (Graphics2D) image.getGraphics();
\r
586 gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
\r
587 RenderingHints.VALUE_ANTIALIAS_ON);
\r
589 gg.setFont(av.getFont());
\r
590 fm = gg.getFontMetrics();
\r
591 gg.setColor(Color.white);
\r
592 gg.fillRect(0, 0, imgWidth, image.getHeight());
\r
596 drawComponent(gg, av.startRes, av.endRes + 1);
\r
597 g.drawImage(image, 0, 0, this);
\r
603 * @param horizontal DOCUMENT ME!
\r
605 public void fastPaint(int horizontal)
\r
607 if ((horizontal == 0)
\r
609 || av.alignment.getAlignmentAnnotation()==null
\r
610 || av.alignment.getAlignmentAnnotation().length < 1
\r
611 || av.updatingConsensus
\r
612 || av.updatingConservation)
\r
618 gg.copyArea(0, 0, imgWidth, getHeight(), -horizontal * av.charWidth, 0);
\r
620 int sr = av.startRes;
\r
621 int er = av.endRes + 1;
\r
624 if (horizontal > 0) // scrollbar pulled right, image to the left
\r
626 transX = (er - sr - horizontal) * av.charWidth;
\r
627 sr = er - horizontal;
\r
629 else if (horizontal < 0)
\r
631 er = sr - horizontal;
\r
634 gg.translate(transX, 0);
\r
636 drawComponent(gg, sr, er);
\r
638 gg.translate(-transX, 0);
\r
649 * @param g DOCUMENT ME!
\r
650 * @param startRes DOCUMENT ME!
\r
651 * @param endRes DOCUMENT ME!
\r
653 public void drawComponent(Graphics g, int startRes, int endRes)
\r
655 if(av.updatingConsensus || av.updatingConservation)
\r
657 //We'll keep a record of the old image,
\r
658 //and draw a faded image until the calculation
\r
660 if(fadedImage==null
\r
661 || fadedImage.getWidth()!=imgWidth
\r
662 || fadedImage.getHeight()!=image.getHeight())
\r
664 fadedImage = new BufferedImage(
\r
665 imgWidth, image.getHeight(),
\r
666 BufferedImage.TYPE_INT_RGB);
\r
668 Graphics2D fadedG = (Graphics2D) fadedImage.getGraphics();
\r
670 fadedG.setColor(Color.white);
\r
671 fadedG.fillRect(0, 0, imgWidth, image.getHeight());
\r
673 fadedG.setComposite(
\r
674 AlphaComposite.getInstance(
\r
675 AlphaComposite.SRC_OVER, .3f));
\r
676 fadedG.drawImage(image, 0, 0, this);
\r
685 g.setColor(Color.white);
\r
686 g.fillRect(0, 0, (endRes - startRes) * av.charWidth, getHeight());
\r
688 g.setFont(av.getFont());
\r
690 fm = g.getFontMetrics();
\r
695 if ( (av.alignment.getAlignmentAnnotation() == null) ||
\r
696 (av.alignment.getAlignmentAnnotation().length < 1))
\r
698 g.setColor(Color.white);
\r
699 g.fillRect(0, 0, getWidth(), getHeight());
\r
700 g.setColor(Color.black);
\r
701 if(av.validCharWidth)
\r
702 g.drawString("Alignment has no annotations", 20, 15);
\r
708 AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
\r
714 int iconOffset = av.charHeight / 2;
\r
715 boolean validRes = false;
\r
717 boolean [] graphGroupDrawn = new boolean[aa.length];
\r
721 for (int i = 0; i < aa.length; i++)
\r
723 AlignmentAnnotation row = aa[i];
\r
736 if(row.graphGroup>-1 && graphGroupDrawn[ row.graphGroup ] )
\r
739 // this is so that we draw the characters below the graph
\r
744 y -= av.charHeight;
\r
748 if (av.updatingConsensus && aa[i].label.equals("Consensus"))
\r
750 y += av.charHeight;
\r
752 g.drawImage(fadedImage,
\r
753 0,y-row.height,imgWidth, y,
\r
754 0,y-row.height,imgWidth, y, this);
\r
755 g.setColor(Color.black);
\r
756 // g.drawString("Calculating Consensus....",20, y-row.height/2);
\r
760 else if (av.updatingConservation && aa[i].label.equals("Conservation"))
\r
763 y += av.charHeight;
\r
764 g.drawImage(fadedImage,
\r
765 0, y - row.height, imgWidth, y,
\r
766 0, y - row.height, imgWidth, y, this);
\r
768 g.setColor(Color.black);
\r
769 // g.drawString("Calculating Conservation.....",20, y-row.height/2);
\r
773 else if (av.updatingConservation && aa[i].label.equals("Quality"))
\r
776 y += av.charHeight;
\r
777 g.drawImage(fadedImage,
\r
778 0, y - row.height, imgWidth, y,
\r
779 0, y - row.height, imgWidth, y, this);
\r
780 g.setColor(Color.black);
\r
781 /// g.drawString("Calculating Quality....",20, y-row.height/2);
\r
789 iconOffset = av.charHeight / 2 + 4;
\r
797 while (x < endRes-startRes)
\r
799 if (av.hasHiddenColumns)
\r
801 column = av.getColumnSelection().adjustForHiddenColumns(startRes+x);
\r
802 if (column > row.annotations.length-1)
\r
808 column = startRes+x;
\r
811 if ((row.annotations.length <= column) ||
\r
812 (row.annotations[column] == null))
\r
822 if (activeRow == i)
\r
824 g.setColor(Color.red);
\r
826 if (av.getColumnSelection() != null)
\r
828 for (int n = 0; n < av.getColumnSelection().size(); n++)
\r
830 int v = av.getColumnSelection().columnAt(n);
\r
834 g.fillRect(x * av.charWidth, y,
\r
835 av.charWidth, av.charHeight);
\r
841 if (av.validCharWidth && validRes &&
\r
842 (row.annotations[column].displayCharacter.length() > 0))
\r
845 int charOffset = (av.charWidth -
\r
846 fm.charWidth(row.annotations[column].displayCharacter.charAt(
\r
848 g.setColor(row.annotations[column].colour);
\r
850 if (column == 0 || row.graph>0)
\r
852 g.drawString(row.annotations[column].displayCharacter,
\r
853 (x*av.charWidth)+charOffset,
\r
857 row.annotations[column - 1] == null
\r
858 ||(!row.annotations[column].displayCharacter.equals(
\r
859 row.annotations[column - 1].displayCharacter)
\r
861 (row.annotations[column].displayCharacter.length() <2 &&
\r
862 row.annotations[column].secondaryStructure==' ')))
\r
864 g.drawString(row.annotations[column].displayCharacter,
\r
865 x*av.charWidth+charOffset,
\r
873 (row.annotations[column].secondaryStructure != lastSS))
\r
878 g.setColor(HELIX_COLOUR);
\r
881 //Off by 1 offset when drawing rects and ovals
\r
882 //to offscreen image on the MAC
\r
883 g.fillRoundRect(lastSSX, y + 4 + iconOffset,
\r
884 (x*av.charWidth) - lastSSX, 7, 8, 8);
\r
888 int sCol = (lastSSX / av.charWidth) + startRes;
\r
890 int x2 = (x*av.charWidth);
\r
893 row.annotations[sCol-1]==null ||
\r
894 row.annotations[sCol-1].secondaryStructure!='H')
\r
896 g.fillArc(lastSSX, y+4+iconOffset, av.charWidth, 8, 90,180) ;
\r
897 x1 += av.charWidth/2;
\r
900 if(row.annotations[column]==null ||
\r
901 row.annotations[column].secondaryStructure!='H')
\r
903 g.fillArc((x*av.charWidth)-av.charWidth,
\r
904 y+4+iconOffset, av.charWidth, 8, 270,180);
\r
905 x2 -= av.charWidth/2;
\r
908 g.fillRect(x1, y+4+iconOffset, x2-x1, 8);
\r
912 g.setColor(SHEET_COLOUR);
\r
913 g.fillRect(lastSSX, y + 4 + iconOffset,
\r
914 (x*av.charWidth) - lastSSX - 4, 7);
\r
915 g.fillPolygon(new int[] { (x*av.charWidth) - 4,
\r
916 (x*av.charWidth) - 4,
\r
917 (x*av.charWidth) },
\r
920 y + iconOffset, y + 14 + iconOffset,
\r
928 g.setColor(Color.gray);
\r
929 g.fillRect(lastSSX, y + 6 + iconOffset,
\r
930 (x*av.charWidth) - lastSSX, 2);
\r
937 lastSS = row.annotations[column].secondaryStructure;
\r
944 lastSSX = (x*av.charWidth);
\r
953 if(column>=row.annotations.length)
\r
954 column = row.annotations.length-1;
\r
963 g.setColor(HELIX_COLOUR);
\r
966 //Off by 1 offset when drawing rects and ovals
\r
967 //to offscreen image on the MAC
\r
968 g.fillRoundRect(lastSSX, y + 4 + iconOffset,
\r
969 (x*av.charWidth) - lastSSX, 7, 8, 8);
\r
973 int sCol = (lastSSX / av.charWidth) + startRes;
\r
975 int x2 = (x*av.charWidth);
\r
978 row.annotations[sCol - 1] == null ||
\r
979 row.annotations[sCol - 1].secondaryStructure != 'H')
\r
981 g.fillArc(lastSSX, y + 4 + iconOffset, av.charWidth, 8, 90, 180);
\r
982 x1 += av.charWidth / 2;
\r
985 if (row.annotations[column] == null ||
\r
986 row.annotations[column].secondaryStructure != 'H')
\r
988 g.fillArc((x*av.charWidth) - av.charWidth,
\r
989 y + 4 + iconOffset, av.charWidth, 8, 270,
\r
991 x2 -= av.charWidth / 2;
\r
994 g.fillRect(x1, y + 4 + iconOffset, x2 - x1, 8);
\r
999 g.setColor(SHEET_COLOUR);
\r
1001 if (row.annotations[endRes] == null
\r
1002 || row.annotations[endRes].secondaryStructure != 'E')
\r
1004 g.fillRect(lastSSX, y + 4 + iconOffset,
\r
1005 (x*av.charWidth) - lastSSX - 4, 7);
\r
1006 g.fillPolygon(new int[]
\r
1007 {(x*av.charWidth) - 4,
\r
1008 (x*av.charWidth) - 4,
\r
1009 (x*av.charWidth)},
\r
1012 y + iconOffset, y + 14 + iconOffset,
\r
1013 y + 7 + iconOffset
\r
1018 g.fillRect(lastSSX, y + 4 + iconOffset,
\r
1019 (x+1) * av.charWidth - lastSSX, 7);
\r
1024 g.setColor(Color.gray);
\r
1025 if(!av.wrapAlignment || endRes==av.endRes)
\r
1026 g.fillRect(lastSSX, y + 6 + iconOffset,
\r
1027 (x*av.charWidth) - lastSSX, 2);
\r
1033 if (row.graph>0 && row.graphHeight>0)
\r
1035 if(row.graph == AlignmentAnnotation.LINE_GRAPH )
\r
1037 if(row.graphGroup>-1 && !graphGroupDrawn[row.graphGroup])
\r
1039 float groupmax=-999999, groupmin=9999999;
\r
1040 for(int gg=0; gg<aa.length; gg++)
\r
1042 if(aa[gg].graphGroup!=row.graphGroup)
\r
1046 aa[gg].visible = false;
\r
1048 if(aa[gg].graphMax>groupmax)
\r
1049 groupmax = aa[gg].graphMax;
\r
1050 if(aa[gg].graphMin<groupmin)
\r
1051 groupmin = aa[gg].graphMin;
\r
1054 for (int gg = 0; gg < aa.length; gg++)
\r
1056 if (aa[gg].graphGroup == row.graphGroup)
\r
1058 drawLineGraph(g, aa[gg], startRes, endRes, y,
\r
1059 groupmin, groupmax,
\r
1064 graphGroupDrawn[ row.graphGroup ] = true;
\r
1067 drawLineGraph(g, row, startRes, endRes,
\r
1068 y, row.graphMin, row.graphMax, row.graphHeight );
\r
1070 else if(row.graph == AlignmentAnnotation.BAR_GRAPH )
\r
1071 drawBarGraph(g, row, startRes, endRes,
\r
1072 row.graphMin, row.graphMax, y);
\r
1075 if (row.graph>0 && row.hasText)
\r
1077 y += av.charHeight;
\r
1082 y += aa[i].height;
\r
1087 public void drawLineGraph(Graphics g, AlignmentAnnotation aa,
\r
1088 int sRes, int eRes,
\r
1090 float min, float max,
\r
1093 if(sRes>aa.annotations.length)
\r
1099 //Adjustment for fastpaint to left
\r
1100 if(eRes<av.endRes)
\r
1103 eRes = Math.min(eRes, aa.annotations.length);
\r
1111 float range = max - min;
\r
1115 y2 = y - (int)((0-min / range)*graphHeight);
\r
1117 g.setColor(Color.gray);
\r
1118 g.drawLine(x-av.charWidth,y2,(eRes-sRes+1)*av.charWidth,y2);
\r
1120 eRes = Math.min(eRes, aa.annotations.length);
\r
1123 int aaMax = aa.annotations.length-1;
\r
1125 while( x < eRes - sRes )
\r
1127 column = sRes + x;
\r
1128 if(av.hasHiddenColumns)
\r
1130 column = av.getColumnSelection().adjustForHiddenColumns(column);
\r
1133 if (column > aaMax)
\r
1138 if(aa.annotations[column]==null || aa.annotations[column-1]==null)
\r
1145 g.setColor(aa.annotations[column].colour);
\r
1146 y1 = y - (int) (((aa.annotations[column-1].value-min) / range) * graphHeight);
\r
1147 y2 = y - (int) (((aa.annotations[column].value-min) / range) * graphHeight);
\r
1149 g.drawLine(x*av.charWidth-av.charWidth/2, y1, x*av.charWidth+av.charWidth/2, y2);
\r
1153 if(aa.threshold!=null)
\r
1155 g.setColor(aa.threshold.colour);
\r
1156 Graphics2D g2 = (Graphics2D)g;
\r
1157 g2.setStroke(new BasicStroke(1,
\r
1158 BasicStroke.CAP_SQUARE,
\r
1159 BasicStroke.JOIN_ROUND, 3f,
\r
1160 new float[] { 5f, 3f }, 0f));
\r
1162 y2 = (int)(y - ((aa.threshold.value-min) / range)*graphHeight);
\r
1163 g.drawLine(0,y2,(eRes-sRes)*av.charWidth,y2);
\r
1164 g2.setStroke(new BasicStroke());
\r
1168 public void drawBarGraph(Graphics g, AlignmentAnnotation aa,
\r
1169 int sRes, int eRes,
\r
1170 float min, float max,
\r
1173 if(sRes>aa.annotations.length)
\r
1176 eRes = Math.min(eRes, aa.annotations.length);
\r
1178 int x=0, y1=y, y2=y;
\r
1180 float range = max - min;
\r
1183 y2 = y - (int)((0-min / (range))*aa.graphHeight);
\r
1185 g.setColor(Color.gray);
\r
1187 g.drawLine(x,y2,(eRes-sRes)*av.charWidth,y2);
\r
1190 int aaMax = aa.annotations.length-1;
\r
1192 while( x < eRes-sRes )
\r
1194 column = sRes + x;
\r
1195 if(av.hasHiddenColumns)
\r
1197 column = av.getColumnSelection().adjustForHiddenColumns(column);
\r
1200 if(column > aaMax)
\r
1205 if (aa.annotations[column] == null)
\r
1211 g.setColor(aa.annotations[column].colour);
\r
1212 y1 = y - (int) (((aa.annotations[column].value-min) / (range)) * aa.graphHeight);
\r
1215 g.fillRect(x*av.charWidth, y2, av.charWidth, y1-y2 );
\r
1217 g.fillRect(x*av.charWidth, y1, av.charWidth, y2-y1 );
\r
1222 if(aa.threshold!=null)
\r
1224 g.setColor(aa.threshold.colour);
\r
1225 Graphics2D g2 = (Graphics2D)g;
\r
1226 g2.setStroke(new BasicStroke(1,
\r
1227 BasicStroke.CAP_SQUARE,
\r
1228 BasicStroke.JOIN_ROUND, 3f,
\r
1229 new float[] { 5f, 3f }, 0f));
\r
1231 y2 = (int)(y - ((aa.threshold.value-min) / range)*aa.graphHeight);
\r
1232 g.drawLine(0,y2,(eRes-sRes)*av.charWidth,y2);
\r
1233 g2.setStroke(new BasicStroke());
\r
1237 // used by overview window
\r
1238 public void drawGraph(Graphics g, AlignmentAnnotation aa, int width, int y, int sRes, int eRes)
\r
1240 eRes = Math.min(eRes, aa.annotations.length);
\r
1241 g.setColor(Color.white);
\r
1242 g.fillRect(0, 0, width, y);
\r
1243 g.setColor(new Color(0, 0, 180));
\r
1245 int x = 0, height;
\r
1247 for (int j = sRes; j < eRes; j++)
\r
1249 if (aa.annotations[j] != null)
\r
1251 g.setColor(aa.annotations[j].colour);
\r
1253 height = (int) ( (aa.annotations[j].value / aa.graphMax) * y);
\r
1257 g.fillRect(x, y - height, av.charWidth, height);
\r
1259 x += av.charWidth;
\r