1 Clazz.declarePackage ("jalview.appletgui");
\r
2 Clazz.load (["awt2swing.Panel", "java.awt.event.ActionListener", "$.AdjustmentListener", "$.ItemListener", "$.MouseListener", "awt2swing.Checkbox", "$.Choice", "$.Scrollbar", "$.TextField"], "jalview.appletgui.FeatureColourChooser", ["awt2swing.Label", "jalview.appletgui.JVDialog", "$.PaintRefresher", "$.UserDefinedColours", "jalview.datamodel.GraphLine", "jalview.schemes.GraduatedColor", "jalview.util.MessageManager", "java.awt.Color", "$.Dimension", "$.FlowLayout", "$.Font", "$.GridLayout", "java.awt.event.ActionEvent", "java.lang.Float"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
10 this.oldgroupColours = null;
\r
11 this.adjusting = false;
\r
16 this.minColour = null;
\r
17 this.maxColour = null;
\r
18 this.jPanel1 = null;
\r
19 this.jPanel2 = null;
\r
20 this.threshold = null;
\r
21 this.jPanel3 = null;
\r
22 this.jPanel4 = null;
\r
24 this.thresholdValue = null;
\r
25 this.thresholdIsMin = null;
\r
26 this.colourFromLabel = null;
\r
27 this.threshline = null;
\r
28 Clazz.instantialize (this, arguments);
\r
29 }, jalview.appletgui, "FeatureColourChooser", awt2swing.Panel, [java.awt.event.ActionListener, java.awt.event.AdjustmentListener, java.awt.event.ItemListener, java.awt.event.MouseListener]);
\r
30 Clazz.prepareFields (c$, function () {
\r
31 this.minColour = new awt2swing.Panel ();
\r
32 this.maxColour = new awt2swing.Panel ();
\r
33 this.jPanel1 = new awt2swing.Panel ();
\r
34 this.jPanel2 = new awt2swing.Panel ();
\r
35 this.threshold = new awt2swing.Choice ();
\r
36 this.jPanel3 = new awt2swing.Panel ();
\r
37 this.jPanel4 = new awt2swing.Panel ();
\r
38 this.slider = new awt2swing.Scrollbar (0);
\r
39 this.thresholdValue = new awt2swing.TextField (20);
\r
40 this.thresholdIsMin = new awt2swing.Checkbox ();
\r
41 this.colourFromLabel = new awt2swing.Checkbox ();
\r
43 Clazz.makeConstructor (c$,
\r
44 function (af, type) {
\r
45 Clazz.superConstructor (this, jalview.appletgui.FeatureColourChooser, []);
\r
47 this.init (af.getSeqcanvas ().getFeatureRenderer (), type);
\r
48 }, "jalview.appletgui.AlignFrame,~S");
\r
49 Clazz.makeConstructor (c$,
\r
50 function (fsettings, type) {
\r
51 Clazz.superConstructor (this, jalview.appletgui.FeatureColourChooser, []);
\r
52 this.fs = fsettings;
\r
53 this.init (fsettings.fr, type);
\r
54 }, "jalview.appletgui.FeatureSettings,~S");
\r
55 Clazz.defineMethod (c$, "init",
\r
56 function (frenderer, type) {
\r
58 this.fr = frenderer;
\r
59 var mm = (this.fr.getMinMax ().get (type))[0];
\r
62 this.oldcs = this.fr.getFeatureColours ().get (type);
\r
63 if (Clazz.instanceOf (this.oldcs, jalview.schemes.GraduatedColor)) {
\r
64 this.cs = new jalview.schemes.GraduatedColor (this.oldcs, this.min, this.max);
\r
66 var bl = java.awt.Color.black;
\r
67 if (Clazz.instanceOf (this.oldcs, java.awt.Color)) {
\r
69 }this.cs = new jalview.schemes.GraduatedColor (java.awt.Color.white, bl, mm[0], mm[1]);
\r
70 }this.minColour.setBackground (this.cs.getMinColor ());
\r
71 this.maxColour.setBackground (this.cs.getMaxColor ());
\r
72 this.minColour.setForeground (this.cs.getMinColor ());
\r
73 this.maxColour.setForeground (this.cs.getMaxColor ());
\r
74 this.colourFromLabel.setState (this.cs.isColourByLabel ());
\r
75 this.adjusting = true;
\r
79 if (Clazz.exceptionOf (ex, Exception)) {
\r
84 this.threshold.select (new Integer (this.cs.getThreshType () == -1 ? 0 : this.cs.getThreshType () == 1 ? 1 : 2));
\r
85 this.adjusting = false;
\r
86 this.changeColour ();
\r
87 this.colourFromLabel.addItemListener (this);
\r
88 this.slider.addAdjustmentListener (this);
\r
89 this.slider.addMouseListener (this);
\r
90 this.owner = (this.af != null) ? this.af : this.fs.frame;
\r
91 this.frame = new jalview.appletgui.JVDialog (this.owner, jalview.util.MessageManager.formatMessage ("label.graduated_color_for_params", Clazz.newArray (-1, [type])), true, 480, 248);
\r
92 this.frame.setMainPanel (this);
\r
94 this.frame.setVisible (true);
\r
95 if (this.frame.accept) {
\r
96 this.changeColour ();
\r
99 jalview.appletgui.PaintRefresher.Refresh (this, this.fr.getViewport ().getSequenceSetId ());
\r
100 this.frame.setVisible (false);
\r
101 }}, "jalview.appletgui.FeatureRenderer,~S");
\r
102 Clazz.makeConstructor (c$,
\r
104 Clazz.superConstructor (this, jalview.appletgui.FeatureColourChooser, []);
\r
108 if (Clazz.exceptionOf (ex, Exception)) {
\r
109 ex.printStackTrace ();
\r
115 Clazz.defineMethod (c$, "jbInit",
\r
117 var minLabel = new awt2swing.Label (jalview.util.MessageManager.getString ("label.min"));
\r
118 var maxLabel = new awt2swing.Label (jalview.util.MessageManager.getString ("label.max"));
\r
119 minLabel.setFont ( new java.awt.Font ("Verdana", 0, 11));
\r
120 maxLabel.setFont ( new java.awt.Font ("Verdana", 0, 11));
\r
121 this.minColour.setBounds (0, 0, 40, 27);
\r
122 this.maxColour.setBounds (0, 0, 40, 27);
\r
123 this.minColour.addMouseListener (this);
\r
124 this.maxColour.setFont ( new java.awt.Font ("Verdana", 0, 11));
\r
125 this.maxColour.addMouseListener (this);
\r
126 this.thresholdIsMin.addItemListener (this);
\r
127 this.setLayout ( new java.awt.GridLayout (4, 1));
\r
128 this.jPanel1.setLayout ( new java.awt.FlowLayout ());
\r
129 this.jPanel2.setLayout ( new java.awt.FlowLayout ());
\r
130 this.jPanel3.setLayout ( new java.awt.GridLayout (1, 1));
\r
131 this.jPanel4.setLayout ( new java.awt.FlowLayout ());
\r
132 this.jPanel1.setBackground (java.awt.Color.white);
\r
133 this.jPanel2.setBackground (java.awt.Color.white);
\r
134 this.jPanel4.setBackground (java.awt.Color.white);
\r
135 this.threshold.addItemListener (this);
\r
136 this.threshold.addItem (jalview.util.MessageManager.getString ("label.threshold_feature_no_thereshold"));
\r
137 this.threshold.addItem (jalview.util.MessageManager.getString ("label.threshold_feature_above_thereshold"));
\r
138 this.threshold.addItem (jalview.util.MessageManager.getString ("label.threshold_feature_below_thereshold"));
\r
139 this.thresholdValue.addActionListener (this);
\r
140 this.slider.setBackground (java.awt.Color.white);
\r
141 this.slider.setEnabled (false);
\r
142 this.slider.setSize ( new java.awt.Dimension (93, 21));
\r
143 this.thresholdValue.setEnabled (false);
\r
144 this.thresholdValue.setSize ( new java.awt.Dimension (79, 22));
\r
145 this.thresholdValue.setColumns (5);
\r
146 this.jPanel3.setBackground (java.awt.Color.white);
\r
147 this.colourFromLabel.setFont ( new java.awt.Font ("Verdana", 0, 11));
\r
148 this.colourFromLabel.setLabel (jalview.util.MessageManager.getString ("label.colour_by_label"));
\r
149 this.colourFromLabel.setSize ( new java.awt.Dimension (139, 22));
\r
150 this.thresholdIsMin.setBackground (java.awt.Color.white);
\r
151 this.thresholdIsMin.setLabel (jalview.util.MessageManager.getString ("label.threshold_minmax"));
\r
152 this.thresholdIsMin.setSize ( new java.awt.Dimension (135, 23));
\r
153 this.jPanel1.add (minLabel);
\r
154 this.jPanel1.add (this.minColour);
\r
155 this.jPanel1.add (maxLabel);
\r
156 this.jPanel1.add (this.maxColour);
\r
157 this.jPanel1.add (this.colourFromLabel);
\r
158 this.jPanel2.add (this.threshold);
\r
159 this.jPanel3.add (this.slider);
\r
160 this.jPanel4.add (this.thresholdValue);
\r
161 this.jPanel4.add (this.thresholdIsMin);
\r
162 this.add (this.jPanel1);
\r
163 this.add (this.jPanel2);
\r
164 this.add (this.jPanel3);
\r
165 this.add (this.jPanel4);
\r
167 Clazz.overrideMethod (c$, "actionPerformed",
\r
169 if (evt.getSource () === this.thresholdValue) {
\r
171 var f = new Float (this.thresholdValue.getText ()).floatValue ();
\r
172 this.slider.setValue (Clazz.floatToInt (f * 1000));
\r
173 this.adjustmentValueChanged (null);
\r
175 if (Clazz.exceptionOf (ex, NumberFormatException)) {
\r
180 } else if (evt.getSource () === this.minColour) {
\r
181 this.minColour_actionPerformed (null);
\r
182 } else if (evt.getSource () === this.maxColour) {
\r
183 this.maxColour_actionPerformed (null);
\r
185 this.changeColour ();
\r
186 }}, "java.awt.event.ActionEvent");
\r
187 Clazz.overrideMethod (c$, "itemStateChanged",
\r
189 this.maxColour.setEnabled (!this.colourFromLabel.getState ());
\r
190 this.minColour.setEnabled (!this.colourFromLabel.getState ());
\r
191 this.changeColour ();
\r
192 }, "java.awt.event.ItemEvent");
\r
193 Clazz.overrideMethod (c$, "adjustmentValueChanged",
\r
195 if (!this.adjusting) {
\r
196 this.thresholdValue.setText ((this.slider.getValue () / 1000) + "");
\r
197 this.valueChanged ();
\r
198 }}, "java.awt.event.AdjustmentEvent");
\r
199 Clazz.defineMethod (c$, "valueChanged",
\r
201 this.threshline.value = this.slider.getValue () / 1000;
\r
202 this.cs.setThresh (this.threshline.value);
\r
203 this.changeColour ();
\r
204 jalview.appletgui.PaintRefresher.Refresh (this, this.fr.getViewport ().getSequenceSetId ());
\r
206 Clazz.defineMethod (c$, "minColour_actionPerformed",
\r
207 function (newCol) {
\r
208 if (newCol == null) {
\r
209 var udc = new jalview.appletgui.UserDefinedColours (this, this.minColour.getBackground (), this.owner, jalview.util.MessageManager.getString ("label.select_colour_minimum_value"));
\r
211 this.minColour.setBackground (newCol);
\r
212 this.minColour.setForeground (newCol);
\r
213 this.minColour.repaint ();
\r
214 this.changeColour ();
\r
215 }}, "java.awt.Color");
\r
216 Clazz.defineMethod (c$, "maxColour_actionPerformed",
\r
217 function (newCol) {
\r
218 if (newCol == null) {
\r
219 var udc = new jalview.appletgui.UserDefinedColours (this, this.maxColour.getBackground (), this.owner, jalview.util.MessageManager.getString ("label.select_colour_maximum_value"));
\r
221 this.maxColour.setBackground (newCol);
\r
222 this.maxColour.setForeground (newCol);
\r
223 this.maxColour.repaint ();
\r
224 this.changeColour ();
\r
225 }}, "java.awt.Color");
\r
226 Clazz.defineMethod (c$, "changeColour",
\r
228 if (this.adjusting) {
\r
230 }var aboveThreshold = -1;
\r
231 if (this.threshold.getSelectedIndex () == 1) {
\r
232 aboveThreshold = 1;
\r
233 } else if (this.threshold.getSelectedIndex () == 2) {
\r
234 aboveThreshold = 0;
\r
235 }this.slider.setEnabled (true);
\r
236 this.thresholdValue.setEnabled (true);
\r
237 var acg = new jalview.schemes.GraduatedColor (this.minColour.getBackground (), this.maxColour.getBackground (), this.min, this.max);
\r
238 acg.setColourByLabel (this.colourFromLabel.getState ());
\r
239 this.maxColour.setEnabled (!this.colourFromLabel.getState ());
\r
240 this.minColour.setEnabled (!this.colourFromLabel.getState ());
\r
241 if (aboveThreshold == -1) {
\r
242 this.slider.setEnabled (false);
\r
243 this.thresholdValue.setEnabled (false);
\r
244 this.thresholdValue.setText ("");
\r
245 } else if (aboveThreshold != -1 && this.threshline == null) {
\r
246 this.threshline = new jalview.datamodel.GraphLine ((this.max - this.min) / 2, "Threshold", java.awt.Color.black);
\r
247 }if (aboveThreshold != -1) {
\r
248 this.adjusting = true;
\r
249 acg.setThresh (this.threshline.value);
\r
250 var range = this.max * 1000 - this.min * 1000;
\r
251 this.slider.setMinimum (Clazz.floatToInt (this.min * 1000));
\r
252 this.slider.setMaximum (Clazz.floatToInt (this.max * 1000));
\r
253 this.slider.setValue (Clazz.floatToInt (this.threshline.value * 1000));
\r
254 this.thresholdValue.setText (this.threshline.value + "");
\r
255 this.slider.setEnabled (true);
\r
256 this.thresholdValue.setEnabled (true);
\r
257 this.adjusting = false;
\r
258 }acg.setThreshType (aboveThreshold);
\r
259 if (this.thresholdIsMin.getState () && aboveThreshold != -1) {
\r
260 if (aboveThreshold == 1) {
\r
261 acg = new jalview.schemes.GraduatedColor (acg, this.threshline.value, this.max);
\r
263 acg = new jalview.schemes.GraduatedColor (acg, this.min, this.threshline.value);
\r
264 }}this.fr.setColour (this.type, acg);
\r
266 jalview.appletgui.PaintRefresher.Refresh (this, this.fr.getViewport ().getSequenceSetId ());
\r
268 Clazz.defineMethod (c$, "reset",
\r
270 this.fr.setColour (this.type, this.oldcs);
\r
271 jalview.appletgui.PaintRefresher.Refresh (this, this.fr.getViewport ().getSequenceSetId ());
\r
273 Clazz.overrideMethod (c$, "mouseClicked",
\r
275 }, "java.awt.event.MouseEvent");
\r
276 Clazz.overrideMethod (c$, "mousePressed",
\r
278 }, "java.awt.event.MouseEvent");
\r
279 Clazz.overrideMethod (c$, "mouseReleased",
\r
281 if (evt.getSource () === this.minColour || evt.getSource () === this.maxColour) {
\r
282 this.actionPerformed ( new java.awt.event.ActionEvent (evt.getSource (), 1, "Clicked"));
\r
284 jalview.appletgui.PaintRefresher.Refresh (this, this.fr.getViewport ().getSequenceSetId ());
\r
285 }}, "java.awt.event.MouseEvent");
\r
286 Clazz.overrideMethod (c$, "mouseEntered",
\r
288 }, "java.awt.event.MouseEvent");
\r
289 Clazz.overrideMethod (c$, "mouseExited",
\r
291 }, "java.awt.event.MouseEvent");
\r