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