1 Clazz.declarePackage ("jalview.renderer");
\r
2 Clazz.load (["jalview.util.Platform", "java.awt.Color"], "jalview.renderer.AnnotationRenderer", ["jalview.analysis.AAFrequency", "$.CodingUtils", "$.StructureFrequency", "jalview.jsdev.RegExp", "jalview.schemes.NucleotideColourScheme", "$.ResidueProperties", "$.ZappoColourScheme", "java.awt.BasicStroke", "java.awt.geom.AffineTransform", "java.util.BitSet"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
4 this.debugRedraw = false;
\r
8 this.validCharWidth = false;
\r
9 this.hasHiddenColumns = false;
\r
12 this.av_renderHistogram = true;
\r
13 this.av_renderProfile = true;
\r
14 this.av_normaliseProfile = false;
\r
15 this.profcolour = null;
\r
16 this.columnSelection = null;
\r
17 this.hconsensus = null;
\r
18 this.complementConsensus = null;
\r
19 this.hStrucConsensus = null;
\r
20 this.av_ignoreGapsConsensus = false;
\r
21 this.fadedImage = null;
\r
22 this.annotationPanel = null;
\r
26 this.useClip = true;
\r
27 this.canClip = false;
\r
29 this.sdNOTCANONICAL_COLOUR = null;
\r
30 Clazz.instantialize (this, arguments);
\r
31 }, jalview.renderer, "AnnotationRenderer");
\r
32 Clazz.prepareFields (c$, function () {
\r
33 this.MAC = jalview.util.Platform.isAMac ();
\r
35 Clazz.makeConstructor (c$,
\r
37 this.construct (false);
\r
39 Clazz.makeConstructor (c$,
\r
40 function (debugRedraw) {
\r
41 this.debugRedraw = debugRedraw;
\r
43 Clazz.defineMethod (c$, "drawStemAnnot",
\r
44 function (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd) {
\r
45 g.setColor (jalview.renderer.AnnotationRenderer.STEM_COLOUR);
\r
46 var sCol = (Clazz.doubleToInt (lastSSX / this.charWidth)) + startRes;
\r
48 var x2 = (x * this.charWidth);
\r
49 var closeparen = jalview.jsdev.RegExp.newRegex (["(\\))"]);
\r
50 var dc = (column == 0 || row_annotations[column - 1] == null) ? ' ' : row_annotations[column - 1].secondaryStructure;
\r
51 var diffupstream = sCol == 0 || row_annotations[sCol - 1] == null || dc != row_annotations[sCol - 1].secondaryStructure;
\r
52 var diffdownstream = !validRes || !validEnd || row_annotations[column] == null || dc != row_annotations[column].secondaryStructure;
\r
53 if (column > 0 && jalview.schemes.ResidueProperties.isCloseParenRNA (dc)) {
\r
55 g.fillPolygon ( Clazz.newIntArray (-1, [lastSSX + 5, lastSSX + 5, lastSSX]), Clazz.newIntArray (-1, [y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset]), 3);
\r
57 }if (diffdownstream) {
\r
60 if (diffdownstream) {
\r
61 g.fillPolygon ( Clazz.newIntArray (-1, [x2 - 5, x2 - 5, x2]), Clazz.newIntArray (-1, [y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset]), 3);
\r
63 }if (diffupstream) {
\r
65 }}g.fillRect (x1, y + 4 + iconOffset, x2 - x1, 7);
\r
66 }, "java.awt.Graphics,~A,~N,~N,~N,~N,~N,~N,~B,~B");
\r
67 Clazz.defineMethod (c$, "drawNotCanonicalAnnot",
\r
68 function (g, nonCanColor, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd) {
\r
69 g.setColor (nonCanColor);
\r
70 var sCol = (Clazz.doubleToInt (lastSSX / this.charWidth)) + startRes;
\r
72 var x2 = (x * this.charWidth);
\r
73 var closeparen = jalview.jsdev.RegExp.newRegex (["}|]|<|[a-z]"]);
\r
74 var dc = (column == 0 || row_annotations[column - 1] == null) ? "" : row_annotations[column - 1].displayCharacter;
\r
75 var diffupstream = sCol == 0 || row_annotations[sCol - 1] == null || !dc.equals (row_annotations[sCol - 1].displayCharacter);
\r
76 var diffdownstream = !validRes || !validEnd || row_annotations[column] == null || !dc.equals (row_annotations[column].displayCharacter);
\r
77 if (column > 0 && closeparen.search (dc)) {
\r
79 g.fillPolygon ( Clazz.newIntArray (-1, [lastSSX + 5, lastSSX + 5, lastSSX]), Clazz.newIntArray (-1, [y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset]), 3);
\r
81 }if (diffdownstream) {
\r
84 if (diffdownstream) {
\r
85 g.fillPolygon ( Clazz.newIntArray (-1, [x2 - 5, x2 - 5, x2]), Clazz.newIntArray (-1, [y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset]), 3);
\r
87 }if (diffupstream) {
\r
89 }}g.fillRect (x1, y + 4 + iconOffset, x2 - x1, 7);
\r
90 }, "java.awt.Graphics,java.awt.Color,~A,~N,~N,~N,~N,~N,~N,~B,~B");
\r
91 Clazz.defineMethod (c$, "updateFromAwtRenderPanel",
\r
92 function (annotPanel, av) {
\r
93 this.fm = annotPanel.getFontMetrics ();
\r
94 this.annotationPanel = annotPanel;
\r
95 this.fadedImage = annotPanel.getFadedImage ();
\r
96 this.imgWidth = annotPanel.getFadedImageWidth ();
\r
97 var bounds = annotPanel.getVisibleVRange ();
\r
98 if (bounds != null) {
\r
99 this.sOffset = bounds[0];
\r
100 this.visHeight = bounds[1];
\r
101 if (this.visHeight == 0) {
\r
102 this.useClip = false;
\r
104 this.useClip = this.canClip;
\r
106 this.useClip = false;
\r
107 }this.updateFromAlignViewport (av);
\r
108 }, "jalview.renderer.AwtRenderPanelI,jalview.api.AlignViewportI");
\r
109 Clazz.defineMethod (c$, "updateFromAlignViewport",
\r
111 this.charWidth = av.getCharWidth ();
\r
112 this.endRes = av.getEndRes ();
\r
113 this.charHeight = av.getCharHeight ();
\r
114 this.hasHiddenColumns = av.hasHiddenColumns ();
\r
115 this.validCharWidth = av.isValidCharWidth ();
\r
116 this.av_renderHistogram = av.isShowConsensusHistogram ();
\r
117 this.av_renderProfile = av.isShowSequenceLogo ();
\r
118 this.av_normaliseProfile = av.isNormaliseSequenceLogo ();
\r
119 this.profcolour = av.getGlobalColourScheme ();
\r
120 if (this.profcolour == null) {
\r
121 this.profcolour = av.getAlignment ().isNucleotide () ? new jalview.schemes.NucleotideColourScheme () : new jalview.schemes.ZappoColourScheme ();
\r
122 }this.columnSelection = av.getColumnSelection ();
\r
123 this.hconsensus = av.getSequenceConsensusHash ();
\r
124 this.complementConsensus = av.getComplementConsensusHash ();
\r
125 this.hStrucConsensus = av.getRnaStructureConsensusHash ();
\r
126 this.av_ignoreGapsConsensus = av.isIgnoreGapsConsensus ();
\r
127 }, "jalview.api.AlignViewportI");
\r
128 Clazz.defineMethod (c$, "getProfileFor",
\r
129 function (aa, column) {
\r
130 if (aa.autoCalculated && (aa.label.startsWith ("Consensus") || aa.label.startsWith ("cDNA Consensus"))) {
\r
131 var forComplement = aa.label.startsWith ("cDNA Consensus");
\r
132 if (aa.groupRef != null && aa.groupRef.consensusData != null && aa.groupRef.isShowSequenceLogo ()) {
\r
133 return jalview.analysis.AAFrequency.extractProfile (aa.groupRef.consensusData[column], aa.groupRef.getIgnoreGapsConsensus ());
\r
134 }if (aa.groupRef == null && aa.sequenceRef == null) {
\r
135 if (forComplement) {
\r
136 return jalview.analysis.AAFrequency.extractCdnaProfile (this.complementConsensus[column], this.av_ignoreGapsConsensus);
\r
138 return jalview.analysis.AAFrequency.extractProfile (this.hconsensus[column], this.av_ignoreGapsConsensus);
\r
140 if (aa.autoCalculated && aa.label.startsWith ("StrucConsensus")) {
\r
141 if (aa.groupRef == null && aa.sequenceRef == null && this.hStrucConsensus != null && this.hStrucConsensus.length > column) {
\r
142 return jalview.analysis.StructureFrequency.extractProfile (this.hStrucConsensus[column], this.av_ignoreGapsConsensus);
\r
144 }, "jalview.datamodel.AlignmentAnnotation,~N");
\r
145 Clazz.defineMethod (c$, "drawComponent",
\r
146 function (annotPanel, av, g, activeRow, startRes, endRes) {
\r
147 var stime = System.currentTimeMillis ();
\r
148 var usedFaded = false;
\r
149 this.updateFromAwtRenderPanel (annotPanel, av);
\r
150 this.fm = g.getFontMetrics ();
\r
151 var aa = av.getAlignment ().getAlignmentAnnotation ();
\r
160 var iconOffset = 0;
\r
161 var validRes = false;
\r
162 var validEnd = false;
\r
163 var labelAllCols = false;
\r
164 var centreColLabels;
\r
165 var centreColLabelsDef = av.isCentreColumnLabels ();
\r
166 var scaleColLabel = false;
\r
167 var consensusAnnot = av.getAlignmentConsensusAnnotation ();
\r
168 var structConsensusAnnot = av.getAlignmentStrucConsensusAnnotation ();
\r
169 var complementConsensusAnnot = av.getComplementConsensusAnnotation ();
\r
170 var renderHistogram = true;
\r
171 var renderProfile = true;
\r
172 var normaliseProfile = false;
\r
173 var isRNA = this.rna;
\r
174 var graphGroupDrawn = new java.util.BitSet ();
\r
175 var charOffset = 0;
\r
178 var ofont = g.getFont ();
\r
183 var clipst = false;
\r
184 var clipend = false;
\r
185 for (var i = 0; i < aa.length; i++) {
\r
187 isRNA = row.isRNA ();
\r
189 if (row.groupRef != null && row === row.groupRef.getConsensus ()) {
\r
190 renderHistogram = row.groupRef.isShowConsensusHistogram ();
\r
191 renderProfile = row.groupRef.isShowSequenceLogo ();
\r
192 normaliseProfile = row.groupRef.isNormaliseSequenceLogo ();
\r
193 } else if (row === consensusAnnot || row === structConsensusAnnot || row === complementConsensusAnnot) {
\r
194 renderHistogram = this.av_renderHistogram;
\r
195 renderProfile = this.av_renderProfile;
\r
196 normaliseProfile = this.av_normaliseProfile;
\r
198 renderHistogram = true;
\r
199 }}var row_annotations = row.annotations;
\r
200 if (!row.visible) {
\r
202 }centreColLabels = row.centreColLabels || centreColLabelsDef;
\r
203 labelAllCols = row.showAllColLabels;
\r
204 scaleColLabel = row.scaleColLabel;
\r
207 if (!this.useClip || ((y - this.charHeight) < this.visHeight && (y + row.height + this.charHeight * 2) >= this.sOffset)) {
\r
214 if (row.graph > 0) {
\r
215 if (row.graphGroup > -1 && graphGroupDrawn.get (row.graphGroup)) {
\r
219 iconOffset = this.charHeight - this.fm.getDescent ();
\r
220 y -= this.charHeight;
\r
221 }} else if (row.hasText) {
\r
222 iconOffset = this.charHeight - this.fm.getDescent ();
\r
225 }if (row.autoCalculated && av.isCalculationInProgress (row)) {
\r
226 y += this.charHeight;
\r
228 g.drawImage (this.fadedImage, 0, y - row.height, this.imgWidth, y, 0, y - row.height, this.imgWidth, y, this.annotationPanel);
\r
229 g.setColor (java.awt.Color.black);
\r
231 }x = (startRes == 0) ? 0 : -1;
\r
232 while (x < endRes - startRes) {
\r
233 if (this.hasHiddenColumns) {
\r
234 column = this.columnSelection.adjustForHiddenColumns (startRes + x);
\r
235 if (column > row_annotations.length - 1) {
\r
238 column = startRes + x;
\r
239 }if ((row_annotations == null) || (row_annotations.length <= column) || (row_annotations[column] == null)) {
\r
243 }var displayChar = validRes ? row_annotations[column].displayCharacter : null;
\r
245 if (activeRow == i) {
\r
246 g.setColor (java.awt.Color.red);
\r
247 if (this.columnSelection != null) {
\r
248 for (var n = 0; n < this.columnSelection.size (); n++) {
\r
249 var v = this.columnSelection.columnAt (n);
\r
251 g.fillRect (x * this.charWidth, y, this.charWidth, this.charHeight);
\r
253 }}if (row.getInvalidStrucPos () > x) {
\r
254 g.setColor (java.awt.Color.orange);
\r
255 g.fillRect (x * this.charWidth, y, this.charWidth, this.charHeight);
\r
256 } else if (row.getInvalidStrucPos () == x) {
\r
257 g.setColor (java.awt.Color.orange.darker ());
\r
258 g.fillRect (x * this.charWidth, y, this.charWidth, this.charHeight);
\r
259 }if (this.validCharWidth && validRes && displayChar != null && (displayChar.length > 0)) {
\r
260 fmWidth = this.fm.charsWidth (displayChar.toCharArray (), 0, displayChar.length);
\r
261 if (scaleColLabel) {
\r
262 if (fmWidth > this.charWidth) {
\r
263 fmScaling = this.charWidth;
\r
264 fmScaling /= fmWidth;
\r
265 g.setFont (ofont.deriveFont (java.awt.geom.AffineTransform.getScaleInstance (fmScaling, 1.0)));
\r
266 fmWidth = this.charWidth;
\r
267 }}charOffset = Clazz.floatToInt ((this.charWidth - fmWidth) / 2);
\r
268 if (row_annotations[column].colour == null) {
\r
269 g.setColor (java.awt.Color.black);
\r
271 g.setColor (row_annotations[column].colour);
\r
272 }if (column == 0 || row.graph > 0) {
\r
273 g.drawString (displayChar, (x * this.charWidth) + charOffset, y + iconOffset);
\r
274 } else if (row_annotations[column - 1] == null || (labelAllCols || !displayChar.equals (row_annotations[column - 1].displayCharacter) || (displayChar.length < 2 && row_annotations[column].secondaryStructure == ' '))) {
\r
275 g.drawString (displayChar, x * this.charWidth + charOffset, y + iconOffset);
\r
276 }g.setFont (ofont);
\r
277 }}if (row.hasIcons) {
\r
278 var ss = validRes ? row_annotations[column].secondaryStructure : '-';
\r
280 if (displayChar.indexOf (')') > -1) {
\r
283 if ((displayChar.indexOf (']') > -1)) {
\r
286 if (displayChar.indexOf ('}') > -1) {
\r
289 if (displayChar.indexOf ('<') > -1) {
\r
291 }}if (ss.charCodeAt (0) >= 65) {
\r
292 if (displayChar.indexOf (ss.charCodeAt (0) + 32) > -1) {
\r
293 ss = String.fromCharCode (ss.charCodeAt (0) + 32);
\r
294 }}if (!validRes || (ss != lastSS)) {
\r
296 var nb_annot = x - temp;
\r
300 this.drawStemAnnot (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd);
\r
305 this.drawHelixAnnot (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd);
\r
309 this.drawSheetAnnot (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd);
\r
367 var nonCanColor = this.getNotCanonicalColor (lastSS);
\r
368 this.drawNotCanonicalAnnot (g, nonCanColor, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd);
\r
372 g.setColor (java.awt.Color.gray);
\r
373 g.fillRect (lastSSX, y + 6 + iconOffset, (x * this.charWidth) - lastSSX, 2);
\r
382 lastSSX = (x * this.charWidth);
\r
386 if (column >= row_annotations.length) {
\r
387 column = row_annotations.length - 1;
\r
391 }if ((row_annotations == null) || (row_annotations.length <= column) || (row_annotations[column] == null)) {
\r
395 }if (row.hasIcons) {
\r
399 this.drawHelixAnnot (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd);
\r
403 this.drawSheetAnnot (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd);
\r
407 this.drawStemAnnot (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd);
\r
463 var nonCanColor = this.getNotCanonicalColor (lastSS);
\r
464 this.drawNotCanonicalAnnot (g, nonCanColor, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd);
\r
467 this.drawGlyphLine (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd);
\r
470 }if (row.graph > 0 && row.graphHeight > 0) {
\r
471 if (row.graph == 2) {
\r
472 if (row.graphGroup > -1 && !graphGroupDrawn.get (row.graphGroup)) {
\r
473 var groupmax = -999999;
\r
474 var groupmin = 9999999;
\r
475 for (var gg = 0; gg < aa.length; gg++) {
\r
476 if (aa[gg].graphGroup != row.graphGroup) {
\r
478 }if (aa[gg] !== row) {
\r
479 aa[gg].visible = false;
\r
480 }if (aa[gg].graphMax > groupmax) {
\r
481 groupmax = aa[gg].graphMax;
\r
482 }if (aa[gg].graphMin < groupmin) {
\r
483 groupmin = aa[gg].graphMin;
\r
485 for (var gg = 0; gg < aa.length; gg++) {
\r
486 if (aa[gg].graphGroup == row.graphGroup) {
\r
487 this.drawLineGraph (g, aa[gg], aa[gg].annotations, startRes, endRes, y, groupmin, groupmax, row.graphHeight);
\r
489 graphGroupDrawn.set (row.graphGroup);
\r
491 this.drawLineGraph (g, row, row_annotations, startRes, endRes, y, row.graphMin, row.graphMax, row.graphHeight);
\r
492 }} else if (row.graph == 1) {
\r
493 this.drawBarGraph (g, row, row_annotations, startRes, endRes, row.graphMin, row.graphMax, y, renderHistogram, renderProfile, normaliseProfile);
\r
495 if (clipst && !clipend) {
\r
497 }}if (row.graph > 0 && row.hasText) {
\r
498 y += this.charHeight;
\r
499 }if (row.graph == 0) {
\r
502 if (this.debugRedraw) {
\r
503 if (this.canClip) {
\r
505 System.err.println ("Start clip at : " + yfrom + " (index " + f_i + ")");
\r
507 System.err.println ("End clip at : " + yto + " (index " + f_to + ")");
\r
508 }};System.err.println ("Annotation Rendering time:" + (System.currentTimeMillis () - stime));
\r
509 };return !usedFaded;
\r
510 }, "jalview.renderer.AwtRenderPanelI,jalview.api.AlignViewportI,java.awt.Graphics,~N,~N,~N");
\r
511 Clazz.defineMethod (c$, "drawGlyphLine",
\r
512 function (g, row, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd) {
\r
513 g.setColor (jalview.renderer.AnnotationRenderer.GLYPHLINE_COLOR);
\r
514 g.fillRect (lastSSX, y + 6 + iconOffset, (x * this.charWidth) - lastSSX, 2);
\r
515 }, "java.awt.Graphics,~A,~N,~N,~N,~N,~N,~N,~B,~B");
\r
516 Clazz.defineMethod (c$, "drawSheetAnnot",
\r
517 function (g, row, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd) {
\r
518 g.setColor (jalview.renderer.AnnotationRenderer.SHEET_COLOUR);
\r
519 if (!validEnd || !validRes || row == null || row[column] == null || row[column].secondaryStructure != 'E') {
\r
520 g.fillRect (lastSSX, y + 4 + iconOffset, (x * this.charWidth) - lastSSX - 4, 7);
\r
521 g.fillPolygon ( Clazz.newIntArray (-1, [(x * this.charWidth) - 4, (x * this.charWidth) - 4, (x * this.charWidth)]), Clazz.newIntArray (-1, [y + iconOffset, y + 14 + iconOffset, y + 7 + iconOffset]), 3);
\r
523 g.fillRect (lastSSX, y + 4 + iconOffset, (x + 1) * this.charWidth - lastSSX, 7);
\r
524 }}, "java.awt.Graphics,~A,~N,~N,~N,~N,~N,~N,~B,~B");
\r
525 Clazz.defineMethod (c$, "drawHelixAnnot",
\r
526 function (g, row, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd) {
\r
527 g.setColor (jalview.renderer.AnnotationRenderer.HELIX_COLOUR);
\r
528 var sCol = (Clazz.doubleToInt (lastSSX / this.charWidth)) + startRes;
\r
530 var x2 = (x * this.charWidth);
\r
532 var ofs = Clazz.doubleToInt (this.charWidth / 2);
\r
533 g.fillRoundRect (lastSSX, y + 4 + iconOffset, x2 - x1, 8, 8, 8);
\r
534 if (sCol == 0 || row[sCol - 1] == null || row[sCol - 1].secondaryStructure != 'H') {
\r
536 g.fillRoundRect (lastSSX, y + 4 + iconOffset, x2 - x1 - ofs + 1, 8, 0, 0);
\r
537 }if (!validRes || row[column] == null || row[column].secondaryStructure != 'H') {
\r
539 g.fillRoundRect (lastSSX + ofs, y + 4 + iconOffset, x2 - x1 - ofs + 1, 8, 0, 0);
\r
541 }if (sCol == 0 || row[sCol - 1] == null || row[sCol - 1].secondaryStructure != 'H') {
\r
542 g.fillArc (lastSSX, y + 4 + iconOffset, this.charWidth, 8, 90, 180);
\r
543 x1 += Clazz.doubleToInt (this.charWidth / 2);
\r
544 }if (!validRes || row[column] == null || row[column].secondaryStructure != 'H') {
\r
545 g.fillArc ((x * this.charWidth) - this.charWidth, y + 4 + iconOffset, this.charWidth, 8, 270, 180);
\r
546 x2 -= Clazz.doubleToInt (this.charWidth / 2);
\r
547 }g.fillRect (x1, y + 4 + iconOffset, x2 - x1, 8);
\r
548 }, "java.awt.Graphics,~A,~N,~N,~N,~N,~N,~N,~B,~B");
\r
549 Clazz.defineMethod (c$, "drawLineGraph",
\r
550 function (g, _aa, aa_annotations, sRes, eRes, y, min, max, graphHeight) {
\r
551 if (sRes > aa_annotations.length) {
\r
554 if (eRes < this.endRes) {
\r
556 }eRes = Math.min (eRes, aa_annotations.length);
\r
561 var range = max - min;
\r
563 y2 = y - Clazz.floatToInt ((0 - min / range) * graphHeight);
\r
564 }g.setColor (java.awt.Color.gray);
\r
565 g.drawLine (x - this.charWidth, y2, (eRes - sRes + 1) * this.charWidth, y2);
\r
566 eRes = Math.min (eRes, aa_annotations.length);
\r
568 var aaMax = aa_annotations.length - 1;
\r
569 while (x < eRes - sRes) {
\r
571 if (this.hasHiddenColumns) {
\r
572 column = this.columnSelection.adjustForHiddenColumns (column);
\r
573 }if (column > aaMax) {
\r
575 }if (aa_annotations[column] == null || aa_annotations[column - 1] == null) {
\r
578 }if (aa_annotations[column].colour == null) {
\r
579 g.setColor (java.awt.Color.black);
\r
581 g.setColor (aa_annotations[column].colour);
\r
582 }y1 = y - Clazz.floatToInt (((aa_annotations[column - 1].value - min) / range) * graphHeight);
\r
583 y2 = y - Clazz.floatToInt (((aa_annotations[column].value - min) / range) * graphHeight);
\r
584 g.drawLine (x * this.charWidth - Clazz.doubleToInt (this.charWidth / 2), y1, x * this.charWidth + Clazz.doubleToInt (this.charWidth / 2), y2);
\r
587 if (_aa.threshold != null) {
\r
588 g.setColor (_aa.threshold.colour);
\r
590 g2.setStroke ( new java.awt.BasicStroke (1, 2, 1, 3, Clazz.newFloatArray (-1, [5, 3]), 0));
\r
591 y2 = Clazz.floatToInt (y - ((_aa.threshold.value - min) / range) * graphHeight);
\r
592 g.drawLine (0, y2, (eRes - sRes) * this.charWidth, y2);
\r
593 g2.setStroke ( new java.awt.BasicStroke ());
\r
594 }}, "java.awt.Graphics,jalview.datamodel.AlignmentAnnotation,~A,~N,~N,~N,~N,~N,~N");
\r
595 Clazz.defineMethod (c$, "drawBarGraph",
\r
596 function (g, _aa, aa_annotations, sRes, eRes, min, max, y, renderHistogram, renderProfile, normaliseProfile) {
\r
597 if (sRes > aa_annotations.length) {
\r
599 }var ofont = g.getFont ();
\r
600 eRes = Math.min (eRes, aa_annotations.length);
\r
604 var range = max - min;
\r
606 y2 = y - Clazz.floatToInt ((0 - min / (range)) * _aa.graphHeight);
\r
607 }g.setColor (java.awt.Color.gray);
\r
608 g.drawLine (x, y2, (eRes - sRes) * this.charWidth, y2);
\r
610 var aaMax = aa_annotations.length - 1;
\r
611 while (x < eRes - sRes) {
\r
613 if (this.hasHiddenColumns) {
\r
614 column = this.columnSelection.adjustForHiddenColumns (column);
\r
615 }if (column > aaMax) {
\r
617 }if (aa_annotations[column] == null) {
\r
620 }if (aa_annotations[column].colour == null) {
\r
621 g.setColor (java.awt.Color.black);
\r
623 g.setColor (aa_annotations[column].colour);
\r
624 }y1 = y - Clazz.floatToInt (((aa_annotations[column].value - min) / (range)) * _aa.graphHeight);
\r
625 if (renderHistogram) {
\r
627 g.fillRect (x * this.charWidth, y2, this.charWidth, y1 - y2);
\r
629 g.fillRect (x * this.charWidth, y1, this.charWidth, y2 - y1);
\r
630 }}if (renderProfile) {
\r
631 var profl = this.getProfileFor (_aa, column);
\r
632 if (profl != null && profl[2] != 0) {
\r
633 var isStructureProfile = profl[0] == 1;
\r
634 var isCdnaProfile = profl[0] == 2;
\r
635 var ht = normaliseProfile ? y - _aa.graphHeight : y1;
\r
636 var htn = normaliseProfile ? _aa.graphHeight : (y2 - y1);
\r
641 dc = Clazz.newCharArray (isStructureProfile ? 2 : (isCdnaProfile ? 3 : 1), '\0');
\r
642 var lm = g.getFontMetrics (ofont).getLineMetrics ("Q", g);
\r
643 var scale = 1 / (normaliseProfile ? profl[2] : 100);
\r
644 var ofontHeight = 1 / lm.getAscent ();
\r
647 var valuesProcessed = 0;
\r
648 while (valuesProcessed < profl[1]) {
\r
649 if (isStructureProfile) {
\r
650 dc[0] = String.fromCharCode (profl[c++]);
\r
651 dc[1] = String.fromCharCode (profl[c++]);
\r
652 } else if (isCdnaProfile) {
\r
653 dc = jalview.analysis.CodingUtils.decodeCodon (profl[c++]);
\r
655 dc[0] = String.fromCharCode (profl[c++]);
\r
656 }wdth = this.charWidth;
\r
657 wdth /= this.fm.charsWidth (dc, 0, dc.length);
\r
659 scl = htn * scale * profl[c++];
\r
660 lm = ofont.getLineMetrics (dc, 0, 1, g.getFontMetrics ().getFontRenderContext ());
\r
661 g.setFont (ofont.deriveFont (java.awt.geom.AffineTransform.getScaleInstance (wdth, scl / lm.getAscent ())));
\r
662 lm = g.getFontMetrics ().getLineMetrics (dc, 0, 1, g);
\r
664 if (isCdnaProfile) {
\r
665 var codonTranslation = jalview.schemes.ResidueProperties.codonTranslate ( String.instantialize (dc));
\r
666 colour = this.profcolour.findColour (codonTranslation.charAt (0), column, null);
\r
668 colour = this.profcolour.findColour (dc[0], column, null);
\r
669 }g.setColor (colour === java.awt.Color.white ? java.awt.Color.lightGray : colour);
\r
670 hght = (ht + (scl - lm.getDescent () - lm.getBaselineOffsets ()[lm.getBaselineIndex ()]));
\r
671 g.drawChars (dc, 0, dc.length, x * this.charWidth, Clazz.doubleToInt (hght));
\r
677 if (_aa.threshold != null) {
\r
678 g.setColor (_aa.threshold.colour);
\r
680 g2.setStroke ( new java.awt.BasicStroke (1, 2, 1, 3, Clazz.newFloatArray (-1, [5, 3]), 0));
\r
681 y2 = Clazz.floatToInt (y - ((_aa.threshold.value - min) / range) * _aa.graphHeight);
\r
682 g.drawLine (0, y2, (eRes - sRes) * this.charWidth, y2);
\r
683 g2.setStroke ( new java.awt.BasicStroke ());
\r
684 }}, "java.awt.Graphics,jalview.datamodel.AlignmentAnnotation,~A,~N,~N,~N,~N,~N,~B,~B,~B");
\r
685 Clazz.defineMethod (c$, "drawGraph",
\r
686 function (g, _aa, aa_annotations, width, y, sRes, eRes) {
\r
687 eRes = Math.min (eRes, aa_annotations.length);
\r
688 g.setColor (java.awt.Color.white);
\r
689 g.fillRect (0, 0, width, y);
\r
690 g.setColor ( new java.awt.Color (0, 0, 180));
\r
693 for (var j = sRes; j < eRes; j++) {
\r
694 if (aa_annotations[j] != null) {
\r
695 if (aa_annotations[j].colour == null) {
\r
696 g.setColor (java.awt.Color.black);
\r
698 g.setColor (aa_annotations[j].colour);
\r
699 }height = Clazz.floatToInt ((aa_annotations[j].value / _aa.graphMax) * y);
\r
702 }g.fillRect (x, y - height, this.charWidth, height);
\r
703 }x += this.charWidth;
\r
705 }, "java.awt.Graphics,jalview.datamodel.AlignmentAnnotation,~A,~N,~N,~N,~N");
\r
706 Clazz.defineMethod (c$, "getNotCanonicalColor",
\r
707 function (lastss) {
\r
711 return new java.awt.Color (255, 125, 5);
\r
714 return new java.awt.Color (245, 115, 10);
\r
717 return new java.awt.Color (235, 135, 15);
\r
720 return new java.awt.Color (225, 105, 20);
\r
723 return new java.awt.Color (215, 145, 30);
\r
726 return new java.awt.Color (205, 95, 35);
\r
729 return new java.awt.Color (195, 155, 45);
\r
732 return new java.awt.Color (185, 85, 55);
\r
735 return new java.awt.Color (175, 165, 65);
\r
738 return new java.awt.Color (170, 75, 75);
\r
741 return new java.awt.Color (160, 175, 85);
\r
744 return new java.awt.Color (150, 65, 95);
\r
747 return new java.awt.Color (140, 185, 105);
\r
750 return new java.awt.Color (130, 55, 110);
\r
753 return new java.awt.Color (120, 195, 120);
\r
756 return new java.awt.Color (110, 45, 130);
\r
759 return new java.awt.Color (100, 205, 140);
\r
762 return new java.awt.Color (90, 35, 150);
\r
765 return new java.awt.Color (85, 215, 160);
\r
768 return new java.awt.Color (75, 25, 170);
\r
771 return new java.awt.Color (65, 225, 180);
\r
774 return new java.awt.Color (55, 15, 185);
\r
777 return new java.awt.Color (45, 235, 195);
\r
780 return new java.awt.Color (35, 5, 205);
\r
783 return new java.awt.Color (25, 245, 215);
\r
786 return new java.awt.Color (15, 0, 225);
\r
789 return new java.awt.Color (10, 255, 235);
\r
792 return new java.awt.Color (5, 150, 245);
\r
795 return new java.awt.Color (0, 80, 255);
\r
797 System.out.println ("This is not a interaction : " + lastss);
\r
801 c$.GLYPHLINE_COLOR = c$.prototype.GLYPHLINE_COLOR = java.awt.Color.gray;
\r
802 c$.SHEET_COLOUR = c$.prototype.SHEET_COLOUR = java.awt.Color.green;
\r
803 c$.HELIX_COLOUR = c$.prototype.HELIX_COLOUR = java.awt.Color.red;
\r
804 c$.STEM_COLOUR = c$.prototype.STEM_COLOUR = java.awt.Color.blue;
\r