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