2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
3 * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
18 package jalview.renderer;
20 import jalview.analysis.AAFrequency;
21 import jalview.analysis.StructureFrequency;
22 import jalview.api.AlignViewportI;
23 import jalview.datamodel.AlignmentAnnotation;
24 import jalview.datamodel.Annotation;
25 import jalview.datamodel.ColumnSelection;
26 import jalview.schemes.ColourSchemeI;
28 import java.awt.BasicStroke;
29 import java.awt.Color;
31 import java.awt.FontMetrics;
32 import java.awt.Graphics;
33 import java.awt.Graphics2D;
34 import java.awt.Image;
35 import java.awt.font.LineMetrics;
36 import java.awt.geom.AffineTransform;
37 import java.awt.image.ImageObserver;
38 import java.util.Hashtable;
40 import com.stevesoft.pat.Regex;
42 public class AnnotationRenderer
45 public AnnotationRenderer()
47 // TODO Auto-generated constructor stub
50 public void drawStemAnnot(Graphics g, Annotation[] row_annotations,
51 int lastSSX, int x, int y, int iconOffset, int startRes,
52 int column, boolean validRes, boolean validEnd)
54 g.setColor(STEM_COLOUR);
55 int sCol = (lastSSX / charWidth) + startRes;
57 int x2 = (x * charWidth);
58 Regex closeparen = new Regex("(\\))");
60 String dc = (column == 0 || row_annotations[column - 1] == null) ? ""
61 : row_annotations[column - 1].displayCharacter;
63 boolean diffupstream = sCol == 0 || row_annotations[sCol - 1] == null
64 || !dc.equals(row_annotations[sCol - 1].displayCharacter);
65 boolean diffdownstream = !validRes || !validEnd
66 || row_annotations[column] == null
67 || !dc.equals(row_annotations[column].displayCharacter);
68 // System.out.println("Column "+column+" diff up: "+diffupstream+" down:"+diffdownstream);
69 // If a closing base pair half of the stem, display a backward arrow
70 if (column > 0 && closeparen.search(dc))
74 // if (validRes && column>1 && row_annotations[column-2]!=null &&
75 // dc.equals(row_annotations[column-2].displayCharacter))
77 g.fillPolygon(new int[]
78 { lastSSX + 5, lastSSX + 5, lastSSX }, new int[]
79 { y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset }, 3);
90 // display a forward arrow
93 g.fillPolygon(new int[]
94 { x2 - 5, x2 - 5, x2 }, new int[]
95 { y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset }, 3);
104 g.fillRect(x1, y + 4 + iconOffset, x2 - x1, 7);
107 private int charWidth, endRes, charHeight;
109 private boolean validCharWidth, hasHiddenColumns;
111 private FontMetrics fm;
113 private final boolean MAC = new jalview.util.Platform().isAMac();
115 boolean av_renderHistogram = true, av_renderProfile = true,
116 av_normaliseProfile = false;
118 ColourSchemeI profcolour = null;
120 private ColumnSelection columnSelection;
122 private Hashtable[] hconsensus;
124 private Hashtable[] hStrucConsensus;
126 private boolean av_ignoreGapsConsensus;
129 * attributes set from AwtRenderPanelI
132 * old image used when data is currently being calculated and cannot be
135 private Image fadedImage;
138 * panel being rendered into
140 private ImageObserver annotationPanel;
143 * width of image to render in panel
145 private int imgWidth;
148 public void drawPseudoNode(Graphics g, Color nonCanColor, Annotation[] row_annotations,
149 int lastSSX, int x, int y, int iconOffset, int startRes,
150 int column, boolean validRes, boolean validEnd)
152 //System.out.println(nonCanColor);
154 g.setColor(nonCanColor);
155 int sCol = (lastSSX / charWidth) + startRes;
157 int x2 = (x * charWidth);
158 Regex closeparen = new Regex("}|]|<|[a-z]");
160 String dc = (column == 0 || row_annotations[column - 1] == null) ? ""
161 : row_annotations[column - 1].displayCharacter;
163 boolean diffupstream = sCol == 0 || row_annotations[sCol - 1] == null
164 || !dc.equals(row_annotations[sCol - 1].displayCharacter);
165 boolean diffdownstream = !validRes || !validEnd
166 || row_annotations[column] == null
167 || !dc.equals(row_annotations[column].displayCharacter);
168 // System.out.println("Column "+column+" diff up: "+diffupstream+" down:"+diffdownstream);
169 // If a closing base pair half of the stem, display a backward arrow
170 if (column > 0 && closeparen.search(dc))// closeletter_b.search(dc)||closeletter_c.search(dc)||closeletter_d.search(dc)||closecrochet.search(dc)) )
174 // if (validRes && column>1 && row_annotations[column-2]!=null &&
175 // dc.equals(row_annotations[column-2].displayCharacter))
177 g.fillPolygon(new int[]
178 { lastSSX + 5, lastSSX + 5, lastSSX }, new int[]
179 { y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset }, 3);
190 // display a forward arrow
193 g.fillPolygon(new int[]
194 { x2 - 5, x2 - 5, x2 }, new int[]
195 { y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset }, 3);
204 g.fillRect(x1, y + 4 + iconOffset, x2 - x1, 7);
206 // public void updateFromAnnotationPanel(FontMetrics annotFM, AlignViewportI
208 public void updateFromAwtRenderPanel(AwtRenderPanelI annotPanel,
211 fm = annotPanel.getFontMetrics();
212 annotationPanel = annotPanel;
213 fadedImage = annotPanel.getFadedImage();
214 imgWidth = annotPanel.getFadedImageWidth();
215 updateFromAlignViewport(av);
218 public void updateFromAlignViewport(AlignViewportI av)
220 charWidth = av.getCharWidth();
221 endRes = av.getEndRes();
222 charHeight = av.getCharHeight();
223 hasHiddenColumns = av.hasHiddenColumns();
224 validCharWidth = av.isValidCharWidth();
225 av_renderHistogram = av.isShowConsensusHistogram();
226 av_renderProfile = av.isShowSequenceLogo();
227 av_normaliseProfile = av.isNormaliseSequenceLogo();
228 profcolour = av.getGlobalColourScheme();
229 if (profcolour == null)
231 // Set the default colour for sequence logo if the alignnent has no
233 profcolour = av.getAlignment().isNucleotide() ? new jalview.schemes.NucleotideColourScheme()
234 : new jalview.schemes.ZappoColourScheme();
236 columnSelection = av.getColumnSelection();
237 hconsensus = av.getSequenceConsensusHash();// hconsensus;
238 hStrucConsensus = av.getRnaStructureConsensusHash(); // hStrucConsensus;
239 av_ignoreGapsConsensus = av.getIgnoreGapsConsensus();
242 public int[] getProfileFor(AlignmentAnnotation aa, int column)
244 // TODO : consider refactoring the global alignment calculation
245 // properties/rendering attributes as a global 'alignment group' which holds
246 // all vis settings for the alignment as a whole rather than a subset
248 if (aa.autoCalculated && aa.label.startsWith("Consensus"))
250 if (aa.groupRef != null && aa.groupRef.consensusData != null
251 && aa.groupRef.isShowSequenceLogo())
253 return AAFrequency.extractProfile(
254 aa.groupRef.consensusData[column],
255 aa.groupRef.getIgnoreGapsConsensus());
257 // TODO extend annotation row to enable dynamic and static profile data to
259 if (aa.groupRef == null && aa.sequenceRef == null && av_renderProfile)
261 return AAFrequency.extractProfile(hconsensus[column],
262 av_ignoreGapsConsensus);
267 if (aa.autoCalculated && aa.label.startsWith("StrucConsensus"))
269 // TODO implement group structure consensus
271 * if (aa.groupRef != null && aa.groupRef.consensusData != null &&
272 * aa.groupRef.isShowSequenceLogo()) { //TODO check what happens for
273 * group selections return StructureFrequency.extractProfile(
274 * aa.groupRef.consensusData[column], aa.groupRef
275 * .getIgnoreGapsConsensus()); }
277 // TODO extend annotation row to enable dynamic and static profile data
280 if (aa.groupRef == null && aa.sequenceRef == null
281 && av_renderProfile && hStrucConsensus != null
282 && hStrucConsensus.length > column)
284 return StructureFrequency.extractProfile(hStrucConsensus[column],
285 av_ignoreGapsConsensus);
293 * Render the annotation rows associated with an alignment.
298 * data and view settings to render
300 * destination for graphics
302 * row where a mouse event occured (or -1)
304 * first column that will be drawn
306 * last column that will be drawn
307 * @return true if the fadedImage was used for any alignment annotation rows
308 * currently being calculated
310 public boolean drawComponent(AwtRenderPanelI annotPanel,
311 AlignViewportI av, Graphics g, int activeRow, int startRes,
314 boolean usedFaded = false;
316 // AnnotationPanel needs to implement: ImageObserver, access to
318 updateFromAwtRenderPanel(annotPanel, av);
319 fm = g.getFontMetrics();
320 AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
327 boolean validRes = false;
328 boolean validEnd = false;
329 boolean labelAllCols = false;
330 boolean centreColLabels, centreColLabelsDef = av
331 .getCentreColumnLabels();
332 boolean scaleColLabel = false;
333 boolean[] graphGroupDrawn = new boolean[aa.length];
334 int charOffset = 0; // offset for a label
335 float fmWidth, fmScaling = 1f; // scaling for a label to fit it into a
337 Font ofont = g.getFont();
339 for (int i = 0; i < aa.length; i++)
341 AlignmentAnnotation row = aa[i];
342 Annotation[] row_annotations = row.annotations;
347 centreColLabels = row.centreColLabels || centreColLabelsDef;
348 labelAllCols = row.showAllColLabels;
349 scaleColLabel = row.scaleColLabel;
354 if (row.graphGroup > -1 && graphGroupDrawn[row.graphGroup])
359 // this is so that we draw the characters below the graph
364 iconOffset = charHeight - fm.getDescent();
368 else if (row.hasText)
370 iconOffset = charHeight - fm.getDescent();
378 if (row.autoCalculated && av.isCalculationInProgress(row))
382 g.drawImage(fadedImage, 0, y - row.height, imgWidth, y, 0, y
383 - row.height, imgWidth, y, annotationPanel);
384 g.setColor(Color.black);
385 // g.drawString("Calculating "+aa[i].label+"....",20, y-row.height/2);
391 * else if (annotationPanel.av.updatingConservation &&
392 * aa[i].label.equals("Conservation")) {
394 * y += charHeight; g.drawImage(annotationPanel.fadedImage, 0, y -
395 * row.height, annotationPanel.imgWidth, y, 0, y - row.height,
396 * annotationPanel.imgWidth, y, annotationPanel);
398 * g.setColor(Color.black); //
399 * g.drawString("Calculating Conservation.....",20, y-row.height/2);
401 * continue; } else if (annotationPanel.av.updatingConservation &&
402 * aa[i].label.equals("Quality")) {
404 * y += charHeight; g.drawImage(annotationPanel.fadedImage, 0, y -
405 * row.height, annotationPanel.imgWidth, y, 0, y - row.height,
406 * annotationPanel.imgWidth, y, annotationPanel); g.setColor(Color.black);
407 * // / g.drawString("Calculating Quality....",20, y-row.height/2);
411 // first pass sets up state for drawing continuation from left-hand column
413 x = (startRes == 0) ? 0 : -1;
414 while (x < endRes - startRes)
416 if (hasHiddenColumns)
418 column = columnSelection.adjustForHiddenColumns(startRes + x);
419 if (column > row_annotations.length - 1)
426 column = startRes + x;
429 if ((row_annotations == null) || (row_annotations.length <= column)
430 || (row_annotations[column] == null))
442 g.setColor(Color.red);
444 if (columnSelection != null)
446 for (int n = 0; n < columnSelection.size(); n++)
448 int v = columnSelection.columnAt(n);
452 g.fillRect(x * charWidth, y, charWidth, charHeight);
457 if (!row.isValidStruc())
459 g.setColor(Color.orange);
460 g.fillRect((int) row.getInvalidStrucPos() * charWidth, y,
461 charWidth, charHeight);
465 && row_annotations[column].displayCharacter != null
466 && (row_annotations[column].displayCharacter.length() > 0))
469 if (centreColLabels || scaleColLabel)
471 fmWidth = fm.charsWidth(
472 row_annotations[column].displayCharacter
474 row_annotations[column].displayCharacter.length());
478 // justify the label and scale to fit in column
479 if (fmWidth > charWidth)
481 // scale only if the current font isn't already small enough
482 fmScaling = charWidth;
483 fmScaling /= fmWidth;
484 g.setFont(ofont.deriveFont(AffineTransform
485 .getScaleInstance(fmScaling, 1.0)));
486 // and update the label's width to reflect the scaling.
494 .charWidth(row_annotations[column].displayCharacter
497 charOffset = (int) ((charWidth - fmWidth) / 2f);
499 if (row_annotations[column].colour == null)
500 g.setColor(Color.black);
502 g.setColor(row_annotations[column].colour);
504 if (column == 0 || row.graph > 0)
506 g.drawString(row_annotations[column].displayCharacter,
507 (x * charWidth) + charOffset, y + iconOffset);
509 else if (row_annotations[column - 1] == null
511 || !row_annotations[column].displayCharacter
512 .equals(row_annotations[column - 1].displayCharacter) || (row_annotations[column].displayCharacter
513 .length() < 2 && row_annotations[column].secondaryStructure == ' ')))
515 g.drawString(row_annotations[column].displayCharacter
517 * charWidth + charOffset, y + iconOffset);
524 char ss = validRes ? row_annotations[column].secondaryStructure
529 // distinguish between forward/backward base-pairing
530 if (row_annotations[column].displayCharacter.indexOf(')') > -1)
539 if ((row_annotations[column].displayCharacter.indexOf(']') > -1))
548 // distinguish between forward/backward base-pairing
549 if (row_annotations[column].displayCharacter.indexOf('}') > -1)
558 // distinguish between forward/backward base-pairing
559 if (row_annotations[column].displayCharacter.indexOf('<') > -1)
568 // System.out.println("ss="+ss);
569 // distinguish between forward/backward base-pairing
570 if (row_annotations[column].displayCharacter.indexOf(ss+32) > -1)
580 if (!validRes || (ss != lastSS))
589 //System.out.println("\t type :"+lastSS+"\t x :"+x+"\t nbre annot :"+nb_annot);
594 drawHelixAnnot(g, row_annotations, lastSSX, x, y, iconOffset, startRes,
595 column, validRes, validEnd);
599 drawSheetAnnot(g, row_annotations, lastSSX, x, y, iconOffset, startRes,
600 column, validRes, validEnd);
603 case '(': // Stem case for RNA secondary structure
604 case ')': // and opposite direction
607 drawStemAnnot(g, row_annotations, lastSSX, x, y, iconOffset, startRes,
608 column, validRes, validEnd);
670 Color nonCanColor= getNotCanonicalColor(lastSS);
671 drawPseudoNode(g, nonCanColor, row_annotations, lastSSX, x, y, iconOffset, startRes,
672 column, validRes, validEnd);
676 g.setColor(Color.gray);
677 g.fillRect(lastSSX, y + 6 + iconOffset, (x * charWidth)
693 lastSSX = (x * charWidth);
700 if (column >= row_annotations.length)
702 column = row_annotations.length - 1;
709 if ((row_annotations == null) || (row_annotations.length <= column)
710 || (row_annotations[column] == null))
726 drawHelixAnnot(g, row_annotations, lastSSX, x, y, iconOffset, startRes,
727 column, validRes, validEnd);
731 drawSheetAnnot(g, row_annotations, lastSSX, x, y, iconOffset, startRes,
732 column, validRes, validEnd);
735 case 'S': // Stem case for RNA secondary structure
737 drawStemAnnot(g, row_annotations, lastSSX, x, y, iconOffset, startRes,
738 column, validRes, validEnd);
797 //System.out.println(lastSS);
799 Color nonCanColor = getNotCanonicalColor(lastSS);
800 drawPseudoNode(g,nonCanColor, row_annotations, lastSSX, x, y, iconOffset, startRes,
801 column, validRes, validEnd);
806 drawGlyphLine(g, row_annotations, lastSSX, x, y, iconOffset, startRes,
807 column, validRes, validEnd);
812 if (row.graph > 0 && row.graphHeight > 0)
814 if (row.graph == AlignmentAnnotation.LINE_GRAPH)
816 if (row.graphGroup > -1 && !graphGroupDrawn[row.graphGroup])
818 float groupmax = -999999, groupmin = 9999999;
819 for (int gg = 0; gg < aa.length; gg++)
821 if (aa[gg].graphGroup != row.graphGroup)
828 aa[gg].visible = false;
831 if (aa[gg].graphMax > groupmax)
833 groupmax = aa[gg].graphMax;
835 if (aa[gg].graphMin < groupmin)
837 groupmin = aa[gg].graphMin;
841 for (int gg = 0; gg < aa.length; gg++)
843 if (aa[gg].graphGroup == row.graphGroup)
845 drawLineGraph(g, aa[gg], aa[gg].annotations, startRes, endRes, y, groupmin,
846 groupmax, row.graphHeight);
850 graphGroupDrawn[row.graphGroup] = true;
854 drawLineGraph(g, row, row_annotations, startRes, endRes, y, row.graphMin,
855 row.graphMax, row.graphHeight);
858 else if (row.graph == AlignmentAnnotation.BAR_GRAPH)
860 drawBarGraph(g, row, row_annotations, startRes, endRes, row.graphMin,
865 if (row.graph > 0 && row.hasText)
878 private final Color GLYPHLINE_COLOR = Color.gray;
880 private final Color SHEET_COLOUR = Color.green;
882 private final Color HELIX_COLOUR = Color.red;
884 private final Color STEM_COLOUR = Color.blue;
886 private Color sdNOTCANONICAL_COLOUR;
888 public void drawGlyphLine(Graphics g, Annotation[] row,
889 int lastSSX, int x, int y, int iconOffset, int startRes,
890 int column, boolean validRes, boolean validEnd)
892 g.setColor(GLYPHLINE_COLOR);
893 g.fillRect(lastSSX, y + 6 + iconOffset, (x * charWidth) - lastSSX, 2);
896 public void drawSheetAnnot(Graphics g, Annotation[] row,
898 int lastSSX, int x, int y, int iconOffset, int startRes,
899 int column, boolean validRes, boolean validEnd)
901 g.setColor(SHEET_COLOUR);
903 if (!validEnd || !validRes || row == null || row[column] == null
904 || row[column].secondaryStructure != 'E')
906 g.fillRect(lastSSX, y + 4 + iconOffset,
907 (x * charWidth) - lastSSX - 4, 7);
908 g.fillPolygon(new int[]
909 { (x * charWidth) - 4, (x * charWidth) - 4, (x * charWidth) },
911 { y + iconOffset, y + 14 + iconOffset, y + 7 + iconOffset },
916 g.fillRect(lastSSX, y + 4 + iconOffset,
917 (x + 1) * charWidth - lastSSX, 7);
922 public void drawHelixAnnot(Graphics g, Annotation[] row, int lastSSX,
923 int x, int y, int iconOffset, int startRes, int column,
924 boolean validRes, boolean validEnd)
926 g.setColor(HELIX_COLOUR);
928 int sCol = (lastSSX / charWidth) + startRes;
930 int x2 = (x * charWidth);
934 int ofs = charWidth / 2;
935 // Off by 1 offset when drawing rects and ovals
936 // to offscreen image on the MAC
937 g.fillRoundRect(lastSSX, y + 4 + iconOffset, x2 - x1, 8, 8, 8);
938 if (sCol == 0 || row[sCol - 1] == null
939 || row[sCol - 1].secondaryStructure != 'H')
944 // g.setColor(Color.orange);
945 g.fillRoundRect(lastSSX, y + 4 + iconOffset, x2 - x1 - ofs + 1, 8,
948 if (!validRes || row[column] == null
949 || row[column].secondaryStructure != 'H')
955 // g.setColor(Color.magenta);
956 g.fillRoundRect(lastSSX + ofs, y + 4 + iconOffset, x2 - x1 - ofs
964 if (sCol == 0 || row[sCol - 1] == null
965 || row[sCol - 1].secondaryStructure != 'H')
967 g.fillArc(lastSSX, y + 4 + iconOffset, charWidth, 8, 90, 180);
971 if (!validRes || row[column] == null
972 || row[column].secondaryStructure != 'H')
974 g.fillArc((x * charWidth) - charWidth, y + 4 + iconOffset, charWidth,
979 g.fillRect(x1, y + 4 + iconOffset, x2 - x1, 8);
982 public void drawLineGraph(Graphics g, AlignmentAnnotation _aa,
983 Annotation[] aa_annotations, int sRes, int eRes, int y,
984 float min, float max, int graphHeight)
986 if (sRes > aa_annotations.length)
993 // Adjustment for fastpaint to left
999 eRes = Math.min(eRes, aa_annotations.length);
1007 float range = max - min;
1012 y2 = y - (int) ((0 - min / range) * graphHeight);
1015 g.setColor(Color.gray);
1016 g.drawLine(x - charWidth, y2, (eRes - sRes + 1) * charWidth, y2);
1018 eRes = Math.min(eRes, aa_annotations.length);
1021 int aaMax = aa_annotations.length - 1;
1023 while (x < eRes - sRes)
1026 if (hasHiddenColumns)
1028 column = columnSelection.adjustForHiddenColumns(column);
1036 if (aa_annotations[column] == null
1037 || aa_annotations[column - 1] == null)
1043 if (aa_annotations[column].colour == null)
1044 g.setColor(Color.black);
1046 g.setColor(aa_annotations[column].colour);
1049 - (int) (((aa_annotations[column - 1].value - min) / range) * graphHeight);
1051 - (int) (((aa_annotations[column].value - min) / range) * graphHeight);
1053 g.drawLine(x * charWidth - charWidth / 2, y1, x * charWidth
1054 + charWidth / 2, y2);
1058 if (_aa.threshold != null)
1060 g.setColor(_aa.threshold.colour);
1061 Graphics2D g2 = (Graphics2D) g;
1062 g2.setStroke(new BasicStroke(1, BasicStroke.CAP_SQUARE,
1063 BasicStroke.JOIN_ROUND, 3f, new float[]
1066 y2 = (int) (y - ((_aa.threshold.value - min) / range) * graphHeight);
1067 g.drawLine(0, y2, (eRes - sRes) * charWidth, y2);
1068 g2.setStroke(new BasicStroke());
1072 public void drawBarGraph(Graphics g, AlignmentAnnotation _aa,
1073 Annotation[] aa_annotations, int sRes, int eRes, float min,
1076 if (sRes > aa_annotations.length)
1080 Font ofont = g.getFont();
1081 eRes = Math.min(eRes, aa_annotations.length);
1083 int x = 0, y1 = y, y2 = y;
1085 float range = max - min;
1089 y2 = y - (int) ((0 - min / (range)) * _aa.graphHeight);
1092 g.setColor(Color.gray);
1094 g.drawLine(x, y2, (eRes - sRes) * charWidth, y2);
1097 int aaMax = aa_annotations.length - 1;
1098 boolean renderHistogram = true, renderProfile = true, normaliseProfile = false;
1099 // if (aa.autoCalculated && aa.label.startsWith("Consensus"))
1101 // TODO: generalise this to have render styles for consensus/profile data
1102 if (_aa.groupRef != null)
1104 renderHistogram = _aa.groupRef.isShowConsensusHistogram();
1105 renderProfile = _aa.groupRef.isShowSequenceLogo();
1106 normaliseProfile = _aa.groupRef.isNormaliseSequenceLogo();
1110 renderHistogram = av_renderHistogram;
1111 renderProfile = av_renderProfile;
1112 normaliseProfile = av_normaliseProfile;
1115 while (x < eRes - sRes)
1118 if (hasHiddenColumns)
1120 column = columnSelection.adjustForHiddenColumns(column);
1128 if (aa_annotations[column] == null)
1133 if (aa_annotations[column].colour == null)
1134 g.setColor(Color.black);
1136 g.setColor(aa_annotations[column].colour);
1139 - (int) (((aa_annotations[column].value - min) / (range)) * _aa.graphHeight);
1141 if (renderHistogram)
1145 g.fillRect(x * charWidth, y2, charWidth, y1 - y2);
1149 g.fillRect(x * charWidth, y1, charWidth, y2 - y1);
1152 // draw profile if available
1156 int profl[] = getProfileFor(_aa, column);
1157 // just try to draw the logo if profl is not null
1158 if (profl != null && profl[1] != 0)
1160 float ht = normaliseProfile ? y - _aa.graphHeight : y1;
1161 double htn = normaliseProfile ? _aa.graphHeight : (y2 - y1);// aa.graphHeight;
1168 * profl.length == 74 indicates that the profile of a secondary
1169 * structure conservation row was accesed. Therefore dc gets length 2,
1170 * to have space for a basepair instead of just a single nucleotide
1172 if (profl.length == 74)
1180 LineMetrics lm = g.getFontMetrics(ofont).getLineMetrics("Q", g);
1181 double scale = 1f / (normaliseProfile ? profl[1] : 100f);
1182 float ofontHeight = 1f / lm.getAscent();// magnify to fill box
1184 for (int c = 2; c < profl[0];)
1186 dc[0] = (char) profl[c++];
1188 if (_aa.label.startsWith("StrucConsensus"))
1190 dc[1] = (char) profl[c++];
1194 wdth /= fm.charsWidth(dc, 0, dc.length);
1198 scl = htn * scale * profl[c++];
1199 lm = ofont.getLineMetrics(dc, 0, 1, g.getFontMetrics()
1200 .getFontRenderContext());
1201 g.setFont(ofont.deriveFont(AffineTransform.getScaleInstance(
1202 wdth, scl / lm.getAscent())));
1203 lm = g.getFontMetrics().getLineMetrics(dc, 0, 1, g);
1205 // Debug - render boxes around characters
1206 // g.setColor(Color.red);
1207 // g.drawRect(x*av.charWidth, (int)ht, av.charWidth,
1209 // g.setColor(profcolour.findColour(dc[0]).darker());
1210 g.setColor(profcolour.findColour(dc[0], column, null));
1212 hght = (ht + (scl - lm.getDescent() - lm.getBaselineOffsets()[lm
1213 .getBaselineIndex()]));
1215 g.drawChars(dc, 0, dc.length, x * charWidth, (int) hght);
1223 if (_aa.threshold != null)
1225 g.setColor(_aa.threshold.colour);
1226 Graphics2D g2 = (Graphics2D) g;
1227 g2.setStroke(new BasicStroke(1, BasicStroke.CAP_SQUARE,
1228 BasicStroke.JOIN_ROUND, 3f, new float[]
1231 y2 = (int) (y - ((_aa.threshold.value - min) / range)
1233 g.drawLine(0, y2, (eRes - sRes) * charWidth, y2);
1234 g2.setStroke(new BasicStroke());
1238 // used by overview window
1239 public void drawGraph(Graphics g, AlignmentAnnotation _aa,
1240 Annotation[] aa_annotations, int width, int y, int sRes, int eRes)
1242 eRes = Math.min(eRes, aa_annotations.length);
1243 g.setColor(Color.white);
1244 g.fillRect(0, 0, width, y);
1245 g.setColor(new Color(0, 0, 180));
1249 for (int j = sRes; j < eRes; j++)
1251 if (aa_annotations[j] != null)
1253 if (aa_annotations[j].colour == null)
1254 g.setColor(Color.black);
1256 g.setColor(aa_annotations[j].colour);
1258 height = (int) ((aa_annotations[j].value / _aa.graphMax) * y);
1264 g.fillRect(x, y - height, charWidth, height);
1271 Color getNotCanonicalColor(char lastss)
1277 return new Color(255,125,5);
1281 return new Color(245,115,10);
1285 return new Color(235,135,15);
1289 return new Color(225,105,20);
1293 return new Color(215,145,30);
1297 return new Color(205,95,35);
1301 return new Color(195,155,45);
1305 return new Color(185,85,55);
1309 return new Color(175,165,65);
1313 return new Color(170,75,75);
1317 return new Color(160,175,85);
1321 return new Color(150,65,95);
1325 return new Color(140,185,105);
1329 return new Color(130,55,110);
1333 return new Color(120,195,120);
1337 return new Color(110,45,130);
1341 return new Color(100,205,140);
1345 return new Color(90,35,150);
1349 return new Color(85,215,160);
1353 return new Color(75,25,170);
1357 return new Color(65,225,180);
1361 return new Color(55,15,185);
1365 return new Color(45,235,195);
1369 return new Color(35,5,205);
1373 return new Color(25,245,215);
1377 return new Color(15,0,225);
1381 return new Color(10,255,235);
1385 return new Color(5,150,245);
1389 return new Color(0,80,255);
1392 System.out.println("This is not a interaction : "+lastss);