e5e12766008affa5a63c93eb79280c2f5716df35
[jalviewjs.git] / site / j2s / javax / swing / JProgressBar.js
1 Clazz.declarePackage ("javax.swing");
2 Clazz.load (["javax.swing.JComponent", "$.SwingConstants", "javax.swing.event.ChangeListener"], "javax.swing.JProgressBar", ["java.lang.Double", "$.IllegalArgumentException", "java.text.NumberFormat", "javax.swing.DefaultBoundedRangeModel", "$.UIManager", "javax.swing.event.ChangeEvent"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.orientation = 0;
5 this.$paintBorder = false;
6 this.model = null;
7 this.progressString = null;
8 this.paintString = false;
9 this.changeEvent = null;
10 this.changeListener = null;
11 this.format = null;
12 this.indeterminate = false;
13 if (!Clazz.isClassDefined ("javax.swing.JProgressBar.ModelListener")) {
14 javax.swing.JProgressBar.$JProgressBar$ModelListener$ ();
15 }
16 Clazz.instantialize (this, arguments);
17 }, javax.swing, "JProgressBar", javax.swing.JComponent, javax.swing.SwingConstants);
18 Clazz.makeConstructor (c$, 
19 function () {
20 this.construct (0);
21 });
22 Clazz.makeConstructor (c$, 
23 function (orient) {
24 this.construct (orient, 0, 100);
25 }, "~N");
26 Clazz.makeConstructor (c$, 
27 function (min, max) {
28 this.construct (0, min, max);
29 }, "~N,~N");
30 Clazz.makeConstructor (c$, 
31 function (orient, min, max) {
32 Clazz.superConstructor (this, javax.swing.JProgressBar, []);
33 this.setModel ( new javax.swing.DefaultBoundedRangeModel (min, 0, min, max));
34 this.updateUI ();
35 this.setOrientation (orient);
36 this.setBorderPainted (true);
37 this.setStringPainted (false);
38 this.setString (null);
39 this.setIndeterminate (false);
40 }, "~N,~N,~N");
41 Clazz.makeConstructor (c$, 
42 function (newModel) {
43 Clazz.superConstructor (this, javax.swing.JProgressBar, []);
44 this.setModel (newModel);
45 this.updateUI ();
46 this.setOrientation (0);
47 this.setBorderPainted (true);
48 this.setStringPainted (false);
49 this.setString (null);
50 this.setIndeterminate (false);
51 }, "javax.swing.BoundedRangeModel");
52 Clazz.defineMethod (c$, "getOrientation", 
53 function () {
54 return this.orientation;
55 });
56 Clazz.defineMethod (c$, "setOrientation", 
57 function (newOrientation) {
58 if (this.orientation != newOrientation) {
59 switch (newOrientation) {
60 case 1:
61 case 0:
62 var oldOrientation = this.orientation;
63 this.orientation = newOrientation;
64 this.firePropertyChangeInt ("orientation", oldOrientation, newOrientation);
65 break;
66 default:
67 throw  new IllegalArgumentException (newOrientation + " is not a legal orientation");
68 }
69 this.revalidate ();
70 }}, "~N");
71 Clazz.defineMethod (c$, "isStringPainted", 
72 function () {
73 return this.paintString;
74 });
75 Clazz.defineMethod (c$, "setStringPainted", 
76 function (b) {
77 var oldValue = this.paintString;
78 this.paintString = b;
79 this.firePropertyChangeBool ("stringPainted", oldValue, this.paintString);
80 if (this.paintString != oldValue) {
81 this.revalidate ();
82 this.repaint ();
83 }}, "~B");
84 Clazz.defineMethod (c$, "getString", 
85 function () {
86 if (this.progressString != null) {
87 return this.progressString;
88 } else {
89 if (this.format == null) {
90 this.format = java.text.NumberFormat.getPercentInstance ();
91 }return this.format.format ( new Double (this.getPercentComplete ()));
92 }});
93 Clazz.defineMethod (c$, "setString", 
94 function (s) {
95 var oldValue = this.progressString;
96 this.progressString = s;
97 this.firePropertyChangeObject ("string", oldValue, this.progressString);
98 if (this.progressString == null || oldValue == null || !this.progressString.equals (oldValue)) {
99 this.repaint ();
100 }}, "~S");
101 Clazz.defineMethod (c$, "getPercentComplete", 
102 function () {
103 var span = this.model.getMaximum () - this.model.getMinimum ();
104 var currentValue = this.model.getValue ();
105 var pc = (currentValue - this.model.getMinimum ()) / span;
106 return pc;
107 });
108 Clazz.defineMethod (c$, "isBorderPainted", 
109 function () {
110 return this.$paintBorder;
111 });
112 Clazz.defineMethod (c$, "setBorderPainted", 
113 function (b) {
114 var oldValue = this.$paintBorder;
115 this.$paintBorder = b;
116 this.firePropertyChangeBool ("borderPainted", oldValue, this.$paintBorder);
117 if (this.$paintBorder != oldValue) {
118 this.repaint ();
119 }}, "~B");
120 Clazz.defineMethod (c$, "paintBorder", 
121 function (g) {
122 if (this.isBorderPainted ()) {
123 Clazz.superCall (this, javax.swing.JProgressBar, "paintBorder", [g]);
124 }}, "java.awt.Graphics");
125 Clazz.overrideMethod (c$, "getUI", 
126 function () {
127 return this.ui;
128 });
129 Clazz.overrideMethod (c$, "updateUI", 
130 function () {
131 this.setUI (javax.swing.UIManager.getUI (this));
132 });
133 Clazz.overrideMethod (c$, "getUIClassID", 
134 function () {
135 return "ProgressBarUI";
136 });
137 Clazz.defineMethod (c$, "createChangeListener", 
138 function () {
139 return Clazz.innerTypeInstance (javax.swing.JProgressBar.ModelListener, this, null);
140 });
141 Clazz.defineMethod (c$, "addChangeListener", 
142 function (l) {
143 this.listenerList.add (javax.swing.event.ChangeListener, l);
144 }, "javax.swing.event.ChangeListener");
145 Clazz.defineMethod (c$, "removeChangeListener", 
146 function (l) {
147 this.listenerList.remove (javax.swing.event.ChangeListener, l);
148 }, "javax.swing.event.ChangeListener");
149 Clazz.defineMethod (c$, "getChangeListeners", 
150 function () {
151 return this.listenerList.getListeners (javax.swing.event.ChangeListener);
152 });
153 Clazz.defineMethod (c$, "fireStateChanged", 
154 function () {
155 var listeners = this.listenerList.getListenerList ();
156 for (var i = listeners.length - 2; i >= 0; i -= 2) {
157 if (listeners[i] === javax.swing.event.ChangeListener) {
158 if (this.changeEvent == null) this.changeEvent =  new javax.swing.event.ChangeEvent (this);
159 (listeners[i + 1]).stateChanged (this.changeEvent);
160 }}
161 });
162 Clazz.defineMethod (c$, "getModel", 
163 function () {
164 return this.model;
165 });
166 Clazz.defineMethod (c$, "setModel", 
167 function (newModel) {
168 var oldModel = this.getModel ();
169 if (newModel !== oldModel) {
170 if (oldModel != null) {
171 oldModel.removeChangeListener (this.changeListener);
172 this.changeListener = null;
173 }this.model = newModel;
174 if (newModel != null) {
175 this.changeListener = this.createChangeListener ();
176 newModel.addChangeListener (this.changeListener);
177 }if (this.model != null) {
178 this.model.setExtent (0);
179 }this.repaint ();
180 }}, "javax.swing.BoundedRangeModel");
181 Clazz.defineMethod (c$, "getValue", 
182 function () {
183 return this.getModel ().getValue ();
184 });
185 Clazz.defineMethod (c$, "getMinimum", 
186 function () {
187 return this.getModel ().getMinimum ();
188 });
189 Clazz.defineMethod (c$, "getMaximum", 
190 function () {
191 return this.getModel ().getMaximum ();
192 });
193 Clazz.defineMethod (c$, "setValue", 
194 function (n) {
195 var brm = this.getModel ();
196 brm.setValue (n);
197 }, "~N");
198 Clazz.defineMethod (c$, "setMinimum", 
199 function (n) {
200 this.getModel ().setMinimum (n);
201 }, "~N");
202 Clazz.defineMethod (c$, "setMaximum", 
203 function (n) {
204 this.getModel ().setMaximum (n);
205 }, "~N");
206 Clazz.defineMethod (c$, "setIndeterminate", 
207 function (newValue) {
208 var oldValue = this.indeterminate;
209 this.indeterminate = newValue;
210 this.firePropertyChangeBool ("indeterminate", oldValue, this.indeterminate);
211 }, "~B");
212 Clazz.defineMethod (c$, "isIndeterminate", 
213 function () {
214 return this.indeterminate;
215 });
216 Clazz.defineMethod (c$, "paramString", 
217 function () {
218 var orientationString = (this.orientation == 0 ? "HORIZONTAL" : "VERTICAL");
219 var paintBorderString = (this.$paintBorder ? "true" : "false");
220 var progressStringString = (this.progressString != null ? this.progressString : "");
221 var paintStringString = (this.paintString ? "true" : "false");
222 var indeterminateString = (this.indeterminate ? "true" : "false");
223 return Clazz.superCall (this, javax.swing.JProgressBar, "paramString", []) + ",orientation=" + orientationString + ",paintBorder=" + paintBorderString + ",paintString=" + paintStringString + ",progressString=" + progressStringString + ",indeterminateString=" + indeterminateString;
224 });
225 c$.$JProgressBar$ModelListener$ = function () {
226 Clazz.pu$h(self.c$);
227 c$ = Clazz.decorateAsClass (function () {
228 Clazz.prepareCallback (this, arguments);
229 Clazz.instantialize (this, arguments);
230 }, javax.swing.JProgressBar, "ModelListener", null, javax.swing.event.ChangeListener);
231 Clazz.overrideMethod (c$, "stateChanged", 
232 function (a) {
233 this.b$["javax.swing.JProgressBar"].fireStateChanged ();
234 }, "javax.swing.event.ChangeEvent");
235 c$ = Clazz.p0p ();
236 };
237 Clazz.defineStatics (c$,
238 "$uiClassID", "ProgressBarUI",
239 "defaultMinimum", 0,
240 "defaultMaximum", 100,
241 "defaultOrientation", 0);
242 });