1 Clazz.declarePackage ("java.awt");
\r
2 Clazz.load (["java.awt.LayoutManager2"], "java.awt.BorderLayout", ["java.lang.IllegalArgumentException", "java.awt.Dimension"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
11 this.firstLine = null;
\r
12 this.lastLine = null;
\r
13 this.firstItem = null;
\r
14 this.lastItem = null;
\r
15 Clazz.instantialize (this, arguments);
\r
16 }, java.awt, "BorderLayout", null, [java.awt.LayoutManager2, java.io.Serializable]);
\r
17 Clazz.makeConstructor (c$,
\r
19 this.construct (0, 0);
\r
21 Clazz.makeConstructor (c$,
\r
22 function (hgap, vgap) {
\r
26 Clazz.defineMethod (c$, "getHgap",
\r
30 Clazz.defineMethod (c$, "setHgap",
\r
34 Clazz.defineMethod (c$, "getVgap",
\r
38 Clazz.defineMethod (c$, "setVgap",
\r
42 Clazz.defineMethod (c$, "addLayoutComponent",
\r
43 function (comp, constraints) {
\r
45 if ((constraints == null) || (Clazz.instanceOf (constraints, String))) {
\r
46 this.addLayoutComponent (constraints, comp);
\r
48 throw new IllegalArgumentException ("cannot add to layout: constraint must be a string (or null)");
\r
49 }}}, "java.awt.Component,~O");
\r
50 Clazz.defineMethod (c$, "addLayoutComponent",
\r
51 function (name, comp) {
\r
55 }System.out.println ("BorderLayout adding " + name + " " + comp);
\r
56 if ("Center".equals (name)) {
\r
58 } else if ("North".equals (name)) {
\r
60 } else if ("South".equals (name)) {
\r
62 } else if ("East".equals (name)) {
\r
64 } else if ("West".equals (name)) {
\r
66 } else if ("First".equals (name)) {
\r
67 this.firstLine = comp;
\r
68 } else if ("Last".equals (name)) {
\r
69 this.lastLine = comp;
\r
70 } else if ("Before".equals (name)) {
\r
71 this.firstItem = comp;
\r
72 } else if ("After".equals (name)) {
\r
73 this.lastItem = comp;
\r
75 throw new IllegalArgumentException ("cannot add to layout: unknown constraint: " + name);
\r
76 }}}, "~S,java.awt.Component");
\r
77 Clazz.overrideMethod (c$, "removeLayoutComponent",
\r
80 if (comp === this.center) {
\r
82 } else if (comp === this.north) {
\r
84 } else if (comp === this.south) {
\r
86 } else if (comp === this.east) {
\r
88 } else if (comp === this.west) {
\r
90 }if (comp === this.firstLine) {
\r
91 this.firstLine = null;
\r
92 } else if (comp === this.lastLine) {
\r
93 this.lastLine = null;
\r
94 } else if (comp === this.firstItem) {
\r
95 this.firstItem = null;
\r
96 } else if (comp === this.lastItem) {
\r
97 this.lastItem = null;
\r
98 }}}, "java.awt.Component");
\r
99 Clazz.defineMethod (c$, "getLayoutComponent",
\r
100 function (constraints) {
\r
101 if ("Center".equals (constraints)) {
\r
102 return this.center;
\r
103 } else if ("North".equals (constraints)) {
\r
105 } else if ("South".equals (constraints)) {
\r
107 } else if ("West".equals (constraints)) {
\r
109 } else if ("East".equals (constraints)) {
\r
111 } else if ("First".equals (constraints)) {
\r
112 return this.firstLine;
\r
113 } else if ("Last".equals (constraints)) {
\r
114 return this.lastLine;
\r
115 } else if ("Before".equals (constraints)) {
\r
116 return this.firstItem;
\r
117 } else if ("After".equals (constraints)) {
\r
118 return this.lastItem;
\r
120 throw new IllegalArgumentException ("cannot get component: unknown constraint: " + constraints);
\r
122 Clazz.defineMethod (c$, "getLayoutComponent",
\r
123 function (target, constraints) {
\r
124 var ltr = target.getComponentOrientation ().isLeftToRight ();
\r
126 if ("North".equals (constraints)) {
\r
127 result = (this.firstLine != null) ? this.firstLine : this.north;
\r
128 } else if ("South".equals (constraints)) {
\r
129 result = (this.lastLine != null) ? this.lastLine : this.south;
\r
130 } else if ("West".equals (constraints)) {
\r
131 result = ltr ? this.firstItem : this.lastItem;
\r
132 if (result == null) {
\r
133 result = this.west;
\r
134 }} else if ("East".equals (constraints)) {
\r
135 result = ltr ? this.lastItem : this.firstItem;
\r
136 if (result == null) {
\r
137 result = this.east;
\r
138 }} else if ("Center".equals (constraints)) {
\r
139 result = this.center;
\r
141 throw new IllegalArgumentException ("cannot get component: invalid constraint: " + constraints);
\r
143 }, "java.awt.Container,~O");
\r
144 Clazz.defineMethod (c$, "getConstraints",
\r
146 if (comp == null) {
\r
148 }if (comp === this.center) {
\r
150 } else if (comp === this.north) {
\r
152 } else if (comp === this.south) {
\r
154 } else if (comp === this.west) {
\r
156 } else if (comp === this.east) {
\r
158 } else if (comp === this.firstLine) {
\r
160 } else if (comp === this.lastLine) {
\r
162 } else if (comp === this.firstItem) {
\r
164 } else if (comp === this.lastItem) {
\r
167 }, "java.awt.Component");
\r
168 Clazz.overrideMethod (c$, "minimumLayoutSize",
\r
169 function (target) {
\r
171 var dim = new java.awt.Dimension (0, 0);
\r
172 var ltr = target.getComponentOrientation ().isLeftToRight ();
\r
174 if ((c = this.getChild ("East", ltr)) != null) {
\r
175 var d = c.getMinimumSize ();
\r
176 dim.width += d.width + this.hgap;
\r
177 dim.height = Math.max (d.height, dim.height);
\r
178 }if ((c = this.getChild ("West", ltr)) != null) {
\r
179 var d = c.getMinimumSize ();
\r
180 dim.width += d.width + this.hgap;
\r
181 dim.height = Math.max (d.height, dim.height);
\r
182 }if ((c = this.getChild ("Center", ltr)) != null) {
\r
183 var d = c.getMinimumSize ();
\r
184 dim.width += d.width;
\r
185 dim.height = Math.max (d.height, dim.height);
\r
186 }if ((c = this.getChild ("North", ltr)) != null) {
\r
187 var d = c.getMinimumSize ();
\r
188 dim.width = Math.max (d.width, dim.width);
\r
189 dim.height += d.height + this.vgap;
\r
190 }if ((c = this.getChild ("South", ltr)) != null) {
\r
191 var d = c.getMinimumSize ();
\r
192 dim.width = Math.max (d.width, dim.width);
\r
193 dim.height += d.height + this.vgap;
\r
194 }var insets = target.getInsets ();
\r
195 dim.width += insets.left + insets.right;
\r
196 dim.height += insets.top + insets.bottom;
\r
198 }}, "java.awt.Container");
\r
199 Clazz.overrideMethod (c$, "preferredLayoutSize",
\r
200 function (target) {
\r
202 var dim = new java.awt.Dimension (0, 0);
\r
203 var ltr = target.getComponentOrientation ().isLeftToRight ();
\r
205 if ((c = this.getChild ("East", ltr)) != null) {
\r
206 var d = c.getPreferredSize ();
\r
207 dim.width += d.width + this.hgap;
\r
208 dim.height = Math.max (d.height, dim.height);
\r
209 }if ((c = this.getChild ("West", ltr)) != null) {
\r
210 var d = c.getPreferredSize ();
\r
211 dim.width += d.width + this.hgap;
\r
212 dim.height = Math.max (d.height, dim.height);
\r
213 }if ((c = this.getChild ("Center", ltr)) != null) {
\r
214 var d = c.getPreferredSize ();
\r
215 dim.width += d.width;
\r
216 dim.height = Math.max (d.height, dim.height);
\r
217 }if ((c = this.getChild ("North", ltr)) != null) {
\r
218 var d = c.getPreferredSize ();
\r
219 dim.width = Math.max (d.width, dim.width);
\r
220 dim.height += d.height + this.vgap;
\r
221 }if ((c = this.getChild ("South", ltr)) != null) {
\r
222 var d = c.getPreferredSize ();
\r
223 dim.width = Math.max (d.width, dim.width);
\r
224 dim.height += d.height + this.vgap;
\r
225 }var insets = target.getInsets ();
\r
226 dim.width += insets.left + insets.right;
\r
227 dim.height += insets.top + insets.bottom;
\r
229 }}, "java.awt.Container");
\r
230 Clazz.overrideMethod (c$, "maximumLayoutSize",
\r
231 function (target) {
\r
232 return new java.awt.Dimension (2147483647, 2147483647);
\r
233 }, "java.awt.Container");
\r
234 Clazz.overrideMethod (c$, "getLayoutAlignmentX",
\r
235 function (parent) {
\r
237 }, "java.awt.Container");
\r
238 Clazz.overrideMethod (c$, "getLayoutAlignmentY",
\r
239 function (parent) {
\r
241 }, "java.awt.Container");
\r
242 Clazz.overrideMethod (c$, "invalidateLayout",
\r
243 function (target) {
\r
244 }, "java.awt.Container");
\r
245 Clazz.overrideMethod (c$, "layoutContainer",
\r
246 function (target) {
\r
247 System.out.println ("BorderLayout laying out " + target);
\r
249 var insets = target.getInsets ();
\r
250 var top = insets.top;
\r
251 var bottom = target.height - insets.bottom;
\r
252 var left = insets.left;
\r
253 var right = target.width - insets.right;
\r
254 var ltr = target.getComponentOrientation ().isLeftToRight ();
\r
256 if ((c = this.getChild ("North", ltr)) != null) {
\r
257 c.setSize (right - left, c.height);
\r
258 var d = c.getPreferredSize ();
\r
259 c.setBounds (left, top, right - left, d.height);
\r
260 top += d.height + this.vgap;
\r
261 }if ((c = this.getChild ("South", ltr)) != null) {
\r
262 c.setSize (right - left, c.height);
\r
263 var d = c.getPreferredSize ();
\r
264 c.setBounds (left, bottom - d.height, right - left, d.height);
\r
265 bottom -= d.height + this.vgap;
\r
266 }if ((c = this.getChild ("East", ltr)) != null) {
\r
267 c.setSize (c.width, bottom - top);
\r
268 var d = c.getPreferredSize ();
\r
269 c.setBounds (right - d.width, top, d.width, bottom - top);
\r
270 right -= d.width + this.hgap;
\r
271 }if ((c = this.getChild ("West", ltr)) != null) {
\r
272 c.setSize (c.width, bottom - top);
\r
273 var d = c.getPreferredSize ();
\r
274 c.setBounds (left, top, d.width, bottom - top);
\r
275 left += d.width + this.hgap;
\r
276 }if ((c = this.getChild ("Center", ltr)) != null) {
\r
277 c.setBounds (left, top, right - left, bottom - top);
\r
278 }}}, "java.awt.Container");
\r
279 Clazz.defineMethod (c$, "getChild",
\r
280 function (key, ltr) {
\r
282 if (key === "North") {
\r
283 result = (this.firstLine != null) ? this.firstLine : this.north;
\r
284 } else if (key === "South") {
\r
285 result = (this.lastLine != null) ? this.lastLine : this.south;
\r
286 } else if (key === "West") {
\r
287 result = ltr ? this.firstItem : this.lastItem;
\r
288 if (result == null) {
\r
289 result = this.west;
\r
290 }} else if (key === "East") {
\r
291 result = ltr ? this.lastItem : this.firstItem;
\r
292 if (result == null) {
\r
293 result = this.east;
\r
294 }} else if (key === "Center") {
\r
295 result = this.center;
\r
296 }if (result != null && !result.visible) {
\r
300 Clazz.overrideMethod (c$, "toString",
\r
302 return this.getClass ().getName () + "[hgap=" + this.hgap + ",vgap=" + this.vgap + "]";
\r
304 Clazz.defineStatics (c$,
\r
309 "CENTER", "Center",
\r
310 "BEFORE_FIRST_LINE", "First",
\r
311 "AFTER_LAST_LINE", "Last",
\r
312 "BEFORE_LINE_BEGINS", "Before",
\r
313 "AFTER_LINE_ENDS", "After");
\r
314 c$.PAGE_START = c$.prototype.PAGE_START = "First";
\r
315 c$.PAGE_END = c$.prototype.PAGE_END = "Last";
\r
316 c$.LINE_START = c$.prototype.LINE_START = "Before";
\r
317 c$.LINE_END = c$.prototype.LINE_END = "After";
\r