badc5f6b683420e61cb063e896ab7b1bcf2e6364
[jalviewjs.git] / site / j2s / javax / swing / JScrollBar.js
1 Clazz.declarePackage ("javax.swing");
2 Clazz.load (["java.awt.Adjustable", "javax.swing.JComponent", "javax.swing.event.ChangeListener"], "javax.swing.JScrollBar", ["java.lang.IllegalArgumentException", "java.awt.Dimension", "java.awt.event.AdjustmentEvent", "$.AdjustmentListener", "javax.swing.BoundedRangeModel", "$.DefaultBoundedRangeModel", "$.UIManager"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.fwdAdjustmentEvents = null;
5 this.model = null;
6 this.orientation = 0;
7 this.unitIncrement = 0;
8 this.blockIncrement = 0;
9 if (!Clazz.isClassDefined ("javax.swing.JScrollBar.ModelListener")) {
10 javax.swing.JScrollBar.$JScrollBar$ModelListener$ ();
11 }
12 Clazz.instantialize (this, arguments);
13 }, javax.swing, "JScrollBar", javax.swing.JComponent, java.awt.Adjustable);
14 Clazz.prepareFields (c$, function () {
15 this.fwdAdjustmentEvents = Clazz.innerTypeInstance (javax.swing.JScrollBar.ModelListener, this, null);
16 });
17 Clazz.defineMethod (c$, "checkOrientation", 
18  function (orientation) {
19 switch (orientation) {
20 case 1:
21 case 0:
22 break;
23 default:
24 throw  new IllegalArgumentException ("orientation must be one of: VERTICAL, HORIZONTAL");
25 }
26 }, "~N");
27 Clazz.makeConstructor (c$, 
28 function (orientation, value, extent, min, max) {
29 Clazz.superConstructor (this, javax.swing.JScrollBar, []);
30 this.checkOrientation (orientation);
31 this.unitIncrement = 1;
32 this.blockIncrement = (extent == 0) ? 1 : extent;
33 this.orientation = orientation;
34 this.model =  new javax.swing.DefaultBoundedRangeModel (value, extent, min, max);
35 this.model.addChangeListener (this.fwdAdjustmentEvents);
36 this.setRequestFocusEnabled (false);
37 this.updateUI ();
38 }, "~N,~N,~N,~N,~N");
39 Clazz.makeConstructor (c$, 
40 function (orientation) {
41 this.construct (orientation, 0, 10, 0, 100);
42 }, "~N");
43 Clazz.makeConstructor (c$, 
44 function () {
45 this.construct (1);
46 });
47 Clazz.overrideMethod (c$, "getUI", 
48 function () {
49 return this.ui;
50 });
51 Clazz.overrideMethod (c$, "updateUI", 
52 function () {
53 this.setUI (javax.swing.UIManager.getUI (this));
54 });
55 Clazz.overrideMethod (c$, "getUIClassID", 
56 function () {
57 return "ScrollBarUI";
58 });
59 Clazz.overrideMethod (c$, "getOrientation", 
60 function () {
61 return this.orientation;
62 });
63 Clazz.defineMethod (c$, "setOrientation", 
64 function (orientation) {
65 this.checkOrientation (orientation);
66 var oldValue = this.orientation;
67 this.orientation = orientation;
68 this.firePropertyChangeInt ("orientation", oldValue, orientation);
69 if (orientation != oldValue) {
70 this.revalidate ();
71 }}, "~N");
72 Clazz.defineMethod (c$, "getModel", 
73 function () {
74 return this.model;
75 });
76 Clazz.defineMethod (c$, "setModel", 
77 function (newModel) {
78 var oldModel = this.model;
79 if (this.model != null) {
80 this.model.removeChangeListener (this.fwdAdjustmentEvents);
81 }this.model = newModel;
82 if (this.model != null) {
83 this.model.addChangeListener (this.fwdAdjustmentEvents);
84 }this.firePropertyChangeObject ("model", oldModel, this.model);
85 }, "javax.swing.BoundedRangeModel");
86 Clazz.defineMethod (c$, "getUnitIncrement", 
87 function (direction) {
88 return this.unitIncrement;
89 }, "~N");
90 Clazz.overrideMethod (c$, "setUnitIncrement", 
91 function (unitIncrement) {
92 var oldValue = this.unitIncrement;
93 this.unitIncrement = unitIncrement;
94 this.firePropertyChangeInt ("unitIncrement", oldValue, unitIncrement);
95 }, "~N");
96 Clazz.defineMethod (c$, "getBlockIncrement", 
97 function (direction) {
98 return this.blockIncrement;
99 }, "~N");
100 Clazz.overrideMethod (c$, "setBlockIncrement", 
101 function (blockIncrement) {
102 var oldValue = this.blockIncrement;
103 this.blockIncrement = blockIncrement;
104 this.firePropertyChangeInt ("blockIncrement", oldValue, blockIncrement);
105 }, "~N");
106 Clazz.defineMethod (c$, "getUnitIncrement", 
107 function () {
108 return this.unitIncrement;
109 });
110 Clazz.defineMethod (c$, "getBlockIncrement", 
111 function () {
112 return this.blockIncrement;
113 });
114 Clazz.overrideMethod (c$, "getValue", 
115 function () {
116 return this.getModel ().getValue ();
117 });
118 Clazz.overrideMethod (c$, "setValue", 
119 function (value) {
120 var m = this.getModel ();
121 m.setValue (value);
122 }, "~N");
123 Clazz.overrideMethod (c$, "getVisibleAmount", 
124 function () {
125 return this.getModel ().getExtent ();
126 });
127 Clazz.overrideMethod (c$, "setVisibleAmount", 
128 function (extent) {
129 this.getModel ().setExtent (extent);
130 }, "~N");
131 Clazz.overrideMethod (c$, "getMinimum", 
132 function () {
133 return this.getModel ().getMinimum ();
134 });
135 Clazz.overrideMethod (c$, "setMinimum", 
136 function (minimum) {
137 this.getModel ().setMinimum (minimum);
138 }, "~N");
139 Clazz.overrideMethod (c$, "getMaximum", 
140 function () {
141 return this.getModel ().getMaximum ();
142 });
143 Clazz.overrideMethod (c$, "setMaximum", 
144 function (maximum) {
145 this.getModel ().setMaximum (maximum);
146 }, "~N");
147 Clazz.defineMethod (c$, "getValueIsAdjusting", 
148 function () {
149 return this.getModel ().getValueIsAdjusting ();
150 });
151 Clazz.defineMethod (c$, "setValueIsAdjusting", 
152 function (b) {
153 var m = this.getModel ();
154 m.setValueIsAdjusting (b);
155 }, "~B");
156 Clazz.defineMethod (c$, "setValues", 
157 function (newValue, newExtent, newMin, newMax) {
158 var m = this.getModel ();
159 m.setRangeProperties (newValue, newExtent, newMin, newMax, m.getValueIsAdjusting ());
160 }, "~N,~N,~N,~N");
161 Clazz.overrideMethod (c$, "addAdjustmentListener", 
162 function (l) {
163 this.listenerList.add (java.awt.event.AdjustmentListener, l);
164 }, "java.awt.event.AdjustmentListener");
165 Clazz.overrideMethod (c$, "removeAdjustmentListener", 
166 function (l) {
167 this.listenerList.remove (java.awt.event.AdjustmentListener, l);
168 }, "java.awt.event.AdjustmentListener");
169 Clazz.defineMethod (c$, "getAdjustmentListeners", 
170 function () {
171 return this.listenerList.getListeners (java.awt.event.AdjustmentListener);
172 });
173 Clazz.defineMethod (c$, "fireAdjustmentValueChanged", 
174 function (id, type, value) {
175 this.fireAdjustmentValueChanged (id, type, value, this.getValueIsAdjusting ());
176 }, "~N,~N,~N");
177 Clazz.defineMethod (c$, "fireAdjustmentValueChanged", 
178  function (id, type, value, isAdjusting) {
179 var listeners = this.listenerList.getListenerList ();
180 var e = null;
181 for (var i = listeners.length - 2; i >= 0; i -= 2) {
182 if (listeners[i] === java.awt.event.AdjustmentListener) {
183 if (e == null) {
184 e =  new java.awt.event.AdjustmentEvent (this, id, type, value, isAdjusting);
185 }(listeners[i + 1]).adjustmentValueChanged (e);
186 }}
187 }, "~N,~N,~N,~B");
188 Clazz.overrideMethod (c$, "getMinimumSize", 
189 function () {
190 var pref = this.getPreferredSize ();
191 if (this.orientation == 1) {
192 return  new java.awt.Dimension (pref.width, 5);
193 } else {
194 return  new java.awt.Dimension (5, pref.height);
195 }});
196 Clazz.overrideMethod (c$, "getMaximumSize", 
197 function () {
198 var pref = this.getPreferredSize ();
199 if (this.getOrientation () == 1) {
200 return  new java.awt.Dimension (pref.width, 32767);
201 } else {
202 return  new java.awt.Dimension (32767, pref.height);
203 }});
204 Clazz.defineMethod (c$, "setEnabled", 
205 function (x) {
206 Clazz.superCall (this, javax.swing.JScrollBar, "setEnabled", [x]);
207 var children = this.getComponents ();
208 for (var i = 0; i < children.length; i++) {
209 children[i].setEnabled (x);
210 }
211 }, "~B");
212 Clazz.defineMethod (c$, "paramString", 
213 function () {
214 var orientationString = (this.orientation == 0 ? "HORIZONTAL" : "VERTICAL");
215 return Clazz.superCall (this, javax.swing.JScrollBar, "paramString", []) + ",blockIncrement=" + this.blockIncrement + ",orientation=" + orientationString + ",unitIncrement=" + this.unitIncrement;
216 });
217 c$.$JScrollBar$ModelListener$ = function () {
218 Clazz.pu$h(self.c$);
219 c$ = Clazz.decorateAsClass (function () {
220 Clazz.prepareCallback (this, arguments);
221 Clazz.instantialize (this, arguments);
222 }, javax.swing.JScrollBar, "ModelListener", null, javax.swing.event.ChangeListener);
223 Clazz.overrideMethod (c$, "stateChanged", 
224 function (a) {
225 var b = a.getSource ();
226 if (Clazz.instanceOf (b, javax.swing.BoundedRangeModel)) {
227 var c = 601;
228 var d = 5;
229 var e = b;
230 var f = e.getValue ();
231 var g = e.getValueIsAdjusting ();
232 this.b$["javax.swing.JScrollBar"].fireAdjustmentValueChanged (c, d, f, g);
233 }}, "javax.swing.event.ChangeEvent");
234 c$ = Clazz.p0p ();
235 };
236 Clazz.defineStatics (c$,
237 "$uiClassID", "ScrollBarUI");
238 });