1 Clazz.declarePackage ("jalview.appletgui");
2 Clazz.load (["awt2swing.Panel", "java.awt.event.ActionListener", "$.AdjustmentListener", "$.FocusListener", "awt2swing.Button", "$.Label", "$.Scrollbar", "$.TextField", "java.awt.GridLayout", "java.util.Vector"], "jalview.appletgui.UserDefinedColours", ["awt2swing.Frame", "jalview.appletgui.AnnotationColourChooser", "$.FeatureColourChooser", "$.FeatureRenderer", "$.FeatureSettings", "jalview.bin.JalviewLite", "jalview.schemes.ResidueProperties", "$.UserColourScheme", "jalview.util.MessageManager", "java.awt.Color", "$.Dialog", "$.Font", "$.Rectangle", "java.awt.event.MouseAdapter", "java.lang.Error"], function () {
3 c$ = Clazz.decorateAsClass (function () {
6 this.selectedButton = null;
7 this.oldColours = null;
8 this.oldColourScheme = null;
13 this.originalLabel = null;
14 this.originalColour = null;
18 this.buttonPanel = null;
19 this.gridLayout = null;
20 this.okcancelPanel = null;
22 this.applyButton = null;
23 this.cancelButton = null;
24 this.rScroller = null;
28 this.gScroller = null;
31 this.bScroller = null;
34 Clazz.instantialize (this, arguments);
35 }, jalview.appletgui, "UserDefinedColours", awt2swing.Panel, [java.awt.event.ActionListener, java.awt.event.AdjustmentListener, java.awt.event.FocusListener]);
36 Clazz.prepareFields (c$, function () {
37 this.oldColours = new java.util.Vector ();
38 this.buttonPanel = new awt2swing.Panel ();
39 this.gridLayout = new java.awt.GridLayout ();
40 this.okcancelPanel = new awt2swing.Panel ();
41 this.okButton = new awt2swing.Button ();
42 this.applyButton = new awt2swing.Button ();
43 this.cancelButton = new awt2swing.Button ();
44 this.rScroller = new awt2swing.Scrollbar ();
45 this.label1 = new awt2swing.Label ();
46 this.rText = new awt2swing.TextField ();
47 this.label4 = new awt2swing.Label ();
48 this.gScroller = new awt2swing.Scrollbar ();
49 this.gText = new awt2swing.TextField ();
50 this.label5 = new awt2swing.Label ();
51 this.bScroller = new awt2swing.Scrollbar ();
52 this.bText = new awt2swing.TextField ();
53 this.target = new awt2swing.Panel ();
55 Clazz.defineMethod (c$, "loadDefaultColours",
59 Clazz.makeConstructor (c$,
61 Clazz.superConstructor (this, jalview.appletgui.UserDefinedColours, []);
64 if (this.seqGroup != null) {
65 this.oldColourScheme = this.seqGroup.cs;
67 this.oldColourScheme = ap.av.getGlobalColourScheme ();
69 }, "jalview.appletgui.AlignmentPanel,jalview.datamodel.SequenceGroup");
70 Clazz.makeConstructor (c$,
72 Clazz.superConstructor (this, jalview.appletgui.UserDefinedColours, []);
75 }, "jalview.appletgui.AppletJmol");
76 Clazz.makeConstructor (c$,
77 function (fr, alignframe) {
78 Clazz.superConstructor (this, jalview.appletgui.UserDefinedColours, []);
80 this.originalColour = fr.colourPanel.getBackground ();
81 this.originalLabel = "Feature Colour";
82 this.setForDialog ("Select Feature Colour", alignframe);
83 this.setTargetColour (fr.colourPanel.getBackground ());
84 this.dialog.setVisible (true);
85 }, "jalview.appletgui.FeatureRenderer,awt2swing.Frame");
86 Clazz.makeConstructor (c$,
87 function (caller, col1, alignframe) {
88 this.construct (caller, col1, alignframe, "Select Colour");
89 }, "java.awt.Component,java.awt.Color,awt2swing.Frame");
90 Clazz.makeConstructor (c$,
91 function (caller, col1, alignframe, title) {
92 Clazz.superConstructor (this, jalview.appletgui.UserDefinedColours, []);
94 this.originalColour = col1;
95 this.originalLabel = title;
96 this.setForDialog (title, alignframe);
97 this.setTargetColour (col1);
98 this.dialog.setVisible (true);
99 }, "java.awt.Component,java.awt.Color,awt2swing.Frame,~S");
100 Clazz.makeConstructor (c$,
101 function (caller, label, colour) {
102 this.construct (caller, label, colour, colour);
103 }, "~O,~S,java.awt.Color");
104 Clazz.makeConstructor (c$,
105 function (me, type, graduatedColor) {
106 this.construct (me, type, graduatedColor, graduatedColor.getMaxColor ());
107 }, "jalview.appletgui.FeatureSettings,~S,jalview.schemes.GraduatedColor");
108 Clazz.makeConstructor (c$,
109 ($fz = function (caller, label, ocolour, colour) {
110 Clazz.superConstructor (this, jalview.appletgui.UserDefinedColours, []);
111 this.caller = caller;
112 this.originalColour = ocolour;
113 this.originalLabel = label;
115 this.remove (this.buttonPanel);
116 this.setTargetColour (colour);
117 this.okcancelPanel.setBounds ( new java.awt.Rectangle (0, 113, 400, 35));
118 this.frame.setTitle (jalview.util.MessageManager.getString ("label.user_defined_colours") + " - " + label);
119 this.frame.setSize (420, 200);
120 }, $fz.isPrivate = true, $fz), "~O,~S,~O,java.awt.Color");
121 Clazz.defineMethod (c$, "setForDialog",
122 function (title, alignframe) {
124 this.frame.setVisible (false);
125 this.remove (this.buttonPanel);
126 if (Clazz.instanceOf (alignframe, awt2swing.Frame)) {
127 this.dialog = new java.awt.Dialog (alignframe, title, true);
129 throw new Error (jalview.util.MessageManager.getString ("label.error_unsupported_owwner_user_colour_scheme"));
130 }this.dialog.add (this);
131 this.setSize (400, 123);
132 this.okcancelPanel.setBounds ( new java.awt.Rectangle (0, 123, 400, 35));
133 var height = 160 + alignframe.getInsets ().top + this.getInsets ().bottom;
135 this.dialog.setBounds (alignframe.getBounds ().x + Clazz.doubleToInt ((alignframe.getSize ().width - width) / 2), alignframe.getBounds ().y + Clazz.doubleToInt ((alignframe.getSize ().height - height) / 2), width, height);
136 }, "~S,java.awt.Container");
137 Clazz.overrideMethod (c$, "actionPerformed",
139 var source = evt.getSource ();
140 if (source === this.okButton) {
141 this.okButton_actionPerformed ();
142 } else if (source === this.applyButton) {
143 this.applyButton_actionPerformed ();
144 } else if (source === this.cancelButton) {
145 this.cancelButton_actionPerformed ();
146 } else if (source === this.rText) {
147 this.rText_actionPerformed ();
148 } else if (source === this.gText) {
149 this.gText_actionPerformed ();
150 } else if (source === this.bText) {
151 this.bText_actionPerformed ();
152 }}, "java.awt.event.ActionEvent");
153 Clazz.overrideMethod (c$, "adjustmentValueChanged",
155 if (evt.getSource () === this.rScroller) {
156 this.rScroller_adjustmentValueChanged ();
157 } else if (evt.getSource () === this.gScroller) {
158 this.gScroller_adjustmentValueChanged ();
159 } else if (evt.getSource () === this.bScroller) {
160 this.bScroller_adjustmentValueChanged ();
161 }}, "java.awt.event.AdjustmentEvent");
162 Clazz.defineMethod (c$, "init",
167 if (Clazz.exceptionOf (e, Exception)) {
168 e.printStackTrace ();
173 this.frame = new awt2swing.Frame ();
174 this.frame.add (this);
175 jalview.bin.JalviewLite.addFrame (this.frame, jalview.util.MessageManager.getString ("label.user_defined_colours"), 420, 345);
176 if (this.seqGroup != null) {
177 this.frame.setTitle (this.frame.getTitle () + " (" + this.seqGroup.getName () + ")");
178 }for (var i = 0; i < 20; i++) {
179 this.makeButton (jalview.schemes.ResidueProperties.aa2Triplet.get (jalview.schemes.ResidueProperties.aa[i]) + "", jalview.schemes.ResidueProperties.aa[i]);
181 this.makeButton ("B", "B");
182 this.makeButton ("Z", "Z");
183 this.makeButton ("X", "X");
184 this.makeButton ("Gap", "'.','-',' '");
187 Clazz.defineMethod (c$, "rText_actionPerformed",
190 var i = Integer.parseInt (this.rText.getText ());
191 this.rScroller.setValue (i);
192 this.rScroller_adjustmentValueChanged ();
194 if (Clazz.exceptionOf (ex, NumberFormatException)) {
200 Clazz.defineMethod (c$, "gText_actionPerformed",
203 var i = Integer.parseInt (this.gText.getText ());
204 this.gScroller.setValue (i);
205 this.gScroller_adjustmentValueChanged ();
207 if (Clazz.exceptionOf (ex, NumberFormatException)) {
213 Clazz.defineMethod (c$, "bText_actionPerformed",
216 var i = Integer.parseInt (this.bText.getText ());
217 this.bScroller.setValue (i);
218 this.bScroller_adjustmentValueChanged ();
220 if (Clazz.exceptionOf (ex, NumberFormatException)) {
226 Clazz.defineMethod (c$, "rScroller_adjustmentValueChanged",
228 this.R = this.rScroller.getValue ();
229 this.rText.setText (this.R + "");
230 this.colourChanged ();
232 Clazz.defineMethod (c$, "gScroller_adjustmentValueChanged",
234 this.G = this.gScroller.getValue ();
235 this.gText.setText (this.G + "");
236 this.colourChanged ();
238 Clazz.defineMethod (c$, "bScroller_adjustmentValueChanged",
240 this.B = this.bScroller.getValue ();
241 this.bText.setText (this.B + "");
242 this.colourChanged ();
244 Clazz.defineMethod (c$, "colourChanged",
246 var col = new java.awt.Color (this.R, this.G, this.B);
247 this.target.setBackground (col);
248 this.target.repaint ();
249 if (this.selectedButton != null) {
250 this.selectedButton.setBackground (col);
251 this.selectedButton.repaint ();
253 Clazz.defineMethod (c$, "setTargetColour",
255 this.R = col.getRed ();
256 this.G = col.getGreen ();
257 this.B = col.getBlue ();
258 this.rScroller.setValue (this.R);
259 this.gScroller.setValue (this.G);
260 this.bScroller.setValue (this.B);
261 this.rText.setText (this.R + "");
262 this.gText.setText (this.G + "");
263 this.bText.setText (this.B + "");
264 this.colourChanged ();
265 }, "java.awt.Color");
266 Clazz.defineMethod (c$, "colourButtonPressed",
268 this.selectedButton = e.getSource ();
269 this.setTargetColour (this.selectedButton.getBackground ());
270 }, "java.awt.event.MouseEvent");
271 Clazz.defineMethod (c$, "makeButton",
272 function (label, aa) {
273 var button = new awt2swing.Button ();
274 var col = java.awt.Color.white;
275 if (this.oldColourScheme != null) {
277 col = this.oldColourScheme.findColour (aa.charAt (0), -1, null);
279 if (Clazz.exceptionOf (ex, Exception)) {
284 }button.setBackground (col);
285 this.oldColours.addElement (col);
286 button.setLabel (label);
287 button.setForeground (col.darker ().darker ().darker ());
288 button.setFont ( new java.awt.Font ("Verdana", 1, 10));
289 button.addMouseListener (((Clazz.isClassDefined ("jalview.appletgui.UserDefinedColours$1") ? 0 : jalview.appletgui.UserDefinedColours.$UserDefinedColours$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.UserDefinedColours$1, this, null)));
290 this.buttonPanel.add (button, null);
292 Clazz.defineMethod (c$, "okButton_actionPerformed",
294 this.applyButton_actionPerformed ();
295 if (this.dialog != null) {
296 this.dialog.setVisible (false);
297 }this.frame.setVisible (false);
299 Clazz.defineMethod (c$, "getColor",
301 return new java.awt.Color (this.R, this.G, this.B);
303 Clazz.defineMethod (c$, "applyButton_actionPerformed",
305 if (this.caller != null) {
306 if (Clazz.instanceOf (this.caller, jalview.appletgui.FeatureSettings)) {
307 (this.caller).setUserColour (this.originalLabel, this.getColor ());
308 } else if (Clazz.instanceOf (this.caller, jalview.appletgui.AnnotationColourChooser)) {
309 if (this.originalLabel.equals ("Min Colour")) {
310 (this.caller).minColour_actionPerformed (this.getColor ());
312 (this.caller).maxColour_actionPerformed (this.getColor ());
313 }} else if (Clazz.instanceOf (this.caller, jalview.appletgui.FeatureRenderer)) {
314 (this.caller).colourPanel.updateColor (this.getColor ());
315 } else if (Clazz.instanceOf (this.caller, jalview.appletgui.FeatureColourChooser)) {
316 if (this.originalLabel.indexOf ("inimum") > -1) {
317 (this.caller).minColour_actionPerformed (this.getColor ());
319 (this.caller).maxColour_actionPerformed (this.getColor ());
321 }var newColours = new Array (24);
322 for (var i = 0; i < 24; i++) {
323 var button = this.buttonPanel.getComponent (i);
324 newColours[i] = button.getBackground ();
326 var ucs = new jalview.schemes.UserColourScheme (newColours);
327 if (this.ap != null) {
328 ucs.setThreshold (0, this.ap.av.isIgnoreGapsConsensus ());
329 }if (this.ap != null) {
330 if (this.seqGroup != null) {
331 this.seqGroup.cs = ucs;
333 this.ap.av.setGlobalColourScheme (ucs);
334 }this.ap.seqPanel.seqCanvas.img = null;
335 this.ap.paintAlignment (true);
336 } else if (this.jmol != null) {
337 this.jmol.setJalviewColourScheme (ucs);
339 Clazz.defineMethod (c$, "cancelButton_actionPerformed",
341 if (this.caller != null) {
342 if (Clazz.instanceOf (this.caller, jalview.appletgui.FeatureSettings)) {
343 (this.caller).setUserColour (this.originalLabel, this.originalColour);
344 } else if (Clazz.instanceOf (this.caller, jalview.appletgui.AnnotationColourChooser)) {
345 if (this.originalLabel.equals ("Min Colour")) {
346 (this.caller).minColour_actionPerformed (this.originalColour);
348 (this.caller).maxColour_actionPerformed (this.originalColour);
349 }} else if (Clazz.instanceOf (this.caller, jalview.appletgui.FeatureRenderer)) {
350 (this.caller).colourPanel.updateColor (this.originalColour);
351 } else if (Clazz.instanceOf (this.caller, jalview.appletgui.FeatureColourChooser)) {
352 if (this.originalLabel.indexOf ("inimum") > -1) {
353 (this.caller).minColour_actionPerformed (this.originalColour);
355 (this.caller).maxColour_actionPerformed (this.originalColour);
356 }}if (this.dialog != null) {
357 this.dialog.setVisible (false);
358 }this.frame.setVisible (false);
360 }var newColours = new Array (24);
361 for (var i = 0; i < 24; i++) {
362 newColours[i] = this.oldColours.elementAt (i);
363 this.buttonPanel.getComponent (i).setBackground (newColours[i]);
365 var ucs = new jalview.schemes.UserColourScheme (newColours);
366 if (this.ap != null) {
367 if (this.seqGroup != null) {
368 this.seqGroup.cs = ucs;
370 this.ap.av.setGlobalColourScheme (ucs);
371 }this.ap.paintAlignment (true);
372 } else if (this.jmol != null) {
373 this.jmol.setJalviewColourScheme (ucs);
374 }this.frame.setVisible (false);
376 Clazz.defineMethod (c$, "jbInit",
378 this.setLayout (null);
379 this.buttonPanel.setLayout (this.gridLayout);
380 this.gridLayout.setColumns (6);
381 this.gridLayout.setRows (4);
382 this.okButton.setFont ( new java.awt.Font ("Verdana", 0, 11));
383 this.okButton.setLabel (jalview.util.MessageManager.getString ("action.ok"));
384 this.okButton.addActionListener (this);
385 this.applyButton.setFont ( new java.awt.Font ("Verdana", 0, 11));
386 this.applyButton.setLabel (jalview.util.MessageManager.getString ("action.apply"));
387 this.applyButton.addActionListener (this);
388 this.cancelButton.setFont ( new java.awt.Font ("Verdana", 0, 11));
389 this.cancelButton.setLabel (jalview.util.MessageManager.getString ("action.cancel"));
390 this.cancelButton.addActionListener (this);
391 this.setBackground ( new java.awt.Color (212, 208, 223));
392 this.okcancelPanel.setBounds ( new java.awt.Rectangle (0, 265, 400, 35));
393 this.buttonPanel.setBounds ( new java.awt.Rectangle (0, 123, 400, 142));
394 this.rScroller.setMaximum (256);
395 this.rScroller.setMinimum (0);
396 this.rScroller.setOrientation (0);
397 this.rScroller.setUnitIncrement (1);
398 this.rScroller.setVisibleAmount (1);
399 this.rScroller.setBounds ( new java.awt.Rectangle (36, 27, 119, 19));
400 this.rScroller.addAdjustmentListener (this);
401 this.label1.setAlignment (4);
402 this.label1.setText ("R");
403 this.label1.setBounds ( new java.awt.Rectangle (19, 30, 16, 15));
404 this.rText.setFont ( new java.awt.Font ("Dialog", 0, 10));
405 this.rText.setText ("0 ");
406 this.rText.setBounds ( new java.awt.Rectangle (156, 27, 53, 19));
407 this.rText.addActionListener (this);
408 this.rText.addFocusListener (this);
409 this.label4.setAlignment (4);
410 this.label4.setText ("G");
411 this.label4.setBounds ( new java.awt.Rectangle (15, 56, 20, 15));
412 this.gScroller.setMaximum (256);
413 this.gScroller.setMinimum (0);
414 this.gScroller.setOrientation (0);
415 this.gScroller.setUnitIncrement (1);
416 this.gScroller.setVisibleAmount (1);
417 this.gScroller.setBounds ( new java.awt.Rectangle (35, 52, 120, 20));
418 this.gScroller.addAdjustmentListener (this);
419 this.gText.setFont ( new java.awt.Font ("Dialog", 0, 10));
420 this.gText.setText ("0 ");
421 this.gText.setBounds ( new java.awt.Rectangle (156, 52, 53, 20));
422 this.gText.addActionListener (this);
423 this.gText.addFocusListener (this);
424 this.label5.setAlignment (4);
425 this.label5.setText ("B");
426 this.label5.setBounds ( new java.awt.Rectangle (14, 82, 20, 15));
427 this.bScroller.setMaximum (256);
428 this.bScroller.setMinimum (0);
429 this.bScroller.setOrientation (0);
430 this.bScroller.setUnitIncrement (1);
431 this.bScroller.setVisibleAmount (1);
432 this.bScroller.setBounds ( new java.awt.Rectangle (35, 78, 120, 20));
433 this.bScroller.addAdjustmentListener (this);
434 this.bText.setFont ( new java.awt.Font ("Dialog", 0, 10));
435 this.bText.setText ("0 ");
436 this.bText.setBounds ( new java.awt.Rectangle (157, 78, 52, 20));
437 this.bText.addActionListener (this);
438 this.bText.addFocusListener (this);
439 this.target.setBackground (java.awt.Color.black);
440 this.target.setBounds ( new java.awt.Rectangle (229, 26, 134, 79));
441 this.add (this.okcancelPanel, null);
442 this.okcancelPanel.add (this.okButton, null);
443 this.okcancelPanel.add (this.applyButton, null);
444 this.okcancelPanel.add (this.cancelButton, null);
445 this.add (this.rText);
446 this.add (this.gText);
447 this.add (this.bText);
448 this.add (this.buttonPanel, null);
449 this.add (this.target, null);
450 this.add (this.gScroller);
451 this.add (this.rScroller);
452 this.add (this.bScroller);
453 this.add (this.label5);
454 this.add (this.label4);
455 this.add (this.label1);
456 }, $fz.isPrivate = true, $fz));
457 Clazz.overrideMethod (c$, "focusGained",
459 }, "java.awt.event.FocusEvent");
460 Clazz.overrideMethod (c$, "focusLost",
462 var c = e.getComponent ();
463 if (c === this.rText) {
464 this.rText_actionPerformed ();
466 if (c === this.gText) {
467 this.gText_actionPerformed ();
469 if (c === this.bText) {
470 this.bText_actionPerformed ();
471 }}}}, "java.awt.event.FocusEvent");
472 c$.$UserDefinedColours$1$ = function () {
474 c$ = Clazz.declareAnonymous (jalview.appletgui, "UserDefinedColours$1", java.awt.event.MouseAdapter);
475 Clazz.overrideMethod (c$, "mousePressed",
477 this.b$["jalview.appletgui.UserDefinedColours"].colourButtonPressed (e);
478 }, "java.awt.event.MouseEvent");