X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=site%2Fj2s%2Fjalview%2Frenderer%2FAnnotationRenderer.js;h=221e5d3a373bec935506556534c9218c29ff588b;hp=00d98e4b0985aec531aac59742ce804fad12bc31;hb=b9b7a352eee79b7764c3b09c9d19663075061d8c;hpb=7301a2415adab88038b291fc54caeeb3a5a47a44 diff --git a/site/j2s/jalview/renderer/AnnotationRenderer.js b/site/j2s/jalview/renderer/AnnotationRenderer.js index 00d98e4..221e5d3 100644 --- a/site/j2s/jalview/renderer/AnnotationRenderer.js +++ b/site/j2s/jalview/renderer/AnnotationRenderer.js @@ -1,805 +1,805 @@ -Clazz.declarePackage ("jalview.renderer"); -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 () { -c$ = Clazz.decorateAsClass (function () { -this.debugRedraw = false; -this.charWidth = 0; -this.endRes = 0; -this.charHeight = 0; -this.validCharWidth = false; -this.hasHiddenColumns = false; -this.fm = null; -this.MAC = false; -this.av_renderHistogram = true; -this.av_renderProfile = true; -this.av_normaliseProfile = false; -this.profcolour = null; -this.columnSelection = null; -this.hconsensus = null; -this.complementConsensus = null; -this.hStrucConsensus = null; -this.av_ignoreGapsConsensus = false; -this.fadedImage = null; -this.annotationPanel = null; -this.imgWidth = 0; -this.sOffset = 0; -this.visHeight = 0; -this.useClip = true; -this.canClip = false; -this.rna = false; -this.sdNOTCANONICAL_COLOUR = null; -Clazz.instantialize (this, arguments); -}, jalview.renderer, "AnnotationRenderer"); -Clazz.prepareFields (c$, function () { -this.MAC = jalview.util.Platform.isAMac (); -}); -Clazz.makeConstructor (c$, -function () { -this.construct (false); -}); -Clazz.makeConstructor (c$, -function (debugRedraw) { -this.debugRedraw = debugRedraw; -}, "~B"); -Clazz.defineMethod (c$, "drawStemAnnot", -function (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd) { -g.setColor (jalview.renderer.AnnotationRenderer.STEM_COLOUR); -var sCol = (Clazz.doubleToInt (lastSSX / this.charWidth)) + startRes; -var x1 = lastSSX; -var x2 = (x * this.charWidth); -var closeparen = jalview.jsdev.RegExp.newRegex (["(\\))"]); -var dc = (column == 0 || row_annotations[column - 1] == null) ? ' ' : row_annotations[column - 1].secondaryStructure; -var diffupstream = sCol == 0 || row_annotations[sCol - 1] == null || dc != row_annotations[sCol - 1].secondaryStructure; -var diffdownstream = !validRes || !validEnd || row_annotations[column] == null || dc != row_annotations[column].secondaryStructure; -if (column > 0 && jalview.schemes.ResidueProperties.isCloseParenRNA (dc)) { -if (diffupstream) { -g.fillPolygon ( Clazz.newIntArray (-1, [lastSSX + 5, lastSSX + 5, lastSSX]), Clazz.newIntArray (-1, [y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset]), 3); -x1 += 5; -}if (diffdownstream) { -x2 -= 1; -}} else { -if (diffdownstream) { -g.fillPolygon ( Clazz.newIntArray (-1, [x2 - 5, x2 - 5, x2]), Clazz.newIntArray (-1, [y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset]), 3); -x2 -= 5; -}if (diffupstream) { -x1 += 1; -}}g.fillRect (x1, y + 4 + iconOffset, x2 - x1, 7); -}, "java.awt.Graphics,~A,~N,~N,~N,~N,~N,~N,~B,~B"); -Clazz.defineMethod (c$, "drawNotCanonicalAnnot", -function (g, nonCanColor, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd) { -g.setColor (nonCanColor); -var sCol = (Clazz.doubleToInt (lastSSX / this.charWidth)) + startRes; -var x1 = lastSSX; -var x2 = (x * this.charWidth); -var closeparen = jalview.jsdev.RegExp.newRegex (["}|]|<|[a-z]"]); -var dc = (column == 0 || row_annotations[column - 1] == null) ? "" : row_annotations[column - 1].displayCharacter; -var diffupstream = sCol == 0 || row_annotations[sCol - 1] == null || !dc.equals (row_annotations[sCol - 1].displayCharacter); -var diffdownstream = !validRes || !validEnd || row_annotations[column] == null || !dc.equals (row_annotations[column].displayCharacter); -if (column > 0 && closeparen.search (dc)) { -if (diffupstream) { -g.fillPolygon ( Clazz.newIntArray (-1, [lastSSX + 5, lastSSX + 5, lastSSX]), Clazz.newIntArray (-1, [y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset]), 3); -x1 += 5; -}if (diffdownstream) { -x2 -= 1; -}} else { -if (diffdownstream) { -g.fillPolygon ( Clazz.newIntArray (-1, [x2 - 5, x2 - 5, x2]), Clazz.newIntArray (-1, [y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset]), 3); -x2 -= 5; -}if (diffupstream) { -x1 += 1; -}}g.fillRect (x1, y + 4 + iconOffset, x2 - x1, 7); -}, "java.awt.Graphics,java.awt.Color,~A,~N,~N,~N,~N,~N,~N,~B,~B"); -Clazz.defineMethod (c$, "updateFromAwtRenderPanel", -function (annotPanel, av) { -this.fm = annotPanel.getFontMetrics (); -this.annotationPanel = annotPanel; -this.fadedImage = annotPanel.getFadedImage (); -this.imgWidth = annotPanel.getFadedImageWidth (); -var bounds = annotPanel.getVisibleVRange (); -if (bounds != null) { -this.sOffset = bounds[0]; -this.visHeight = bounds[1]; -if (this.visHeight == 0) { -this.useClip = false; -} else { -this.useClip = this.canClip; -}} else { -this.useClip = false; -}this.updateFromAlignViewport (av); -}, "jalview.renderer.AwtRenderPanelI,jalview.api.AlignViewportI"); -Clazz.defineMethod (c$, "updateFromAlignViewport", -function (av) { -this.charWidth = av.getCharWidth (); -this.endRes = av.getEndRes (); -this.charHeight = av.getCharHeight (); -this.hasHiddenColumns = av.hasHiddenColumns (); -this.validCharWidth = av.isValidCharWidth (); -this.av_renderHistogram = av.isShowConsensusHistogram (); -this.av_renderProfile = av.isShowSequenceLogo (); -this.av_normaliseProfile = av.isNormaliseSequenceLogo (); -this.profcolour = av.getGlobalColourScheme (); -if (this.profcolour == null) { -this.profcolour = av.getAlignment ().isNucleotide () ? new jalview.schemes.NucleotideColourScheme () : new jalview.schemes.ZappoColourScheme (); -}this.columnSelection = av.getColumnSelection (); -this.hconsensus = av.getSequenceConsensusHash (); -this.complementConsensus = av.getComplementConsensusHash (); -this.hStrucConsensus = av.getRnaStructureConsensusHash (); -this.av_ignoreGapsConsensus = av.isIgnoreGapsConsensus (); -}, "jalview.api.AlignViewportI"); -Clazz.defineMethod (c$, "getProfileFor", -function (aa, column) { -if (aa.autoCalculated && (aa.label.startsWith ("Consensus") || aa.label.startsWith ("cDNA Consensus"))) { -var forComplement = aa.label.startsWith ("cDNA Consensus"); -if (aa.groupRef != null && aa.groupRef.consensusData != null && aa.groupRef.isShowSequenceLogo ()) { -return jalview.analysis.AAFrequency.extractProfile (aa.groupRef.consensusData[column], aa.groupRef.getIgnoreGapsConsensus ()); -}if (aa.groupRef == null && aa.sequenceRef == null) { -if (forComplement) { -return jalview.analysis.AAFrequency.extractCdnaProfile (this.complementConsensus[column], this.av_ignoreGapsConsensus); -} else { -return jalview.analysis.AAFrequency.extractProfile (this.hconsensus[column], this.av_ignoreGapsConsensus); -}}} else { -if (aa.autoCalculated && aa.label.startsWith ("StrucConsensus")) { -if (aa.groupRef == null && aa.sequenceRef == null && this.hStrucConsensus != null && this.hStrucConsensus.length > column) { -return jalview.analysis.StructureFrequency.extractProfile (this.hStrucConsensus[column], this.av_ignoreGapsConsensus); -}}}return null; -}, "jalview.datamodel.AlignmentAnnotation,~N"); -Clazz.defineMethod (c$, "drawComponent", -function (annotPanel, av, g, activeRow, startRes, endRes) { -var stime = System.currentTimeMillis (); -var usedFaded = false; -this.updateFromAwtRenderPanel (annotPanel, av); -this.fm = g.getFontMetrics (); -var aa = av.getAlignment ().getAlignmentAnnotation (); -var temp = 0; -if (aa == null) { -return false; -}var x = 0; -var y = 0; -var column = 0; -var lastSS; -var lastSSX; -var iconOffset = 0; -var validRes = false; -var validEnd = false; -var labelAllCols = false; -var centreColLabels; -var centreColLabelsDef = av.isCentreColumnLabels (); -var scaleColLabel = false; -var consensusAnnot = av.getAlignmentConsensusAnnotation (); -var structConsensusAnnot = av.getAlignmentStrucConsensusAnnotation (); -var complementConsensusAnnot = av.getComplementConsensusAnnotation (); -var renderHistogram = true; -var renderProfile = true; -var normaliseProfile = false; -var isRNA = this.rna; -var graphGroupDrawn = new java.util.BitSet (); -var charOffset = 0; -var fmWidth; -var fmScaling = 1; -var ofont = g.getFont (); -var yfrom = 0; -var f_i = 0; -var yto = 0; -var f_to = 0; -var clipst = false; -var clipend = false; -for (var i = 0; i < aa.length; i++) { -var row = aa[i]; -isRNA = row.isRNA (); -{ -if (row.groupRef != null && row === row.groupRef.getConsensus ()) { -renderHistogram = row.groupRef.isShowConsensusHistogram (); -renderProfile = row.groupRef.isShowSequenceLogo (); -normaliseProfile = row.groupRef.isNormaliseSequenceLogo (); -} else if (row === consensusAnnot || row === structConsensusAnnot || row === complementConsensusAnnot) { -renderHistogram = this.av_renderHistogram; -renderProfile = this.av_renderProfile; -normaliseProfile = this.av_normaliseProfile; -} else { -renderHistogram = true; -}}var row_annotations = row.annotations; -if (!row.visible) { -continue; -}centreColLabels = row.centreColLabels || centreColLabelsDef; -labelAllCols = row.showAllColLabels; -scaleColLabel = row.scaleColLabel; -lastSS = ' '; -lastSSX = 0; -if (!this.useClip || ((y - this.charHeight) < this.visHeight && (y + row.height + this.charHeight * 2) >= this.sOffset)) { -if (!clipst) { -clipst = true; -yfrom = y; -f_i = i; -}yto = y; -f_to = i; -if (row.graph > 0) { -if (row.graphGroup > -1 && graphGroupDrawn.get (row.graphGroup)) { -continue; -}y += row.height; -if (row.hasText) { -iconOffset = this.charHeight - this.fm.getDescent (); -y -= this.charHeight; -}} else if (row.hasText) { -iconOffset = this.charHeight - this.fm.getDescent (); -} else { -iconOffset = 0; -}if (row.autoCalculated && av.isCalculationInProgress (row)) { -y += this.charHeight; -usedFaded = true; -g.drawImage (this.fadedImage, 0, y - row.height, this.imgWidth, y, 0, y - row.height, this.imgWidth, y, this.annotationPanel); -g.setColor (java.awt.Color.black); -continue; -}x = (startRes == 0) ? 0 : -1; -while (x < endRes - startRes) { -if (this.hasHiddenColumns) { -column = this.columnSelection.adjustForHiddenColumns (startRes + x); -if (column > row_annotations.length - 1) { -break; -}} else { -column = startRes + x; -}if ((row_annotations == null) || (row_annotations.length <= column) || (row_annotations[column] == null)) { -validRes = false; -} else { -validRes = true; -}var displayChar = validRes ? row_annotations[column].displayCharacter : null; -if (x > -1) { -if (activeRow == i) { -g.setColor (java.awt.Color.red); -if (this.columnSelection != null) { -for (var n = 0; n < this.columnSelection.size (); n++) { -var v = this.columnSelection.columnAt (n); -if (v == column) { -g.fillRect (x * this.charWidth, y, this.charWidth, this.charHeight); -}} -}}if (row.getInvalidStrucPos () > x) { -g.setColor (java.awt.Color.orange); -g.fillRect (x * this.charWidth, y, this.charWidth, this.charHeight); -} else if (row.getInvalidStrucPos () == x) { -g.setColor (java.awt.Color.orange.darker ()); -g.fillRect (x * this.charWidth, y, this.charWidth, this.charHeight); -}if (this.validCharWidth && validRes && displayChar != null && (displayChar.length > 0)) { -fmWidth = this.fm.charsWidth (displayChar.toCharArray (), 0, displayChar.length); -if (scaleColLabel) { -if (fmWidth > this.charWidth) { -fmScaling = this.charWidth; -fmScaling /= fmWidth; -g.setFont (ofont.deriveFont (java.awt.geom.AffineTransform.getScaleInstance (fmScaling, 1.0))); -fmWidth = this.charWidth; -}}charOffset = Clazz.floatToInt ((this.charWidth - fmWidth) / 2); -if (row_annotations[column].colour == null) { -g.setColor (java.awt.Color.black); -} else { -g.setColor (row_annotations[column].colour); -}if (column == 0 || row.graph > 0) { -g.drawString (displayChar, (x * this.charWidth) + charOffset, y + iconOffset); -} else if (row_annotations[column - 1] == null || (labelAllCols || !displayChar.equals (row_annotations[column - 1].displayCharacter) || (displayChar.length < 2 && row_annotations[column].secondaryStructure == ' '))) { -g.drawString (displayChar, x * this.charWidth + charOffset, y + iconOffset); -}g.setFont (ofont); -}}if (row.hasIcons) { -var ss = validRes ? row_annotations[column].secondaryStructure : '-'; -if (ss == '(') { -if (displayChar.indexOf (')') > -1) { -ss = ')'; -}}if (ss == '[') { -if ((displayChar.indexOf (']') > -1)) { -ss = ']'; -}}if (ss == '{') { -if (displayChar.indexOf ('}') > -1) { -ss = '}'; -}}if (ss == '<') { -if (displayChar.indexOf ('<') > -1) { -ss = '>'; -}}if (ss.charCodeAt (0) >= 65) { -if (displayChar.indexOf (ss.charCodeAt (0) + 32) > -1) { -ss = String.fromCharCode (ss.charCodeAt (0) + 32); -}}if (!validRes || (ss != lastSS)) { -if (x > -1) { -var nb_annot = x - temp; -switch (lastSS) { -case '(': -case ')': -this.drawStemAnnot (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); -temp = x; -break; -case 'H': -if (!isRNA) { -this.drawHelixAnnot (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); -break; -}case 'E': -if (!isRNA) { -this.drawSheetAnnot (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); -break; -}case '{': -case '}': -case '[': -case ']': -case '>': -case '<': -case 'A': -case 'a': -case 'B': -case 'b': -case 'C': -case 'c': -case 'D': -case 'd': -case 'e': -case 'F': -case 'f': -case 'G': -case 'g': -case 'h': -case 'I': -case 'i': -case 'J': -case 'j': -case 'K': -case 'k': -case 'L': -case 'l': -case 'M': -case 'm': -case 'N': -case 'n': -case 'O': -case 'o': -case 'P': -case 'p': -case 'Q': -case 'q': -case 'R': -case 'r': -case 'S': -case 's': -case 'T': -case 't': -case 'U': -case 'u': -case 'V': -case 'v': -case 'W': -case 'w': -case 'X': -case 'x': -case 'Y': -case 'y': -case 'Z': -case 'z': -var nonCanColor = this.getNotCanonicalColor (lastSS); -this.drawNotCanonicalAnnot (g, nonCanColor, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); -temp = x; -break; -default: -g.setColor (java.awt.Color.gray); -g.fillRect (lastSSX, y + 6 + iconOffset, (x * this.charWidth) - lastSSX, 2); -temp = x; -break; -} -}if (validRes) { -lastSS = ss; -} else { -lastSS = ' '; -}if (x > -1) { -lastSSX = (x * this.charWidth); -}}}column++; -x++; -} -if (column >= row_annotations.length) { -column = row_annotations.length - 1; -validEnd = false; -} else { -validEnd = true; -}if ((row_annotations == null) || (row_annotations.length <= column) || (row_annotations[column] == null)) { -validRes = false; -} else { -validRes = true; -}if (row.hasIcons) { -switch (lastSS) { -case 'H': -if (!isRNA) { -this.drawHelixAnnot (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); -break; -}case 'E': -if (!isRNA) { -this.drawSheetAnnot (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); -break; -}case '(': -case ')': -this.drawStemAnnot (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); -break; -case '{': -case '}': -case '[': -case ']': -case '>': -case '<': -case 'A': -case 'a': -case 'B': -case 'b': -case 'C': -case 'c': -case 'D': -case 'd': -case 'e': -case 'F': -case 'f': -case 'G': -case 'g': -case 'h': -case 'I': -case 'i': -case 'J': -case 'j': -case 'K': -case 'k': -case 'L': -case 'l': -case 'M': -case 'm': -case 'N': -case 'n': -case 'O': -case 'o': -case 'P': -case 'p': -case 'Q': -case 'q': -case 'R': -case 'r': -case 'T': -case 't': -case 'U': -case 'u': -case 'V': -case 'v': -case 'W': -case 'w': -case 'X': -case 'x': -case 'Y': -case 'y': -case 'Z': -case 'z': -var nonCanColor = this.getNotCanonicalColor (lastSS); -this.drawNotCanonicalAnnot (g, nonCanColor, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); -break; -default: -this.drawGlyphLine (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); -break; -} -}if (row.graph > 0 && row.graphHeight > 0) { -if (row.graph == 2) { -if (row.graphGroup > -1 && !graphGroupDrawn.get (row.graphGroup)) { -var groupmax = -999999; -var groupmin = 9999999; -for (var gg = 0; gg < aa.length; gg++) { -if (aa[gg].graphGroup != row.graphGroup) { -continue; -}if (aa[gg] !== row) { -aa[gg].visible = false; -}if (aa[gg].graphMax > groupmax) { -groupmax = aa[gg].graphMax; -}if (aa[gg].graphMin < groupmin) { -groupmin = aa[gg].graphMin; -}} -for (var gg = 0; gg < aa.length; gg++) { -if (aa[gg].graphGroup == row.graphGroup) { -this.drawLineGraph (g, aa[gg], aa[gg].annotations, startRes, endRes, y, groupmin, groupmax, row.graphHeight); -}} -graphGroupDrawn.set (row.graphGroup); -} else { -this.drawLineGraph (g, row, row_annotations, startRes, endRes, y, row.graphMin, row.graphMax, row.graphHeight); -}} else if (row.graph == 1) { -this.drawBarGraph (g, row, row_annotations, startRes, endRes, row.graphMin, row.graphMax, y, renderHistogram, renderProfile, normaliseProfile); -}}} else { -if (clipst && !clipend) { -clipend = true; -}}if (row.graph > 0 && row.hasText) { -y += this.charHeight; -}if (row.graph == 0) { -y += aa[i].height; -}} -if (this.debugRedraw) { -if (this.canClip) { -if (clipst) { -System.err.println ("Start clip at : " + yfrom + " (index " + f_i + ")"); -}if (clipend) { -System.err.println ("End clip at : " + yto + " (index " + f_to + ")"); -}};System.err.println ("Annotation Rendering time:" + (System.currentTimeMillis () - stime)); -};return !usedFaded; -}, "jalview.renderer.AwtRenderPanelI,jalview.api.AlignViewportI,java.awt.Graphics,~N,~N,~N"); -Clazz.defineMethod (c$, "drawGlyphLine", -function (g, row, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd) { -g.setColor (jalview.renderer.AnnotationRenderer.GLYPHLINE_COLOR); -g.fillRect (lastSSX, y + 6 + iconOffset, (x * this.charWidth) - lastSSX, 2); -}, "java.awt.Graphics,~A,~N,~N,~N,~N,~N,~N,~B,~B"); -Clazz.defineMethod (c$, "drawSheetAnnot", -function (g, row, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd) { -g.setColor (jalview.renderer.AnnotationRenderer.SHEET_COLOUR); -if (!validEnd || !validRes || row == null || row[column] == null || row[column].secondaryStructure != 'E') { -g.fillRect (lastSSX, y + 4 + iconOffset, (x * this.charWidth) - lastSSX - 4, 7); -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); -} else { -g.fillRect (lastSSX, y + 4 + iconOffset, (x + 1) * this.charWidth - lastSSX, 7); -}}, "java.awt.Graphics,~A,~N,~N,~N,~N,~N,~N,~B,~B"); -Clazz.defineMethod (c$, "drawHelixAnnot", -function (g, row, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd) { -g.setColor (jalview.renderer.AnnotationRenderer.HELIX_COLOUR); -var sCol = (Clazz.doubleToInt (lastSSX / this.charWidth)) + startRes; -var x1 = lastSSX; -var x2 = (x * this.charWidth); -if (this.MAC) { -var ofs = Clazz.doubleToInt (this.charWidth / 2); -g.fillRoundRect (lastSSX, y + 4 + iconOffset, x2 - x1, 8, 8, 8); -if (sCol == 0 || row[sCol - 1] == null || row[sCol - 1].secondaryStructure != 'H') { -} else { -g.fillRoundRect (lastSSX, y + 4 + iconOffset, x2 - x1 - ofs + 1, 8, 0, 0); -}if (!validRes || row[column] == null || row[column].secondaryStructure != 'H') { -} else { -g.fillRoundRect (lastSSX + ofs, y + 4 + iconOffset, x2 - x1 - ofs + 1, 8, 0, 0); -}return; -}if (sCol == 0 || row[sCol - 1] == null || row[sCol - 1].secondaryStructure != 'H') { -g.fillArc (lastSSX, y + 4 + iconOffset, this.charWidth, 8, 90, 180); -x1 += Clazz.doubleToInt (this.charWidth / 2); -}if (!validRes || row[column] == null || row[column].secondaryStructure != 'H') { -g.fillArc ((x * this.charWidth) - this.charWidth, y + 4 + iconOffset, this.charWidth, 8, 270, 180); -x2 -= Clazz.doubleToInt (this.charWidth / 2); -}g.fillRect (x1, y + 4 + iconOffset, x2 - x1, 8); -}, "java.awt.Graphics,~A,~N,~N,~N,~N,~N,~N,~B,~B"); -Clazz.defineMethod (c$, "drawLineGraph", -function (g, _aa, aa_annotations, sRes, eRes, y, min, max, graphHeight) { -if (sRes > aa_annotations.length) { -return; -}var x = 0; -if (eRes < this.endRes) { -eRes++; -}eRes = Math.min (eRes, aa_annotations.length); -if (sRes == 0) { -x++; -}var y1 = y; -var y2 = y; -var range = max - min; -if (min < 0) { -y2 = y - Clazz.floatToInt ((0 - min / range) * graphHeight); -}g.setColor (java.awt.Color.gray); -g.drawLine (x - this.charWidth, y2, (eRes - sRes + 1) * this.charWidth, y2); -eRes = Math.min (eRes, aa_annotations.length); -var column; -var aaMax = aa_annotations.length - 1; -while (x < eRes - sRes) { -column = sRes + x; -if (this.hasHiddenColumns) { -column = this.columnSelection.adjustForHiddenColumns (column); -}if (column > aaMax) { -break; -}if (aa_annotations[column] == null || aa_annotations[column - 1] == null) { -x++; -continue; -}if (aa_annotations[column].colour == null) { -g.setColor (java.awt.Color.black); -} else { -g.setColor (aa_annotations[column].colour); -}y1 = y - Clazz.floatToInt (((aa_annotations[column - 1].value - min) / range) * graphHeight); -y2 = y - Clazz.floatToInt (((aa_annotations[column].value - min) / range) * graphHeight); -g.drawLine (x * this.charWidth - Clazz.doubleToInt (this.charWidth / 2), y1, x * this.charWidth + Clazz.doubleToInt (this.charWidth / 2), y2); -x++; -} -if (_aa.threshold != null) { -g.setColor (_aa.threshold.colour); -var g2 = g; -g2.setStroke ( new java.awt.BasicStroke (1, 2, 1, 3, Clazz.newFloatArray (-1, [5, 3]), 0)); -y2 = Clazz.floatToInt (y - ((_aa.threshold.value - min) / range) * graphHeight); -g.drawLine (0, y2, (eRes - sRes) * this.charWidth, y2); -g2.setStroke ( new java.awt.BasicStroke ()); -}}, "java.awt.Graphics,jalview.datamodel.AlignmentAnnotation,~A,~N,~N,~N,~N,~N,~N"); -Clazz.defineMethod (c$, "drawBarGraph", -function (g, _aa, aa_annotations, sRes, eRes, min, max, y, renderHistogram, renderProfile, normaliseProfile) { -if (sRes > aa_annotations.length) { -return; -}var ofont = g.getFont (); -eRes = Math.min (eRes, aa_annotations.length); -var x = 0; -var y1 = y; -var y2 = y; -var range = max - min; -if (min < 0) { -y2 = y - Clazz.floatToInt ((0 - min / (range)) * _aa.graphHeight); -}g.setColor (java.awt.Color.gray); -g.drawLine (x, y2, (eRes - sRes) * this.charWidth, y2); -var column; -var aaMax = aa_annotations.length - 1; -while (x < eRes - sRes) { -column = sRes + x; -if (this.hasHiddenColumns) { -column = this.columnSelection.adjustForHiddenColumns (column); -}if (column > aaMax) { -break; -}if (aa_annotations[column] == null) { -x++; -continue; -}if (aa_annotations[column].colour == null) { -g.setColor (java.awt.Color.black); -} else { -g.setColor (aa_annotations[column].colour); -}y1 = y - Clazz.floatToInt (((aa_annotations[column].value - min) / (range)) * _aa.graphHeight); -if (renderHistogram) { -if (y1 - y2 > 0) { -g.fillRect (x * this.charWidth, y2, this.charWidth, y1 - y2); -} else { -g.fillRect (x * this.charWidth, y1, this.charWidth, y2 - y1); -}}if (renderProfile) { -var profl = this.getProfileFor (_aa, column); -if (profl != null && profl[2] != 0) { -var isStructureProfile = profl[0] == 1; -var isCdnaProfile = profl[0] == 2; -var ht = normaliseProfile ? y - _aa.graphHeight : y1; -var htn = normaliseProfile ? _aa.graphHeight : (y2 - y1); -var hght; -var wdth; -var ht2 = 0; -var dc; -dc = Clazz.newCharArray (isStructureProfile ? 2 : (isCdnaProfile ? 3 : 1), '\0'); -var lm = g.getFontMetrics (ofont).getLineMetrics ("Q", g); -var scale = 1 / (normaliseProfile ? profl[2] : 100); -var ofontHeight = 1 / lm.getAscent (); -var scl = 0.0; -var c = 3; -var valuesProcessed = 0; -while (valuesProcessed < profl[1]) { -if (isStructureProfile) { -dc[0] = String.fromCharCode (profl[c++]); -dc[1] = String.fromCharCode (profl[c++]); -} else if (isCdnaProfile) { -dc = jalview.analysis.CodingUtils.decodeCodon (profl[c++]); -} else { -dc[0] = String.fromCharCode (profl[c++]); -}wdth = this.charWidth; -wdth /= this.fm.charsWidth (dc, 0, dc.length); -ht += scl; -scl = htn * scale * profl[c++]; -lm = ofont.getLineMetrics (dc, 0, 1, g.getFontMetrics ().getFontRenderContext ()); -g.setFont (ofont.deriveFont (java.awt.geom.AffineTransform.getScaleInstance (wdth, scl / lm.getAscent ()))); -lm = g.getFontMetrics ().getLineMetrics (dc, 0, 1, g); -var colour = null; -if (isCdnaProfile) { -var codonTranslation = jalview.schemes.ResidueProperties.codonTranslate ( String.instantialize (dc)); -colour = this.profcolour.findColour (codonTranslation.charAt (0), column, null); -} else { -colour = this.profcolour.findColour (dc[0], column, null); -}g.setColor (colour === java.awt.Color.white ? java.awt.Color.lightGray : colour); -hght = (ht + (scl - lm.getDescent () - lm.getBaselineOffsets ()[lm.getBaselineIndex ()])); -g.drawChars (dc, 0, dc.length, x * this.charWidth, Clazz.doubleToInt (hght)); -valuesProcessed++; -} -g.setFont (ofont); -}}x++; -} -if (_aa.threshold != null) { -g.setColor (_aa.threshold.colour); -var g2 = g; -g2.setStroke ( new java.awt.BasicStroke (1, 2, 1, 3, Clazz.newFloatArray (-1, [5, 3]), 0)); -y2 = Clazz.floatToInt (y - ((_aa.threshold.value - min) / range) * _aa.graphHeight); -g.drawLine (0, y2, (eRes - sRes) * this.charWidth, y2); -g2.setStroke ( new java.awt.BasicStroke ()); -}}, "java.awt.Graphics,jalview.datamodel.AlignmentAnnotation,~A,~N,~N,~N,~N,~N,~B,~B,~B"); -Clazz.defineMethod (c$, "drawGraph", -function (g, _aa, aa_annotations, width, y, sRes, eRes) { -eRes = Math.min (eRes, aa_annotations.length); -g.setColor (java.awt.Color.white); -g.fillRect (0, 0, width, y); -g.setColor ( new java.awt.Color (0, 0, 180)); -var x = 0; -var height; -for (var j = sRes; j < eRes; j++) { -if (aa_annotations[j] != null) { -if (aa_annotations[j].colour == null) { -g.setColor (java.awt.Color.black); -} else { -g.setColor (aa_annotations[j].colour); -}height = Clazz.floatToInt ((aa_annotations[j].value / _aa.graphMax) * y); -if (height > y) { -height = y; -}g.fillRect (x, y - height, this.charWidth, height); -}x += this.charWidth; -} -}, "java.awt.Graphics,jalview.datamodel.AlignmentAnnotation,~A,~N,~N,~N,~N"); -Clazz.defineMethod (c$, "getNotCanonicalColor", -function (lastss) { -switch (lastss) { -case '{': -case '}': -return new java.awt.Color (255, 125, 5); -case '[': -case ']': -return new java.awt.Color (245, 115, 10); -case '>': -case '<': -return new java.awt.Color (235, 135, 15); -case 'A': -case 'a': -return new java.awt.Color (225, 105, 20); -case 'B': -case 'b': -return new java.awt.Color (215, 145, 30); -case 'C': -case 'c': -return new java.awt.Color (205, 95, 35); -case 'D': -case 'd': -return new java.awt.Color (195, 155, 45); -case 'E': -case 'e': -return new java.awt.Color (185, 85, 55); -case 'F': -case 'f': -return new java.awt.Color (175, 165, 65); -case 'G': -case 'g': -return new java.awt.Color (170, 75, 75); -case 'H': -case 'h': -return new java.awt.Color (160, 175, 85); -case 'I': -case 'i': -return new java.awt.Color (150, 65, 95); -case 'J': -case 'j': -return new java.awt.Color (140, 185, 105); -case 'K': -case 'k': -return new java.awt.Color (130, 55, 110); -case 'L': -case 'l': -return new java.awt.Color (120, 195, 120); -case 'M': -case 'm': -return new java.awt.Color (110, 45, 130); -case 'N': -case 'n': -return new java.awt.Color (100, 205, 140); -case 'O': -case 'o': -return new java.awt.Color (90, 35, 150); -case 'P': -case 'p': -return new java.awt.Color (85, 215, 160); -case 'Q': -case 'q': -return new java.awt.Color (75, 25, 170); -case 'R': -case 'r': -return new java.awt.Color (65, 225, 180); -case 'S': -case 's': -return new java.awt.Color (55, 15, 185); -case 'T': -case 't': -return new java.awt.Color (45, 235, 195); -case 'U': -case 'u': -return new java.awt.Color (35, 5, 205); -case 'V': -case 'v': -return new java.awt.Color (25, 245, 215); -case 'W': -case 'w': -return new java.awt.Color (15, 0, 225); -case 'X': -case 'x': -return new java.awt.Color (10, 255, 235); -case 'Y': -case 'y': -return new java.awt.Color (5, 150, 245); -case 'Z': -case 'z': -return new java.awt.Color (0, 80, 255); -default: -System.out.println ("This is not a interaction : " + lastss); -return null; -} -}, "~S"); -c$.GLYPHLINE_COLOR = c$.prototype.GLYPHLINE_COLOR = java.awt.Color.gray; -c$.SHEET_COLOUR = c$.prototype.SHEET_COLOUR = java.awt.Color.green; -c$.HELIX_COLOUR = c$.prototype.HELIX_COLOUR = java.awt.Color.red; -c$.STEM_COLOUR = c$.prototype.STEM_COLOUR = java.awt.Color.blue; -}); +Clazz.declarePackage ("jalview.renderer"); +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 () { +c$ = Clazz.decorateAsClass (function () { +this.debugRedraw = false; +this.charWidth = 0; +this.endRes = 0; +this.charHeight = 0; +this.validCharWidth = false; +this.hasHiddenColumns = false; +this.fm = null; +this.MAC = false; +this.av_renderHistogram = true; +this.av_renderProfile = true; +this.av_normaliseProfile = false; +this.profcolour = null; +this.columnSelection = null; +this.hconsensus = null; +this.complementConsensus = null; +this.hStrucConsensus = null; +this.av_ignoreGapsConsensus = false; +this.fadedImage = null; +this.annotationPanel = null; +this.imgWidth = 0; +this.sOffset = 0; +this.visHeight = 0; +this.useClip = true; +this.canClip = false; +this.rna = false; +this.sdNOTCANONICAL_COLOUR = null; +Clazz.instantialize (this, arguments); +}, jalview.renderer, "AnnotationRenderer"); +Clazz.prepareFields (c$, function () { +this.MAC = jalview.util.Platform.isAMac (); +}); +Clazz.makeConstructor (c$, +function () { +this.construct (false); +}); +Clazz.makeConstructor (c$, +function (debugRedraw) { +this.debugRedraw = debugRedraw; +}, "~B"); +Clazz.defineMethod (c$, "drawStemAnnot", +function (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd) { +g.setColor (jalview.renderer.AnnotationRenderer.STEM_COLOUR); +var sCol = (Clazz.doubleToInt (lastSSX / this.charWidth)) + startRes; +var x1 = lastSSX; +var x2 = (x * this.charWidth); +var closeparen = jalview.jsdev.RegExp.newRegex (["(\\))"]); +var dc = (column == 0 || row_annotations[column - 1] == null) ? ' ' : row_annotations[column - 1].secondaryStructure; +var diffupstream = sCol == 0 || row_annotations[sCol - 1] == null || dc != row_annotations[sCol - 1].secondaryStructure; +var diffdownstream = !validRes || !validEnd || row_annotations[column] == null || dc != row_annotations[column].secondaryStructure; +if (column > 0 && jalview.schemes.ResidueProperties.isCloseParenRNA (dc)) { +if (diffupstream) { +g.fillPolygon ( Clazz.newIntArray (-1, [lastSSX + 5, lastSSX + 5, lastSSX]), Clazz.newIntArray (-1, [y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset]), 3); +x1 += 5; +}if (diffdownstream) { +x2 -= 1; +}} else { +if (diffdownstream) { +g.fillPolygon ( Clazz.newIntArray (-1, [x2 - 5, x2 - 5, x2]), Clazz.newIntArray (-1, [y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset]), 3); +x2 -= 5; +}if (diffupstream) { +x1 += 1; +}}g.fillRect (x1, y + 4 + iconOffset, x2 - x1, 7); +}, "java.awt.Graphics,~A,~N,~N,~N,~N,~N,~N,~B,~B"); +Clazz.defineMethod (c$, "drawNotCanonicalAnnot", +function (g, nonCanColor, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd) { +g.setColor (nonCanColor); +var sCol = (Clazz.doubleToInt (lastSSX / this.charWidth)) + startRes; +var x1 = lastSSX; +var x2 = (x * this.charWidth); +var closeparen = jalview.jsdev.RegExp.newRegex (["}|]|<|[a-z]"]); +var dc = (column == 0 || row_annotations[column - 1] == null) ? "" : row_annotations[column - 1].displayCharacter; +var diffupstream = sCol == 0 || row_annotations[sCol - 1] == null || !dc.equals (row_annotations[sCol - 1].displayCharacter); +var diffdownstream = !validRes || !validEnd || row_annotations[column] == null || !dc.equals (row_annotations[column].displayCharacter); +if (column > 0 && closeparen.search (dc)) { +if (diffupstream) { +g.fillPolygon ( Clazz.newIntArray (-1, [lastSSX + 5, lastSSX + 5, lastSSX]), Clazz.newIntArray (-1, [y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset]), 3); +x1 += 5; +}if (diffdownstream) { +x2 -= 1; +}} else { +if (diffdownstream) { +g.fillPolygon ( Clazz.newIntArray (-1, [x2 - 5, x2 - 5, x2]), Clazz.newIntArray (-1, [y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset]), 3); +x2 -= 5; +}if (diffupstream) { +x1 += 1; +}}g.fillRect (x1, y + 4 + iconOffset, x2 - x1, 7); +}, "java.awt.Graphics,java.awt.Color,~A,~N,~N,~N,~N,~N,~N,~B,~B"); +Clazz.defineMethod (c$, "updateFromAwtRenderPanel", +function (annotPanel, av) { +this.fm = annotPanel.getFontMetrics (); +this.annotationPanel = annotPanel; +this.fadedImage = annotPanel.getFadedImage (); +this.imgWidth = annotPanel.getFadedImageWidth (); +var bounds = annotPanel.getVisibleVRange (); +if (bounds != null) { +this.sOffset = bounds[0]; +this.visHeight = bounds[1]; +if (this.visHeight == 0) { +this.useClip = false; +} else { +this.useClip = this.canClip; +}} else { +this.useClip = false; +}this.updateFromAlignViewport (av); +}, "jalview.renderer.AwtRenderPanelI,jalview.api.AlignViewportI"); +Clazz.defineMethod (c$, "updateFromAlignViewport", +function (av) { +this.charWidth = av.getCharWidth (); +this.endRes = av.getEndRes (); +this.charHeight = av.getCharHeight (); +this.hasHiddenColumns = av.hasHiddenColumns (); +this.validCharWidth = av.isValidCharWidth (); +this.av_renderHistogram = av.isShowConsensusHistogram (); +this.av_renderProfile = av.isShowSequenceLogo (); +this.av_normaliseProfile = av.isNormaliseSequenceLogo (); +this.profcolour = av.getGlobalColourScheme (); +if (this.profcolour == null) { +this.profcolour = av.getAlignment ().isNucleotide () ? new jalview.schemes.NucleotideColourScheme () : new jalview.schemes.ZappoColourScheme (); +}this.columnSelection = av.getColumnSelection (); +this.hconsensus = av.getSequenceConsensusHash (); +this.complementConsensus = av.getComplementConsensusHash (); +this.hStrucConsensus = av.getRnaStructureConsensusHash (); +this.av_ignoreGapsConsensus = av.isIgnoreGapsConsensus (); +}, "jalview.api.AlignViewportI"); +Clazz.defineMethod (c$, "getProfileFor", +function (aa, column) { +if (aa.autoCalculated && (aa.label.startsWith ("Consensus") || aa.label.startsWith ("cDNA Consensus"))) { +var forComplement = aa.label.startsWith ("cDNA Consensus"); +if (aa.groupRef != null && aa.groupRef.consensusData != null && aa.groupRef.isShowSequenceLogo ()) { +return jalview.analysis.AAFrequency.extractProfile (aa.groupRef.consensusData[column], aa.groupRef.getIgnoreGapsConsensus ()); +}if (aa.groupRef == null && aa.sequenceRef == null) { +if (forComplement) { +return jalview.analysis.AAFrequency.extractCdnaProfile (this.complementConsensus[column], this.av_ignoreGapsConsensus); +} else { +return jalview.analysis.AAFrequency.extractProfile (this.hconsensus[column], this.av_ignoreGapsConsensus); +}}} else { +if (aa.autoCalculated && aa.label.startsWith ("StrucConsensus")) { +if (aa.groupRef == null && aa.sequenceRef == null && this.hStrucConsensus != null && this.hStrucConsensus.length > column) { +return jalview.analysis.StructureFrequency.extractProfile (this.hStrucConsensus[column], this.av_ignoreGapsConsensus); +}}}return null; +}, "jalview.datamodel.AlignmentAnnotation,~N"); +Clazz.defineMethod (c$, "drawComponent", +function (annotPanel, av, g, activeRow, startRes, endRes) { +var stime = System.currentTimeMillis (); +var usedFaded = false; +this.updateFromAwtRenderPanel (annotPanel, av); +this.fm = g.getFontMetrics (); +var aa = av.getAlignment ().getAlignmentAnnotation (); +var temp = 0; +if (aa == null) { +return false; +}var x = 0; +var y = 0; +var column = 0; +var lastSS; +var lastSSX; +var iconOffset = 0; +var validRes = false; +var validEnd = false; +var labelAllCols = false; +var centreColLabels; +var centreColLabelsDef = av.isCentreColumnLabels (); +var scaleColLabel = false; +var consensusAnnot = av.getAlignmentConsensusAnnotation (); +var structConsensusAnnot = av.getAlignmentStrucConsensusAnnotation (); +var complementConsensusAnnot = av.getComplementConsensusAnnotation (); +var renderHistogram = true; +var renderProfile = true; +var normaliseProfile = false; +var isRNA = this.rna; +var graphGroupDrawn = new java.util.BitSet (); +var charOffset = 0; +var fmWidth; +var fmScaling = 1; +var ofont = g.getFont (); +var yfrom = 0; +var f_i = 0; +var yto = 0; +var f_to = 0; +var clipst = false; +var clipend = false; +for (var i = 0; i < aa.length; i++) { +var row = aa[i]; +isRNA = row.isRNA (); +{ +if (row.groupRef != null && row === row.groupRef.getConsensus ()) { +renderHistogram = row.groupRef.isShowConsensusHistogram (); +renderProfile = row.groupRef.isShowSequenceLogo (); +normaliseProfile = row.groupRef.isNormaliseSequenceLogo (); +} else if (row === consensusAnnot || row === structConsensusAnnot || row === complementConsensusAnnot) { +renderHistogram = this.av_renderHistogram; +renderProfile = this.av_renderProfile; +normaliseProfile = this.av_normaliseProfile; +} else { +renderHistogram = true; +}}var row_annotations = row.annotations; +if (!row.visible) { +continue; +}centreColLabels = row.centreColLabels || centreColLabelsDef; +labelAllCols = row.showAllColLabels; +scaleColLabel = row.scaleColLabel; +lastSS = ' '; +lastSSX = 0; +if (!this.useClip || ((y - this.charHeight) < this.visHeight && (y + row.height + this.charHeight * 2) >= this.sOffset)) { +if (!clipst) { +clipst = true; +yfrom = y; +f_i = i; +}yto = y; +f_to = i; +if (row.graph > 0) { +if (row.graphGroup > -1 && graphGroupDrawn.get (row.graphGroup)) { +continue; +}y += row.height; +if (row.hasText) { +iconOffset = this.charHeight - this.fm.getDescent (); +y -= this.charHeight; +}} else if (row.hasText) { +iconOffset = this.charHeight - this.fm.getDescent (); +} else { +iconOffset = 0; +}if (row.autoCalculated && av.isCalculationInProgress (row)) { +y += this.charHeight; +usedFaded = true; +g.drawImage (this.fadedImage, 0, y - row.height, this.imgWidth, y, 0, y - row.height, this.imgWidth, y, this.annotationPanel); +g.setColor (java.awt.Color.black); +continue; +}x = (startRes == 0) ? 0 : -1; +while (x < endRes - startRes) { +if (this.hasHiddenColumns) { +column = this.columnSelection.adjustForHiddenColumns (startRes + x); +if (column > row_annotations.length - 1) { +break; +}} else { +column = startRes + x; +}if ((row_annotations == null) || (row_annotations.length <= column) || (row_annotations[column] == null)) { +validRes = false; +} else { +validRes = true; +}var displayChar = validRes ? row_annotations[column].displayCharacter : null; +if (x > -1) { +if (activeRow == i) { +g.setColor (java.awt.Color.red); +if (this.columnSelection != null) { +for (var n = 0; n < this.columnSelection.size (); n++) { +var v = this.columnSelection.columnAt (n); +if (v == column) { +g.fillRect (x * this.charWidth, y, this.charWidth, this.charHeight); +}} +}}if (row.getInvalidStrucPos () > x) { +g.setColor (java.awt.Color.orange); +g.fillRect (x * this.charWidth, y, this.charWidth, this.charHeight); +} else if (row.getInvalidStrucPos () == x) { +g.setColor (java.awt.Color.orange.darker ()); +g.fillRect (x * this.charWidth, y, this.charWidth, this.charHeight); +}if (this.validCharWidth && validRes && displayChar != null && (displayChar.length > 0)) { +fmWidth = this.fm.charsWidth (displayChar.toCharArray (), 0, displayChar.length); +if (scaleColLabel) { +if (fmWidth > this.charWidth) { +fmScaling = this.charWidth; +fmScaling /= fmWidth; +g.setFont (ofont.deriveFont (java.awt.geom.AffineTransform.getScaleInstance (fmScaling, 1.0))); +fmWidth = this.charWidth; +}}charOffset = Clazz.floatToInt ((this.charWidth - fmWidth) / 2); +if (row_annotations[column].colour == null) { +g.setColor (java.awt.Color.black); +} else { +g.setColor (row_annotations[column].colour); +}if (column == 0 || row.graph > 0) { +g.drawString (displayChar, (x * this.charWidth) + charOffset, y + iconOffset); +} else if (row_annotations[column - 1] == null || (labelAllCols || !displayChar.equals (row_annotations[column - 1].displayCharacter) || (displayChar.length < 2 && row_annotations[column].secondaryStructure == ' '))) { +g.drawString (displayChar, x * this.charWidth + charOffset, y + iconOffset); +}g.setFont (ofont); +}}if (row.hasIcons) { +var ss = validRes ? row_annotations[column].secondaryStructure : '-'; +if (ss == '(') { +if (displayChar.indexOf (')') > -1) { +ss = ')'; +}}if (ss == '[') { +if ((displayChar.indexOf (']') > -1)) { +ss = ']'; +}}if (ss == '{') { +if (displayChar.indexOf ('}') > -1) { +ss = '}'; +}}if (ss == '<') { +if (displayChar.indexOf ('<') > -1) { +ss = '>'; +}}if (ss.charCodeAt (0) >= 65) { +if (displayChar.indexOf (ss.charCodeAt (0) + 32) > -1) { +ss = String.fromCharCode (ss.charCodeAt (0) + 32); +}}if (!validRes || (ss != lastSS)) { +if (x > -1) { +var nb_annot = x - temp; +switch (lastSS) { +case '(': +case ')': +this.drawStemAnnot (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); +temp = x; +break; +case 'H': +if (!isRNA) { +this.drawHelixAnnot (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); +break; +}case 'E': +if (!isRNA) { +this.drawSheetAnnot (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); +break; +}case '{': +case '}': +case '[': +case ']': +case '>': +case '<': +case 'A': +case 'a': +case 'B': +case 'b': +case 'C': +case 'c': +case 'D': +case 'd': +case 'e': +case 'F': +case 'f': +case 'G': +case 'g': +case 'h': +case 'I': +case 'i': +case 'J': +case 'j': +case 'K': +case 'k': +case 'L': +case 'l': +case 'M': +case 'm': +case 'N': +case 'n': +case 'O': +case 'o': +case 'P': +case 'p': +case 'Q': +case 'q': +case 'R': +case 'r': +case 'S': +case 's': +case 'T': +case 't': +case 'U': +case 'u': +case 'V': +case 'v': +case 'W': +case 'w': +case 'X': +case 'x': +case 'Y': +case 'y': +case 'Z': +case 'z': +var nonCanColor = this.getNotCanonicalColor (lastSS); +this.drawNotCanonicalAnnot (g, nonCanColor, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); +temp = x; +break; +default: +g.setColor (java.awt.Color.gray); +g.fillRect (lastSSX, y + 6 + iconOffset, (x * this.charWidth) - lastSSX, 2); +temp = x; +break; +} +}if (validRes) { +lastSS = ss; +} else { +lastSS = ' '; +}if (x > -1) { +lastSSX = (x * this.charWidth); +}}}column++; +x++; +} +if (column >= row_annotations.length) { +column = row_annotations.length - 1; +validEnd = false; +} else { +validEnd = true; +}if ((row_annotations == null) || (row_annotations.length <= column) || (row_annotations[column] == null)) { +validRes = false; +} else { +validRes = true; +}if (row.hasIcons) { +switch (lastSS) { +case 'H': +if (!isRNA) { +this.drawHelixAnnot (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); +break; +}case 'E': +if (!isRNA) { +this.drawSheetAnnot (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); +break; +}case '(': +case ')': +this.drawStemAnnot (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); +break; +case '{': +case '}': +case '[': +case ']': +case '>': +case '<': +case 'A': +case 'a': +case 'B': +case 'b': +case 'C': +case 'c': +case 'D': +case 'd': +case 'e': +case 'F': +case 'f': +case 'G': +case 'g': +case 'h': +case 'I': +case 'i': +case 'J': +case 'j': +case 'K': +case 'k': +case 'L': +case 'l': +case 'M': +case 'm': +case 'N': +case 'n': +case 'O': +case 'o': +case 'P': +case 'p': +case 'Q': +case 'q': +case 'R': +case 'r': +case 'T': +case 't': +case 'U': +case 'u': +case 'V': +case 'v': +case 'W': +case 'w': +case 'X': +case 'x': +case 'Y': +case 'y': +case 'Z': +case 'z': +var nonCanColor = this.getNotCanonicalColor (lastSS); +this.drawNotCanonicalAnnot (g, nonCanColor, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); +break; +default: +this.drawGlyphLine (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); +break; +} +}if (row.graph > 0 && row.graphHeight > 0) { +if (row.graph == 2) { +if (row.graphGroup > -1 && !graphGroupDrawn.get (row.graphGroup)) { +var groupmax = -999999; +var groupmin = 9999999; +for (var gg = 0; gg < aa.length; gg++) { +if (aa[gg].graphGroup != row.graphGroup) { +continue; +}if (aa[gg] !== row) { +aa[gg].visible = false; +}if (aa[gg].graphMax > groupmax) { +groupmax = aa[gg].graphMax; +}if (aa[gg].graphMin < groupmin) { +groupmin = aa[gg].graphMin; +}} +for (var gg = 0; gg < aa.length; gg++) { +if (aa[gg].graphGroup == row.graphGroup) { +this.drawLineGraph (g, aa[gg], aa[gg].annotations, startRes, endRes, y, groupmin, groupmax, row.graphHeight); +}} +graphGroupDrawn.set (row.graphGroup); +} else { +this.drawLineGraph (g, row, row_annotations, startRes, endRes, y, row.graphMin, row.graphMax, row.graphHeight); +}} else if (row.graph == 1) { +this.drawBarGraph (g, row, row_annotations, startRes, endRes, row.graphMin, row.graphMax, y, renderHistogram, renderProfile, normaliseProfile); +}}} else { +if (clipst && !clipend) { +clipend = true; +}}if (row.graph > 0 && row.hasText) { +y += this.charHeight; +}if (row.graph == 0) { +y += aa[i].height; +}} +if (this.debugRedraw) { +if (this.canClip) { +if (clipst) { +System.err.println ("Start clip at : " + yfrom + " (index " + f_i + ")"); +}if (clipend) { +System.err.println ("End clip at : " + yto + " (index " + f_to + ")"); +}};System.err.println ("Annotation Rendering time:" + (System.currentTimeMillis () - stime)); +};return !usedFaded; +}, "jalview.renderer.AwtRenderPanelI,jalview.api.AlignViewportI,java.awt.Graphics,~N,~N,~N"); +Clazz.defineMethod (c$, "drawGlyphLine", +function (g, row, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd) { +g.setColor (jalview.renderer.AnnotationRenderer.GLYPHLINE_COLOR); +g.fillRect (lastSSX, y + 6 + iconOffset, (x * this.charWidth) - lastSSX, 2); +}, "java.awt.Graphics,~A,~N,~N,~N,~N,~N,~N,~B,~B"); +Clazz.defineMethod (c$, "drawSheetAnnot", +function (g, row, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd) { +g.setColor (jalview.renderer.AnnotationRenderer.SHEET_COLOUR); +if (!validEnd || !validRes || row == null || row[column] == null || row[column].secondaryStructure != 'E') { +g.fillRect (lastSSX, y + 4 + iconOffset, (x * this.charWidth) - lastSSX - 4, 7); +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); +} else { +g.fillRect (lastSSX, y + 4 + iconOffset, (x + 1) * this.charWidth - lastSSX, 7); +}}, "java.awt.Graphics,~A,~N,~N,~N,~N,~N,~N,~B,~B"); +Clazz.defineMethod (c$, "drawHelixAnnot", +function (g, row, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd) { +g.setColor (jalview.renderer.AnnotationRenderer.HELIX_COLOUR); +var sCol = (Clazz.doubleToInt (lastSSX / this.charWidth)) + startRes; +var x1 = lastSSX; +var x2 = (x * this.charWidth); +if (this.MAC) { +var ofs = Clazz.doubleToInt (this.charWidth / 2); +g.fillRoundRect (lastSSX, y + 4 + iconOffset, x2 - x1, 8, 8, 8); +if (sCol == 0 || row[sCol - 1] == null || row[sCol - 1].secondaryStructure != 'H') { +} else { +g.fillRoundRect (lastSSX, y + 4 + iconOffset, x2 - x1 - ofs + 1, 8, 0, 0); +}if (!validRes || row[column] == null || row[column].secondaryStructure != 'H') { +} else { +g.fillRoundRect (lastSSX + ofs, y + 4 + iconOffset, x2 - x1 - ofs + 1, 8, 0, 0); +}return; +}if (sCol == 0 || row[sCol - 1] == null || row[sCol - 1].secondaryStructure != 'H') { +g.fillArc (lastSSX, y + 4 + iconOffset, this.charWidth, 8, 90, 180); +x1 += Clazz.doubleToInt (this.charWidth / 2); +}if (!validRes || row[column] == null || row[column].secondaryStructure != 'H') { +g.fillArc ((x * this.charWidth) - this.charWidth, y + 4 + iconOffset, this.charWidth, 8, 270, 180); +x2 -= Clazz.doubleToInt (this.charWidth / 2); +}g.fillRect (x1, y + 4 + iconOffset, x2 - x1, 8); +}, "java.awt.Graphics,~A,~N,~N,~N,~N,~N,~N,~B,~B"); +Clazz.defineMethod (c$, "drawLineGraph", +function (g, _aa, aa_annotations, sRes, eRes, y, min, max, graphHeight) { +if (sRes > aa_annotations.length) { +return; +}var x = 0; +if (eRes < this.endRes) { +eRes++; +}eRes = Math.min (eRes, aa_annotations.length); +if (sRes == 0) { +x++; +}var y1 = y; +var y2 = y; +var range = max - min; +if (min < 0) { +y2 = y - Clazz.floatToInt ((0 - min / range) * graphHeight); +}g.setColor (java.awt.Color.gray); +g.drawLine (x - this.charWidth, y2, (eRes - sRes + 1) * this.charWidth, y2); +eRes = Math.min (eRes, aa_annotations.length); +var column; +var aaMax = aa_annotations.length - 1; +while (x < eRes - sRes) { +column = sRes + x; +if (this.hasHiddenColumns) { +column = this.columnSelection.adjustForHiddenColumns (column); +}if (column > aaMax) { +break; +}if (aa_annotations[column] == null || aa_annotations[column - 1] == null) { +x++; +continue; +}if (aa_annotations[column].colour == null) { +g.setColor (java.awt.Color.black); +} else { +g.setColor (aa_annotations[column].colour); +}y1 = y - Clazz.floatToInt (((aa_annotations[column - 1].value - min) / range) * graphHeight); +y2 = y - Clazz.floatToInt (((aa_annotations[column].value - min) / range) * graphHeight); +g.drawLine (x * this.charWidth - Clazz.doubleToInt (this.charWidth / 2), y1, x * this.charWidth + Clazz.doubleToInt (this.charWidth / 2), y2); +x++; +} +if (_aa.threshold != null) { +g.setColor (_aa.threshold.colour); +var g2 = g; +g2.setStroke ( new java.awt.BasicStroke (1, 2, 1, 3, Clazz.newFloatArray (-1, [5, 3]), 0)); +y2 = Clazz.floatToInt (y - ((_aa.threshold.value - min) / range) * graphHeight); +g.drawLine (0, y2, (eRes - sRes) * this.charWidth, y2); +g2.setStroke ( new java.awt.BasicStroke ()); +}}, "java.awt.Graphics,jalview.datamodel.AlignmentAnnotation,~A,~N,~N,~N,~N,~N,~N"); +Clazz.defineMethod (c$, "drawBarGraph", +function (g, _aa, aa_annotations, sRes, eRes, min, max, y, renderHistogram, renderProfile, normaliseProfile) { +if (sRes > aa_annotations.length) { +return; +}var ofont = g.getFont (); +eRes = Math.min (eRes, aa_annotations.length); +var x = 0; +var y1 = y; +var y2 = y; +var range = max - min; +if (min < 0) { +y2 = y - Clazz.floatToInt ((0 - min / (range)) * _aa.graphHeight); +}g.setColor (java.awt.Color.gray); +g.drawLine (x, y2, (eRes - sRes) * this.charWidth, y2); +var column; +var aaMax = aa_annotations.length - 1; +while (x < eRes - sRes) { +column = sRes + x; +if (this.hasHiddenColumns) { +column = this.columnSelection.adjustForHiddenColumns (column); +}if (column > aaMax) { +break; +}if (aa_annotations[column] == null) { +x++; +continue; +}if (aa_annotations[column].colour == null) { +g.setColor (java.awt.Color.black); +} else { +g.setColor (aa_annotations[column].colour); +}y1 = y - Clazz.floatToInt (((aa_annotations[column].value - min) / (range)) * _aa.graphHeight); +if (renderHistogram) { +if (y1 - y2 > 0) { +g.fillRect (x * this.charWidth, y2, this.charWidth, y1 - y2); +} else { +g.fillRect (x * this.charWidth, y1, this.charWidth, y2 - y1); +}}if (renderProfile) { +var profl = this.getProfileFor (_aa, column); +if (profl != null && profl[2] != 0) { +var isStructureProfile = profl[0] == 1; +var isCdnaProfile = profl[0] == 2; +var ht = normaliseProfile ? y - _aa.graphHeight : y1; +var htn = normaliseProfile ? _aa.graphHeight : (y2 - y1); +var hght; +var wdth; +var ht2 = 0; +var dc; +dc = Clazz.newCharArray (isStructureProfile ? 2 : (isCdnaProfile ? 3 : 1), '\0'); +var lm = g.getFontMetrics (ofont).getLineMetrics ("Q", g); +var scale = 1 / (normaliseProfile ? profl[2] : 100); +var ofontHeight = 1 / lm.getAscent (); +var scl = 0.0; +var c = 3; +var valuesProcessed = 0; +while (valuesProcessed < profl[1]) { +if (isStructureProfile) { +dc[0] = String.fromCharCode (profl[c++]); +dc[1] = String.fromCharCode (profl[c++]); +} else if (isCdnaProfile) { +dc = jalview.analysis.CodingUtils.decodeCodon (profl[c++]); +} else { +dc[0] = String.fromCharCode (profl[c++]); +}wdth = this.charWidth; +wdth /= this.fm.charsWidth (dc, 0, dc.length); +ht += scl; +scl = htn * scale * profl[c++]; +lm = ofont.getLineMetrics (dc, 0, 1, g.getFontMetrics ().getFontRenderContext ()); +g.setFont (ofont.deriveFont (java.awt.geom.AffineTransform.getScaleInstance (wdth, scl / lm.getAscent ()))); +lm = g.getFontMetrics ().getLineMetrics (dc, 0, 1, g); +var colour = null; +if (isCdnaProfile) { +var codonTranslation = jalview.schemes.ResidueProperties.codonTranslate ( String.instantialize (dc)); +colour = this.profcolour.findColour (codonTranslation.charAt (0), column, null); +} else { +colour = this.profcolour.findColour (dc[0], column, null); +}g.setColor (colour === java.awt.Color.white ? java.awt.Color.lightGray : colour); +hght = (ht + (scl - lm.getDescent () - lm.getBaselineOffsets ()[lm.getBaselineIndex ()])); +g.drawChars (dc, 0, dc.length, x * this.charWidth, Clazz.doubleToInt (hght)); +valuesProcessed++; +} +g.setFont (ofont); +}}x++; +} +if (_aa.threshold != null) { +g.setColor (_aa.threshold.colour); +var g2 = g; +g2.setStroke ( new java.awt.BasicStroke (1, 2, 1, 3, Clazz.newFloatArray (-1, [5, 3]), 0)); +y2 = Clazz.floatToInt (y - ((_aa.threshold.value - min) / range) * _aa.graphHeight); +g.drawLine (0, y2, (eRes - sRes) * this.charWidth, y2); +g2.setStroke ( new java.awt.BasicStroke ()); +}}, "java.awt.Graphics,jalview.datamodel.AlignmentAnnotation,~A,~N,~N,~N,~N,~N,~B,~B,~B"); +Clazz.defineMethod (c$, "drawGraph", +function (g, _aa, aa_annotations, width, y, sRes, eRes) { +eRes = Math.min (eRes, aa_annotations.length); +g.setColor (java.awt.Color.white); +g.fillRect (0, 0, width, y); +g.setColor ( new java.awt.Color (0, 0, 180)); +var x = 0; +var height; +for (var j = sRes; j < eRes; j++) { +if (aa_annotations[j] != null) { +if (aa_annotations[j].colour == null) { +g.setColor (java.awt.Color.black); +} else { +g.setColor (aa_annotations[j].colour); +}height = Clazz.floatToInt ((aa_annotations[j].value / _aa.graphMax) * y); +if (height > y) { +height = y; +}g.fillRect (x, y - height, this.charWidth, height); +}x += this.charWidth; +} +}, "java.awt.Graphics,jalview.datamodel.AlignmentAnnotation,~A,~N,~N,~N,~N"); +Clazz.defineMethod (c$, "getNotCanonicalColor", +function (lastss) { +switch (lastss) { +case '{': +case '}': +return new java.awt.Color (255, 125, 5); +case '[': +case ']': +return new java.awt.Color (245, 115, 10); +case '>': +case '<': +return new java.awt.Color (235, 135, 15); +case 'A': +case 'a': +return new java.awt.Color (225, 105, 20); +case 'B': +case 'b': +return new java.awt.Color (215, 145, 30); +case 'C': +case 'c': +return new java.awt.Color (205, 95, 35); +case 'D': +case 'd': +return new java.awt.Color (195, 155, 45); +case 'E': +case 'e': +return new java.awt.Color (185, 85, 55); +case 'F': +case 'f': +return new java.awt.Color (175, 165, 65); +case 'G': +case 'g': +return new java.awt.Color (170, 75, 75); +case 'H': +case 'h': +return new java.awt.Color (160, 175, 85); +case 'I': +case 'i': +return new java.awt.Color (150, 65, 95); +case 'J': +case 'j': +return new java.awt.Color (140, 185, 105); +case 'K': +case 'k': +return new java.awt.Color (130, 55, 110); +case 'L': +case 'l': +return new java.awt.Color (120, 195, 120); +case 'M': +case 'm': +return new java.awt.Color (110, 45, 130); +case 'N': +case 'n': +return new java.awt.Color (100, 205, 140); +case 'O': +case 'o': +return new java.awt.Color (90, 35, 150); +case 'P': +case 'p': +return new java.awt.Color (85, 215, 160); +case 'Q': +case 'q': +return new java.awt.Color (75, 25, 170); +case 'R': +case 'r': +return new java.awt.Color (65, 225, 180); +case 'S': +case 's': +return new java.awt.Color (55, 15, 185); +case 'T': +case 't': +return new java.awt.Color (45, 235, 195); +case 'U': +case 'u': +return new java.awt.Color (35, 5, 205); +case 'V': +case 'v': +return new java.awt.Color (25, 245, 215); +case 'W': +case 'w': +return new java.awt.Color (15, 0, 225); +case 'X': +case 'x': +return new java.awt.Color (10, 255, 235); +case 'Y': +case 'y': +return new java.awt.Color (5, 150, 245); +case 'Z': +case 'z': +return new java.awt.Color (0, 80, 255); +default: +System.out.println ("This is not a interaction : " + lastss); +return null; +} +}, "~S"); +c$.GLYPHLINE_COLOR = c$.prototype.GLYPHLINE_COLOR = java.awt.Color.gray; +c$.SHEET_COLOUR = c$.prototype.SHEET_COLOUR = java.awt.Color.green; +c$.HELIX_COLOUR = c$.prototype.HELIX_COLOUR = java.awt.Color.red; +c$.STEM_COLOUR = c$.prototype.STEM_COLOUR = java.awt.Color.blue; +});