X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=site%2Fj2s%2Fjalview%2Frenderer%2Fseqfeatures%2FFeatureRenderer.js;h=7dc84b1e47d5b249e1101c05bb37dd469927cb3f;hp=019d21830f7f01a2a5bd9b1797f94f94292e980f;hb=b9b7a352eee79b7764c3b09c9d19663075061d8c;hpb=7301a2415adab88038b291fc54caeeb3a5a47a44 diff --git a/site/j2s/jalview/renderer/seqfeatures/FeatureRenderer.js b/site/j2s/jalview/renderer/seqfeatures/FeatureRenderer.js index 019d218..7dc84b1 100644 --- a/site/j2s/jalview/renderer/seqfeatures/FeatureRenderer.js +++ b/site/j2s/jalview/renderer/seqfeatures/FeatureRenderer.js @@ -1,187 +1,187 @@ -Clazz.declarePackage ("jalview.renderer.seqfeatures"); -Clazz.load (["jalview.viewmodel.seqfeatures.FeatureRendererModel"], "jalview.renderer.seqfeatures.FeatureRenderer", ["jalview.util.Comparison", "java.awt.AlphaComposite", "$.Color", "java.awt.image.BufferedImage", "java.lang.Float"], function () { -c$ = Clazz.decorateAsClass (function () { -this.fm = null; -this.charOffset = 0; -this.offscreenRender = false; -this.lastSeq = null; -this.s = '\0'; -this.i = 0; -this.av_charHeight = 0; -this.av_charWidth = 0; -this.av_validCharWidth = false; -this.av_isShowSeqFeatureHeight = false; -this.offscreenImage = null; -this.lastSequenceFeatures = null; -this.sfSize = 0; -this.sfindex = 0; -this.spos = 0; -this.epos = 0; -this.transparencyAvailable = true; -Clazz.instantialize (this, arguments); -}, jalview.renderer.seqfeatures, "FeatureRenderer", jalview.viewmodel.seqfeatures.FeatureRendererModel); -Clazz.defineMethod (c$, "updateAvConfig", -function () { -this.av_charHeight = this.av.getCharHeight (); -this.av_charWidth = this.av.getCharWidth (); -this.av_validCharWidth = this.av.isValidCharWidth (); -this.av_isShowSeqFeatureHeight = this.av.isShowSequenceFeaturesHeight (); -}); -Clazz.defineMethod (c$, "renderFeature", -function (g, seq, fstart, fend, featureColour, start, end, y1) { -this.updateAvConfig (); -if (((fstart <= end) && (fend >= start))) { -if (fstart < start) { -fstart = start; -}if (fend >= end) { -fend = end; -}var pady = (y1 + this.av_charHeight) - Clazz.doubleToInt (this.av_charHeight / 5); -for (this.i = fstart; this.i <= fend; this.i++) { -this.s = seq.getCharAt (this.i); -if (jalview.util.Comparison.isGap (this.s)) { -continue; -}g.setColor (featureColour); -g.fillRect ((this.i - start) * this.av_charWidth, y1, this.av_charWidth, this.av_charHeight); -if (this.offscreenRender || !this.av_validCharWidth) { -continue; -}g.setColor (java.awt.Color.white); -this.charOffset = Clazz.doubleToInt ((this.av_charWidth - this.fm.charWidth (this.s)) / 2); -g.drawString (String.valueOf (this.s), this.charOffset + (this.av_charWidth * (this.i - start)), pady); -} -}}, "java.awt.Graphics,jalview.datamodel.SequenceI,~N,~N,java.awt.Color,~N,~N,~N"); -Clazz.defineMethod (c$, "renderScoreFeature", -function (g, seq, fstart, fend, featureColour, start, end, y1, bs) { -this.updateAvConfig (); -if (((fstart <= end) && (fend >= start))) { -if (fstart < start) { -fstart = start; -}if (fend >= end) { -fend = end; -}var pady = (y1 + this.av_charHeight) - Clazz.doubleToInt (this.av_charHeight / 5); -var ystrt = 0; -var yend = this.av_charHeight; -if (bs[0] != 0) { -if (bs[1] < 128) { -yend = Clazz.doubleToInt (this.av_charHeight * (128 - bs[1]) / 512); -ystrt = this.av_charHeight - Clazz.doubleToInt (yend / 2); -} else { -ystrt = Clazz.doubleToInt (this.av_charHeight / 2); -yend = Clazz.doubleToInt (this.av_charHeight * (bs[1] - 128) / 512); -}} else { -yend = Clazz.doubleToInt (this.av_charHeight * bs[1] / 255); -ystrt = this.av_charHeight - yend; -}for (this.i = fstart; this.i <= fend; this.i++) { -this.s = seq.getCharAt (this.i); -if (jalview.util.Comparison.isGap (this.s)) { -continue; -}g.setColor (featureColour); -var x = (this.i - start) * this.av_charWidth; -g.drawRect (x, y1, this.av_charWidth, this.av_charHeight); -g.fillRect (x, y1 + ystrt, this.av_charWidth, yend); -if (this.offscreenRender || !this.av_validCharWidth) { -continue; -}g.setColor (java.awt.Color.black); -this.charOffset = Clazz.doubleToInt ((this.av_charWidth - this.fm.charWidth (this.s)) / 2); -g.drawString (String.valueOf (this.s), this.charOffset + (this.av_charWidth * (this.i - start)), pady); -} -}}, "java.awt.Graphics,jalview.datamodel.SequenceI,~N,~N,java.awt.Color,~N,~N,~N,~A"); -Clazz.defineMethod (c$, "findFeatureColour", -function (initialCol, seq, res) { -return new java.awt.Color (this.findFeatureColour (initialCol.getRGB (), seq, res)); -}, "java.awt.Color,jalview.datamodel.SequenceI,~N"); -Clazz.defineMethod (c$, "findFeatureColour", -function (initialCol, seq, column) { -if (!this.av.isShowSequenceFeatures ()) { -return initialCol; -}var sequenceFeatures = seq.getSequenceFeatures (); -if (seq !== this.lastSeq) { -this.lastSeq = seq; -this.lastSequenceFeatures = sequenceFeatures; -if (this.lastSequenceFeatures != null) { -this.sfSize = this.lastSequenceFeatures.length; -}} else { -if (this.lastSequenceFeatures !== sequenceFeatures) { -this.lastSequenceFeatures = sequenceFeatures; -if (this.lastSequenceFeatures != null) { -this.sfSize = this.lastSequenceFeatures.length; -}}}if (this.lastSequenceFeatures == null || this.sfSize == 0) { -return initialCol; -}if (jalview.util.Comparison.isGap (this.lastSeq.getCharAt (column))) { -return java.awt.Color.white.getRGB (); -}if (this.transparency != 1.0 && this.offscreenImage == null) { -this.offscreenImage = new java.awt.image.BufferedImage (1, 1, 2); -}this.currentColour = null; -this.offscreenRender = true; -if (this.offscreenImage != null) { -this.offscreenImage.setRGB (0, 0, initialCol); -this.drawSequence (this.offscreenImage.getGraphics (), this.lastSeq, column, column, 0); -return this.offscreenImage.getRGB (0, 0); -} else { -this.drawSequence (null, this.lastSeq, this.lastSeq.findPosition (column), -1, -1); -if (this.currentColour == null) { -return initialCol; -} else { -return (this.currentColour).intValue (); -}}}, "~N,jalview.datamodel.SequenceI,~N"); -Clazz.defineMethod (c$, "drawSequence", -function (g, seq, start, end, y1) { -var sequenceFeatures = seq.getSequenceFeatures (); -if (sequenceFeatures == null || sequenceFeatures.length == 0) { -return; -}if (g != null) { -this.fm = g.getFontMetrics (); -}this.updateFeatures (); -if (this.lastSeq == null || seq !== this.lastSeq || sequenceFeatures !== this.lastSequenceFeatures) { -this.lastSeq = seq; -this.lastSequenceFeatures = sequenceFeatures; -}if (this.transparency != 1 && g != null) { -var g2 = g; -g2.setComposite (java.awt.AlphaComposite.getInstance (3, this.transparency)); -}if (!this.offscreenRender) { -this.spos = this.lastSeq.findPosition (start); -this.epos = this.lastSeq.findPosition (end); -}this.sfSize = this.lastSequenceFeatures.length; -var type; -for (var renderIndex = 0; renderIndex < this.renderOrder.length; renderIndex++) { -type = this.renderOrder[renderIndex]; -if (type == null || !this.showFeatureOfType (type)) { -continue; -}for (this.sfindex = 0; this.sfindex < this.sfSize; this.sfindex++) { -var sequenceFeature = this.lastSequenceFeatures[this.sfindex]; -if (!sequenceFeature.type.equals (type)) { -continue; -}if (this.featureGroups != null && sequenceFeature.featureGroup != null && sequenceFeature.featureGroup.length != 0 && this.featureGroups.containsKey (sequenceFeature.featureGroup) && !this.featureGroups.get (sequenceFeature.featureGroup).booleanValue ()) { -continue; -}if (!this.offscreenRender && (sequenceFeature.getBegin () > this.epos || sequenceFeature.getEnd () < this.spos)) { -continue; -}if (this.offscreenRender && this.offscreenImage == null) { -if (sequenceFeature.begin <= start && sequenceFeature.end >= start) { -this.currentColour = new Integer (this.getColour (sequenceFeature).getRGB ()); -}} else if (sequenceFeature.type.equals ("disulfide bond")) { -this.renderFeature (g, seq, seq.findIndex (sequenceFeature.begin) - 1, seq.findIndex (sequenceFeature.begin) - 1, this.getColour (sequenceFeature), start, end, y1); -this.renderFeature (g, seq, seq.findIndex (sequenceFeature.end) - 1, seq.findIndex (sequenceFeature.end) - 1, this.getColour (sequenceFeature), start, end, y1); -} else if (this.showFeature (sequenceFeature)) { -if (this.av_isShowSeqFeatureHeight && !Float.isNaN (sequenceFeature.score)) { -this.renderScoreFeature (g, seq, seq.findIndex (sequenceFeature.begin) - 1, seq.findIndex (sequenceFeature.end) - 1, this.getColour (sequenceFeature), start, end, y1, this.normaliseScore (sequenceFeature)); -} else { -this.renderFeature (g, seq, seq.findIndex (sequenceFeature.begin) - 1, seq.findIndex (sequenceFeature.end) - 1, this.getColour (sequenceFeature), start, end, y1); -}}} -} -if (this.transparency != 1.0 && g != null && this.transparencyAvailable) { -var g2 = g; -g2.setComposite (java.awt.AlphaComposite.getInstance (3, 1.0)); -}}, "java.awt.Graphics,jalview.datamodel.SequenceI,~N,~N,~N"); -Clazz.defineMethod (c$, "setTransparencyAvailable", -function (isTransparencyAvailable) { -this.transparencyAvailable = isTransparencyAvailable; -}, "~B"); -Clazz.overrideMethod (c$, "isTransparencyAvailable", -function () { -return this.transparencyAvailable; -}); -Clazz.overrideMethod (c$, "featuresAdded", -function () { -this.lastSeq = null; -this.findAllFeatures (); -}); -}); +Clazz.declarePackage ("jalview.renderer.seqfeatures"); +Clazz.load (["jalview.viewmodel.seqfeatures.FeatureRendererModel"], "jalview.renderer.seqfeatures.FeatureRenderer", ["jalview.util.Comparison", "java.awt.AlphaComposite", "$.Color", "java.awt.image.BufferedImage", "java.lang.Float"], function () { +c$ = Clazz.decorateAsClass (function () { +this.fm = null; +this.charOffset = 0; +this.offscreenRender = false; +this.lastSeq = null; +this.s = '\0'; +this.i = 0; +this.av_charHeight = 0; +this.av_charWidth = 0; +this.av_validCharWidth = false; +this.av_isShowSeqFeatureHeight = false; +this.offscreenImage = null; +this.lastSequenceFeatures = null; +this.sfSize = 0; +this.sfindex = 0; +this.spos = 0; +this.epos = 0; +this.transparencyAvailable = true; +Clazz.instantialize (this, arguments); +}, jalview.renderer.seqfeatures, "FeatureRenderer", jalview.viewmodel.seqfeatures.FeatureRendererModel); +Clazz.defineMethod (c$, "updateAvConfig", +function () { +this.av_charHeight = this.av.getCharHeight (); +this.av_charWidth = this.av.getCharWidth (); +this.av_validCharWidth = this.av.isValidCharWidth (); +this.av_isShowSeqFeatureHeight = this.av.isShowSequenceFeaturesHeight (); +}); +Clazz.defineMethod (c$, "renderFeature", +function (g, seq, fstart, fend, featureColour, start, end, y1) { +this.updateAvConfig (); +if (((fstart <= end) && (fend >= start))) { +if (fstart < start) { +fstart = start; +}if (fend >= end) { +fend = end; +}var pady = (y1 + this.av_charHeight) - Clazz.doubleToInt (this.av_charHeight / 5); +for (this.i = fstart; this.i <= fend; this.i++) { +this.s = seq.getCharAt (this.i); +if (jalview.util.Comparison.isGap (this.s)) { +continue; +}g.setColor (featureColour); +g.fillRect ((this.i - start) * this.av_charWidth, y1, this.av_charWidth, this.av_charHeight); +if (this.offscreenRender || !this.av_validCharWidth) { +continue; +}g.setColor (java.awt.Color.white); +this.charOffset = Clazz.doubleToInt ((this.av_charWidth - this.fm.charWidth (this.s)) / 2); +g.drawString (String.valueOf (this.s), this.charOffset + (this.av_charWidth * (this.i - start)), pady); +} +}}, "java.awt.Graphics,jalview.datamodel.SequenceI,~N,~N,java.awt.Color,~N,~N,~N"); +Clazz.defineMethod (c$, "renderScoreFeature", +function (g, seq, fstart, fend, featureColour, start, end, y1, bs) { +this.updateAvConfig (); +if (((fstart <= end) && (fend >= start))) { +if (fstart < start) { +fstart = start; +}if (fend >= end) { +fend = end; +}var pady = (y1 + this.av_charHeight) - Clazz.doubleToInt (this.av_charHeight / 5); +var ystrt = 0; +var yend = this.av_charHeight; +if (bs[0] != 0) { +if (bs[1] < 128) { +yend = Clazz.doubleToInt (this.av_charHeight * (128 - bs[1]) / 512); +ystrt = this.av_charHeight - Clazz.doubleToInt (yend / 2); +} else { +ystrt = Clazz.doubleToInt (this.av_charHeight / 2); +yend = Clazz.doubleToInt (this.av_charHeight * (bs[1] - 128) / 512); +}} else { +yend = Clazz.doubleToInt (this.av_charHeight * bs[1] / 255); +ystrt = this.av_charHeight - yend; +}for (this.i = fstart; this.i <= fend; this.i++) { +this.s = seq.getCharAt (this.i); +if (jalview.util.Comparison.isGap (this.s)) { +continue; +}g.setColor (featureColour); +var x = (this.i - start) * this.av_charWidth; +g.drawRect (x, y1, this.av_charWidth, this.av_charHeight); +g.fillRect (x, y1 + ystrt, this.av_charWidth, yend); +if (this.offscreenRender || !this.av_validCharWidth) { +continue; +}g.setColor (java.awt.Color.black); +this.charOffset = Clazz.doubleToInt ((this.av_charWidth - this.fm.charWidth (this.s)) / 2); +g.drawString (String.valueOf (this.s), this.charOffset + (this.av_charWidth * (this.i - start)), pady); +} +}}, "java.awt.Graphics,jalview.datamodel.SequenceI,~N,~N,java.awt.Color,~N,~N,~N,~A"); +Clazz.defineMethod (c$, "findFeatureColour", +function (initialCol, seq, res) { +return new java.awt.Color (this.findFeatureColour (initialCol.getRGB (), seq, res)); +}, "java.awt.Color,jalview.datamodel.SequenceI,~N"); +Clazz.defineMethod (c$, "findFeatureColour", +function (initialCol, seq, column) { +if (!this.av.isShowSequenceFeatures ()) { +return initialCol; +}var sequenceFeatures = seq.getSequenceFeatures (); +if (seq !== this.lastSeq) { +this.lastSeq = seq; +this.lastSequenceFeatures = sequenceFeatures; +if (this.lastSequenceFeatures != null) { +this.sfSize = this.lastSequenceFeatures.length; +}} else { +if (this.lastSequenceFeatures !== sequenceFeatures) { +this.lastSequenceFeatures = sequenceFeatures; +if (this.lastSequenceFeatures != null) { +this.sfSize = this.lastSequenceFeatures.length; +}}}if (this.lastSequenceFeatures == null || this.sfSize == 0) { +return initialCol; +}if (jalview.util.Comparison.isGap (this.lastSeq.getCharAt (column))) { +return java.awt.Color.white.getRGB (); +}if (this.transparency != 1.0 && this.offscreenImage == null) { +this.offscreenImage = new java.awt.image.BufferedImage (1, 1, 2); +}this.currentColour = null; +this.offscreenRender = true; +if (this.offscreenImage != null) { +this.offscreenImage.setRGB (0, 0, initialCol); +this.drawSequence (this.offscreenImage.getGraphics (), this.lastSeq, column, column, 0); +return this.offscreenImage.getRGB (0, 0); +} else { +this.drawSequence (null, this.lastSeq, this.lastSeq.findPosition (column), -1, -1); +if (this.currentColour == null) { +return initialCol; +} else { +return (this.currentColour).intValue (); +}}}, "~N,jalview.datamodel.SequenceI,~N"); +Clazz.defineMethod (c$, "drawSequence", +function (g, seq, start, end, y1) { +var sequenceFeatures = seq.getSequenceFeatures (); +if (sequenceFeatures == null || sequenceFeatures.length == 0) { +return; +}if (g != null) { +this.fm = g.getFontMetrics (); +}this.updateFeatures (); +if (this.lastSeq == null || seq !== this.lastSeq || sequenceFeatures !== this.lastSequenceFeatures) { +this.lastSeq = seq; +this.lastSequenceFeatures = sequenceFeatures; +}if (this.transparency != 1 && g != null) { +var g2 = g; +g2.setComposite (java.awt.AlphaComposite.getInstance (3, this.transparency)); +}if (!this.offscreenRender) { +this.spos = this.lastSeq.findPosition (start); +this.epos = this.lastSeq.findPosition (end); +}this.sfSize = this.lastSequenceFeatures.length; +var type; +for (var renderIndex = 0; renderIndex < this.renderOrder.length; renderIndex++) { +type = this.renderOrder[renderIndex]; +if (type == null || !this.showFeatureOfType (type)) { +continue; +}for (this.sfindex = 0; this.sfindex < this.sfSize; this.sfindex++) { +var sequenceFeature = this.lastSequenceFeatures[this.sfindex]; +if (!sequenceFeature.type.equals (type)) { +continue; +}if (this.featureGroups != null && sequenceFeature.featureGroup != null && sequenceFeature.featureGroup.length != 0 && this.featureGroups.containsKey (sequenceFeature.featureGroup) && !this.featureGroups.get (sequenceFeature.featureGroup).booleanValue ()) { +continue; +}if (!this.offscreenRender && (sequenceFeature.getBegin () > this.epos || sequenceFeature.getEnd () < this.spos)) { +continue; +}if (this.offscreenRender && this.offscreenImage == null) { +if (sequenceFeature.begin <= start && sequenceFeature.end >= start) { +this.currentColour = new Integer (this.getColour (sequenceFeature).getRGB ()); +}} else if (sequenceFeature.type.equals ("disulfide bond")) { +this.renderFeature (g, seq, seq.findIndex (sequenceFeature.begin) - 1, seq.findIndex (sequenceFeature.begin) - 1, this.getColour (sequenceFeature), start, end, y1); +this.renderFeature (g, seq, seq.findIndex (sequenceFeature.end) - 1, seq.findIndex (sequenceFeature.end) - 1, this.getColour (sequenceFeature), start, end, y1); +} else if (this.showFeature (sequenceFeature)) { +if (this.av_isShowSeqFeatureHeight && !Float.isNaN (sequenceFeature.score)) { +this.renderScoreFeature (g, seq, seq.findIndex (sequenceFeature.begin) - 1, seq.findIndex (sequenceFeature.end) - 1, this.getColour (sequenceFeature), start, end, y1, this.normaliseScore (sequenceFeature)); +} else { +this.renderFeature (g, seq, seq.findIndex (sequenceFeature.begin) - 1, seq.findIndex (sequenceFeature.end) - 1, this.getColour (sequenceFeature), start, end, y1); +}}} +} +if (this.transparency != 1.0 && g != null && this.transparencyAvailable) { +var g2 = g; +g2.setComposite (java.awt.AlphaComposite.getInstance (3, 1.0)); +}}, "java.awt.Graphics,jalview.datamodel.SequenceI,~N,~N,~N"); +Clazz.defineMethod (c$, "setTransparencyAvailable", +function (isTransparencyAvailable) { +this.transparencyAvailable = isTransparencyAvailable; +}, "~B"); +Clazz.overrideMethod (c$, "isTransparencyAvailable", +function () { +return this.transparencyAvailable; +}); +Clazz.overrideMethod (c$, "featuresAdded", +function () { +this.lastSeq = null; +this.findAllFeatures (); +}); +});