X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=site%2Fj2s%2Fjalview%2Fschemes%2FResidueColourScheme.js;h=9b2382f1daa860a662e72b29aee8851b8b226fde;hp=aaf6ef5d24700214a85b3c40c50c77f6ffb2b8b1;hb=b9b7a352eee79b7764c3b09c9d19663075061d8c;hpb=8ffd05b3abe52c0b6b79b011c0966361f82d5fe6 diff --git a/site/j2s/jalview/schemes/ResidueColourScheme.js b/site/j2s/jalview/schemes/ResidueColourScheme.js index aaf6ef5..9b2382f 100644 --- a/site/j2s/jalview/schemes/ResidueColourScheme.js +++ b/site/j2s/jalview/schemes/ResidueColourScheme.js @@ -1,146 +1,146 @@ -Clazz.declarePackage ("jalview.schemes"); -Clazz.load (["jalview.schemes.ColourSchemeI"], "jalview.schemes.ResidueColourScheme", ["jalview.util.Comparison", "$.MessageManager", "java.awt.Color", "java.lang.Error"], function () { -c$ = Clazz.decorateAsClass (function () { -this.symbolIndex = null; -this.conservationColouring = false; -this.colors = null; -this.threshold = 0; -this.ignoreGaps = "G"; -this.consensus = null; -this.conservation = null; -this.conservationLength = 0; -this.inc = 30; -Clazz.instantialize (this, arguments); -}, jalview.schemes, "ResidueColourScheme", null, jalview.schemes.ColourSchemeI); -Clazz.makeConstructor (c$, -function (aaOrnaIndex, colours, threshold) { -this.symbolIndex = aaOrnaIndex; -this.colors = colours; -this.threshold = threshold; -}, "~A,~A,~N"); -Clazz.makeConstructor (c$, -function (aaOrNaIndex) { -this.symbolIndex = aaOrNaIndex; -}, "~A"); -Clazz.makeConstructor (c$, -function () { -this.symbolIndex = null; -}); -Clazz.defineMethod (c$, "findColour", -function (c) { -return this.colors == null ? java.awt.Color.white : this.colors[this.symbolIndex[c.charCodeAt (0)]]; -}, "~S"); -Clazz.defineMethod (c$, "findColour", -function (c, j, seq) { -var currentColour; -if (this.colors != null && this.symbolIndex != null && (this.threshold == 0) || this.aboveThreshold (c, j)) { -currentColour = this.colors[this.symbolIndex[c.charCodeAt (0)]]; -} else { -currentColour = java.awt.Color.white; -}if (this.conservationColouring) { -currentColour = this.applyConservation (currentColour, j); -}return currentColour; -}, "~S,~N,jalview.datamodel.SequenceI"); -Clazz.overrideMethod (c$, "getThreshold", -function () { -return this.threshold; -}); -Clazz.overrideMethod (c$, "setThreshold", -function (ct, ignoreGaps) { -this.threshold = ct; -if (ignoreGaps) { -this.ignoreGaps = "N"; -} else { -this.ignoreGaps = "G"; -}}, "~N,~B"); -Clazz.defineMethod (c$, "aboveThreshold", -function (c, j) { -if ('a' <= c && c <= 'z') { -c = String.fromCharCode (c.charCodeAt (0) - (32)); -}if (this.consensus == null || this.consensus.length < j || this.consensus[j] == null) { -return false; -}if (((this.consensus[j].get ("C")).intValue () != -1) && this.consensus[j].contains (String.valueOf (c))) { -if ((this.consensus[j].get (this.ignoreGaps)).floatValue () >= this.threshold) { -return true; -}}return false; -}, "~S,~N"); -Clazz.overrideMethod (c$, "conservationApplied", -function () { -return this.conservationColouring; -}); -Clazz.overrideMethod (c$, "setConservationApplied", -function (conservationApplied) { -this.conservationColouring = conservationApplied; -}, "~B"); -Clazz.overrideMethod (c$, "setConservationInc", -function (i) { -this.inc = i; -}, "~N"); -Clazz.overrideMethod (c$, "getConservationInc", -function () { -return this.inc; -}); -Clazz.overrideMethod (c$, "setConsensus", -function (consensus) { -if (consensus == null) { -return; -}this.consensus = consensus; -}, "~A"); -Clazz.overrideMethod (c$, "setConservation", -function (cons) { -if (cons == null) { -this.conservationColouring = false; -this.conservation = null; -} else { -this.conservationColouring = true; -var i; -var iSize = cons.getConsSequence ().getLength (); -this.conservation = Clazz.newCharArray (iSize, '\0'); -for (i = 0; i < iSize; i++) { -this.conservation[i] = cons.getConsSequence ().getCharAt (i); -} -this.conservationLength = this.conservation.length; -}}, "jalview.analysis.Conservation"); -Clazz.defineMethod (c$, "applyConservation", -function (currentColour, i) { -if ((this.conservationLength > i) && (this.conservation[i] != '*') && (this.conservation[i] != '+')) { -if (jalview.util.Comparison.isGap (this.conservation[i])) { -currentColour = java.awt.Color.white; -} else { -var t = 11 - ((this.conservation[i]).charCodeAt (0) - 48); -if (t == 0) { -return java.awt.Color.white; -}var red = currentColour.getRed (); -var green = currentColour.getGreen (); -var blue = currentColour.getBlue (); -var dr = 255 - red; -var dg = 255 - green; -var db = 255 - blue; -dr *= t / 10; -dg *= t / 10; -db *= t / 10; -red += (this.inc / 20) * dr; -green += (this.inc / 20) * dg; -blue += (this.inc / 20) * db; -if (red > 255 || green > 255 || blue > 255) { -currentColour = java.awt.Color.white; -} else { -currentColour = new java.awt.Color (red, green, blue); -}}}return currentColour; -}, "java.awt.Color,~N"); -Clazz.overrideMethod (c$, "alignmentChanged", -function (alignment, hiddenReps) { -}, "jalview.datamodel.AnnotatedCollectionI,java.util.Map"); -Clazz.overrideMethod (c$, "applyTo", -function (sg, hiddenRepSequences) { -try { -return this.getClass ().newInstance (); -} catch (q) { -if (Clazz.exceptionOf (q, Exception)) { -throw new Error (jalview.util.MessageManager.formatMessage ("error.implementation_error_cannot_duplicate_colour_scheme", Clazz.newArray (-1, [this.getClass ().getName ()])), q); -} else { -throw q; -} -} -}, "jalview.datamodel.AnnotatedCollectionI,java.util.Map"); -}); +Clazz.declarePackage ("jalview.schemes"); +Clazz.load (["jalview.schemes.ColourSchemeI"], "jalview.schemes.ResidueColourScheme", ["jalview.util.Comparison", "$.MessageManager", "java.awt.Color", "java.lang.Error"], function () { +c$ = Clazz.decorateAsClass (function () { +this.symbolIndex = null; +this.conservationColouring = false; +this.colors = null; +this.threshold = 0; +this.ignoreGaps = "G"; +this.consensus = null; +this.conservation = null; +this.conservationLength = 0; +this.inc = 30; +Clazz.instantialize (this, arguments); +}, jalview.schemes, "ResidueColourScheme", null, jalview.schemes.ColourSchemeI); +Clazz.makeConstructor (c$, +function (aaOrnaIndex, colours, threshold) { +this.symbolIndex = aaOrnaIndex; +this.colors = colours; +this.threshold = threshold; +}, "~A,~A,~N"); +Clazz.makeConstructor (c$, +function (aaOrNaIndex) { +this.symbolIndex = aaOrNaIndex; +}, "~A"); +Clazz.makeConstructor (c$, +function () { +this.symbolIndex = null; +}); +Clazz.defineMethod (c$, "findColour", +function (c) { +return this.colors == null ? java.awt.Color.white : this.colors[this.symbolIndex[c.charCodeAt (0)]]; +}, "~S"); +Clazz.defineMethod (c$, "findColour", +function (c, j, seq) { +var currentColour; +if (this.colors != null && this.symbolIndex != null && (this.threshold == 0) || this.aboveThreshold (c, j)) { +currentColour = this.colors[this.symbolIndex[c.charCodeAt (0)]]; +} else { +currentColour = java.awt.Color.white; +}if (this.conservationColouring) { +currentColour = this.applyConservation (currentColour, j); +}return currentColour; +}, "~S,~N,jalview.datamodel.SequenceI"); +Clazz.overrideMethod (c$, "getThreshold", +function () { +return this.threshold; +}); +Clazz.overrideMethod (c$, "setThreshold", +function (ct, ignoreGaps) { +this.threshold = ct; +if (ignoreGaps) { +this.ignoreGaps = "N"; +} else { +this.ignoreGaps = "G"; +}}, "~N,~B"); +Clazz.defineMethod (c$, "aboveThreshold", +function (c, j) { +if ('a' <= c && c <= 'z') { +c = String.fromCharCode (c.charCodeAt (0) - (32)); +}if (this.consensus == null || this.consensus.length < j || this.consensus[j] == null) { +return false; +}if (((this.consensus[j].get ("C")).intValue () != -1) && this.consensus[j].contains (String.valueOf (c))) { +if ((this.consensus[j].get (this.ignoreGaps)).floatValue () >= this.threshold) { +return true; +}}return false; +}, "~S,~N"); +Clazz.overrideMethod (c$, "conservationApplied", +function () { +return this.conservationColouring; +}); +Clazz.overrideMethod (c$, "setConservationApplied", +function (conservationApplied) { +this.conservationColouring = conservationApplied; +}, "~B"); +Clazz.overrideMethod (c$, "setConservationInc", +function (i) { +this.inc = i; +}, "~N"); +Clazz.overrideMethod (c$, "getConservationInc", +function () { +return this.inc; +}); +Clazz.overrideMethod (c$, "setConsensus", +function (consensus) { +if (consensus == null) { +return; +}this.consensus = consensus; +}, "~A"); +Clazz.overrideMethod (c$, "setConservation", +function (cons) { +if (cons == null) { +this.conservationColouring = false; +this.conservation = null; +} else { +this.conservationColouring = true; +var i; +var iSize = cons.getConsSequence ().getLength (); +this.conservation = Clazz.newCharArray (iSize, '\0'); +for (i = 0; i < iSize; i++) { +this.conservation[i] = cons.getConsSequence ().getCharAt (i); +} +this.conservationLength = this.conservation.length; +}}, "jalview.analysis.Conservation"); +Clazz.defineMethod (c$, "applyConservation", +function (currentColour, i) { +if ((this.conservationLength > i) && (this.conservation[i] != '*') && (this.conservation[i] != '+')) { +if (jalview.util.Comparison.isGap (this.conservation[i])) { +currentColour = java.awt.Color.white; +} else { +var t = 11 - ((this.conservation[i]).charCodeAt (0) - 48); +if (t == 0) { +return java.awt.Color.white; +}var red = currentColour.getRed (); +var green = currentColour.getGreen (); +var blue = currentColour.getBlue (); +var dr = 255 - red; +var dg = 255 - green; +var db = 255 - blue; +dr *= t / 10; +dg *= t / 10; +db *= t / 10; +red += (this.inc / 20) * dr; +green += (this.inc / 20) * dg; +blue += (this.inc / 20) * db; +if (red > 255 || green > 255 || blue > 255) { +currentColour = java.awt.Color.white; +} else { +currentColour = new java.awt.Color (red, green, blue); +}}}return currentColour; +}, "java.awt.Color,~N"); +Clazz.overrideMethod (c$, "alignmentChanged", +function (alignment, hiddenReps) { +}, "jalview.datamodel.AnnotatedCollectionI,java.util.Map"); +Clazz.overrideMethod (c$, "applyTo", +function (sg, hiddenRepSequences) { +try { +return this.getClass ().newInstance (); +} catch (q) { +if (Clazz.exceptionOf (q, Exception)) { +throw new Error (jalview.util.MessageManager.formatMessage ("error.implementation_error_cannot_duplicate_colour_scheme", Clazz.newArray (-1, [this.getClass ().getName ()])), q); +} else { +throw q; +} +} +}, "jalview.datamodel.AnnotatedCollectionI,java.util.Map"); +});