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.BitSet;
39 import java.util.Hashtable;
41 import com.stevesoft.pat.Regex;
43 public class AnnotationRenderer
46 * flag indicating if timing and redraw parameter info should be output
48 private final boolean debugRedraw;
50 public AnnotationRenderer()
55 * Create a new annotation Renderer
56 * @param debugRedraw flag indicating if timing and redraw parameter info should be output
58 public AnnotationRenderer(boolean debugRedraw)
60 this.debugRedraw=debugRedraw;
63 public void drawStemAnnot(Graphics g, Annotation[] row_annotations,
64 int lastSSX, int x, int y, int iconOffset, int startRes,
65 int column, boolean validRes, boolean validEnd)
67 g.setColor(STEM_COLOUR);
68 int sCol = (lastSSX / charWidth) + startRes;
70 int x2 = (x * charWidth);
71 Regex closeparen = new Regex("(\\))");
73 String dc = (column == 0 || row_annotations[column - 1] == null) ? ""
74 : row_annotations[column - 1].displayCharacter;
76 boolean diffupstream = sCol == 0 || row_annotations[sCol - 1] == null
77 || !dc.equals(row_annotations[sCol - 1].displayCharacter);
78 boolean diffdownstream = !validRes || !validEnd
79 || row_annotations[column] == null
80 || !dc.equals(row_annotations[column].displayCharacter);
81 // System.out.println("Column "+column+" diff up: "+diffupstream+" down:"+diffdownstream);
82 // If a closing base pair half of the stem, display a backward arrow
83 if (column > 0 && closeparen.search(dc))
86 // if (validRes && column>1 && row_annotations[column-2]!=null &&
87 // dc.equals(row_annotations[column-2].displayCharacter))
89 g.fillPolygon(new int[]
90 { lastSSX + 5, lastSSX + 5, lastSSX }, new int[]
91 { y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset }, 3);
101 // display a forward arrow
104 g.fillPolygon(new int[]
105 { x2 - 5, x2 - 5, x2 }, new int[]
106 { y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset }, 3);
115 g.fillRect(x1, y + 4 + iconOffset, x2 - x1, 7);
118 private int charWidth, endRes, charHeight;
120 private boolean validCharWidth, hasHiddenColumns;
122 private FontMetrics fm;
124 private final boolean MAC = new jalview.util.Platform().isAMac();
126 boolean av_renderHistogram = true, av_renderProfile = true,
127 av_normaliseProfile = false;
129 ColourSchemeI profcolour = null;
131 private ColumnSelection columnSelection;
133 private Hashtable[] hconsensus;
135 private Hashtable[] hStrucConsensus;
137 private boolean av_ignoreGapsConsensus;
140 * attributes set from AwtRenderPanelI
143 * old image used when data is currently being calculated and cannot be
146 private Image fadedImage;
149 * panel being rendered into
151 private ImageObserver annotationPanel;
154 * width of image to render in panel
156 private int imgWidth;
158 * offset to beginning of visible area
162 * offset to end of visible area
164 private int visHeight;
166 * indicate if the renderer should only render the visible portion of the annotation given the current view settings
168 private boolean useClip=true;
170 * master flag indicating if renderer should ever try to clip. not enabled for jalview 2.8.1
172 private boolean canClip=false;
174 // public void updateFromAnnotationPanel(FontMetrics annotFM, AlignViewportI
176 public void updateFromAwtRenderPanel(AwtRenderPanelI annotPanel,
179 fm = annotPanel.getFontMetrics();
180 annotationPanel = annotPanel;
181 fadedImage = annotPanel.getFadedImage();
182 imgWidth = annotPanel.getFadedImageWidth();
183 // visible area for rendering
184 int[] bounds=annotPanel.getVisibleVRange();
188 visHeight = bounds[1];
199 updateFromAlignViewport(av);
202 public void updateFromAlignViewport(AlignViewportI av)
204 charWidth = av.getCharWidth();
205 endRes = av.getEndRes();
206 charHeight = av.getCharHeight();
207 hasHiddenColumns = av.hasHiddenColumns();
208 validCharWidth = av.isValidCharWidth();
209 av_renderHistogram = av.isShowConsensusHistogram();
210 av_renderProfile = av.isShowSequenceLogo();
211 av_normaliseProfile = av.isNormaliseSequenceLogo();
212 profcolour = av.getGlobalColourScheme();
213 if (profcolour == null)
215 // Set the default colour for sequence logo if the alignnent has no
217 profcolour = av.getAlignment().isNucleotide() ? new jalview.schemes.NucleotideColourScheme()
218 : new jalview.schemes.ZappoColourScheme();
220 columnSelection = av.getColumnSelection();
221 hconsensus = av.getSequenceConsensusHash();// hconsensus;
222 hStrucConsensus = av.getRnaStructureConsensusHash(); // hStrucConsensus;
223 av_ignoreGapsConsensus = av.getIgnoreGapsConsensus();
226 public int[] getProfileFor(AlignmentAnnotation aa, int column)
228 // TODO : consider refactoring the global alignment calculation
229 // properties/rendering attributes as a global 'alignment group' which holds
230 // all vis settings for the alignment as a whole rather than a subset
232 if (aa.autoCalculated && aa.label.startsWith("Consensus"))
234 if (aa.groupRef != null && aa.groupRef.consensusData != null
235 && aa.groupRef.isShowSequenceLogo())
237 return AAFrequency.extractProfile(
238 aa.groupRef.consensusData[column],
239 aa.groupRef.getIgnoreGapsConsensus());
241 // TODO extend annotation row to enable dynamic and static profile data to
243 if (aa.groupRef == null && aa.sequenceRef == null && av_renderProfile)
245 return AAFrequency.extractProfile(hconsensus[column],
246 av_ignoreGapsConsensus);
251 if (aa.autoCalculated && aa.label.startsWith("StrucConsensus"))
253 // TODO implement group structure consensus
255 * if (aa.groupRef != null && aa.groupRef.consensusData != null &&
256 * aa.groupRef.isShowSequenceLogo()) { //TODO check what happens for
257 * group selections return StructureFrequency.extractProfile(
258 * aa.groupRef.consensusData[column], aa.groupRef
259 * .getIgnoreGapsConsensus()); }
261 // TODO extend annotation row to enable dynamic and static profile data
264 if (aa.groupRef == null && aa.sequenceRef == null
265 && av_renderProfile && hStrucConsensus != null
266 && hStrucConsensus.length > column)
268 return StructureFrequency.extractProfile(hStrucConsensus[column],
269 av_ignoreGapsConsensus);
277 * Render the annotation rows associated with an alignment.
282 * data and view settings to render
284 * destination for graphics
286 * row where a mouse event occured (or -1)
288 * first column that will be drawn
290 * last column that will be drawn
291 * @return true if the fadedImage was used for any alignment annotation rows
292 * currently being calculated
294 public boolean drawComponent(AwtRenderPanelI annotPanel,
295 AlignViewportI av, Graphics g, int activeRow, int startRes,
298 long stime=System.currentTimeMillis();
299 boolean usedFaded = false;
301 // AnnotationPanel needs to implement: ImageObserver, access to
303 updateFromAwtRenderPanel(annotPanel, av);
304 fm = g.getFontMetrics();
305 AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
315 boolean validRes = false;
316 boolean validEnd = false;
317 boolean labelAllCols = false;
318 boolean centreColLabels, centreColLabelsDef = av
319 .getCentreColumnLabels();
320 boolean scaleColLabel = false;
322 BitSet graphGroupDrawn = new BitSet();
323 int charOffset = 0; // offset for a label
324 float fmWidth, fmScaling = 1f; // scaling for a label to fit it into a
326 Font ofont = g.getFont();
329 int yfrom=0,f_i=0,yto=0,f_to=0;
330 boolean clipst=false,clipend=false;
331 for (int i = 0; i < aa.length; i++)
333 AlignmentAnnotation row = aa[i];
334 Annotation[] row_annotations = row.annotations;
339 centreColLabels = row.centreColLabels || centreColLabelsDef;
340 labelAllCols = row.showAllColLabels;
341 scaleColLabel = row.scaleColLabel;
345 if (!useClip || ((y-charHeight)<visHeight && (y+row.height+charHeight*2)>=sOffset))
346 {// if_in_visible_region
357 if (row.graphGroup > -1 && graphGroupDrawn.get(row.graphGroup)) {
361 // this is so that we draw the characters below the graph
366 iconOffset = charHeight - fm.getDescent();
370 else if (row.hasText)
372 iconOffset = charHeight - fm.getDescent();
380 if (row.autoCalculated && av.isCalculationInProgress(row))
384 g.drawImage(fadedImage, 0, y - row.height, imgWidth, y, 0, y
385 - row.height, imgWidth, y, annotationPanel);
386 g.setColor(Color.black);
387 // g.drawString("Calculating "+aa[i].label+"....",20, y-row.height/2);
393 * else if (annotationPanel.av.updatingConservation &&
394 * aa[i].label.equals("Conservation")) {
396 * y += charHeight; g.drawImage(annotationPanel.fadedImage, 0, y -
397 * row.height, annotationPanel.imgWidth, y, 0, y - row.height,
398 * annotationPanel.imgWidth, y, annotationPanel);
400 * g.setColor(Color.black); //
401 * g.drawString("Calculating Conservation.....",20, y-row.height/2);
403 * continue; } else if (annotationPanel.av.updatingConservation &&
404 * aa[i].label.equals("Quality")) {
406 * y += charHeight; g.drawImage(annotationPanel.fadedImage, 0, y -
407 * row.height, annotationPanel.imgWidth, y, 0, y - row.height,
408 * annotationPanel.imgWidth, y, annotationPanel); g.setColor(Color.black);
409 * // / g.drawString("Calculating Quality....",20, y-row.height/2);
413 // first pass sets up state for drawing continuation from left-hand column
415 x = (startRes == 0) ? 0 : -1;
416 while (x < endRes - startRes)
418 if (hasHiddenColumns)
420 column = columnSelection.adjustForHiddenColumns(startRes + x);
421 if (column > row_annotations.length - 1)
428 column = startRes + x;
431 if ((row_annotations == null) || (row_annotations.length <= column)
432 || (row_annotations[column] == null))
444 g.setColor(Color.red);
446 if (columnSelection != null)
448 for (int n = 0; n < columnSelection.size(); n++)
450 int v = columnSelection.columnAt(n);
454 g.fillRect(x * charWidth, y, charWidth, charHeight);
459 if (!row.isValidStruc())
461 g.setColor(Color.orange);
462 g.fillRect((int) row.getInvalidStrucPos() * charWidth, y,
463 charWidth, charHeight);
467 && row_annotations[column].displayCharacter != null
468 && (row_annotations[column].displayCharacter.length() > 0))
471 if (centreColLabels || scaleColLabel)
473 fmWidth = fm.charsWidth(
474 row_annotations[column].displayCharacter
476 row_annotations[column].displayCharacter.length());
480 // justify the label and scale to fit in column
481 if (fmWidth > charWidth)
483 // scale only if the current font isn't already small enough
484 fmScaling = charWidth;
485 fmScaling /= fmWidth;
486 g.setFont(ofont.deriveFont(AffineTransform
487 .getScaleInstance(fmScaling, 1.0)));
488 // and update the label's width to reflect the scaling.
496 .charWidth(row_annotations[column].displayCharacter
499 charOffset = (int) ((charWidth - fmWidth) / 2f);
501 if (row_annotations[column].colour == null)
502 g.setColor(Color.black);
504 g.setColor(row_annotations[column].colour);
506 if (column == 0 || row.graph > 0)
508 g.drawString(row_annotations[column].displayCharacter,
509 (x * charWidth) + charOffset, y + iconOffset);
511 else if (row_annotations[column - 1] == null
513 || !row_annotations[column].displayCharacter
514 .equals(row_annotations[column - 1].displayCharacter) || (row_annotations[column].displayCharacter
515 .length() < 2 && row_annotations[column].secondaryStructure == ' ')))
517 g.drawString(row_annotations[column].displayCharacter, x
518 * charWidth + charOffset, y + iconOffset);
525 char ss = validRes ? row_annotations[column].secondaryStructure
529 // distinguish between forward/backward base-pairing
530 if (row_annotations[column].displayCharacter.indexOf(')') > -1)
535 if (!validRes || (ss != lastSS))
542 drawHelixAnnot(g, row_annotations, lastSSX, x, y,
543 iconOffset, startRes, column, validRes, validEnd);
547 drawSheetAnnot(g, row_annotations, lastSSX, x, y,
548 iconOffset, startRes, column, validRes, validEnd);
551 case 'S': // Stem case for RNA secondary structure
552 case 's': // and opposite direction
553 drawStemAnnot(g, row_annotations, lastSSX, x, y,
554 iconOffset, startRes, column, validRes, validEnd);
558 g.setColor(Color.gray);
559 g.fillRect(lastSSX, y + 6 + iconOffset, (x * charWidth)
575 lastSSX = (x * charWidth);
582 if (column >= row_annotations.length)
584 column = row_annotations.length - 1;
591 if ((row_annotations == null) || (row_annotations.length <= column)
592 || (row_annotations[column] == null))
608 drawHelixAnnot(g, row_annotations, lastSSX, x, y, iconOffset,
609 startRes, column, validRes, validEnd);
613 drawSheetAnnot(g, row_annotations, lastSSX, x, y, iconOffset,
614 startRes, column, validRes, validEnd);
617 case 'S': // Stem case for RNA secondary structure
618 drawStemAnnot(g, row_annotations, lastSSX, x, y, iconOffset,
619 startRes, column, validRes, validEnd);
622 drawGlyphLine(g, row_annotations, lastSSX, x, y, iconOffset,
623 startRes, column, validRes, validEnd);
628 if (row.graph > 0 && row.graphHeight > 0)
630 if (row.graph == AlignmentAnnotation.LINE_GRAPH)
632 if (row.graphGroup > -1 && !graphGroupDrawn.get(row.graphGroup))
634 // TODO: JAL-1291 revise rendering model so the graphGroup map is computed efficiently for all visible labels
635 float groupmax = -999999, groupmin = 9999999;
636 for (int gg = 0; gg < aa.length; gg++)
638 if (aa[gg].graphGroup != row.graphGroup)
645 aa[gg].visible = false;
647 if (aa[gg].graphMax > groupmax)
649 groupmax = aa[gg].graphMax;
651 if (aa[gg].graphMin < groupmin)
653 groupmin = aa[gg].graphMin;
657 for (int gg = 0; gg < aa.length; gg++)
659 if (aa[gg].graphGroup == row.graphGroup)
661 drawLineGraph(g, aa[gg], aa[gg].annotations, startRes,
662 endRes, y, groupmin, groupmax, row.graphHeight);
666 graphGroupDrawn.set(row.graphGroup);
670 drawLineGraph(g, row, row_annotations, startRes, endRes, y,
671 row.graphMin, row.graphMax, row.graphHeight);
674 else if (row.graph == AlignmentAnnotation.BAR_GRAPH)
676 drawBarGraph(g, row, row_annotations, startRes, endRes,
677 row.graphMin, row.graphMax, y);
681 if (clipst && !clipend)
685 }// end if_in_visible_region
686 if (row.graph > 0 && row.hasText)
702 System.err.println("Start clip at : " + yfrom + " (index " + f_i
707 System.err.println("End clip at : " + yto + " (index " + f_to
712 System.err.println("Annotation Rendering time:"
713 + (System.currentTimeMillis() - stime));
720 private final Color GLYPHLINE_COLOR = Color.gray;
722 private final Color SHEET_COLOUR = Color.green;
724 private final Color HELIX_COLOUR = Color.red;
726 private final Color STEM_COLOUR = Color.blue;
728 public void drawGlyphLine(Graphics g, Annotation[] row, int lastSSX,
729 int x, int y, int iconOffset, int startRes, int column,
730 boolean validRes, boolean validEnd)
732 g.setColor(GLYPHLINE_COLOR);
733 g.fillRect(lastSSX, y + 6 + iconOffset, (x * charWidth) - lastSSX, 2);
736 public void drawSheetAnnot(Graphics g, Annotation[] row, int lastSSX,
737 int x, int y, int iconOffset, int startRes, int column,
738 boolean validRes, boolean validEnd)
740 g.setColor(SHEET_COLOUR);
742 if (!validEnd || !validRes || row == null || row[column] == null
743 || row[column].secondaryStructure != 'E')
745 g.fillRect(lastSSX, y + 4 + iconOffset,
746 (x * charWidth) - lastSSX - 4, 7);
747 g.fillPolygon(new int[]
748 { (x * charWidth) - 4, (x * charWidth) - 4, (x * charWidth) },
750 { y + iconOffset, y + 14 + iconOffset, y + 7 + iconOffset },
755 g.fillRect(lastSSX, y + 4 + iconOffset,
756 (x + 1) * charWidth - lastSSX, 7);
761 public void drawHelixAnnot(Graphics g, Annotation[] row, int lastSSX,
762 int x, int y, int iconOffset, int startRes, int column,
763 boolean validRes, boolean validEnd)
765 g.setColor(HELIX_COLOUR);
767 int sCol = (lastSSX / charWidth) + startRes;
769 int x2 = (x * charWidth);
773 int ofs = charWidth / 2;
774 // Off by 1 offset when drawing rects and ovals
775 // to offscreen image on the MAC
776 g.fillRoundRect(lastSSX, y + 4 + iconOffset, x2 - x1, 8, 8, 8);
777 if (sCol == 0 || row[sCol - 1] == null
778 || row[sCol - 1].secondaryStructure != 'H')
783 // g.setColor(Color.orange);
784 g.fillRoundRect(lastSSX, y + 4 + iconOffset, x2 - x1 - ofs + 1, 8,
787 if (!validRes || row[column] == null
788 || row[column].secondaryStructure != 'H')
794 // g.setColor(Color.magenta);
795 g.fillRoundRect(lastSSX + ofs, y + 4 + iconOffset, x2 - x1 - ofs
803 if (sCol == 0 || row[sCol - 1] == null
804 || row[sCol - 1].secondaryStructure != 'H')
806 g.fillArc(lastSSX, y + 4 + iconOffset, charWidth, 8, 90, 180);
810 if (!validRes || row[column] == null
811 || row[column].secondaryStructure != 'H')
813 g.fillArc((x * charWidth) - charWidth, y + 4 + iconOffset, charWidth,
818 g.fillRect(x1, y + 4 + iconOffset, x2 - x1, 8);
821 public void drawLineGraph(Graphics g, AlignmentAnnotation _aa,
822 Annotation[] aa_annotations, int sRes, int eRes, int y,
823 float min, float max, int graphHeight)
825 if (sRes > aa_annotations.length)
832 // Adjustment for fastpaint to left
838 eRes = Math.min(eRes, aa_annotations.length);
846 float range = max - min;
851 y2 = y - (int) ((0 - min / range) * graphHeight);
854 g.setColor(Color.gray);
855 g.drawLine(x - charWidth, y2, (eRes - sRes + 1) * charWidth, y2);
857 eRes = Math.min(eRes, aa_annotations.length);
860 int aaMax = aa_annotations.length - 1;
862 while (x < eRes - sRes)
865 if (hasHiddenColumns)
867 column = columnSelection.adjustForHiddenColumns(column);
875 if (aa_annotations[column] == null
876 || aa_annotations[column - 1] == null)
882 if (aa_annotations[column].colour == null)
883 g.setColor(Color.black);
885 g.setColor(aa_annotations[column].colour);
888 - (int) (((aa_annotations[column - 1].value - min) / range) * graphHeight);
890 - (int) (((aa_annotations[column].value - min) / range) * graphHeight);
892 g.drawLine(x * charWidth - charWidth / 2, y1, x * charWidth
893 + charWidth / 2, y2);
897 if (_aa.threshold != null)
899 g.setColor(_aa.threshold.colour);
900 Graphics2D g2 = (Graphics2D) g;
901 g2.setStroke(new BasicStroke(1, BasicStroke.CAP_SQUARE,
902 BasicStroke.JOIN_ROUND, 3f, new float[]
905 y2 = (int) (y - ((_aa.threshold.value - min) / range) * graphHeight);
906 g.drawLine(0, y2, (eRes - sRes) * charWidth, y2);
907 g2.setStroke(new BasicStroke());
911 public void drawBarGraph(Graphics g, AlignmentAnnotation _aa,
912 Annotation[] aa_annotations, int sRes, int eRes, float min,
915 if (sRes > aa_annotations.length)
919 Font ofont = g.getFont();
920 eRes = Math.min(eRes, aa_annotations.length);
922 int x = 0, y1 = y, y2 = y;
924 float range = max - min;
928 y2 = y - (int) ((0 - min / (range)) * _aa.graphHeight);
931 g.setColor(Color.gray);
933 g.drawLine(x, y2, (eRes - sRes) * charWidth, y2);
936 int aaMax = aa_annotations.length - 1;
937 boolean renderHistogram = true, renderProfile = true, normaliseProfile = false;
938 // if (aa.autoCalculated && aa.label.startsWith("Consensus"))
940 // TODO: generalise this to have render styles for consensus/profile data
941 if (_aa.groupRef != null)
943 renderHistogram = _aa.groupRef.isShowConsensusHistogram();
944 renderProfile = _aa.groupRef.isShowSequenceLogo();
945 normaliseProfile = _aa.groupRef.isNormaliseSequenceLogo();
949 renderHistogram = av_renderHistogram;
950 renderProfile = av_renderProfile;
951 normaliseProfile = av_normaliseProfile;
954 while (x < eRes - sRes)
957 if (hasHiddenColumns)
959 column = columnSelection.adjustForHiddenColumns(column);
967 if (aa_annotations[column] == null)
972 if (aa_annotations[column].colour == null)
973 g.setColor(Color.black);
975 g.setColor(aa_annotations[column].colour);
978 - (int) (((aa_annotations[column].value - min) / (range)) * _aa.graphHeight);
984 g.fillRect(x * charWidth, y2, charWidth, y1 - y2);
988 g.fillRect(x * charWidth, y1, charWidth, y2 - y1);
991 // draw profile if available
995 int profl[] = getProfileFor(_aa, column);
996 // just try to draw the logo if profl is not null
997 if (profl != null && profl[1] != 0)
999 float ht = normaliseProfile ? y - _aa.graphHeight : y1;
1000 double htn = normaliseProfile ? _aa.graphHeight : (y2 - y1);// aa.graphHeight;
1007 * profl.length == 74 indicates that the profile of a secondary
1008 * structure conservation row was accesed. Therefore dc gets length 2,
1009 * to have space for a basepair instead of just a single nucleotide
1011 if (profl.length == 74)
1019 LineMetrics lm = g.getFontMetrics(ofont).getLineMetrics("Q", g);
1020 double scale = 1f / (normaliseProfile ? profl[1] : 100f);
1021 float ofontHeight = 1f / lm.getAscent();// magnify to fill box
1023 for (int c = 2; c < profl[0];)
1025 dc[0] = (char) profl[c++];
1027 if (_aa.label.startsWith("StrucConsensus"))
1029 dc[1] = (char) profl[c++];
1033 wdth /= fm.charsWidth(dc, 0, dc.length);
1037 scl = htn * scale * profl[c++];
1038 lm = ofont.getLineMetrics(dc, 0, 1, g.getFontMetrics()
1039 .getFontRenderContext());
1040 g.setFont(ofont.deriveFont(AffineTransform.getScaleInstance(
1041 wdth, scl / lm.getAscent())));
1042 lm = g.getFontMetrics().getLineMetrics(dc, 0, 1, g);
1044 // Debug - render boxes around characters
1045 // g.setColor(Color.red);
1046 // g.drawRect(x*av.charWidth, (int)ht, av.charWidth,
1048 // g.setColor(profcolour.findColour(dc[0]).darker());
1049 g.setColor(profcolour.findColour(dc[0], column, null));
1051 hght = (ht + (scl - lm.getDescent() - lm.getBaselineOffsets()[lm
1052 .getBaselineIndex()]));
1054 g.drawChars(dc, 0, dc.length, x * charWidth, (int) hght);
1062 if (_aa.threshold != null)
1064 g.setColor(_aa.threshold.colour);
1065 Graphics2D g2 = (Graphics2D) g;
1066 g2.setStroke(new BasicStroke(1, BasicStroke.CAP_SQUARE,
1067 BasicStroke.JOIN_ROUND, 3f, new float[]
1070 y2 = (int) (y - ((_aa.threshold.value - min) / range)
1072 g.drawLine(0, y2, (eRes - sRes) * charWidth, y2);
1073 g2.setStroke(new BasicStroke());
1077 // used by overview window
1078 public void drawGraph(Graphics g, AlignmentAnnotation _aa,
1079 Annotation[] aa_annotations, int width, int y, int sRes, int eRes)
1081 eRes = Math.min(eRes, aa_annotations.length);
1082 g.setColor(Color.white);
1083 g.fillRect(0, 0, width, y);
1084 g.setColor(new Color(0, 0, 180));
1088 for (int j = sRes; j < eRes; j++)
1090 if (aa_annotations[j] != null)
1092 if (aa_annotations[j].colour == null)
1093 g.setColor(Color.black);
1095 g.setColor(aa_annotations[j].colour);
1097 height = (int) ((aa_annotations[j].value / _aa.graphMax) * y);
1103 g.fillRect(x, y - height, charWidth, height);