1 Clazz.declarePackage ("javax.swing");
2 Clazz.load (["javax.swing.JComponent"], "javax.swing.JLayeredPane", ["java.util.ArrayList", "$.Hashtable", "java.awt.Color"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.componentToLayer = null;
5 this.optimizedDrawingPossible = true;
6 Clazz.instantialize (this, arguments);
7 }, javax.swing, "JLayeredPane", javax.swing.JComponent);
8 Clazz.makeConstructor (c$,
10 Clazz.superConstructor (this, javax.swing.JLayeredPane, []);
11 this.setLayout (null);
13 Clazz.defineMethod (c$, "validateOptimizedDrawing",
15 var layeredComponentFound = false;
18 for (var c, $c = 0, $$c = this.getComponents (); $c < $$c.length && ((c = $$c[$c]) || true); $c++) {
20 if ((Clazz.instanceOf (c, javax.swing.JComponent) && (layer = (c).getClientProperty ("layeredContainerLayer")) != null)) {
21 if (layer != null && layer.equals (javax.swing.JLayeredPane.FRAME_CONTENT_LAYER)) continue;
22 layeredComponentFound = true;
25 }if (layeredComponentFound) this.optimizedDrawingPossible = false;
26 else this.optimizedDrawingPossible = true;
28 Clazz.overrideMethod (c$, "addImpl",
29 function (comp, constraints, index) {
30 var layer = javax.swing.JLayeredPane.DEFAULT_LAYER.intValue ();
32 if (Clazz.instanceOf (constraints, Integer)) {
33 layer = (constraints).intValue ();
34 this.setLayer (comp, layer);
35 } else layer = this.getLayer (comp);
36 pos = this.insertIndexForLayer (layer, index);
37 this.addImplSAEM (comp, constraints, pos);
40 this.validateOptimizedDrawing ();
42 }, "java.awt.Component,~O,~N");
43 Clazz.defineMethod (c$, "remove",
45 var c = this.getComponent (index);
46 Clazz.superCall (this, javax.swing.JLayeredPane, "remove", [index]);
47 if (c != null && !(Clazz.instanceOf (c, javax.swing.JComponent))) {
48 this.getComponentToLayer ().remove (c);
49 }this.validateOptimizedDrawing ();
51 Clazz.defineMethod (c$, "removeAll",
53 var children = this.getComponents ();
54 var cToL = this.getComponentToLayer ();
55 for (var counter = children.length - 1; counter >= 0; counter--) {
56 var c = children[counter];
57 if (c != null && !(Clazz.instanceOf (c, javax.swing.JComponent))) {
60 Clazz.superCall (this, javax.swing.JLayeredPane, "removeAll", []);
62 Clazz.overrideMethod (c$, "isOptimizedDrawingEnabled",
64 return this.optimizedDrawingPossible;
66 c$.putLayer = Clazz.defineMethod (c$, "putLayer",
69 layerObj = new Integer (layer);
70 c.putClientProperty ("layeredContainerLayer", layerObj);
71 }, "javax.swing.JComponent,~N");
72 c$.getLayer = Clazz.defineMethod (c$, "getLayer",
75 if ((i = c.getClientProperty ("layeredContainerLayer")) != null) return i.intValue ();
76 return javax.swing.JLayeredPane.DEFAULT_LAYER.intValue ();
77 }, "javax.swing.JComponent");
78 c$.getLayeredPaneAbove = Clazz.defineMethod (c$, "getLayeredPaneAbove",
80 if (c == null) return null;
81 var parent = c.getParent ();
82 while (parent != null && !(Clazz.instanceOf (parent, javax.swing.JLayeredPane))) parent = parent.getParent ();
85 }, "java.awt.Component");
86 Clazz.defineMethod (c$, "setLayer",
88 this.setLayer (c, layer, -1);
89 }, "java.awt.Component,~N");
90 Clazz.defineMethod (c$, "setLayer",
91 function (c, layer, position) {
93 layerObj = this.getObjectForLayer (layer);
94 if (layer == this.getLayer (c) && position == this.getPosition (c)) {
95 this.repaint (c.getBounds ());
97 }if (Clazz.instanceOf (c, javax.swing.JComponent)) (c).putClientProperty ("layeredContainerLayer", layerObj);
98 else this.getComponentToLayer ().put (c, layerObj);
99 if (c.getParent () == null || c.getParent () !== this) {
100 this.repaint (c.getBounds ());
102 }var index = this.insertIndexForLayer (c, layer, position);
103 this.setComponentZOrder (c, index);
104 this.repaint (c.getBounds ());
105 }, "java.awt.Component,~N,~N");
106 Clazz.defineMethod (c$, "getLayer",
109 if (Clazz.instanceOf (c, javax.swing.JComponent)) i = (c).getClientProperty ("layeredContainerLayer");
110 else i = this.getComponentToLayer ().get (c);
111 if (i == null) return javax.swing.JLayeredPane.DEFAULT_LAYER.intValue ();
112 return i.intValue ();
113 }, "java.awt.Component");
114 Clazz.defineMethod (c$, "getIndexOf",
118 count = this.getComponentCount ();
119 for (i = 0; i < count; i++) {
120 if (c === this.getComponent (i)) return i;
123 }, "java.awt.Component");
124 Clazz.defineMethod (c$, "moveToFront",
126 this.setPosition (c, 0);
127 }, "java.awt.Component");
128 Clazz.defineMethod (c$, "moveToBack",
130 this.setPosition (c, -1);
131 }, "java.awt.Component");
132 Clazz.defineMethod (c$, "setPosition",
133 function (c, position) {
134 this.setLayer (c, this.getLayer (c), position);
135 }, "java.awt.Component,~N");
136 Clazz.defineMethod (c$, "getPosition",
144 count = this.getComponentCount ();
145 startLocation = this.getIndexOf (c);
146 if (startLocation == -1) return -1;
147 startLayer = this.getLayer (c);
148 for (i = startLocation - 1; i >= 0; i--) {
149 curLayer = this.getLayer (this.getComponent (i));
150 if (curLayer == startLayer) pos++;
154 }, "java.awt.Component");
155 Clazz.defineMethod (c$, "highestLayer",
157 if (this.getComponentCount () > 0) return this.getLayer (this.getComponent (0));
160 Clazz.defineMethod (c$, "lowestLayer",
162 var count = this.getComponentCount ();
163 if (count > 0) return this.getLayer (this.getComponent (count - 1));
166 Clazz.defineMethod (c$, "getComponentCountInLayer",
172 count = this.getComponentCount ();
173 for (i = 0; i < count; i++) {
174 curLayer = this.getLayer (this.getComponent (i));
175 if (curLayer == layer) {
177 } else if (layerCount > 0 || curLayer < layer) {
182 Clazz.defineMethod (c$, "getComponentsInLayer",
189 results = new Array (this.getComponentCountInLayer (layer));
190 count = this.getComponentCount ();
191 for (i = 0; i < count; i++) {
192 curLayer = this.getLayer (this.getComponent (i));
193 if (curLayer == layer) {
194 results[layerCount++] = this.getComponent (i);
195 } else if (layerCount > 0 || curLayer < layer) {
200 Clazz.defineMethod (c$, "paint",
202 if (this.isOpaque ()) {
203 var r = g.getClipBounds ();
204 var c = this.getBackground ();
205 if (c == null) c = java.awt.Color.lightGray;
208 g.fillRect (r.x, r.y, r.width, r.height);
210 g.fillRect (0, 0, this.getWidth (), this.getHeight ());
211 }}Clazz.superCall (this, javax.swing.JLayeredPane, "paint", [g]);
212 }, "java.awt.Graphics");
213 Clazz.defineMethod (c$, "getComponentToLayer",
215 if (this.componentToLayer == null) this.componentToLayer = new java.util.Hashtable (4);
216 return this.componentToLayer;
218 Clazz.defineMethod (c$, "getObjectForLayer",
223 layerObj = javax.swing.JLayeredPane.DEFAULT_LAYER;
226 layerObj = javax.swing.JLayeredPane.PALETTE_LAYER;
229 layerObj = javax.swing.JLayeredPane.MODAL_LAYER;
232 layerObj = javax.swing.JLayeredPane.POPUP_LAYER;
235 layerObj = javax.swing.JLayeredPane.DRAG_LAYER;
238 layerObj = new Integer (layer);
242 Clazz.defineMethod (c$, "insertIndexForLayer",
243 function (layer, position) {
244 return this.insertIndexForLayer (null, layer, position);
246 Clazz.defineMethod (c$, "insertIndexForLayer",
247 function (comp, layer, position) {
253 var componentCount = this.getComponentCount ();
254 var compList = new java.util.ArrayList (componentCount);
255 for (var index = 0; index < componentCount; index++) {
256 if (this.getComponent (index) !== comp) {
257 compList.add (this.getComponent (index));
259 count = compList.size ();
260 for (i = 0; i < count; i++) {
261 curLayer = this.getLayer (compList.get (i));
262 if (layerStart == -1 && curLayer == layer) {
264 }if (curLayer < layer) {
272 if (layerStart == -1 && layerEnd == -1) return count;
273 if (layerStart != -1 && layerEnd == -1) layerEnd = count;
274 if (layerEnd != -1 && layerStart == -1) layerStart = layerEnd;
275 if (position == -1) return layerEnd;
276 if (position > -1 && layerStart + position <= layerEnd) return layerStart + position;
278 }, "java.awt.Component,~N,~N");
279 Clazz.defineMethod (c$, "paramString",
281 var optimizedDrawingPossibleString = (this.optimizedDrawingPossible ? "true" : "false");
282 return Clazz.superCall (this, javax.swing.JLayeredPane, "paramString", []) + ",optimizedDrawingPossible=" + optimizedDrawingPossibleString;
284 c$.DEFAULT_LAYER = c$.prototype.DEFAULT_LAYER = new Integer (0);
285 c$.PALETTE_LAYER = c$.prototype.PALETTE_LAYER = new Integer (100);
286 c$.MODAL_LAYER = c$.prototype.MODAL_LAYER = new Integer (200);
287 c$.POPUP_LAYER = c$.prototype.POPUP_LAYER = new Integer (300);
288 c$.DRAG_LAYER = c$.prototype.DRAG_LAYER = new Integer (400);
289 c$.FRAME_CONTENT_LAYER = c$.prototype.FRAME_CONTENT_LAYER = new Integer (-30000);
290 Clazz.defineStatics (c$,
291 "LAYER_PROPERTY", "layeredContainerLayer");