JAL-1807 still testing
[jalviewjs.git] / bin / jalview / appletgui / SequenceRenderer.js
index 43ee455..449c271 100644 (file)
-Clazz.declarePackage ("jalview.appletgui");
-Clazz.load (["jalview.api.SequenceRenderer"], "jalview.appletgui.SequenceRenderer", ["jalview.util.Comparison", "java.awt.Color", "$.Font"], function () {
-c$ = Clazz.decorateAsClass (function () {
-this.av = null;
-this.fm = null;
-this.renderGaps = true;
-this.currentSequenceGroup = null;
-this.allGroups = null;
-this.resBoxColour = null;
-this.graphics = null;
-this.forOverview = false;
-Clazz.instantialize (this, arguments);
-}, jalview.appletgui, "SequenceRenderer", null, jalview.api.SequenceRenderer);
-Clazz.makeConstructor (c$, 
-function (av) {
-this.av = av;
-}, "jalview.appletgui.AlignViewport");
-Clazz.defineMethod (c$, "prepare", 
-function (g, renderGaps) {
-this.graphics = g;
-this.fm = g.getFontMetrics ();
-this.renderGaps = renderGaps;
-}, "java.awt.Graphics,~B");
-Clazz.overrideMethod (c$, "getResidueBoxColour", 
-function (seq, i) {
-this.allGroups = this.av.getAlignment ().findAllGroups (seq);
-if (this.inCurrentSequenceGroup (i)) {
-if (this.currentSequenceGroup.getDisplayBoxes ()) {
-this.getBoxColour (this.currentSequenceGroup.cs, seq, i);
-}} else if (this.av.getShowBoxes ()) {
-this.getBoxColour (this.av.getGlobalColourScheme (), seq, i);
-}return this.resBoxColour;
-}, "jalview.datamodel.SequenceI,~N");
-Clazz.overrideMethod (c$, "getResidueColour", 
-function (seq, position, fr) {
-var col = this.getResidueBoxColour (seq, position);
-if (fr != null) {
-col = fr.findFeatureColour (col, seq, position);
-}return col;
-}, "jalview.datamodel.SequenceI,~N,jalview.api.FeatureRenderer");
-Clazz.defineMethod (c$, "getBoxColour", 
-function (cs, seq, i) {
-if (cs != null) {
-this.resBoxColour = cs.findColour (seq.getCharAt (i), i, seq);
-} else if (this.forOverview && !jalview.util.Comparison.isGap (seq.getCharAt (i))) {
-this.resBoxColour = java.awt.Color.lightGray;
-} else {
-this.resBoxColour = java.awt.Color.white;
-}}, "jalview.schemes.ColourSchemeI,jalview.datamodel.SequenceI,~N");
-Clazz.defineMethod (c$, "findSequenceColour", 
-function (seq, i) {
-this.allGroups = this.av.getAlignment ().findAllGroups (seq);
-this.drawBoxes (seq, i, i, 0);
-return this.resBoxColour;
-}, "jalview.datamodel.SequenceI,~N");
-Clazz.defineMethod (c$, "drawSequence", 
-function (seq, sg, start, end, y1) {
-if (seq == null) {
-return;
-}this.allGroups = sg;
-this.drawBoxes (seq, start, end, y1);
-if (this.av.validCharWidth) {
-this.drawText (seq, start, end, y1);
-}}, "jalview.datamodel.SequenceI,~A,~N,~N,~N");
-Clazz.defineMethod (c$, "drawBoxes", 
-function (seq, start, end, y1) {
-var i = start;
-var length = seq.getLength ();
-var curStart = -1;
-var curWidth = this.av.getCharWidth ();
-var avCharWidth = this.av.getCharWidth ();
-var avCharHeight = this.av.getCharHeight ();
-var tempColour = null;
-while (i <= end) {
-this.resBoxColour = java.awt.Color.white;
-if (i < length) {
-if (this.inCurrentSequenceGroup (i)) {
-if (this.currentSequenceGroup.getDisplayBoxes ()) {
-this.getBoxColour (this.currentSequenceGroup.cs, seq, i);
-}} else if (this.av.getShowBoxes ()) {
-this.getBoxColour (this.av.getGlobalColourScheme (), seq, i);
-}}if (this.resBoxColour !== tempColour) {
-if (tempColour != null) {
-this.graphics.fillRect (avCharWidth * (curStart - start), y1, curWidth, avCharHeight);
-}this.graphics.setColor (this.resBoxColour);
-curStart = i;
-curWidth = avCharWidth;
-tempColour = this.resBoxColour;
-} else {
-curWidth += avCharWidth;
-}i++;
-}
-this.graphics.fillRect (avCharWidth * (curStart - start), y1, curWidth, avCharHeight);
-}, "jalview.datamodel.SequenceI,~N,~N,~N");
-Clazz.defineMethod (c$, "drawText", 
-function (seq, start, end, y1) {
-var avCharWidth = this.av.getCharWidth ();
-var avCharHeight = this.av.getCharHeight ();
-var boldFont = null;
-var bold = false;
-if (this.av.isUpperCasebold ()) {
-boldFont =  new java.awt.Font (this.av.getFont ().getName (), 1, avCharHeight);
-this.graphics.setFont (this.av.getFont ());
-}y1 += avCharHeight - Clazz.doubleToInt (avCharHeight / 5);
-var charOffset = 0;
-if (end + 1 >= seq.getLength ()) {
-end = seq.getLength () - 1;
-}var s = ' ';
-var srep = this.av.isDisplayReferenceSeq ();
-for (var i = start; i <= end; i++) {
-this.graphics.setColor (java.awt.Color.black);
-s = seq.getCharAt (i);
-if (!this.renderGaps && jalview.util.Comparison.isGap (s)) {
-continue;
-}if (this.inCurrentSequenceGroup (i)) {
-if (!this.currentSequenceGroup.getDisplayText ()) {
-continue;
-}if (this.currentSequenceGroup.getColourText ()) {
-this.getBoxColour (this.currentSequenceGroup.cs, seq, i);
-this.graphics.setColor (this.resBoxColour.darker ());
-}if (this.currentSequenceGroup.getShowNonconserved ()) {
-s = this.getDisplayChar (srep, i, s, '.');
-}} else {
-if (!this.av.getShowText ()) {
-continue;
-}if (this.av.getColourText ()) {
-this.getBoxColour (this.av.getGlobalColourScheme (), seq, i);
-if (this.av.getShowBoxes ()) {
-this.graphics.setColor (this.resBoxColour.darker ());
-} else {
-this.graphics.setColor (this.resBoxColour);
-}}if (this.av.getShowUnconserved ()) {
-s = this.getDisplayChar (srep, i, s, '.');
-}}if (this.av.isUpperCasebold ()) {
-this.fm = this.graphics.getFontMetrics ();
-if ('A' <= s && s <= 'Z') {
-if (!bold) {
-this.graphics.setFont (boldFont);
-}bold = true;
-} else if (bold) {
-this.graphics.setFont (this.av.font);
-bold = false;
-}}charOffset = Clazz.doubleToInt ((avCharWidth - this.fm.charWidth (s)) / 2);
-this.graphics.drawString (String.valueOf (s), charOffset + avCharWidth * (i - start), y1);
-}
-}, "jalview.datamodel.SequenceI,~N,~N,~N");
-Clazz.defineMethod (c$, "getDisplayChar", 
-($fz = function (usesrep, position, s, c) {
-var conschar = (usesrep) ? this.av.getAlignment ().getSeqrep ().getCharAt (position) : this.av.getAlignmentConsensusAnnotation ().annotations[position].displayCharacter.charAt (0);
-if (conschar != '-' && s == conschar) {
-s = c;
-}return s;
-}, $fz.isPrivate = true, $fz), "~B,~N,~S,~S");
-Clazz.defineMethod (c$, "inCurrentSequenceGroup", 
-function (res) {
-if (this.allGroups == null) {
-return false;
-}for (var i = 0; i < this.allGroups.length; i++) {
-if (this.allGroups[i].getStartRes () <= res && this.allGroups[i].getEndRes () >= res) {
-this.currentSequenceGroup = this.allGroups[i];
-return true;
-}}
-return false;
-}, "~N");
-Clazz.defineMethod (c$, "drawHighlightedText", 
-function (seq, start, end, x1, y1) {
-var avCharWidth = this.av.getCharWidth ();
-var avCharHeight = this.av.getCharHeight ();
-var pady = Clazz.doubleToInt (avCharHeight / 5);
-var charOffset = 0;
-this.graphics.setColor (java.awt.Color.black);
-this.graphics.fillRect (x1, y1, avCharWidth * (end - start + 1), avCharHeight);
-this.graphics.setColor (java.awt.Color.white);
-var s = '~';
-if (this.av.validCharWidth) {
-for (var i = start; i <= end; i++) {
-if (i < seq.getLength ()) {
-s = seq.getCharAt (i);
-}charOffset = Clazz.doubleToInt ((avCharWidth - this.fm.charWidth (s)) / 2);
-this.graphics.drawString (String.valueOf (s), charOffset + x1 + avCharWidth * (i - start), y1 + avCharHeight - pady);
-}
-}}, "jalview.datamodel.SequenceI,~N,~N,~N,~N");
-Clazz.defineMethod (c$, "drawCursor", 
-function (seq, res, x1, y1) {
-var pady = Clazz.doubleToInt (this.av.getCharHeight () / 5);
-var charOffset = 0;
-this.graphics.setColor (java.awt.Color.black);
-this.graphics.fillRect (x1, y1, this.av.getCharWidth (), this.av.getCharHeight ());
-this.graphics.setColor (java.awt.Color.white);
-this.graphics.setColor (java.awt.Color.white);
-var s = seq.getCharAt (res);
-if (this.av.validCharWidth) {
-charOffset = Clazz.doubleToInt ((this.av.getCharWidth () - this.fm.charWidth (s)) / 2);
-this.graphics.drawString (String.valueOf (s), charOffset + x1, (y1 + this.av.getCharHeight ()) - pady);
-}}, "jalview.datamodel.SequenceI,~N,~N,~N");
-});
+Clazz.declarePackage ("jalview.appletgui");\r
+Clazz.load (["jalview.api.SequenceRenderer"], "jalview.appletgui.SequenceRenderer", ["jalview.util.Comparison", "java.awt.Color", "$.Font"], function () {\r
+c$ = Clazz.decorateAsClass (function () {\r
+this.av = null;\r
+this.fm = null;\r
+this.renderGaps = true;\r
+this.currentSequenceGroup = null;\r
+this.allGroups = null;\r
+this.resBoxColour = null;\r
+this.graphics = null;\r
+this.forOverview = false;\r
+Clazz.instantialize (this, arguments);\r
+}, jalview.appletgui, "SequenceRenderer", null, jalview.api.SequenceRenderer);\r
+Clazz.makeConstructor (c$, \r
+function (av) {\r
+this.av = av;\r
+}, "jalview.appletgui.AlignViewport");\r
+Clazz.defineMethod (c$, "prepare", \r
+function (g, renderGaps) {\r
+this.graphics = g;\r
+this.fm = g.getFontMetrics ();\r
+this.renderGaps = renderGaps;\r
+}, "java.awt.Graphics,~B");\r
+Clazz.overrideMethod (c$, "getResidueBoxColour", \r
+function (seq, i) {\r
+this.allGroups = this.av.getAlignment ().findAllGroups (seq);\r
+if (this.inCurrentSequenceGroup (i)) {\r
+if (this.currentSequenceGroup.getDisplayBoxes ()) {\r
+this.getBoxColour (this.currentSequenceGroup.cs, seq, i);\r
+}} else if (this.av.getShowBoxes ()) {\r
+this.getBoxColour (this.av.getGlobalColourScheme (), seq, i);\r
+}return this.resBoxColour;\r
+}, "jalview.datamodel.SequenceI,~N");\r
+Clazz.overrideMethod (c$, "getResidueColour", \r
+function (seq, position, fr) {\r
+var col = this.getResidueBoxColour (seq, position);\r
+if (fr != null) {\r
+col = fr.findFeatureColour (col, seq, position);\r
+}return col;\r
+}, "jalview.datamodel.SequenceI,~N,jalview.api.FeatureRenderer");\r
+Clazz.defineMethod (c$, "getBoxColour", \r
+function (cs, seq, i) {\r
+if (cs != null) {\r
+this.resBoxColour = cs.findColour (seq.getCharAt (i), i, seq);\r
+} else if (this.forOverview && !jalview.util.Comparison.isGap (seq.getCharAt (i))) {\r
+this.resBoxColour = java.awt.Color.lightGray;\r
+} else {\r
+this.resBoxColour = java.awt.Color.white;\r
+}}, "jalview.schemes.ColourSchemeI,jalview.datamodel.SequenceI,~N");\r
+Clazz.defineMethod (c$, "findSequenceColour", \r
+function (seq, i) {\r
+this.allGroups = this.av.getAlignment ().findAllGroups (seq);\r
+this.drawBoxes (seq, i, i, 0);\r
+return this.resBoxColour;\r
+}, "jalview.datamodel.SequenceI,~N");\r
+Clazz.defineMethod (c$, "drawSequence", \r
+function (seq, sg, start, end, y1) {\r
+if (seq == null) {\r
+return;\r
+}this.allGroups = sg;\r
+this.drawBoxes (seq, start, end, y1);\r
+if (this.av.validCharWidth) {\r
+this.drawText (seq, start, end, y1);\r
+}}, "jalview.datamodel.SequenceI,~A,~N,~N,~N");\r
+Clazz.defineMethod (c$, "drawBoxes", \r
+function (seq, start, end, y1) {\r
+var i = start;\r
+var length = seq.getLength ();\r
+var curStart = -1;\r
+var curWidth = this.av.getCharWidth ();\r
+var avCharWidth = this.av.getCharWidth ();\r
+var avCharHeight = this.av.getCharHeight ();\r
+var tempColour = null;\r
+while (i <= end) {\r
+this.resBoxColour = java.awt.Color.white;\r
+if (i < length) {\r
+if (this.inCurrentSequenceGroup (i)) {\r
+if (this.currentSequenceGroup.getDisplayBoxes ()) {\r
+this.getBoxColour (this.currentSequenceGroup.cs, seq, i);\r
+}} else if (this.av.getShowBoxes ()) {\r
+this.getBoxColour (this.av.getGlobalColourScheme (), seq, i);\r
+}}if (this.resBoxColour !== tempColour) {\r
+if (tempColour != null) {\r
+this.graphics.fillRect (avCharWidth * (curStart - start), y1, curWidth, avCharHeight);\r
+}this.graphics.setColor (this.resBoxColour);\r
+curStart = i;\r
+curWidth = avCharWidth;\r
+tempColour = this.resBoxColour;\r
+} else {\r
+curWidth += avCharWidth;\r
+}i++;\r
+}\r
+this.graphics.fillRect (avCharWidth * (curStart - start), y1, curWidth, avCharHeight);\r
+}, "jalview.datamodel.SequenceI,~N,~N,~N");\r
+Clazz.defineMethod (c$, "drawText", \r
+function (seq, start, end, y1) {\r
+var avCharWidth = this.av.getCharWidth ();\r
+var avCharHeight = this.av.getCharHeight ();\r
+var boldFont = null;\r
+var bold = false;\r
+if (this.av.isUpperCasebold ()) {\r
+boldFont =  new java.awt.Font (this.av.getFont ().getName (), 1, avCharHeight);\r
+this.graphics.setFont (this.av.getFont ());\r
+}y1 += avCharHeight - Clazz.doubleToInt (avCharHeight / 5);\r
+var charOffset = 0;\r
+if (end + 1 >= seq.getLength ()) {\r
+end = seq.getLength () - 1;\r
+}var s = ' ';\r
+var srep = this.av.isDisplayReferenceSeq ();\r
+for (var i = start; i <= end; i++) {\r
+this.graphics.setColor (java.awt.Color.black);\r
+s = seq.getCharAt (i);\r
+if (!this.renderGaps && jalview.util.Comparison.isGap (s)) {\r
+continue;\r
+}if (this.inCurrentSequenceGroup (i)) {\r
+if (!this.currentSequenceGroup.getDisplayText ()) {\r
+continue;\r
+}if (this.currentSequenceGroup.getColourText ()) {\r
+this.getBoxColour (this.currentSequenceGroup.cs, seq, i);\r
+this.graphics.setColor (this.resBoxColour.darker ());\r
+}if (this.currentSequenceGroup.getShowNonconserved ()) {\r
+s = this.getDisplayChar (srep, i, s, '.');\r
+}} else {\r
+if (!this.av.getShowText ()) {\r
+continue;\r
+}if (this.av.getColourText ()) {\r
+this.getBoxColour (this.av.getGlobalColourScheme (), seq, i);\r
+if (this.av.getShowBoxes ()) {\r
+this.graphics.setColor (this.resBoxColour.darker ());\r
+} else {\r
+this.graphics.setColor (this.resBoxColour);\r
+}}if (this.av.getShowUnconserved ()) {\r
+s = this.getDisplayChar (srep, i, s, '.');\r
+}}if (this.av.isUpperCasebold ()) {\r
+this.fm = this.graphics.getFontMetrics ();\r
+if ('A' <= s && s <= 'Z') {\r
+if (!bold) {\r
+this.graphics.setFont (boldFont);\r
+}bold = true;\r
+} else if (bold) {\r
+this.graphics.setFont (this.av.font);\r
+bold = false;\r
+}}charOffset = Clazz.doubleToInt ((avCharWidth - this.fm.charWidth (s)) / 2);\r
+this.graphics.drawString (String.valueOf (s), charOffset + avCharWidth * (i - start), y1);\r
+}\r
+}, "jalview.datamodel.SequenceI,~N,~N,~N");\r
+Clazz.defineMethod (c$, "getDisplayChar", \r
+($fz = function (usesrep, position, s, c) {\r
+var conschar = (usesrep) ? this.av.getAlignment ().getSeqrep ().getCharAt (position) : this.av.getAlignmentConsensusAnnotation ().annotations[position].displayCharacter.charAt (0);\r
+if (conschar != '-' && s == conschar) {\r
+s = c;\r
+}return s;\r
+}, $fz.isPrivate = true, $fz), "~B,~N,~S,~S");\r
+Clazz.defineMethod (c$, "inCurrentSequenceGroup", \r
+function (res) {\r
+if (this.allGroups == null) {\r
+return false;\r
+}for (var i = 0; i < this.allGroups.length; i++) {\r
+if (this.allGroups[i].getStartRes () <= res && this.allGroups[i].getEndRes () >= res) {\r
+this.currentSequenceGroup = this.allGroups[i];\r
+return true;\r
+}}\r
+return false;\r
+}, "~N");\r
+Clazz.defineMethod (c$, "drawHighlightedText", \r
+function (seq, start, end, x1, y1) {\r
+var avCharWidth = this.av.getCharWidth ();\r
+var avCharHeight = this.av.getCharHeight ();\r
+var pady = Clazz.doubleToInt (avCharHeight / 5);\r
+var charOffset = 0;\r
+this.graphics.setColor (java.awt.Color.black);\r
+this.graphics.fillRect (x1, y1, avCharWidth * (end - start + 1), avCharHeight);\r
+this.graphics.setColor (java.awt.Color.white);\r
+var s = '~';\r
+if (this.av.validCharWidth) {\r
+for (var i = start; i <= end; i++) {\r
+if (i < seq.getLength ()) {\r
+s = seq.getCharAt (i);\r
+}charOffset = Clazz.doubleToInt ((avCharWidth - this.fm.charWidth (s)) / 2);\r
+this.graphics.drawString (String.valueOf (s), charOffset + x1 + avCharWidth * (i - start), y1 + avCharHeight - pady);\r
+}\r
+}}, "jalview.datamodel.SequenceI,~N,~N,~N,~N");\r
+Clazz.defineMethod (c$, "drawCursor", \r
+function (seq, res, x1, y1) {\r
+var pady = Clazz.doubleToInt (this.av.getCharHeight () / 5);\r
+var charOffset = 0;\r
+this.graphics.setColor (java.awt.Color.black);\r
+this.graphics.fillRect (x1, y1, this.av.getCharWidth (), this.av.getCharHeight ());\r
+this.graphics.setColor (java.awt.Color.white);\r
+this.graphics.setColor (java.awt.Color.white);\r
+var s = seq.getCharAt (res);\r
+if (this.av.validCharWidth) {\r
+charOffset = Clazz.doubleToInt ((this.av.getCharWidth () - this.fm.charWidth (s)) / 2);\r
+this.graphics.drawString (String.valueOf (s), charOffset + x1, (y1 + this.av.getCharHeight ()) - pady);\r
+}}, "jalview.datamodel.SequenceI,~N,~N,~N");\r
+});\r