JAL-1807 includes ?j2sdebug flag and DebugJS._(msg)
[jalviewjs.git] / bin / jalview / schemes / ScoreColourScheme.js
1 Clazz.declarePackage ("jalview.schemes");
2 Clazz.load (["jalview.schemes.ResidueColourScheme"], "jalview.schemes.ScoreColourScheme", ["jalview.schemes.ResidueProperties", "jalview.util.Comparison", "java.awt.Color"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.min = 0;
5 this.max = 0;
6 this.scores = null;
7 Clazz.instantialize (this, arguments);
8 }, jalview.schemes, "ScoreColourScheme", jalview.schemes.ResidueColourScheme);
9 Clazz.makeConstructor (c$, 
10 function (symbolIndex, scores, min, max) {
11 Clazz.superConstructor (this, jalview.schemes.ScoreColourScheme, [symbolIndex]);
12 this.scores = scores;
13 this.min = min;
14 this.max = max;
15 var i;
16 var iSize = scores.length;
17 this.colors =  new Array (scores.length);
18 for (i = 0; i < iSize; i++) {
19 var red = (scores[i] - min) / (max - min);
20 if (red > 1.0) {
21 red = 1.0;
22 }if (red < 0.0) {
23 red = 0.0;
24 }this.colors[i] = this.makeColour (red);
25 }
26 }, "~A,~A,~N,~N");
27 Clazz.defineMethod (c$, "findColour", 
28 function (c, j, seq) {
29 if (this.threshold > 0) {
30 if (!this.aboveThreshold (c, j)) {
31 return java.awt.Color.white;
32 }}if (jalview.util.Comparison.isGap (c)) {
33 return java.awt.Color.white;
34 }var currentColour = this.colors[jalview.schemes.ResidueProperties.aaIndex[c.charCodeAt (0)]];
35 if (this.conservationColouring) {
36 currentColour = this.applyConservation (currentColour, j);
37 }return currentColour;
38 }, "~S,~N,jalview.datamodel.SequenceI");
39 Clazz.defineMethod (c$, "makeColour", 
40 function (c) {
41 return  new java.awt.Color (c, 0.0, 1.0 - c);
42 }, "~N");
43 });