X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=site%2Fj2s%2Fjalview%2Fschemes%2FGraduatedColor.js;fp=site%2Fj2s%2Fjalview%2Fschemes%2FGraduatedColor.js;h=e9998a1bb0293461a0bd7a49a0c4f8abb0103fdb;hp=5daa0fba6bf0954742499e56de5c0b4070b3f8ea;hb=b9b7a352eee79b7764c3b09c9d19663075061d8c;hpb=7301a2415adab88038b291fc54caeeb3a5a47a44 diff --git a/site/j2s/jalview/schemes/GraduatedColor.js b/site/j2s/jalview/schemes/GraduatedColor.js index 5daa0fb..e9998a1 100644 --- a/site/j2s/jalview/schemes/GraduatedColor.js +++ b/site/j2s/jalview/schemes/GraduatedColor.js @@ -1,160 +1,160 @@ -Clazz.declarePackage ("jalview.schemes"); -Clazz.load (null, "jalview.schemes.GraduatedColor", ["jalview.schemes.UserColourScheme", "java.awt.Color", "java.lang.Float"], function () { -c$ = Clazz.decorateAsClass (function () { -this.thresholdState = -1; -this.lr = 0; -this.lg = 0; -this.lb = 0; -this.dr = 0; -this.dg = 0; -this.db = 0; -this.base = 0; -this.range = 0; -this.thrsh = 0; -this.tolow = false; -this.autoScale = true; -this.ucs = null; -this.colourByLabel = false; -Clazz.instantialize (this, arguments); -}, jalview.schemes, "GraduatedColor"); -Clazz.makeConstructor (c$, -function (low, high, min, max) { -this.thrsh = NaN; -this.tolow = min >= max; -this.lr = low.getRed () / 255; -this.lg = low.getGreen () / 255; -this.lb = low.getBlue () / 255; -this.dr = (high.getRed () / 255) - this.lr; -this.dg = (high.getGreen () / 255) - this.lg; -this.db = (high.getBlue () / 255) - this.lb; -if (this.tolow) { -this.base = max; -this.range = min - max; -} else { -this.base = min; -this.range = max - min; -}}, "java.awt.Color,java.awt.Color,~N,~N"); -Clazz.makeConstructor (c$, -function (oldcs) { -this.lr = oldcs.lr; -this.lg = oldcs.lg; -this.lb = oldcs.lb; -this.dr = oldcs.dr; -this.dg = oldcs.dg; -this.db = oldcs.db; -this.base = oldcs.base; -this.range = oldcs.range; -this.tolow = oldcs.tolow; -this.thresholdState = oldcs.thresholdState; -this.thrsh = oldcs.thrsh; -this.autoScale = oldcs.autoScale; -this.colourByLabel = oldcs.colourByLabel; -}, "jalview.schemes.GraduatedColor"); -Clazz.makeConstructor (c$, -function (oldcs, min, max) { -this.construct (oldcs); -this.updateBounds (min, max); -}, "jalview.schemes.GraduatedColor,~N,~N"); -Clazz.defineMethod (c$, "getMinColor", -function () { -return new java.awt.Color (this.lr, this.lg, this.lb); -}); -Clazz.defineMethod (c$, "getMaxColor", -function () { -return new java.awt.Color (this.lr + this.dr, this.lg + this.dg, this.lb + this.db); -}); -Clazz.defineMethod (c$, "getTolow", -function () { -return this.tolow; -}); -Clazz.defineMethod (c$, "setTolow", -function (tolower) { -this.tolow = tolower; -}, "~B"); -Clazz.defineMethod (c$, "isColored", -function (feature) { -var val = feature.getScore (); -if (Float.isNaN (val)) { -return true; -}if (this.thresholdState == -1) { -return true; -}if (Float.isNaN (this.thrsh)) { -return true; -}var rtn = this.thresholdState == 1; -if (val <= this.thrsh) { -return !rtn; -} else { -return rtn; -}}, "jalview.datamodel.SequenceFeature"); -Clazz.defineMethod (c$, "isColourByLabel", -function () { -return this.colourByLabel; -}); -Clazz.defineMethod (c$, "setColourByLabel", -function (colourByLabel) { -this.colourByLabel = colourByLabel; -}, "~B"); -Clazz.defineMethod (c$, "findColor", -function (feature) { -if (this.colourByLabel) { -if (this.ucs == null) { -this.ucs = new jalview.schemes.UserColourScheme (); -}return this.ucs.createColourFromName (feature.getDescription ()); -}if (this.range == 0.0) { -return this.getMaxColor (); -}var scr = feature.getScore (); -if (Float.isNaN (scr)) { -return this.getMinColor (); -}var scl = (scr - this.base) / this.range; -if (this.tolow) { -scl = -scl; -}if (scl < 0) { -scl = 0; -}if (scl > 1) { -scl = 1; -}return new java.awt.Color (this.lr + scl * this.dr, this.lg + scl * this.dg, this.lb + scl * this.db); -}, "jalview.datamodel.SequenceFeature"); -Clazz.defineMethod (c$, "setThresh", -function (value) { -this.thrsh = value; -}, "~N"); -Clazz.defineMethod (c$, "getThresh", -function () { -return this.thrsh; -}); -Clazz.defineMethod (c$, "setThreshType", -function (aboveThreshold) { -this.thresholdState = aboveThreshold; -}, "~N"); -Clazz.defineMethod (c$, "getThreshType", -function () { -return this.thresholdState; -}); -Clazz.defineMethod (c$, "getMax", -function () { -return (this.tolow) ? this.base : (this.base + this.range); -}); -Clazz.defineMethod (c$, "getMin", -function () { -return (this.tolow) ? (this.base + this.range) : this.base; -}); -Clazz.defineMethod (c$, "isAutoScale", -function () { -return this.autoScale; -}); -Clazz.defineMethod (c$, "setAutoScaled", -function (autoscale) { -this.autoScale = autoscale; -}, "~B"); -Clazz.defineMethod (c$, "updateBounds", -function (min, max) { -if (max < min) { -this.base = max; -this.range = min - max; -this.tolow = true; -} else { -this.base = min; -this.range = max - min; -this.tolow = false; -}}, "~N,~N"); -}); +Clazz.declarePackage ("jalview.schemes"); +Clazz.load (null, "jalview.schemes.GraduatedColor", ["jalview.schemes.UserColourScheme", "java.awt.Color", "java.lang.Float"], function () { +c$ = Clazz.decorateAsClass (function () { +this.thresholdState = -1; +this.lr = 0; +this.lg = 0; +this.lb = 0; +this.dr = 0; +this.dg = 0; +this.db = 0; +this.base = 0; +this.range = 0; +this.thrsh = 0; +this.tolow = false; +this.autoScale = true; +this.ucs = null; +this.colourByLabel = false; +Clazz.instantialize (this, arguments); +}, jalview.schemes, "GraduatedColor"); +Clazz.makeConstructor (c$, +function (low, high, min, max) { +this.thrsh = NaN; +this.tolow = min >= max; +this.lr = low.getRed () / 255; +this.lg = low.getGreen () / 255; +this.lb = low.getBlue () / 255; +this.dr = (high.getRed () / 255) - this.lr; +this.dg = (high.getGreen () / 255) - this.lg; +this.db = (high.getBlue () / 255) - this.lb; +if (this.tolow) { +this.base = max; +this.range = min - max; +} else { +this.base = min; +this.range = max - min; +}}, "java.awt.Color,java.awt.Color,~N,~N"); +Clazz.makeConstructor (c$, +function (oldcs) { +this.lr = oldcs.lr; +this.lg = oldcs.lg; +this.lb = oldcs.lb; +this.dr = oldcs.dr; +this.dg = oldcs.dg; +this.db = oldcs.db; +this.base = oldcs.base; +this.range = oldcs.range; +this.tolow = oldcs.tolow; +this.thresholdState = oldcs.thresholdState; +this.thrsh = oldcs.thrsh; +this.autoScale = oldcs.autoScale; +this.colourByLabel = oldcs.colourByLabel; +}, "jalview.schemes.GraduatedColor"); +Clazz.makeConstructor (c$, +function (oldcs, min, max) { +this.construct (oldcs); +this.updateBounds (min, max); +}, "jalview.schemes.GraduatedColor,~N,~N"); +Clazz.defineMethod (c$, "getMinColor", +function () { +return new java.awt.Color (this.lr, this.lg, this.lb); +}); +Clazz.defineMethod (c$, "getMaxColor", +function () { +return new java.awt.Color (this.lr + this.dr, this.lg + this.dg, this.lb + this.db); +}); +Clazz.defineMethod (c$, "getTolow", +function () { +return this.tolow; +}); +Clazz.defineMethod (c$, "setTolow", +function (tolower) { +this.tolow = tolower; +}, "~B"); +Clazz.defineMethod (c$, "isColored", +function (feature) { +var val = feature.getScore (); +if (Float.isNaN (val)) { +return true; +}if (this.thresholdState == -1) { +return true; +}if (Float.isNaN (this.thrsh)) { +return true; +}var rtn = this.thresholdState == 1; +if (val <= this.thrsh) { +return !rtn; +} else { +return rtn; +}}, "jalview.datamodel.SequenceFeature"); +Clazz.defineMethod (c$, "isColourByLabel", +function () { +return this.colourByLabel; +}); +Clazz.defineMethod (c$, "setColourByLabel", +function (colourByLabel) { +this.colourByLabel = colourByLabel; +}, "~B"); +Clazz.defineMethod (c$, "findColor", +function (feature) { +if (this.colourByLabel) { +if (this.ucs == null) { +this.ucs = new jalview.schemes.UserColourScheme (); +}return this.ucs.createColourFromName (feature.getDescription ()); +}if (this.range == 0.0) { +return this.getMaxColor (); +}var scr = feature.getScore (); +if (Float.isNaN (scr)) { +return this.getMinColor (); +}var scl = (scr - this.base) / this.range; +if (this.tolow) { +scl = -scl; +}if (scl < 0) { +scl = 0; +}if (scl > 1) { +scl = 1; +}return new java.awt.Color (this.lr + scl * this.dr, this.lg + scl * this.dg, this.lb + scl * this.db); +}, "jalview.datamodel.SequenceFeature"); +Clazz.defineMethod (c$, "setThresh", +function (value) { +this.thrsh = value; +}, "~N"); +Clazz.defineMethod (c$, "getThresh", +function () { +return this.thrsh; +}); +Clazz.defineMethod (c$, "setThreshType", +function (aboveThreshold) { +this.thresholdState = aboveThreshold; +}, "~N"); +Clazz.defineMethod (c$, "getThreshType", +function () { +return this.thresholdState; +}); +Clazz.defineMethod (c$, "getMax", +function () { +return (this.tolow) ? this.base : (this.base + this.range); +}); +Clazz.defineMethod (c$, "getMin", +function () { +return (this.tolow) ? (this.base + this.range) : this.base; +}); +Clazz.defineMethod (c$, "isAutoScale", +function () { +return this.autoScale; +}); +Clazz.defineMethod (c$, "setAutoScaled", +function (autoscale) { +this.autoScale = autoscale; +}, "~B"); +Clazz.defineMethod (c$, "updateBounds", +function (min, max) { +if (max < min) { +this.base = max; +this.range = min - max; +this.tolow = true; +} else { +this.base = min; +this.range = max - min; +this.tolow = false; +}}, "~N,~N"); +});