1 Clazz.declarePackage ("jalview.appletgui");
2 Clazz.load (["awt2swing.Panel", "java.awt.event.ActionListener", "$.AdjustmentListener", "$.ItemListener", "$.MouseListener", "awt2swing.Button", "$.Checkbox", "$.Choice", "$.Scrollbar", "$.TextField", "java.awt.BorderLayout", "$.FlowLayout"], "jalview.appletgui.AnnotationColourChooser", ["awt2swing.Frame", "jalview.appletgui.UserDefinedColours", "jalview.bin.JalviewLite", "jalview.datamodel.GraphLine", "jalview.schemes.AnnotationColourGradient", "$.ColourSchemeI", "jalview.util.MessageManager", "java.awt.Color", "$.Dimension", "$.Font", "java.lang.Error", "$.Float", "java.util.Hashtable", "$.Vector"], function () {
3 c$ = Clazz.decorateAsClass (function () {
8 this.oldgroupColours = null;
9 this.currentAnnotation = null;
10 this.adjusting = false;
11 this.annotations = null;
12 this.minColour = null;
13 this.maxColour = null;
16 this.defColours = null;
19 this.threshold = null;
20 this.flowLayout1 = null;
23 this.thresholdValue = null;
24 this.currentColours = null;
25 this.borderLayout1 = null;
26 this.thresholdIsMin = null;
27 Clazz.instantialize (this, arguments);
28 }, jalview.appletgui, "AnnotationColourChooser", awt2swing.Panel, [java.awt.event.ActionListener, java.awt.event.AdjustmentListener, java.awt.event.ItemListener, java.awt.event.MouseListener]);
29 Clazz.prepareFields (c$, function () {
30 this.annotations = new awt2swing.Choice ();
31 this.minColour = new awt2swing.Button ();
32 this.maxColour = new awt2swing.Button ();
33 this.ok = new awt2swing.Button ();
34 this.cancel = new awt2swing.Button ();
35 this.defColours = new awt2swing.Button ();
36 this.jPanel1 = new awt2swing.Panel ();
37 this.jPanel2 = new awt2swing.Panel ();
38 this.threshold = new awt2swing.Choice ();
39 this.flowLayout1 = new java.awt.FlowLayout ();
40 this.jPanel3 = new awt2swing.Panel ();
41 this.slider = new awt2swing.Scrollbar (0);
42 this.thresholdValue = new awt2swing.TextField (20);
43 this.currentColours = new awt2swing.Checkbox ();
44 this.borderLayout1 = new java.awt.BorderLayout ();
45 this.thresholdIsMin = new awt2swing.Checkbox ();
47 Clazz.makeConstructor (c$,
49 Clazz.superConstructor (this, jalview.appletgui.AnnotationColourChooser, []);
53 if (Clazz.exceptionOf (ex, Exception)) {
58 this.oldcs = av.getGlobalColourScheme ();
59 if (av.getAlignment ().getGroups () != null) {
60 this.oldgroupColours = new java.util.Hashtable ();
61 for (var sg, $sg = ap.av.getAlignment ().getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) {
63 this.oldgroupColours.put (sg, sg.cs);
65 this.oldgroupColours.put (sg, "null");
69 this.slider.addAdjustmentListener (this);
70 this.slider.addMouseListener (this);
71 if (av.getAlignment ().getAlignmentAnnotation () == null) {
73 }this.setDefaultMinMax ();
74 this.adjusting = true;
75 if (Clazz.instanceOf (this.oldcs, jalview.schemes.AnnotationColourGradient)) {
77 this.currentColours.setState (acg.isPredefinedColours () || acg.getBaseColour () != null);
78 if (!acg.isPredefinedColours () && acg.getBaseColour () == null) {
79 this.minColour.setBackground (acg.getMinColour ());
80 this.maxColour.setBackground (acg.getMaxColour ());
81 }}var list = new java.util.Vector ();
83 for (var i = 0; i < av.getAlignment ().getAlignmentAnnotation ().length; i++) {
84 var label = av.getAlignment ().getAlignmentAnnotation ()[i].label;
85 if (!list.contains (label)) {
86 list.addElement (label);
88 list.addElement (label + "_" + (index++));
90 for (var i = 0; i < list.size (); i++) {
91 this.annotations.addItem (list.elementAt (i).toString ());
93 this.threshold.addItem (jalview.util.MessageManager.getString ("label.threshold_feature_no_thereshold"));
94 this.threshold.addItem (jalview.util.MessageManager.getString ("label.threshold_feature_above_thereshold"));
95 this.threshold.addItem (jalview.util.MessageManager.getString ("label.threshold_feature_below_thereshold"));
96 if (Clazz.instanceOf (this.oldcs, jalview.schemes.AnnotationColourGradient)) {
98 this.annotations.select (acg.getAnnotation ());
99 switch (acg.getAboveThreshold ()) {
101 this.threshold.select (new Integer (0));
104 this.threshold.select (new Integer (1));
107 this.threshold.select (new Integer (1));
110 throw new Error (jalview.util.MessageManager.getString ("error.implementation_error_dont_know_thereshold_annotationcolourgradient"));
112 this.thresholdIsMin.setState (acg.thresholdIsMinMax);
113 this.thresholdValue.setText ("" + acg.getAnnotationThreshold ());
114 }this.adjusting = false;
115 this.changeColour ();
116 this.frame = new awt2swing.Frame ();
117 this.frame.add (this);
118 jalview.bin.JalviewLite.addFrame (this.frame, jalview.util.MessageManager.getString ("label.colour_by_annotation"), 560, 175);
120 }, "jalview.appletgui.AlignViewport,jalview.appletgui.AlignmentPanel");
121 Clazz.defineMethod (c$, "setDefaultMinMax",
123 this.minColour.setBackground (this.av.applet.getDefaultColourParameter ("ANNOTATIONCOLOUR_MIN", java.awt.Color.orange));
124 this.maxColour.setBackground (this.av.applet.getDefaultColourParameter ("ANNOTATIONCOLOUR_MAX", java.awt.Color.red));
125 }, $fz.isPrivate = true, $fz));
126 Clazz.makeConstructor (c$,
128 Clazz.superConstructor (this, jalview.appletgui.AnnotationColourChooser, []);
132 if (Clazz.exceptionOf (ex, Exception)) {
133 ex.printStackTrace ();
139 Clazz.defineMethod (c$, "jbInit",
141 this.minColour.setFont ( new java.awt.Font ("Verdana", 0, 11));
142 this.minColour.setLabel (jalview.util.MessageManager.getString ("label.min_colour"));
143 this.minColour.addActionListener (this);
144 this.maxColour.setFont ( new java.awt.Font ("Verdana", 0, 11));
145 this.maxColour.setLabel (jalview.util.MessageManager.getString ("label.max_colour"));
146 this.maxColour.addActionListener (this);
147 this.thresholdIsMin.addItemListener (this);
148 this.ok.setLabel (jalview.util.MessageManager.getString ("action.ok"));
149 this.ok.addActionListener (this);
150 this.cancel.setLabel (jalview.util.MessageManager.getString ("action.cancel"));
151 this.cancel.addActionListener (this);
152 this.defColours.setLabel (jalview.util.MessageManager.getString ("action.set_defaults"));
153 this.defColours.addActionListener (this);
154 this.annotations.addItemListener (this);
155 this.thresholdValue.addActionListener (this);
156 this.slider.setBackground (java.awt.Color.white);
157 this.slider.setPreferredSize ( new java.awt.Dimension (193, 21));
158 this.slider.setEnabled (false);
159 this.thresholdValue.setPreferredSize ( new java.awt.Dimension (79, 22));
160 this.thresholdValue.setEnabled (false);
161 this.thresholdValue.setColumns (5);
162 this.currentColours.setFont ( new java.awt.Font ("Verdana", 0, 11));
163 this.currentColours.setLabel (jalview.util.MessageManager.getString ("label.use_original_colours"));
164 this.currentColours.addItemListener (this);
165 this.thresholdIsMin.setBackground (java.awt.Color.white);
166 this.thresholdIsMin.setLabel (jalview.util.MessageManager.getString ("label.threshold_minmax"));
167 this.setLayout (this.borderLayout1);
168 this.jPanel1.setBackground (java.awt.Color.white);
169 this.jPanel2.setLayout ( new java.awt.FlowLayout ());
170 this.jPanel2.setBackground (java.awt.Color.white);
171 this.threshold.addItemListener (this);
172 this.jPanel3.setLayout ( new java.awt.FlowLayout ());
173 this.jPanel3.setBackground (java.awt.Color.white);
174 var jPanel4 = new awt2swing.Panel ();
175 jPanel4.setLayout ( new java.awt.BorderLayout ());
176 jPanel4.setBackground (java.awt.Color.white);
177 this.jPanel1.add (this.ok);
178 this.jPanel1.add (this.cancel);
179 this.jPanel2.add (this.annotations);
180 this.jPanel2.add (this.currentColours);
181 this.jPanel2.add (this.minColour);
182 this.jPanel2.add (this.maxColour);
183 jPanel4.add (this.thresholdIsMin, "West");
184 jPanel4.add (this.slider, "Center");
185 jPanel4.add (this.thresholdValue, "East");
186 var jPanel34 = new awt2swing.Panel ();
187 jPanel34.setLayout ( new java.awt.BorderLayout ());
188 jPanel34.setBackground (java.awt.Color.white);
189 jPanel34.add (this.jPanel2, "North");
190 jPanel34.add (this.threshold, "West");
191 this.jPanel3.add (this.defColours);
192 jPanel34.add (this.jPanel3, "East");
193 jPanel34.add (jPanel4, "South");
194 this.add (jPanel34, "Center");
195 this.add (this.jPanel1, "South");
196 }, $fz.isPrivate = true, $fz));
197 Clazz.overrideMethod (c$, "actionPerformed",
199 if (evt.getSource () === this.thresholdValue) {
201 var f = new Float (this.thresholdValue.getText ()).floatValue ();
202 this.slider.setValue (Clazz.floatToInt (f * 1000));
203 this.adjustmentValueChanged (null);
205 if (Clazz.exceptionOf (ex, NumberFormatException)) {
210 } else if (evt.getSource () === this.minColour) {
211 this.minColour_actionPerformed (null);
212 } else if (evt.getSource () === this.maxColour) {
213 this.maxColour_actionPerformed (null);
214 } else if (evt.getSource () === this.defColours) {
215 this.defColour_actionPerformed ();
216 } else if (evt.getSource () === this.ok) {
217 this.changeColour ();
218 this.frame.setVisible (false);
219 } else if (evt.getSource () === this.cancel) {
221 this.ap.paintAlignment (true);
222 this.frame.setVisible (false);
224 this.changeColour ();
225 }}, "java.awt.event.ActionEvent");
226 Clazz.overrideMethod (c$, "itemStateChanged",
228 if (evt.getSource () === this.currentColours) {
229 if (this.currentColours.getState ()) {
231 }this.maxColour.setEnabled (!this.currentColours.getState ());
232 this.minColour.setEnabled (!this.currentColours.getState ());
233 }this.changeColour ();
234 }, "java.awt.event.ItemEvent");
235 Clazz.overrideMethod (c$, "adjustmentValueChanged",
237 if (!this.adjusting) {
238 this.thresholdValue.setText ((this.slider.getValue () / 1000) + "");
239 if (this.currentColours.getState () && !(Clazz.instanceOf (this.av.getGlobalColourScheme (), jalview.schemes.AnnotationColourGradient))) {
240 this.changeColour ();
241 }this.currentAnnotation.threshold.value = this.slider.getValue () / 1000;
242 this.ap.paintAlignment (false);
243 }}, "java.awt.event.AdjustmentEvent");
244 Clazz.defineMethod (c$, "minColour_actionPerformed",
246 if (newCol != null) {
247 this.minColour.setBackground (newCol);
248 this.minColour.repaint ();
249 this.changeColour ();
251 new jalview.appletgui.UserDefinedColours (this, "Min Colour", this.minColour.getBackground ());
252 }}, "java.awt.Color");
253 Clazz.defineMethod (c$, "maxColour_actionPerformed",
255 if (newCol != null) {
256 this.maxColour.setBackground (newCol);
257 this.maxColour.repaint ();
258 this.changeColour ();
260 new jalview.appletgui.UserDefinedColours (this, "Max Colour", this.maxColour.getBackground ());
261 }}, "java.awt.Color");
262 Clazz.defineMethod (c$, "defColour_actionPerformed",
264 this.setDefaultMinMax ();
265 this.minColour.repaint ();
266 this.maxColour.repaint ();
267 this.changeColour ();
269 Clazz.defineMethod (c$, "changeColour",
271 if (this.adjusting) {
273 }this.currentAnnotation = this.av.getAlignment ().getAlignmentAnnotation ()[this.annotations.getSelectedIndex ()];
274 var aboveThreshold = -1;
275 if (this.threshold.getSelectedIndex () == 1) {
277 } else if (this.threshold.getSelectedIndex () == 2) {
279 }this.slider.setEnabled (true);
280 this.thresholdValue.setEnabled (true);
281 this.thresholdIsMin.setEnabled (true);
282 if (aboveThreshold == -1) {
283 this.slider.setEnabled (false);
284 this.thresholdValue.setEnabled (false);
285 this.thresholdIsMin.setEnabled (false);
286 this.thresholdValue.setText ("");
287 } else if (aboveThreshold != -1 && this.currentAnnotation.threshold == null) {
288 this.currentAnnotation.setThreshold ( new jalview.datamodel.GraphLine ((this.currentAnnotation.graphMax - this.currentAnnotation.graphMin) / 2, "Threshold", java.awt.Color.black));
289 }if (aboveThreshold != -1) {
290 this.adjusting = true;
291 this.slider.setMinimum (Clazz.floatToInt (this.currentAnnotation.graphMin * 1000));
292 this.slider.setMaximum (Clazz.floatToInt (this.currentAnnotation.graphMax * 1000));
293 this.slider.setValue (Clazz.floatToInt (this.currentAnnotation.threshold.value * 1000));
294 this.thresholdValue.setText (this.currentAnnotation.threshold.value + "");
295 this.slider.setEnabled (true);
296 this.thresholdValue.setEnabled (true);
297 this.adjusting = false;
299 if (this.currentColours.getState ()) {
300 acg = new jalview.schemes.AnnotationColourGradient (this.currentAnnotation, this.av.getGlobalColourScheme (), aboveThreshold);
302 acg = new jalview.schemes.AnnotationColourGradient (this.currentAnnotation, this.minColour.getBackground (), this.maxColour.getBackground (), aboveThreshold);
303 }if (this.currentAnnotation.graphMin == 0 && this.currentAnnotation.graphMax == 0) {
304 acg.setPredefinedColours (true);
305 }acg.thresholdIsMinMax = this.thresholdIsMin.getState ();
306 this.av.setGlobalColourScheme (acg);
307 if (this.av.getAlignment ().getGroups () != null) {
308 for (var sg, $sg = this.ap.av.getAlignment ().getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) {
311 }if (this.currentColours.getState ()) {
312 sg.cs = new jalview.schemes.AnnotationColourGradient (this.currentAnnotation, sg.cs, aboveThreshold);
314 sg.cs = new jalview.schemes.AnnotationColourGradient (this.currentAnnotation, this.minColour.getBackground (), this.maxColour.getBackground (), aboveThreshold);
316 }this.ap.alignmentChanged ();
317 this.ap.paintAlignment (true);
319 Clazz.defineMethod (c$, "reset",
321 this.av.setGlobalColourScheme (this.oldcs);
322 if (this.av.getAlignment ().getGroups () != null) {
323 for (var sg, $sg = this.ap.av.getAlignment ().getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) {
324 var cs = this.oldgroupColours.get (sg);
325 if (Clazz.instanceOf (cs, jalview.schemes.ColourSchemeI)) {
330 }this.ap.paintAlignment (true);
332 Clazz.overrideMethod (c$, "mouseClicked",
334 }, "java.awt.event.MouseEvent");
335 Clazz.overrideMethod (c$, "mousePressed",
337 }, "java.awt.event.MouseEvent");
338 Clazz.overrideMethod (c$, "mouseReleased",
340 this.ap.paintAlignment (true);
341 }, "java.awt.event.MouseEvent");
342 Clazz.overrideMethod (c$, "mouseEntered",
344 }, "java.awt.event.MouseEvent");
345 Clazz.overrideMethod (c$, "mouseExited",
347 }, "java.awt.event.MouseEvent");