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