1 Clazz.declarePackage ("jalview.schemes");
\r
2 Clazz.load (["jalview.schemes.ColourSchemeI"], "jalview.schemes.ResidueColourScheme", ["jalview.util.Comparison", "$.MessageManager", "java.awt.Color", "java.lang.Error"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
4 this.symbolIndex = null;
\r
5 this.conservationColouring = false;
\r
8 this.ignoreGaps = "G";
\r
9 this.consensus = null;
\r
10 this.conservation = null;
\r
11 this.conservationLength = 0;
\r
13 Clazz.instantialize (this, arguments);
\r
14 }, jalview.schemes, "ResidueColourScheme", null, jalview.schemes.ColourSchemeI);
\r
15 Clazz.makeConstructor (c$,
\r
16 function (aaOrnaIndex, colours, threshold) {
\r
17 this.symbolIndex = aaOrnaIndex;
\r
18 this.colors = colours;
\r
19 this.threshold = threshold;
\r
21 Clazz.makeConstructor (c$,
\r
22 function (aaOrNaIndex) {
\r
23 this.symbolIndex = aaOrNaIndex;
\r
25 Clazz.makeConstructor (c$,
\r
27 this.symbolIndex = null;
\r
29 Clazz.defineMethod (c$, "findColour",
\r
31 return this.colors == null ? java.awt.Color.white : this.colors[this.symbolIndex[c.charCodeAt (0)]];
\r
33 Clazz.defineMethod (c$, "findColour",
\r
34 function (c, j, seq) {
\r
36 if (this.colors != null && this.symbolIndex != null && (this.threshold == 0) || this.aboveThreshold (c, j)) {
\r
37 currentColour = this.colors[this.symbolIndex[c.charCodeAt (0)]];
\r
39 currentColour = java.awt.Color.white;
\r
40 }if (this.conservationColouring) {
\r
41 currentColour = this.applyConservation (currentColour, j);
\r
42 }return currentColour;
\r
43 }, "~S,~N,jalview.datamodel.SequenceI");
\r
44 Clazz.overrideMethod (c$, "getThreshold",
\r
46 return this.threshold;
\r
48 Clazz.overrideMethod (c$, "setThreshold",
\r
49 function (ct, ignoreGaps) {
\r
50 this.threshold = ct;
\r
52 this.ignoreGaps = "N";
\r
54 this.ignoreGaps = "G";
\r
56 Clazz.defineMethod (c$, "aboveThreshold",
\r
58 if ('a' <= c && c <= 'z') {
\r
59 c = String.fromCharCode (c.charCodeAt (0) - (32));
\r
60 }if (this.consensus == null || this.consensus.length < j || this.consensus[j] == null) {
\r
62 }if (((this.consensus[j].get ("C")).intValue () != -1) && this.consensus[j].contains (String.valueOf (c))) {
\r
63 if ((this.consensus[j].get (this.ignoreGaps)).floatValue () >= this.threshold) {
\r
67 Clazz.overrideMethod (c$, "conservationApplied",
\r
69 return this.conservationColouring;
\r
71 Clazz.overrideMethod (c$, "setConservationApplied",
\r
72 function (conservationApplied) {
\r
73 this.conservationColouring = conservationApplied;
\r
75 Clazz.overrideMethod (c$, "setConservationInc",
\r
79 Clazz.overrideMethod (c$, "getConservationInc",
\r
83 Clazz.overrideMethod (c$, "setConsensus",
\r
84 function (consensus) {
\r
85 if (consensus == null) {
\r
87 }this.consensus = consensus;
\r
89 Clazz.overrideMethod (c$, "setConservation",
\r
92 this.conservationColouring = false;
\r
93 this.conservation = null;
\r
95 this.conservationColouring = true;
\r
97 var iSize = cons.getConsSequence ().getLength ();
\r
98 this.conservation = Clazz.newCharArray (iSize, '\0');
\r
99 for (i = 0; i < iSize; i++) {
\r
100 this.conservation[i] = cons.getConsSequence ().getCharAt (i);
\r
102 this.conservationLength = this.conservation.length;
\r
103 }}, "jalview.analysis.Conservation");
\r
104 Clazz.defineMethod (c$, "applyConservation",
\r
105 function (currentColour, i) {
\r
106 if ((this.conservationLength > i) && (this.conservation[i] != '*') && (this.conservation[i] != '+')) {
\r
107 if (jalview.util.Comparison.isGap (this.conservation[i])) {
\r
108 currentColour = java.awt.Color.white;
\r
110 var t = 11 - ((this.conservation[i]).charCodeAt (0) - 48);
\r
112 return java.awt.Color.white;
\r
113 }var red = currentColour.getRed ();
\r
114 var green = currentColour.getGreen ();
\r
115 var blue = currentColour.getBlue ();
\r
116 var dr = 255 - red;
\r
117 var dg = 255 - green;
\r
118 var db = 255 - blue;
\r
122 red += (this.inc / 20) * dr;
\r
123 green += (this.inc / 20) * dg;
\r
124 blue += (this.inc / 20) * db;
\r
125 if (red > 255 || green > 255 || blue > 255) {
\r
126 currentColour = java.awt.Color.white;
\r
128 currentColour = new java.awt.Color (red, green, blue);
\r
129 }}}return currentColour;
\r
130 }, "java.awt.Color,~N");
\r
131 Clazz.overrideMethod (c$, "alignmentChanged",
\r
132 function (alignment, hiddenReps) {
\r
133 }, "jalview.datamodel.AnnotatedCollectionI,java.util.Map");
\r
134 Clazz.overrideMethod (c$, "applyTo",
\r
135 function (sg, hiddenRepSequences) {
\r
137 return this.getClass ().newInstance ();
\r
139 if (Clazz.exceptionOf (q, Exception)) {
\r
140 throw new Error (jalview.util.MessageManager.formatMessage ("error.implementation_error_cannot_duplicate_colour_scheme", Clazz.newArray (-1, [this.getClass ().getName ()])), q);
\r
145 }, "jalview.datamodel.AnnotatedCollectionI,java.util.Map");
\r