JAL-1807 test
[jalviewjs.git] / bin / jalview / appletgui / SliderPanel.js
1 Clazz.declarePackage ("jalview.appletgui");
2 Clazz.load (["awt2swing.Panel", "java.awt.event.ActionListener", "$.AdjustmentListener", "$.MouseListener", "awt2swing.Button", "$.Checkbox", "$.Label", "$.Scrollbar", "$.TextField", "java.awt.BorderLayout", "$.FlowLayout"], "jalview.appletgui.SliderPanel", ["awt2swing.Frame", "jalview.bin.JalviewLite", "jalview.util.MessageManager", "java.awt.Color", "$.Font", "java.awt.event.WindowAdapter"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.ap = null;
5 this.forConservation = true;
6 this.cs = null;
7 this.slider = null;
8 this.valueField = null;
9 this.label = null;
10 this.jPanel1 = null;
11 this.jPanel2 = null;
12 this.applyButton = null;
13 this.undoButton = null;
14 this.flowLayout1 = null;
15 this.allGroupsCheck = null;
16 this.borderLayout1 = null;
17 this.borderLayout2 = null;
18 this.flowLayout2 = null;
19 Clazz.instantialize (this, arguments);
20 }, jalview.appletgui, "SliderPanel", awt2swing.Panel, [java.awt.event.ActionListener, java.awt.event.AdjustmentListener, java.awt.event.MouseListener]);
21 Clazz.prepareFields (c$, function () {
22 this.slider =  new awt2swing.Scrollbar ();
23 this.valueField =  new awt2swing.TextField ();
24 this.label =  new awt2swing.Label ();
25 this.jPanel1 =  new awt2swing.Panel ();
26 this.jPanel2 =  new awt2swing.Panel ();
27 this.applyButton =  new awt2swing.Button ();
28 this.undoButton =  new awt2swing.Button ();
29 this.flowLayout1 =  new java.awt.FlowLayout ();
30 this.allGroupsCheck =  new awt2swing.Checkbox ();
31 this.borderLayout1 =  new java.awt.BorderLayout ();
32 this.borderLayout2 =  new java.awt.BorderLayout ();
33 this.flowLayout2 =  new java.awt.FlowLayout ();
34 });
35 c$.setConservationSlider = Clazz.defineMethod (c$, "setConservationSlider", 
36 function (ap, cs, source) {
37 var sp = null;
38 if (jalview.appletgui.SliderPanel.conservationSlider == null) {
39 sp =  new jalview.appletgui.SliderPanel (ap, cs.getConservationInc (), true, cs);
40 jalview.appletgui.SliderPanel.conservationSlider =  new awt2swing.Frame ();
41 jalview.appletgui.SliderPanel.conservationSlider.add (sp);
42 } else {
43 sp = jalview.appletgui.SliderPanel.conservationSlider.getComponent (0);
44 sp.cs = cs;
45 }jalview.appletgui.SliderPanel.conservationSlider.setTitle (jalview.util.MessageManager.formatMessage ("label.conservation_colour_increment",  Clazz.newArray (-1, [source])));
46 if (ap.av.getAlignment ().getGroups () != null) {
47 sp.setAllGroupsCheckEnabled (true);
48 } else {
49 sp.setAllGroupsCheckEnabled (false);
50 }return sp.getValue ();
51 }, "jalview.appletgui.AlignmentPanel,jalview.schemes.ColourSchemeI,~S");
52 c$.showConservationSlider = Clazz.defineMethod (c$, "showConservationSlider", 
53 function () {
54 try {
55 jalview.appletgui.SliderPanel.PIDSlider.setVisible (false);
56 jalview.appletgui.SliderPanel.PIDSlider = null;
57 } catch (ex) {
58 if (Clazz.exceptionOf (ex, Exception)) {
59 } else {
60 throw ex;
61 }
62 }
63 if (!jalview.appletgui.SliderPanel.conservationSlider.isVisible ()) {
64 jalview.bin.JalviewLite.addFrame (jalview.appletgui.SliderPanel.conservationSlider, jalview.appletgui.SliderPanel.conservationSlider.getTitle (), 420, 100);
65 jalview.appletgui.SliderPanel.conservationSlider.addWindowListener (((Clazz.isClassDefined ("jalview.appletgui.SliderPanel$1") ? 0 : jalview.appletgui.SliderPanel.$SliderPanel$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.SliderPanel$1, this, null)));
66 }});
67 c$.setPIDSliderSource = Clazz.defineMethod (c$, "setPIDSliderSource", 
68 function (ap, cs, source) {
69 var pid = null;
70 if (jalview.appletgui.SliderPanel.PIDSlider == null) {
71 pid =  new jalview.appletgui.SliderPanel (ap, 50, false, cs);
72 jalview.appletgui.SliderPanel.PIDSlider =  new awt2swing.Frame ();
73 jalview.appletgui.SliderPanel.PIDSlider.add (pid);
74 } else {
75 pid = jalview.appletgui.SliderPanel.PIDSlider.getComponent (0);
76 pid.cs = cs;
77 }jalview.appletgui.SliderPanel.PIDSlider.setTitle (jalview.util.MessageManager.formatMessage ("label.percentage_identity_thereshold",  Clazz.newArray (-1, [source])));
78 if (ap.av.getAlignment ().getGroups () != null) {
79 pid.setAllGroupsCheckEnabled (true);
80 } else {
81 pid.setAllGroupsCheckEnabled (false);
82 }return pid.getValue ();
83 }, "jalview.appletgui.AlignmentPanel,jalview.schemes.ColourSchemeI,~S");
84 c$.showPIDSlider = Clazz.defineMethod (c$, "showPIDSlider", 
85 function () {
86 try {
87 jalview.appletgui.SliderPanel.conservationSlider.setVisible (false);
88 jalview.appletgui.SliderPanel.conservationSlider = null;
89 } catch (ex) {
90 if (Clazz.exceptionOf (ex, Exception)) {
91 } else {
92 throw ex;
93 }
94 }
95 if (!jalview.appletgui.SliderPanel.PIDSlider.isVisible ()) {
96 jalview.bin.JalviewLite.addFrame (jalview.appletgui.SliderPanel.PIDSlider, jalview.appletgui.SliderPanel.PIDSlider.getTitle (), 420, 100);
97 jalview.appletgui.SliderPanel.PIDSlider.addWindowListener (((Clazz.isClassDefined ("jalview.appletgui.SliderPanel$2") ? 0 : jalview.appletgui.SliderPanel.$SliderPanel$2$ ()), Clazz.innerTypeInstance (jalview.appletgui.SliderPanel$2, this, null)));
98 }});
99 Clazz.makeConstructor (c$, 
100 function (ap, value, forConserve, cs) {
101 Clazz.superConstructor (this, jalview.appletgui.SliderPanel, []);
102 try {
103 this.jbInit ();
104 } catch (e) {
105 if (Clazz.exceptionOf (e, Exception)) {
106 e.printStackTrace ();
107 } else {
108 throw e;
109 }
110 }
111 this.ap = ap;
112 this.cs = cs;
113 this.forConservation = forConserve;
114 this.undoButton.setVisible (false);
115 this.applyButton.setVisible (false);
116 if (this.forConservation) {
117 this.label.setText (jalview.util.MessageManager.getString ("label.modify_conservation_visibility"));
118 this.slider.setMinimum (0);
119 this.slider.setMaximum (50 + this.slider.getVisibleAmount ());
120 this.slider.setUnitIncrement (1);
121 } else {
122 this.label.setText (jalview.util.MessageManager.getString ("label.colour_residues_above_occurence"));
123 this.slider.setMinimum (0);
124 this.slider.setMaximum (100 + this.slider.getVisibleAmount ());
125 this.slider.setBlockIncrement (1);
126 }this.slider.addAdjustmentListener (this);
127 this.slider.addMouseListener (this);
128 this.slider.setValue (value);
129 this.valueField.setText (value + "");
130 }, "jalview.appletgui.AlignmentPanel,~N,~B,jalview.schemes.ColourSchemeI");
131 Clazz.defineMethod (c$, "valueChanged", 
132 function (i) {
133 if (this.cs == null) {
134 return;
135 }var toChange = this.cs;
136 var allGroups = null;
137 if (this.allGroupsCheck.getState ()) {
138 allGroups = this.ap.av.getAlignment ().getGroups ().listIterator ();
139 }while (toChange != null) {
140 if (this.forConservation) {
141 toChange.setConservationInc (i);
142 } else {
143 toChange.setThreshold (i, this.ap.av.isIgnoreGapsConsensus ());
144 }if (allGroups != null && allGroups.hasNext ()) {
145 while ((toChange = allGroups.next ().cs) == null && allGroups.hasNext ()) {
146 ;}
147 } else {
148 toChange = null;
149 }}
150 this.ap.seqPanel.seqCanvas.repaint ();
151 }, "~N");
152 Clazz.defineMethod (c$, "setAllGroupsCheckEnabled", 
153 function (b) {
154 this.allGroupsCheck.setEnabled (b);
155 }, "~B");
156 Clazz.overrideMethod (c$, "actionPerformed", 
157 function (evt) {
158 if (evt.getSource () === this.applyButton) {
159 this.applyButton_actionPerformed ();
160 } else if (evt.getSource () === this.undoButton) {
161 this.undoButton_actionPerformed ();
162 } else if (evt.getSource () === this.valueField) {
163 this.valueField_actionPerformed ();
164 }}, "java.awt.event.ActionEvent");
165 Clazz.overrideMethod (c$, "adjustmentValueChanged", 
166 function (evt) {
167 this.valueField.setText (this.slider.getValue () + "");
168 this.valueChanged (this.slider.getValue ());
169 }, "java.awt.event.AdjustmentEvent");
170 Clazz.defineMethod (c$, "valueField_actionPerformed", 
171 function () {
172 try {
173 var i = Integer.parseInt (this.valueField.getText ());
174 this.slider.setValue (i);
175 } catch (ex) {
176 if (Clazz.exceptionOf (ex, Exception)) {
177 this.valueField.setText (this.slider.getValue () + "");
178 } else {
179 throw ex;
180 }
181 }
182 });
183 Clazz.defineMethod (c$, "setValue", 
184 function (value) {
185 this.slider.setValue (value);
186 }, "~N");
187 Clazz.defineMethod (c$, "getValue", 
188 function () {
189 return Integer.parseInt (this.valueField.getText ());
190 });
191 Clazz.defineMethod (c$, "jbInit", 
192 ($fz = function () {
193 this.setLayout (this.borderLayout2);
194 this.slider.setBackground (java.awt.Color.white);
195 this.slider.setFont ( new java.awt.Font ("Verdana", 0, 11));
196 this.slider.setOrientation (0);
197 this.valueField.setFont ( new java.awt.Font ("Verdana", 0, 11));
198 this.valueField.setText ("   ");
199 this.valueField.addActionListener (this);
200 this.valueField.setColumns (3);
201 this.label.setFont ( new java.awt.Font ("Verdana", 0, 11));
202 this.label.setText (jalview.util.MessageManager.getString ("label.set_this_label_text"));
203 this.jPanel1.setLayout (this.borderLayout1);
204 this.jPanel2.setLayout (this.flowLayout1);
205 this.applyButton.setFont ( new java.awt.Font ("Verdana", 0, 11));
206 this.applyButton.setLabel (jalview.util.MessageManager.getString ("action.apply"));
207 this.applyButton.addActionListener (this);
208 this.undoButton.setEnabled (false);
209 this.undoButton.setFont ( new java.awt.Font ("Verdana", 0, 11));
210 this.undoButton.setLabel (jalview.util.MessageManager.getString ("action.undo"));
211 this.undoButton.addActionListener (this);
212 this.allGroupsCheck.setEnabled (false);
213 this.allGroupsCheck.setFont ( new java.awt.Font ("Verdana", 0, 11));
214 this.allGroupsCheck.setLabel (jalview.util.MessageManager.getString ("action.apply_threshold_all_groups"));
215 this.allGroupsCheck.setName (jalview.util.MessageManager.getString ("action.apply_all_groups"));
216 this.setBackground (java.awt.Color.white);
217 this.setForeground (java.awt.Color.black);
218 this.jPanel2.add (this.label, null);
219 this.jPanel2.add (this.applyButton, null);
220 this.jPanel2.add (this.undoButton, null);
221 this.jPanel2.add (this.allGroupsCheck);
222 this.jPanel1.add (this.valueField, "East");
223 this.jPanel1.add (this.slider, "Center");
224 this.add (this.jPanel1, "South");
225 this.add (this.jPanel2, "Center");
226 }, $fz.isPrivate = true, $fz));
227 Clazz.defineMethod (c$, "applyButton_actionPerformed", 
228 function () {
229 });
230 Clazz.defineMethod (c$, "undoButton_actionPerformed", 
231 function () {
232 });
233 Clazz.overrideMethod (c$, "mousePressed", 
234 function (evt) {
235 }, "java.awt.event.MouseEvent");
236 Clazz.overrideMethod (c$, "mouseReleased", 
237 function (evt) {
238 this.ap.paintAlignment (true);
239 }, "java.awt.event.MouseEvent");
240 Clazz.overrideMethod (c$, "mouseClicked", 
241 function (evt) {
242 }, "java.awt.event.MouseEvent");
243 Clazz.overrideMethod (c$, "mouseEntered", 
244 function (evt) {
245 }, "java.awt.event.MouseEvent");
246 Clazz.overrideMethod (c$, "mouseExited", 
247 function (evt) {
248 }, "java.awt.event.MouseEvent");
249 c$.$SliderPanel$1$ = function () {
250 Clazz.pu$h ();
251 c$ = Clazz.declareAnonymous (jalview.appletgui, "SliderPanel$1", java.awt.event.WindowAdapter);
252 Clazz.overrideMethod (c$, "windowClosing", 
253 function (e) {
254 jalview.appletgui.SliderPanel.conservationSlider = null;
255 }, "java.awt.event.WindowEvent");
256 c$ = Clazz.p0p ();
257 };
258 c$.$SliderPanel$2$ = function () {
259 Clazz.pu$h ();
260 c$ = Clazz.declareAnonymous (jalview.appletgui, "SliderPanel$2", java.awt.event.WindowAdapter);
261 Clazz.overrideMethod (c$, "windowClosing", 
262 function (e) {
263 jalview.appletgui.SliderPanel.PIDSlider = null;
264 }, "java.awt.event.WindowEvent");
265 c$ = Clazz.p0p ();
266 };
267 Clazz.defineStatics (c$,
268 "conservationSlider", null,
269 "PIDSlider", null);
270 });