JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / bin / jalview / schemes / CovariationColourScheme.js
1 Clazz.declarePackage ("jalview.schemes");\r
2 Clazz.load (["jalview.schemes.ResidueColourScheme", "java.util.Hashtable"], "jalview.schemes.CovariationColourScheme", ["jalview.schemes.ResidueProperties", "jalview.util.ColorUtils", "java.awt.Color"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.helixcolorhash = null;\r
5 this.positionsToHelix = null;\r
6 this.numHelix = 0;\r
7 this.annotation = null;\r
8 Clazz.instantialize (this, arguments);\r
9 }, jalview.schemes, "CovariationColourScheme", jalview.schemes.ResidueColourScheme);\r
10 Clazz.prepareFields (c$, function () {\r
11 this.helixcolorhash =  new java.util.Hashtable ();\r
12 this.positionsToHelix =  new java.util.Hashtable ();\r
13 });\r
14 Clazz.makeConstructor (c$, \r
15 function (annotation) {\r
16 Clazz.superConstructor (this, jalview.schemes.CovariationColourScheme, []);\r
17 this.annotation = annotation;\r
18 for (var x = 0; x < this.annotation._rnasecstr.length; x++) {\r
19 this.positionsToHelix.put (new Integer (this.annotation._rnasecstr[x].getBegin ()), this.annotation._rnasecstr[x].getFeatureGroup ());\r
20 this.positionsToHelix.put (new Integer (this.annotation._rnasecstr[x].getEnd ()), this.annotation._rnasecstr[x].getFeatureGroup ());\r
21 if (Integer.parseInt (this.annotation._rnasecstr[x].getFeatureGroup ()) > this.numHelix) {\r
22 this.numHelix = Integer.parseInt (this.annotation._rnasecstr[x].getFeatureGroup ());\r
23 }}\r
24 for (var j = 0; j <= this.numHelix; j++) {\r
25 this.helixcolorhash.put (Integer.toString (j), jalview.util.ColorUtils.generateRandomColor (java.awt.Color.white));\r
26 }\r
27 }, "jalview.datamodel.AlignmentAnnotation");\r
28 Clazz.defineMethod (c$, "findColour", \r
29 function (c) {\r
30 return jalview.schemes.ResidueProperties.purinepyrimidine[jalview.schemes.ResidueProperties.purinepyrimidineIndex[c.charCodeAt (0)]];\r
31 }, "~S");\r
32 Clazz.defineMethod (c$, "findColour", \r
33 function (c, j) {\r
34 var currentColour = java.awt.Color.white;\r
35 var currentHelix = null;\r
36 currentHelix = this.positionsToHelix.get (new Integer (j));\r
37 if (currentHelix != null) {\r
38 currentColour = this.helixcolorhash.get (currentHelix);\r
39 }return currentColour;\r
40 }, "~S,~N");\r
41 });\r