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