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