1 Clazz.declarePackage ("jalview.schemes");
\r
2 Clazz.load (["jalview.schemes.FollowerColourScheme"], "jalview.schemes.AnnotationColourGradient", ["jalview.datamodel.AlignmentI", "$.GraphLine", "jalview.renderer.AnnotationRenderer", "jalview.schemes.ColourSchemeProperty", "jalview.util.Comparison", "java.awt.Color", "java.util.IdentityHashMap"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
4 this.annotation = null;
\r
5 this.aboveAnnotationThreshold = -1;
\r
6 this.thresholdIsMinMax = false;
\r
7 this.annotationThreshold = null;
\r
14 this.predefinedColours = false;
\r
15 this.seqAssociated = false;
\r
16 this.noGradient = false;
\r
17 this.seqannot = null;
\r
20 Clazz.instantialize (this, arguments);
\r
21 }, jalview.schemes, "AnnotationColourGradient", jalview.schemes.FollowerColourScheme);
\r
22 Clazz.overrideMethod (c$, "applyTo",
\r
23 function (sg, hiddenRepSequences) {
\r
24 var acg = new jalview.schemes.AnnotationColourGradient (this.annotation, this.colourScheme, this.aboveAnnotationThreshold);
\r
25 acg.thresholdIsMinMax = this.thresholdIsMinMax;
\r
26 acg.annotationThreshold = (this.annotationThreshold == null) ? null : new jalview.datamodel.GraphLine (this.annotationThreshold);
\r
33 acg.predefinedColours = this.predefinedColours;
\r
34 acg.seqAssociated = this.seqAssociated;
\r
35 acg.noGradient = this.noGradient;
\r
37 }, "jalview.datamodel.AnnotatedCollectionI,java.util.Map");
\r
38 Clazz.makeConstructor (c$,
\r
39 function (annotation, originalColour, aboveThreshold) {
\r
40 Clazz.superConstructor (this, jalview.schemes.AnnotationColourGradient, []);
\r
41 if (Clazz.instanceOf (originalColour, jalview.schemes.AnnotationColourGradient)) {
\r
42 this.colourScheme = (originalColour).colourScheme;
\r
44 this.colourScheme = originalColour;
\r
45 }this.annotation = annotation;
\r
46 this.aboveAnnotationThreshold = aboveThreshold;
\r
47 if (aboveThreshold != -1 && annotation.threshold != null) {
\r
48 this.annotationThreshold = annotation.threshold;
\r
55 this.noGradient = true;
\r
56 }, "jalview.datamodel.AlignmentAnnotation,jalview.schemes.ColourSchemeI,~N");
\r
57 Clazz.makeConstructor (c$,
\r
58 function (annotation, minColour, maxColour, aboveThreshold) {
\r
59 Clazz.superConstructor (this, jalview.schemes.AnnotationColourGradient, []);
\r
60 this.annotation = annotation;
\r
61 this.aboveAnnotationThreshold = aboveThreshold;
\r
62 if (aboveThreshold != -1 && annotation.threshold != null) {
\r
63 this.annotationThreshold = annotation.threshold;
\r
64 }this.r1 = minColour.getRed ();
\r
65 this.g1 = minColour.getGreen ();
\r
66 this.b1 = minColour.getBlue ();
\r
67 this.rr = maxColour.getRed () - this.r1;
\r
68 this.gg = maxColour.getGreen () - this.g1;
\r
69 this.bb = maxColour.getBlue () - this.b1;
\r
70 this.noGradient = false;
\r
71 this.aamax = annotation.graphMax;
\r
72 this.aamin = annotation.graphMin;
\r
73 if (annotation.isRNA ()) {
\r
74 jalview.schemes.ColourSchemeProperty.initRnaHelicesShading (1 + Clazz.floatToInt (this.aamax));
\r
75 }}, "jalview.datamodel.AlignmentAnnotation,java.awt.Color,java.awt.Color,~N");
\r
76 Clazz.defineMethod (c$, "alignmentChanged",
\r
77 function (alignment, hiddenReps) {
\r
78 Clazz.superCall (this, jalview.schemes.AnnotationColourGradient, "alignmentChanged", [alignment, hiddenReps]);
\r
79 if (this.seqAssociated && this.annotation.getCalcId () != null) {
\r
80 if (this.seqannot != null) {
\r
81 this.seqannot.clear ();
\r
83 this.seqannot = new java.util.IdentityHashMap ();
\r
84 }var alcontext = Clazz.instanceOf (alignment, jalview.datamodel.AlignmentI) ? alignment : alignment.getContext ();
\r
87 for (var alan, $alan = alcontext.findAnnotation (this.annotation.getCalcId ()).iterator (); $alan.hasNext () && ((alan = $alan.next ()) || true);) {
\r
88 if (alan.sequenceRef != null && (alan.label != null && this.annotation != null && alan.label.equals (this.annotation.label))) {
\r
89 if (!rna && alan.isRNA ()) {
\r
91 }this.seqannot.put (alan.sequenceRef, alan);
\r
92 if (f || alan.graphMax > this.aamax) {
\r
93 this.aamax = alan.graphMax;
\r
94 }if (f || alan.graphMin < this.aamin) {
\r
95 this.aamin = alan.graphMin;
\r
99 jalview.schemes.ColourSchemeProperty.initRnaHelicesShading (1 + Clazz.floatToInt (this.aamax));
\r
100 }}}, "jalview.datamodel.AnnotatedCollectionI,java.util.Map");
\r
101 Clazz.defineMethod (c$, "getAnnotation",
\r
103 return this.annotation.label;
\r
105 Clazz.defineMethod (c$, "getAboveThreshold",
\r
107 return this.aboveAnnotationThreshold;
\r
109 Clazz.defineMethod (c$, "getAnnotationThreshold",
\r
111 if (this.annotationThreshold == null) {
\r
114 return this.annotationThreshold.value;
\r
116 Clazz.defineMethod (c$, "getMinColour",
\r
118 return new java.awt.Color (Clazz.floatToInt (this.r1), Clazz.floatToInt (this.g1), Clazz.floatToInt (this.b1));
\r
120 Clazz.defineMethod (c$, "getMaxColour",
\r
122 return new java.awt.Color (Clazz.floatToInt (this.r1 + this.rr), Clazz.floatToInt (this.g1 + this.gg), Clazz.floatToInt (this.b1 + this.bb));
\r
124 Clazz.defineMethod (c$, "findColour",
\r
126 return java.awt.Color.red;
\r
128 Clazz.defineMethod (c$, "findColour",
\r
129 function (c, j, seq) {
\r
130 var currentColour = java.awt.Color.white;
\r
131 var annotation = (this.seqAssociated && this.seqannot != null ? this.seqannot.get (seq) : this.annotation);
\r
132 if (annotation == null) {
\r
133 return currentColour;
\r
134 }if ((this.threshold == 0) || this.aboveThreshold (c, j)) {
\r
135 if (annotation.annotations != null && j < annotation.annotations.length && annotation.annotations[j] != null && !jalview.util.Comparison.isGap (c)) {
\r
136 var aj = annotation.annotations[j];
\r
137 if (this.aboveAnnotationThreshold == -1 || (this.annotationThreshold != null && (this.aboveAnnotationThreshold == 1 ? aj.value >= this.annotationThreshold.value : aj.value <= this.annotationThreshold.value))) {
\r
138 if (this.predefinedColours && aj.colour != null && !aj.colour.equals (java.awt.Color.black)) {
\r
139 currentColour = aj.colour;
\r
140 } else if (annotation.hasIcons && annotation.graph == 0) {
\r
141 if (aj.secondaryStructure > ' ' && aj.secondaryStructure != '.' && aj.secondaryStructure != '-') {
\r
142 if (this.colourScheme != null) {
\r
143 currentColour = this.colourScheme.findColour (c, j, seq);
\r
145 if (annotation.isRNA ()) {
\r
146 currentColour = jalview.schemes.ColourSchemeProperty.rnaHelices[Clazz.floatToInt (aj.value)];
\r
148 currentColour = annotation.annotations[j].secondaryStructure == 'H' ? jalview.renderer.AnnotationRenderer.HELIX_COLOUR : annotation.annotations[j].secondaryStructure == 'E' ? jalview.renderer.AnnotationRenderer.SHEET_COLOUR : jalview.renderer.AnnotationRenderer.STEM_COLOUR;
\r
150 return java.awt.Color.white;
\r
151 }} else if (this.noGradient) {
\r
152 if (this.colourScheme != null) {
\r
153 currentColour = this.colourScheme.findColour (c, j, seq);
\r
155 if (aj.colour != null) {
\r
156 currentColour = aj.colour;
\r
158 currentColour = this.shadeCalculation (annotation, j);
\r
159 }}if (this.conservationColouring) {
\r
160 currentColour = this.applyConservation (currentColour, j);
\r
161 }}}return currentColour;
\r
162 }, "~S,~N,jalview.datamodel.SequenceI");
\r
163 Clazz.defineMethod (c$, "shadeCalculation",
\r
164 ($fz = function (annotation, j) {
\r
166 if (this.thresholdIsMinMax && annotation.threshold != null && this.aboveAnnotationThreshold == 1 && annotation.annotations[j].value >= annotation.threshold.value) {
\r
167 range = (annotation.annotations[j].value - annotation.threshold.value) / (annotation.graphMax - annotation.threshold.value);
\r
168 } else if (this.thresholdIsMinMax && annotation.threshold != null && this.aboveAnnotationThreshold == 0 && annotation.annotations[j].value >= annotation.graphMin) {
\r
169 range = (annotation.annotations[j].value - annotation.graphMin) / (annotation.threshold.value - annotation.graphMin);
\r
171 if (annotation.graphMax != annotation.graphMin) {
\r
172 range = (annotation.annotations[j].value - annotation.graphMin) / (annotation.graphMax - annotation.graphMin);
\r
175 }}var dr = Clazz.floatToInt (this.rr * range + this.r1);
\r
176 var dg = Clazz.floatToInt (this.gg * range + this.g1);
\r
177 var db = Clazz.floatToInt (this.bb * range + this.b1);
\r
178 return new java.awt.Color (dr, dg, db);
\r
179 }, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentAnnotation,~N");
\r
180 Clazz.defineMethod (c$, "isPredefinedColours",
\r
182 return this.predefinedColours;
\r
184 Clazz.defineMethod (c$, "setPredefinedColours",
\r
185 function (predefinedColours) {
\r
186 this.predefinedColours = predefinedColours;
\r
188 Clazz.defineMethod (c$, "isSeqAssociated",
\r
190 return this.seqAssociated;
\r
192 Clazz.defineMethod (c$, "setSeqAssociated",
\r
193 function (sassoc) {
\r
194 this.seqAssociated = sassoc;
\r
196 Clazz.defineStatics (c$,
\r
197 "NO_THRESHOLD", -1,
\r
198 "BELOW_THRESHOLD", 0,
\r
199 "ABOVE_THRESHOLD", 1);
\r