5186202f9a9574f243327f96cec1a63bf66ea96b
[jalviewjs.git] / site / swingjs / j2s / javax / swing / JSplitPane.js
1 Clazz.declarePackage ("javax.swing");
2 Clazz.load (["javax.swing.JComponent"], "javax.swing.JSplitPane", ["java.lang.Boolean", "$.IllegalArgumentException", "javax.swing.JButton", "$.UIManager"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.orientation = 0;
5 this.continuousLayout = false;
6 this.leftComponent = null;
7 this.rightComponent = null;
8 this.dividerSize = 0;
9 this.dividerSizeSet = false;
10 this.oneTouchExpandable = false;
11 this.oneTouchExpandableSet = false;
12 this.lastDividerLocation = 0;
13 this.resizeWeight = 0;
14 this.dividerLocation = 0;
15 Clazz.instantialize (this, arguments);
16 }, javax.swing, "JSplitPane", javax.swing.JComponent);
17 Clazz.makeConstructor (c$, 
18 function () {
19 this.construct (1, false,  new javax.swing.JButton (javax.swing.UIManager.getString ("SplitPane.leftButtonText")),  new javax.swing.JButton (javax.swing.UIManager.getString ("SplitPane.rightButtonText")));
20 });
21 Clazz.makeConstructor (c$, 
22 function (newOrientation) {
23 this.construct (newOrientation, false);
24 }, "~N");
25 Clazz.makeConstructor (c$, 
26 function (newOrientation, newContinuousLayout) {
27 this.construct (newOrientation, newContinuousLayout, null, null);
28 }, "~N,~B");
29 Clazz.makeConstructor (c$, 
30 function (newOrientation, newLeftComponent, newRightComponent) {
31 this.construct (newOrientation, false, newLeftComponent, newRightComponent);
32 }, "~N,java.awt.Component,java.awt.Component");
33 Clazz.makeConstructor (c$, 
34 function (newOrientation, newContinuousLayout, newLeftComponent, newRightComponent) {
35 Clazz.superConstructor (this, javax.swing.JSplitPane);
36 this.dividerLocation = -1;
37 this.setLayout (null);
38 this.setUIProperty ("opaque", Boolean.TRUE);
39 this.orientation = newOrientation;
40 if (this.orientation != 1 && this.orientation != 0) throw  new IllegalArgumentException ("cannot create JSplitPane, orientation must be one of JSplitPane.HORIZONTAL_SPLIT or JSplitPane.VERTICAL_SPLIT");
41 this.continuousLayout = newContinuousLayout;
42 if (newLeftComponent != null) this.setLeftComponent (newLeftComponent);
43 if (newRightComponent != null) this.setRightComponent (newRightComponent);
44 this.updateUI ();
45 }, "~N,~B,java.awt.Component,java.awt.Component");
46 Clazz.defineMethod (c$, "setUI", 
47 function (ui) {
48 if (this.ui !== ui) {
49 Clazz.superCall (this, javax.swing.JSplitPane, "setUI", [ui]);
50 this.revalidate ();
51 }}, "javax.swing.plaf.SplitPaneUI");
52 Clazz.overrideMethod (c$, "getUI", 
53 function () {
54 return this.ui;
55 });
56 Clazz.overrideMethod (c$, "updateUI", 
57 function () {
58 this.setUI (javax.swing.UIManager.getUI (this));
59 this.revalidate ();
60 });
61 Clazz.overrideMethod (c$, "getUIClassID", 
62 function () {
63 return "SplitPaneUI";
64 });
65 Clazz.defineMethod (c$, "setDividerSize", 
66 function (newSize) {
67 var oldSize = this.dividerSize;
68 this.dividerSizeSet = true;
69 if (oldSize != newSize) {
70 this.dividerSize = newSize;
71 this.firePropertyChangeInt ("dividerSize", oldSize, newSize);
72 }}, "~N");
73 Clazz.defineMethod (c$, "getDividerSize", 
74 function () {
75 return this.dividerSize;
76 });
77 Clazz.defineMethod (c$, "setLeftComponent", 
78 function (comp) {
79 if (comp == null) {
80 if (this.leftComponent != null) {
81 this.remove (this.leftComponent);
82 this.leftComponent = null;
83 }} else {
84 this.add (comp, "left");
85 }}, "java.awt.Component");
86 Clazz.defineMethod (c$, "getLeftComponent", 
87 function () {
88 return this.leftComponent;
89 });
90 Clazz.defineMethod (c$, "setTopComponent", 
91 function (comp) {
92 this.setLeftComponent (comp);
93 }, "java.awt.Component");
94 Clazz.defineMethod (c$, "getTopComponent", 
95 function () {
96 return this.leftComponent;
97 });
98 Clazz.defineMethod (c$, "setRightComponent", 
99 function (comp) {
100 if (comp == null) {
101 if (this.rightComponent != null) {
102 this.remove (this.rightComponent);
103 this.rightComponent = null;
104 }} else {
105 this.add (comp, "right");
106 }}, "java.awt.Component");
107 Clazz.defineMethod (c$, "getRightComponent", 
108 function () {
109 return this.rightComponent;
110 });
111 Clazz.defineMethod (c$, "setBottomComponent", 
112 function (comp) {
113 this.setRightComponent (comp);
114 }, "java.awt.Component");
115 Clazz.defineMethod (c$, "getBottomComponent", 
116 function () {
117 return this.rightComponent;
118 });
119 Clazz.defineMethod (c$, "setOneTouchExpandable", 
120 function (newValue) {
121 var oldValue = this.oneTouchExpandable;
122 this.oneTouchExpandable = newValue;
123 this.oneTouchExpandableSet = true;
124 this.firePropertyChangeBool ("oneTouchExpandable", oldValue, newValue);
125 this.repaint ();
126 }, "~B");
127 Clazz.defineMethod (c$, "isOneTouchExpandable", 
128 function () {
129 return this.oneTouchExpandable;
130 });
131 Clazz.defineMethod (c$, "setLastDividerLocation", 
132 function (newLastLocation) {
133 var oldLocation = this.lastDividerLocation;
134 this.lastDividerLocation = newLastLocation;
135 this.firePropertyChangeInt ("lastDividerLocation", oldLocation, newLastLocation);
136 }, "~N");
137 Clazz.defineMethod (c$, "getLastDividerLocation", 
138 function () {
139 return this.lastDividerLocation;
140 });
141 Clazz.defineMethod (c$, "setOrientation", 
142 function (orientation) {
143 if ((orientation != 0) && (orientation != 1)) {
144 throw  new IllegalArgumentException ("JSplitPane: orientation must be one of JSplitPane.VERTICAL_SPLIT or JSplitPane.HORIZONTAL_SPLIT");
145 }var oldOrientation = this.orientation;
146 this.orientation = orientation;
147 this.firePropertyChangeInt ("orientation", oldOrientation, orientation);
148 }, "~N");
149 Clazz.defineMethod (c$, "getOrientation", 
150 function () {
151 return this.orientation;
152 });
153 Clazz.defineMethod (c$, "setContinuousLayout", 
154 function (newContinuousLayout) {
155 var oldCD = this.continuousLayout;
156 this.continuousLayout = newContinuousLayout;
157 this.firePropertyChangeBool ("continuousLayout", oldCD, newContinuousLayout);
158 }, "~B");
159 Clazz.defineMethod (c$, "isContinuousLayout", 
160 function () {
161 return this.continuousLayout;
162 });
163 Clazz.defineMethod (c$, "setResizeWeight", 
164 function (value) {
165 if (value < 0 || value > 1) {
166 throw  new IllegalArgumentException ("JSplitPane weight must be between 0 and 1");
167 }var oldWeight = this.resizeWeight;
168 this.resizeWeight = value;
169 this.firePropertyChangeObject ("resizeWeight", new Double (oldWeight), new Double (value));
170 }, "~N");
171 Clazz.defineMethod (c$, "getResizeWeight", 
172 function () {
173 return this.resizeWeight;
174 });
175 Clazz.defineMethod (c$, "resetToPreferredSizes", 
176 function () {
177 var ui = this.getUI ();
178 if (ui != null) {
179 ui.resetToPreferredSizes (this);
180 }});
181 Clazz.defineMethod (c$, "setDividerLocation", 
182 function (proportionalLocation) {
183 if (proportionalLocation < 0.0 || proportionalLocation > 1.0) {
184 throw  new IllegalArgumentException ("proportional location must be between 0.0 and 1.0.");
185 }if (this.getOrientation () == 0) {
186 this.setDividerLocation (Clazz.doubleToInt ((this.getHeight () - this.getDividerSize ()) * proportionalLocation));
187 } else {
188 this.setDividerLocation (Clazz.doubleToInt ((this.getWidth () - this.getDividerSize ()) * proportionalLocation));
189 }}, "~N");
190 Clazz.defineMethod (c$, "setDividerLocation", 
191 function (location) {
192 var oldValue = this.dividerLocation;
193 this.dividerLocation = location;
194 var ui = this.getUI ();
195 if (ui != null) {
196 ui.setDividerLocation (this, location);
197 }this.firePropertyChangeInt ("dividerLocation", oldValue, location);
198 this.setLastDividerLocation (oldValue);
199 }, "~N");
200 Clazz.defineMethod (c$, "getDividerLocation", 
201 function () {
202 return this.dividerLocation;
203 });
204 Clazz.defineMethod (c$, "getMinimumDividerLocation", 
205 function () {
206 var ui = this.getUI ();
207 if (ui != null) {
208 return ui.getMinimumDividerLocation (this);
209 }return -1;
210 });
211 Clazz.defineMethod (c$, "getMaximumDividerLocation", 
212 function () {
213 var ui = this.getUI ();
214 if (ui != null) {
215 return ui.getMaximumDividerLocation (this);
216 }return -1;
217 });
218 Clazz.defineMethod (c$, "remove", 
219 function (component) {
220 if (component === this.leftComponent) {
221 this.leftComponent = null;
222 } else if (component === this.rightComponent) {
223 this.rightComponent = null;
224 }Clazz.superCall (this, javax.swing.JSplitPane, "remove", [component]);
225 this.revalidate ();
226 this.repaint ();
227 }, "java.awt.Component");
228 Clazz.defineMethod (c$, "remove", 
229 function (index) {
230 var comp = this.getComponent (index);
231 if (comp === this.leftComponent) {
232 this.leftComponent = null;
233 } else if (comp === this.rightComponent) {
234 this.rightComponent = null;
235 }Clazz.superCall (this, javax.swing.JSplitPane, "remove", [index]);
236 this.revalidate ();
237 this.repaint ();
238 }, "~N");
239 Clazz.defineMethod (c$, "removeAll", 
240 function () {
241 this.leftComponent = this.rightComponent = null;
242 Clazz.superCall (this, javax.swing.JSplitPane, "removeAll", []);
243 this.revalidate ();
244 this.repaint ();
245 });
246 Clazz.overrideMethod (c$, "isValidateRoot", 
247 function () {
248 return true;
249 });
250 Clazz.overrideMethod (c$, "addImpl", 
251 function (comp, constraints, index) {
252 var toRemove;
253 if (constraints != null && !(Clazz.instanceOf (constraints, String))) {
254 throw  new IllegalArgumentException ("cannot add to layout: constraint must be a string (or null)");
255 }if (constraints == null) {
256 if (this.getLeftComponent () == null) {
257 constraints = "left";
258 } else if (this.getRightComponent () == null) {
259 constraints = "right";
260 }}if (constraints != null && (constraints.equals ("left") || constraints.equals ("top"))) {
261 toRemove = this.getLeftComponent ();
262 if (toRemove != null) {
263 this.remove (toRemove);
264 }this.leftComponent = comp;
265 index = -1;
266 } else if (constraints != null && (constraints.equals ("right") || constraints.equals ("bottom"))) {
267 toRemove = this.getRightComponent ();
268 if (toRemove != null) {
269 this.remove (toRemove);
270 }this.rightComponent = comp;
271 index = -1;
272 } else if (constraints != null && constraints.equals ("divider")) {
273 index = -1;
274 }this.addImplSAEM (comp, constraints, index);
275 this.revalidate ();
276 this.repaint ();
277 return comp;
278 }, "java.awt.Component,~O,~N");
279 Clazz.defineMethod (c$, "paintChildren", 
280 function (g) {
281 Clazz.superCall (this, javax.swing.JSplitPane, "paintChildren", [g]);
282 var ui = this.getUI ();
283 if (ui != null) {
284 var tempG = g.createSwingJS ();
285 ui.finishedPaintingChildren (this, tempG);
286 tempG.dispose ();
287 }}, "java.awt.Graphics");
288 Clazz.defineMethod (c$, "setUIProperty", 
289 function (propertyName, value) {
290 if (propertyName === "dividerSize") {
291 if (!this.dividerSizeSet) {
292 this.setDividerSize ((value).intValue ());
293 this.dividerSizeSet = false;
294 }} else if (propertyName === "oneTouchExpandable") {
295 if (!this.oneTouchExpandableSet) {
296 this.setOneTouchExpandable ((value).booleanValue ());
297 this.oneTouchExpandableSet = false;
298 }} else {
299 Clazz.superCall (this, javax.swing.JSplitPane, "setUIProperty", [propertyName, value]);
300 }}, "~S,~O");
301 Clazz.defineMethod (c$, "paramString", 
302 function () {
303 var orientationString = (this.orientation == 1 ? "HORIZONTAL_SPLIT" : "VERTICAL_SPLIT");
304 var continuousLayoutString = (this.continuousLayout ? "true" : "false");
305 var oneTouchExpandableString = (this.oneTouchExpandable ? "true" : "false");
306 return Clazz.superCall (this, javax.swing.JSplitPane, "paramString", []) + ",continuousLayout=" + continuousLayoutString + ",dividerSize=" + this.dividerSize + ",lastDividerLocation=" + this.lastDividerLocation + ",oneTouchExpandable=" + oneTouchExpandableString + ",orientation=" + orientationString;
307 });
308 Clazz.defineStatics (c$,
309 "$uiClassID", "SplitPaneUI",
310 "VERTICAL_SPLIT", 0,
311 "HORIZONTAL_SPLIT", 1,
312 "LEFT", "left",
313 "RIGHT", "right",
314 "TOP", "top",
315 "BOTTOM", "bottom",
316 "DIVIDER", "divider",
317 "ORIENTATION_PROPERTY", "orientation",
318 "CONTINUOUS_LAYOUT_PROPERTY", "continuousLayout",
319 "DIVIDER_SIZE_PROPERTY", "dividerSize",
320 "ONE_TOUCH_EXPANDABLE_PROPERTY", "oneTouchExpandable",
321 "LAST_DIVIDER_LOCATION_PROPERTY", "lastDividerLocation",
322 "DIVIDER_LOCATION_PROPERTY", "dividerLocation",
323 "RESIZE_WEIGHT_PROPERTY", "resizeWeight");
324 });