1 Clazz.declarePackage ("jalview.schemes");
\r
2 Clazz.load (["jalview.schemes.ResidueColourScheme"], "jalview.schemes.UserColourScheme", ["jalview.schemes.ColourSchemeProperty", "$.ResidueProperties", "java.awt.Color", "java.util.StringTokenizer"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
4 this.lowerCaseColours = null;
\r
5 this.schemeName = null;
\r
6 Clazz.instantialize (this, arguments);
\r
7 }, jalview.schemes, "UserColourScheme", jalview.schemes.ResidueColourScheme);
\r
8 Clazz.makeConstructor (c$,
\r
10 Clazz.superConstructor (this, jalview.schemes.UserColourScheme, [jalview.schemes.ResidueProperties.aaIndex]);
\r
12 Clazz.makeConstructor (c$,
\r
13 function (newColors) {
\r
14 Clazz.superConstructor (this, jalview.schemes.UserColourScheme, [jalview.schemes.ResidueProperties.aaIndex]);
\r
15 this.colors = newColors;
\r
17 Clazz.overrideMethod (c$, "applyTo",
\r
18 function (sg, hiddenRepSequences) {
\r
19 var usc = new jalview.schemes.UserColourScheme (this.colors);
\r
20 if (this.lowerCaseColours != null) {
\r
21 usc.schemeName = String.instantialize (this.schemeName);
\r
22 usc.lowerCaseColours = new Array (this.lowerCaseColours.length);
\r
23 System.arraycopy (this.lowerCaseColours, 0, usc.lowerCaseColours, 0, this.lowerCaseColours.length);
\r
25 }, "jalview.datamodel.AnnotatedCollectionI,java.util.Map");
\r
26 Clazz.makeConstructor (c$,
\r
28 Clazz.superConstructor (this, jalview.schemes.UserColourScheme, [jalview.schemes.ResidueProperties.aaIndex]);
\r
29 var col = this.getColourFromString (colour);
\r
31 System.out.println ("Unknown colour!! " + colour);
\r
32 col = this.createColourFromName (colour);
\r
33 }this.colors = new Array (24);
\r
34 for (var i = 0; i < 24; i++) {
\r
35 this.colors[i] = col;
\r
37 this.schemeName = colour;
\r
39 Clazz.defineMethod (c$, "getColours",
\r
43 Clazz.defineMethod (c$, "getLowerCaseColours",
\r
45 return this.lowerCaseColours;
\r
47 Clazz.defineMethod (c$, "setName",
\r
49 this.schemeName = name;
\r
51 Clazz.defineMethod (c$, "getName",
\r
53 return this.schemeName;
\r
55 Clazz.defineMethod (c$, "getColourFromString",
\r
57 colour = colour.trim ();
\r
60 var value = Integer.parseInt (colour, 16);
\r
61 col = new java.awt.Color (value);
\r
63 if (Clazz.exceptionOf (ex, NumberFormatException)) {
\r
69 col = jalview.schemes.ColourSchemeProperty.getAWTColorFromName (colour);
\r
72 var st = new java.util.StringTokenizer (colour, ",");
\r
73 var r = Integer.parseInt (st.nextToken ());
\r
74 var g = Integer.parseInt (st.nextToken ());
\r
75 var b = Integer.parseInt (st.nextToken ());
\r
76 col = new java.awt.Color (r, g, b);
\r
78 if (Clazz.exceptionOf (ex, Exception)) {
\r
85 Clazz.defineMethod (c$, "createColourFromName",
\r
90 var lsize = name.length;
\r
92 var end = Clazz.doubleToInt (lsize / 3);
\r
93 var rgbOffset = Math.abs (name.hashCode () % 10) * 15;
\r
94 r = Math.abs (name.substring (start, end).hashCode () + rgbOffset) % 210 + 20;
\r
96 end += Clazz.doubleToInt (lsize / 3);
\r
99 }g = Math.abs (name.substring (start, end).hashCode () + rgbOffset) % 210 + 20;
\r
100 b = Math.abs (name.substring (end).hashCode () + rgbOffset) % 210 + 20;
\r
101 var color = new java.awt.Color (r, g, b);
\r
104 Clazz.defineMethod (c$, "parseAppletParameter",
\r
105 function (paramValue) {
\r
106 var st = new java.util.StringTokenizer (paramValue, ";");
\r
112 while (st.hasMoreElements ()) {
\r
113 token = st.nextToken ().trim ();
\r
114 residues = token.substring (0, token.indexOf ("="));
\r
115 colour = token.substring (token.indexOf ("=") + 1);
\r
116 st2 = new java.util.StringTokenizer (residues, " ,");
\r
117 while (st2.hasMoreTokens ()) {
\r
118 token = st2.nextToken ();
\r
119 if (jalview.schemes.ResidueProperties.aaIndex[token.charCodeAt (0)] == -1) {
\r
121 }var colIndex = jalview.schemes.ResidueProperties.aaIndex[token.charCodeAt (0)];
\r
122 if (token.equalsIgnoreCase ("lowerCase")) {
\r
123 if (this.lowerCaseColours == null) {
\r
124 this.lowerCaseColours = new Array (23);
\r
125 }for (var i = 0; i < 23; i++) {
\r
126 if (this.lowerCaseColours[i] == null) {
\r
127 this.lowerCaseColours[i] = this.getColourFromString (colour);
\r
130 }if (token.equals (token.toLowerCase ())) {
\r
131 if (this.lowerCaseColours == null) {
\r
132 this.lowerCaseColours = new Array (23);
\r
133 }this.lowerCaseColours[colIndex] = this.getColourFromString (colour);
\r
135 this.colors[colIndex] = this.getColourFromString (colour);
\r
139 if (Clazz.exceptionOf (ex, Exception)) {
\r
140 System.out.println ("Error parsing userDefinedColours:\n" + token + "\n" + ex);
\r
146 Clazz.defineMethod (c$, "findColour",
\r
147 function (c, j, seq) {
\r
149 var index = jalview.schemes.ResidueProperties.aaIndex[c.charCodeAt (0)];
\r
150 if ((this.threshold == 0) || this.aboveThreshold (c, j)) {
\r
151 if (this.lowerCaseColours != null && 'a' <= c && c <= 'z') {
\r
152 currentColour = this.lowerCaseColours[index];
\r
154 currentColour = this.colors[index];
\r
156 currentColour = java.awt.Color.white;
\r
157 }if (this.conservationColouring) {
\r
158 currentColour = this.applyConservation (currentColour, j);
\r
159 }return currentColour;
\r
160 }, "~S,~N,jalview.datamodel.SequenceI");
\r
161 Clazz.defineMethod (c$, "setLowerCaseColours",
\r
162 function (lcolours) {
\r
163 this.lowerCaseColours = lcolours;
\r