4d696b68a26c90e142ee43d36b893ab6229011f9
[jalviewjs.git] / site / swingjs / j2s / javax / swing / JList.js
1 Clazz.declarePackage ("javax.swing");
2 Clazz.load (["javax.swing.JComponent", "$.Scrollable", "javax.swing.event.ListSelectionListener"], "javax.swing.JList", ["java.lang.IllegalArgumentException", "java.awt.Component", "$.Dimension", "$.Point", "java.awt.event.MouseEvent", "javax.swing.AbstractListModel", "$.DefaultListSelectionModel", "$.JViewport", "$.SwingUtilities", "$.UIManager", "javax.swing.event.ListSelectionEvent", "javax.swing.text.Position"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.fixedCellWidth = -1;
5 this.fixedCellHeight = -1;
6 this.horizontalScrollIncrement = -1;
7 this.prototypeCellValue = null;
8 this.visibleRowCount = 8;
9 this.selectionForeground = null;
10 this.selectionBackground = null;
11 this.dragEnabled = false;
12 this.selectionModel = null;
13 this.dataModel = null;
14 this.cellRenderer = null;
15 this.selectionListener = null;
16 this.layoutOrientation = 0;
17 if (!Clazz.isClassDefined ("javax.swing.JList.ListSelectionHandler")) {
18 javax.swing.JList.$JList$ListSelectionHandler$ ();
19 }
20 Clazz.instantialize (this, arguments);
21 }, javax.swing, "JList", javax.swing.JComponent, javax.swing.Scrollable);
22 Clazz.makeConstructor (c$, 
23 function (dataModel) {
24 Clazz.superConstructor (this, javax.swing.JList, []);
25 if (dataModel == null) {
26 throw  new IllegalArgumentException ("dataModel must be non null");
27 }this.layoutOrientation = 0;
28 this.dataModel = dataModel;
29 this.selectionModel = this.createSelectionModel ();
30 this.setAutoscrolls (true);
31 this.setOpaque (true);
32 this.updateUI ();
33 }, "javax.swing.ListModel");
34 Clazz.makeConstructor (c$, 
35 function (listData) {
36 this.construct (((Clazz.isClassDefined ("javax.swing.JList$1") ? 0 : javax.swing.JList.$JList$1$ ()), Clazz.innerTypeInstance (javax.swing.JList$1, this, Clazz.cloneFinals ("listData", listData))));
37 }, "~A");
38 Clazz.makeConstructor (c$, 
39 function (listData) {
40 this.construct (((Clazz.isClassDefined ("javax.swing.JList$2") ? 0 : javax.swing.JList.$JList$2$ ()), Clazz.innerTypeInstance (javax.swing.JList$2, this, Clazz.cloneFinals ("listData", listData))));
41 }, "java.util.Vector");
42 Clazz.makeConstructor (c$, 
43 function () {
44 this.construct (((Clazz.isClassDefined ("javax.swing.JList$3") ? 0 : javax.swing.JList.$JList$3$ ()), Clazz.innerTypeInstance (javax.swing.JList$3, this, null)));
45 });
46 Clazz.overrideMethod (c$, "getUI", 
47 function () {
48 return this.ui;
49 });
50 Clazz.overrideMethod (c$, "updateUI", 
51 function () {
52 this.setUI (javax.swing.UIManager.getUI (this));
53 var renderer = this.getCellRenderer ();
54 if (Clazz.instanceOf (renderer, java.awt.Component)) {
55 javax.swing.SwingUtilities.updateComponentTreeUI (renderer);
56 }});
57 Clazz.overrideMethod (c$, "getUIClassID", 
58 function () {
59 return "ListUI";
60 });
61 Clazz.defineMethod (c$, "updateFixedCellSize", 
62  function () {
63 var cr = this.getCellRenderer ();
64 var value = this.getPrototypeCellValue ();
65 if ((cr != null) && (value != null)) {
66 var c = cr.getListCellRendererComponent (this, value, 0, false, false);
67 var f = c.getFont ();
68 c.setFont (this.getFont ());
69 var d = c.getPreferredSize ();
70 this.fixedCellWidth = d.width;
71 this.fixedCellHeight = d.height;
72 c.setFont (f);
73 }});
74 Clazz.defineMethod (c$, "getPrototypeCellValue", 
75 function () {
76 return this.prototypeCellValue;
77 });
78 Clazz.defineMethod (c$, "setPrototypeCellValue", 
79 function (prototypeCellValue) {
80 var oldValue = this.prototypeCellValue;
81 this.prototypeCellValue = prototypeCellValue;
82 if ((prototypeCellValue != null) && !prototypeCellValue.equals (oldValue)) {
83 this.updateFixedCellSize ();
84 }this.firePropertyChangeObject ("prototypeCellValue", oldValue, prototypeCellValue);
85 }, "~O");
86 Clazz.defineMethod (c$, "getFixedCellWidth", 
87 function () {
88 return this.fixedCellWidth;
89 });
90 Clazz.defineMethod (c$, "setFixedCellWidth", 
91 function (width) {
92 var oldValue = this.fixedCellWidth;
93 this.fixedCellWidth = width;
94 this.firePropertyChangeInt ("fixedCellWidth", oldValue, this.fixedCellWidth);
95 }, "~N");
96 Clazz.defineMethod (c$, "getFixedCellHeight", 
97 function () {
98 return this.fixedCellHeight;
99 });
100 Clazz.defineMethod (c$, "setFixedCellHeight", 
101 function (height) {
102 var oldValue = this.fixedCellHeight;
103 this.fixedCellHeight = height;
104 this.firePropertyChangeInt ("fixedCellHeight", oldValue, this.fixedCellHeight);
105 }, "~N");
106 Clazz.defineMethod (c$, "getCellRenderer", 
107 function () {
108 return this.cellRenderer;
109 });
110 Clazz.defineMethod (c$, "setCellRenderer", 
111 function (cellRenderer) {
112 var oldValue = this.cellRenderer;
113 this.cellRenderer = cellRenderer;
114 if ((cellRenderer != null) && !cellRenderer.equals (oldValue)) {
115 this.updateFixedCellSize ();
116 }this.firePropertyChangeObject ("cellRenderer", oldValue, cellRenderer);
117 }, "javax.swing.ListCellRenderer");
118 Clazz.defineMethod (c$, "getSelectionForeground", 
119 function () {
120 return this.selectionForeground;
121 });
122 Clazz.defineMethod (c$, "setSelectionForeground", 
123 function (selectionForeground) {
124 var oldValue = this.selectionForeground;
125 this.selectionForeground = selectionForeground;
126 this.firePropertyChangeObject ("selectionForeground", oldValue, selectionForeground);
127 }, "java.awt.Color");
128 Clazz.defineMethod (c$, "getSelectionBackground", 
129 function () {
130 return this.selectionBackground;
131 });
132 Clazz.defineMethod (c$, "setSelectionBackground", 
133 function (selectionBackground) {
134 var oldValue = this.selectionBackground;
135 this.selectionBackground = selectionBackground;
136 this.firePropertyChangeObject ("selectionBackground", oldValue, selectionBackground);
137 }, "java.awt.Color");
138 Clazz.defineMethod (c$, "getVisibleRowCount", 
139 function () {
140 return this.visibleRowCount;
141 });
142 Clazz.defineMethod (c$, "setVisibleRowCount", 
143 function (visibleRowCount) {
144 var oldValue = this.visibleRowCount;
145 this.visibleRowCount = Math.max (0, visibleRowCount);
146 this.firePropertyChangeInt ("visibleRowCount", oldValue, visibleRowCount);
147 }, "~N");
148 Clazz.defineMethod (c$, "getLayoutOrientation", 
149 function () {
150 return this.layoutOrientation;
151 });
152 Clazz.defineMethod (c$, "setLayoutOrientation", 
153 function (layoutOrientation) {
154 var oldValue = this.layoutOrientation;
155 switch (layoutOrientation) {
156 case 0:
157 case 1:
158 case 2:
159 this.layoutOrientation = layoutOrientation;
160 this.firePropertyChangeInt ("layoutOrientation", oldValue, layoutOrientation);
161 break;
162 default:
163 throw  new IllegalArgumentException ("layoutOrientation must be one of: VERTICAL, HORIZONTAL_WRAP or VERTICAL_WRAP");
164 }
165 }, "~N");
166 Clazz.defineMethod (c$, "getFirstVisibleIndex", 
167 function () {
168 var r = this.getVisibleRect ();
169 var first;
170 if (this.getComponentOrientation ().isLeftToRight ()) {
171 first = this.locationToIndex (r.getLocation ());
172 } else {
173 first = this.locationToIndex ( new java.awt.Point ((r.x + r.width) - 1, r.y));
174 }if (first != -1) {
175 var bounds = this.getCellBounds (first, first);
176 if (bounds != null) {
177 javax.swing.SwingUtilities.computeIntersection (r.x, r.y, r.width, r.height, bounds);
178 if (bounds.width == 0 || bounds.height == 0) {
179 first = -1;
180 }}}return first;
181 });
182 Clazz.defineMethod (c$, "getLastVisibleIndex", 
183 function () {
184 var leftToRight = this.getComponentOrientation ().isLeftToRight ();
185 var r = this.getVisibleRect ();
186 var lastPoint;
187 if (leftToRight) {
188 lastPoint =  new java.awt.Point ((r.x + r.width) - 1, (r.y + r.height) - 1);
189 } else {
190 lastPoint =  new java.awt.Point (r.x, (r.y + r.height) - 1);
191 }var location = this.locationToIndex (lastPoint);
192 if (location != -1) {
193 var bounds = this.getCellBounds (location, location);
194 if (bounds != null) {
195 javax.swing.SwingUtilities.computeIntersection (r.x, r.y, r.width, r.height, bounds);
196 if (bounds.width == 0 || bounds.height == 0) {
197 var isHorizontalWrap = (this.getLayoutOrientation () == 2);
198 var visibleLocation = isHorizontalWrap ?  new java.awt.Point (lastPoint.x, r.y) :  new java.awt.Point (r.x, lastPoint.y);
199 var last;
200 var visIndex = -1;
201 var lIndex = location;
202 location = -1;
203 do {
204 last = visIndex;
205 visIndex = this.locationToIndex (visibleLocation);
206 if (visIndex != -1) {
207 bounds = this.getCellBounds (visIndex, visIndex);
208 if (visIndex != lIndex && bounds != null && bounds.contains (visibleLocation)) {
209 location = visIndex;
210 if (isHorizontalWrap) {
211 visibleLocation.y = bounds.y + bounds.height;
212 if (visibleLocation.y >= lastPoint.y) {
213 last = visIndex;
214 }} else {
215 visibleLocation.x = bounds.x + bounds.width;
216 if (visibleLocation.x >= lastPoint.x) {
217 last = visIndex;
218 }}} else {
219 last = visIndex;
220 }}} while (visIndex != -1 && last != visIndex);
221 }}}return location;
222 });
223 Clazz.defineMethod (c$, "ensureIndexIsVisible", 
224 function (index) {
225 var cellBounds = this.getCellBounds (index, index);
226 if (cellBounds != null) {
227 this.scrollRectToVisible (cellBounds);
228 }}, "~N");
229 Clazz.defineMethod (c$, "setDragEnabled", 
230 function (b) {
231 this.dragEnabled = b;
232 }, "~B");
233 Clazz.defineMethod (c$, "getDragEnabled", 
234 function () {
235 return this.dragEnabled;
236 });
237 Clazz.defineMethod (c$, "getNextMatch", 
238 function (prefix, startIndex, bias) {
239 var model = this.getModel ();
240 var max = model.getSize ();
241 if (prefix == null) {
242 throw  new IllegalArgumentException ();
243 }if (startIndex < 0 || startIndex >= max) {
244 throw  new IllegalArgumentException ();
245 }prefix = prefix.toUpperCase ();
246 var increment = (bias === javax.swing.text.Position.Bias.Forward) ? 1 : -1;
247 var index = startIndex;
248 do {
249 var o = model.getElementAt (index);
250 if (o != null) {
251 var string;
252 if (Clazz.instanceOf (o, String)) {
253 string = (o).toUpperCase ();
254 } else {
255 string = o.toString ();
256 if (string != null) {
257 string = string.toUpperCase ();
258 }}if (string != null && string.startsWith (prefix)) {
259 return index;
260 }}index = (index + increment + max) % max;
261 } while (index != startIndex);
262 return -1;
263 }, "~S,~N,javax.swing.text.Position.Bias");
264 Clazz.defineMethod (c$, "getToolTipText", 
265 function (event) {
266 if (event != null) {
267 var p = event.getPoint ();
268 var index = this.locationToIndex (p);
269 var r = this.getCellRenderer ();
270 var cellBounds;
271 if (index != -1 && r != null && (cellBounds = this.getCellBounds (index, index)) != null && cellBounds.contains (p.x, p.y)) {
272 var lsm = this.getSelectionModel ();
273 var rComponent = r.getListCellRendererComponent (this, this.getModel ().getElementAt (index), index, lsm.isSelectedIndex (index), (this.hasFocus () && (lsm.getLeadSelectionIndex () == index)));
274 if (Clazz.instanceOf (rComponent, javax.swing.JComponent)) {
275 var newEvent;
276 p.translate (-cellBounds.x, -cellBounds.y);
277 newEvent =  new java.awt.event.MouseEvent (rComponent, event.getID (), event.getWhen (), event.getModifiers (), p.x, p.y, event.getXOnScreen (), event.getYOnScreen (), event.getClickCount (), event.isPopupTrigger (), 0);
278 var tip = (rComponent).getToolTipText (newEvent);
279 if (tip != null) {
280 return tip;
281 }}}}return Clazz.superCall (this, javax.swing.JList, "getToolTipText", []);
282 }, "java.awt.event.MouseEvent");
283 Clazz.defineMethod (c$, "locationToIndex", 
284 function (location) {
285 var ui = this.getUI ();
286 return (ui != null) ? ui.locationToIndex (this, location) : -1;
287 }, "java.awt.Point");
288 Clazz.defineMethod (c$, "indexToLocation", 
289 function (index) {
290 var ui = this.getUI ();
291 return (ui != null) ? ui.indexToLocation (this, index) : null;
292 }, "~N");
293 Clazz.defineMethod (c$, "getCellBounds", 
294 function (index0, index1) {
295 var ui = this.getUI ();
296 return (ui != null) ? ui.getCellBounds (this, index0, index1) : null;
297 }, "~N,~N");
298 Clazz.defineMethod (c$, "getModel", 
299 function () {
300 return this.dataModel;
301 });
302 Clazz.defineMethod (c$, "setModel", 
303 function (model) {
304 if (model == null) {
305 throw  new IllegalArgumentException ("model must be non null");
306 }var oldValue = this.dataModel;
307 this.dataModel = model;
308 this.firePropertyChangeObject ("model", oldValue, this.dataModel);
309 this.clearSelection ();
310 }, "javax.swing.ListModel");
311 Clazz.defineMethod (c$, "setListData", 
312 function (listData) {
313 this.setModel (((Clazz.isClassDefined ("javax.swing.JList$4") ? 0 : javax.swing.JList.$JList$4$ ()), Clazz.innerTypeInstance (javax.swing.JList$4, this, Clazz.cloneFinals ("listData", listData))));
314 }, "~A");
315 Clazz.defineMethod (c$, "setListData", 
316 function (listData) {
317 this.setModel (((Clazz.isClassDefined ("javax.swing.JList$5") ? 0 : javax.swing.JList.$JList$5$ ()), Clazz.innerTypeInstance (javax.swing.JList$5, this, Clazz.cloneFinals ("listData", listData))));
318 }, "java.util.Vector");
319 Clazz.defineMethod (c$, "createSelectionModel", 
320 function () {
321 return  new javax.swing.DefaultListSelectionModel ();
322 });
323 Clazz.defineMethod (c$, "getSelectionModel", 
324 function () {
325 return this.selectionModel;
326 });
327 Clazz.defineMethod (c$, "fireSelectionValueChanged", 
328 function (firstIndex, lastIndex, isAdjusting) {
329 var listeners = this.listenerList.getListenerList ();
330 var e = null;
331 for (var i = listeners.length - 2; i >= 0; i -= 2) {
332 if (listeners[i] === javax.swing.event.ListSelectionListener) {
333 if (e == null) {
334 e =  new javax.swing.event.ListSelectionEvent (this, firstIndex, lastIndex, isAdjusting);
335 }(listeners[i + 1]).valueChanged (e);
336 }}
337 }, "~N,~N,~B");
338 Clazz.defineMethod (c$, "addListSelectionListener", 
339 function (listener) {
340 if (this.selectionListener == null) {
341 this.selectionListener = Clazz.innerTypeInstance (javax.swing.JList.ListSelectionHandler, this, null);
342 this.getSelectionModel ().addListSelectionListener (this.selectionListener);
343 }this.listenerList.add (javax.swing.event.ListSelectionListener, listener);
344 }, "javax.swing.event.ListSelectionListener");
345 Clazz.defineMethod (c$, "removeListSelectionListener", 
346 function (listener) {
347 this.listenerList.remove (javax.swing.event.ListSelectionListener, listener);
348 }, "javax.swing.event.ListSelectionListener");
349 Clazz.defineMethod (c$, "getListSelectionListeners", 
350 function () {
351 return this.listenerList.getListeners (javax.swing.event.ListSelectionListener);
352 });
353 Clazz.defineMethod (c$, "setSelectionModel", 
354 function (selectionModel) {
355 if (selectionModel == null) {
356 throw  new IllegalArgumentException ("selectionModel must be non null");
357 }if (this.selectionListener != null) {
358 this.selectionModel.removeListSelectionListener (this.selectionListener);
359 selectionModel.addListSelectionListener (this.selectionListener);
360 }var oldValue = this.selectionModel;
361 this.selectionModel = selectionModel;
362 this.firePropertyChangeObject ("selectionModel", oldValue, selectionModel);
363 }, "javax.swing.ListSelectionModel");
364 Clazz.defineMethod (c$, "setSelectionMode", 
365 function (selectionMode) {
366 this.getSelectionModel ().setSelectionMode (selectionMode);
367 }, "~N");
368 Clazz.defineMethod (c$, "getSelectionMode", 
369 function () {
370 return this.getSelectionModel ().getSelectionMode ();
371 });
372 Clazz.defineMethod (c$, "getAnchorSelectionIndex", 
373 function () {
374 return this.getSelectionModel ().getAnchorSelectionIndex ();
375 });
376 Clazz.defineMethod (c$, "getLeadSelectionIndex", 
377 function () {
378 return this.getSelectionModel ().getLeadSelectionIndex ();
379 });
380 Clazz.defineMethod (c$, "getMinSelectionIndex", 
381 function () {
382 return this.getSelectionModel ().getMinSelectionIndex ();
383 });
384 Clazz.defineMethod (c$, "getMaxSelectionIndex", 
385 function () {
386 return this.getSelectionModel ().getMaxSelectionIndex ();
387 });
388 Clazz.defineMethod (c$, "isSelectedIndex", 
389 function (index) {
390 return this.getSelectionModel ().isSelectedIndex (index);
391 }, "~N");
392 Clazz.defineMethod (c$, "isSelectionEmpty", 
393 function () {
394 return this.getSelectionModel ().isSelectionEmpty ();
395 });
396 Clazz.defineMethod (c$, "clearSelection", 
397 function () {
398 this.getSelectionModel ().clearSelection ();
399 });
400 Clazz.defineMethod (c$, "setSelectionInterval", 
401 function (anchor, lead) {
402 this.getSelectionModel ().setSelectionInterval (anchor, lead);
403 }, "~N,~N");
404 Clazz.defineMethod (c$, "addSelectionInterval", 
405 function (anchor, lead) {
406 this.getSelectionModel ().addSelectionInterval (anchor, lead);
407 }, "~N,~N");
408 Clazz.defineMethod (c$, "removeSelectionInterval", 
409 function (index0, index1) {
410 this.getSelectionModel ().removeSelectionInterval (index0, index1);
411 }, "~N,~N");
412 Clazz.defineMethod (c$, "setValueIsAdjusting", 
413 function (b) {
414 this.getSelectionModel ().setValueIsAdjusting (b);
415 }, "~B");
416 Clazz.defineMethod (c$, "getValueIsAdjusting", 
417 function () {
418 return this.getSelectionModel ().getValueIsAdjusting ();
419 });
420 Clazz.defineMethod (c$, "getSelectedIndices", 
421 function () {
422 var sm = this.getSelectionModel ();
423 var iMin = sm.getMinSelectionIndex ();
424 var iMax = sm.getMaxSelectionIndex ();
425 if ((iMin < 0) || (iMax < 0)) {
426 return  Clazz.newIntArray (0, 0);
427 }var rvTmp =  Clazz.newIntArray (1 + (iMax - iMin), 0);
428 var n = 0;
429 for (var i = iMin; i <= iMax; i++) {
430 if (sm.isSelectedIndex (i)) {
431 rvTmp[n++] = i;
432 }}
433 var rv =  Clazz.newIntArray (n, 0);
434 System.arraycopy (rvTmp, 0, rv, 0, n);
435 return rv;
436 });
437 Clazz.defineMethod (c$, "setSelectedIndex", 
438 function (index) {
439 if (index >= this.getModel ().getSize ()) {
440 return;
441 }this.getSelectionModel ().setSelectionInterval (index, index);
442 }, "~N");
443 Clazz.defineMethod (c$, "setSelectedIndices", 
444 function (indices) {
445 var sm = this.getSelectionModel ();
446 sm.clearSelection ();
447 var size = this.getModel ().getSize ();
448 for (var i = 0; i < indices.length; i++) {
449 if (indices[i] < size) {
450 sm.addSelectionInterval (indices[i], indices[i]);
451 }}
452 }, "~A");
453 Clazz.defineMethod (c$, "getSelectedValues", 
454 function () {
455 var sm = this.getSelectionModel ();
456 var dm = this.getModel ();
457 var iMin = sm.getMinSelectionIndex ();
458 var iMax = sm.getMaxSelectionIndex ();
459 if ((iMin < 0) || (iMax < 0)) {
460 return  new Array (0);
461 }var rvTmp =  new Array (1 + (iMax - iMin));
462 var n = 0;
463 for (var i = iMin; i <= iMax; i++) {
464 if (sm.isSelectedIndex (i)) {
465 rvTmp[n++] = dm.getElementAt (i);
466 }}
467 var rv =  new Array (n);
468 System.arraycopy (rvTmp, 0, rv, 0, n);
469 return rv;
470 });
471 Clazz.defineMethod (c$, "getSelectedIndex", 
472 function () {
473 return this.getMinSelectionIndex ();
474 });
475 Clazz.defineMethod (c$, "getSelectedValue", 
476 function () {
477 var i = this.getMinSelectionIndex ();
478 return (i == -1) ? null : this.getModel ().getElementAt (i);
479 });
480 Clazz.defineMethod (c$, "setSelectedValue", 
481 function (anObject, shouldScroll) {
482 if (anObject == null) this.setSelectedIndex (-1);
483  else if (!anObject.equals (this.getSelectedValue ())) {
484 var i;
485 var c;
486 var dm = this.getModel ();
487 for (i = 0, c = dm.getSize (); i < c; i++) if (anObject.equals (dm.getElementAt (i))) {
488 this.setSelectedIndex (i);
489 if (shouldScroll) this.ensureIndexIsVisible (i);
490 this.repaint ();
491 return;
492 }
493 this.setSelectedIndex (-1);
494 }this.repaint ();
495 }, "~O,~B");
496 Clazz.defineMethod (c$, "checkScrollableParameters", 
497  function (visibleRect, orientation) {
498 if (visibleRect == null) {
499 throw  new IllegalArgumentException ("visibleRect must be non-null");
500 }switch (orientation) {
501 case 1:
502 case 0:
503 break;
504 default:
505 throw  new IllegalArgumentException ("orientation must be one of: VERTICAL, HORIZONTAL");
506 }
507 }, "java.awt.Rectangle,~N");
508 Clazz.overrideMethod (c$, "getPreferredScrollableViewportSize", 
509 function () {
510 if (this.getLayoutOrientation () != 0) {
511 return this.getPreferredSize ();
512 }var insets = this.getInsets ();
513 var dx = insets.left + insets.right;
514 var dy = insets.top + insets.bottom;
515 var visibleRowCount = this.getVisibleRowCount ();
516 var fixedCellWidth = this.getFixedCellWidth ();
517 var fixedCellHeight = this.getFixedCellHeight ();
518 if ((fixedCellWidth > 0) && (fixedCellHeight > 0)) {
519 var width = fixedCellWidth + dx;
520 var height = (visibleRowCount * fixedCellHeight) + dy;
521 return  new java.awt.Dimension (width, height);
522 } else if (this.getModel ().getSize () > 0) {
523 var width = this.getPreferredSize ().width;
524 var height;
525 var r = this.getCellBounds (0, 0);
526 if (r != null) {
527 height = (visibleRowCount * r.height) + dy;
528 } else {
529 height = 1;
530 }return  new java.awt.Dimension (width, height);
531 } else {
532 fixedCellWidth = (fixedCellWidth > 0) ? fixedCellWidth : 256;
533 fixedCellHeight = (fixedCellHeight > 0) ? fixedCellHeight : 16;
534 return  new java.awt.Dimension (fixedCellWidth, fixedCellHeight * visibleRowCount);
535 }});
536 Clazz.overrideMethod (c$, "getScrollableUnitIncrement", 
537 function (visibleRect, orientation, direction) {
538 this.checkScrollableParameters (visibleRect, orientation);
539 if (orientation == 1) {
540 var row = this.locationToIndex (visibleRect.getLocation ());
541 if (row == -1) {
542 return 0;
543 } else {
544 if (direction > 0) {
545 var r = this.getCellBounds (row, row);
546 return (r == null) ? 0 : r.height - (visibleRect.y - r.y);
547 } else {
548 var r = this.getCellBounds (row, row);
549 if ((r.y == visibleRect.y) && (row == 0)) {
550 return 0;
551 } else if (r.y == visibleRect.y) {
552 var loc = r.getLocation ();
553 loc.y--;
554 var prevIndex = this.locationToIndex (loc);
555 var prevR = this.getCellBounds (prevIndex, prevIndex);
556 if (prevR == null || prevR.y >= r.y) {
557 return 0;
558 }return prevR.height;
559 } else {
560 return visibleRect.y - r.y;
561 }}}} else if (orientation == 0 && this.getLayoutOrientation () != 0) {
562 var leftToRight = this.getComponentOrientation ().isLeftToRight ();
563 var index;
564 var leadingPoint;
565 if (leftToRight) {
566 leadingPoint = visibleRect.getLocation ();
567 } else {
568 leadingPoint =  new java.awt.Point (visibleRect.x + visibleRect.width - 1, visibleRect.y);
569 }index = this.locationToIndex (leadingPoint);
570 if (index != -1) {
571 var cellBounds = this.getCellBounds (index, index);
572 if (cellBounds != null && cellBounds.contains (leadingPoint)) {
573 var leadingVisibleEdge;
574 var leadingCellEdge;
575 if (leftToRight) {
576 leadingVisibleEdge = visibleRect.x;
577 leadingCellEdge = cellBounds.x;
578 } else {
579 leadingVisibleEdge = visibleRect.x + visibleRect.width;
580 leadingCellEdge = cellBounds.x + cellBounds.width;
581 }if (leadingCellEdge != leadingVisibleEdge) {
582 if (direction < 0) {
583 return Math.abs (leadingVisibleEdge - leadingCellEdge);
584 } else if (leftToRight) {
585 return leadingCellEdge + cellBounds.width - leadingVisibleEdge;
586 } else {
587 return leadingVisibleEdge - cellBounds.x;
588 }}return cellBounds.width;
589 }}}var f = this.getFont ();
590 return (f != null) ? f.getSize () : 1;
591 }, "java.awt.Rectangle,~N,~N");
592 Clazz.overrideMethod (c$, "getScrollableBlockIncrement", 
593 function (visibleRect, orientation, direction) {
594 this.checkScrollableParameters (visibleRect, orientation);
595 if (orientation == 1) {
596 var inc = visibleRect.height;
597 if (direction > 0) {
598 var last = this.locationToIndex ( new java.awt.Point (visibleRect.x, visibleRect.y + visibleRect.height - 1));
599 if (last != -1) {
600 var lastRect = this.getCellBounds (last, last);
601 if (lastRect != null) {
602 inc = lastRect.y - visibleRect.y;
603 if ((inc == 0) && (last < this.getModel ().getSize () - 1)) {
604 inc = lastRect.height;
605 }}}} else {
606 var newFirst = this.locationToIndex ( new java.awt.Point (visibleRect.x, visibleRect.y - visibleRect.height));
607 var first = this.getFirstVisibleIndex ();
608 if (newFirst != -1) {
609 if (first == -1) {
610 first = this.locationToIndex (visibleRect.getLocation ());
611 }var newFirstRect = this.getCellBounds (newFirst, newFirst);
612 var firstRect = this.getCellBounds (first, first);
613 if ((newFirstRect != null) && (firstRect != null)) {
614 while ((newFirstRect.y + visibleRect.height < firstRect.y + firstRect.height) && (newFirstRect.y < firstRect.y)) {
615 newFirst++;
616 newFirstRect = this.getCellBounds (newFirst, newFirst);
617 }
618 inc = visibleRect.y - newFirstRect.y;
619 if ((inc <= 0) && (newFirstRect.y > 0)) {
620 newFirst--;
621 newFirstRect = this.getCellBounds (newFirst, newFirst);
622 if (newFirstRect != null) {
623 inc = visibleRect.y - newFirstRect.y;
624 }}}}}return inc;
625 } else if (orientation == 0 && this.getLayoutOrientation () != 0) {
626 var leftToRight = this.getComponentOrientation ().isLeftToRight ();
627 var inc = visibleRect.width;
628 if (direction > 0) {
629 var x = visibleRect.x + (leftToRight ? (visibleRect.width - 1) : 0);
630 var last = this.locationToIndex ( new java.awt.Point (x, visibleRect.y));
631 if (last != -1) {
632 var lastRect = this.getCellBounds (last, last);
633 if (lastRect != null) {
634 if (leftToRight) {
635 inc = lastRect.x - visibleRect.x;
636 } else {
637 inc = visibleRect.x + visibleRect.width - (lastRect.x + lastRect.width);
638 }if (inc < 0) {
639 inc += lastRect.width;
640 } else if ((inc == 0) && (last < this.getModel ().getSize () - 1)) {
641 inc = lastRect.width;
642 }}}} else {
643 var x = visibleRect.x + (leftToRight ? -visibleRect.width : visibleRect.width - 1 + visibleRect.width);
644 var first = this.locationToIndex ( new java.awt.Point (x, visibleRect.y));
645 if (first != -1) {
646 var firstRect = this.getCellBounds (first, first);
647 if (firstRect != null) {
648 var firstRight = firstRect.x + firstRect.width;
649 if (leftToRight) {
650 if ((firstRect.x < visibleRect.x - visibleRect.width) && (firstRight < visibleRect.x)) {
651 inc = visibleRect.x - firstRight;
652 } else {
653 inc = visibleRect.x - firstRect.x;
654 }} else {
655 var visibleRight = visibleRect.x + visibleRect.width;
656 if ((firstRight > visibleRight + visibleRect.width) && (firstRect.x > visibleRight)) {
657 inc = firstRect.x - visibleRight;
658 } else {
659 inc = firstRight - visibleRight;
660 }}}}}return inc;
661 }return visibleRect.width;
662 }, "java.awt.Rectangle,~N,~N");
663 Clazz.overrideMethod (c$, "getScrollableTracksViewportWidth", 
664 function () {
665 if (this.getLayoutOrientation () == 2 && this.getVisibleRowCount () <= 0) {
666 return true;
667 }if (Clazz.instanceOf (this.getParent (), javax.swing.JViewport)) {
668 return ((this.getParent ()).getWidth () > this.getPreferredSize ().width);
669 }return false;
670 });
671 Clazz.overrideMethod (c$, "getScrollableTracksViewportHeight", 
672 function () {
673 if (this.getLayoutOrientation () == 1 && this.getVisibleRowCount () <= 0) {
674 return true;
675 }if (Clazz.instanceOf (this.getParent (), javax.swing.JViewport)) {
676 return ((this.getParent ()).getHeight () > this.getPreferredSize ().height);
677 }return false;
678 });
679 Clazz.defineMethod (c$, "paramString", 
680 function () {
681 var selectionForegroundString = (this.selectionForeground != null ? this.selectionForeground.toString () : "");
682 var selectionBackgroundString = (this.selectionBackground != null ? this.selectionBackground.toString () : "");
683 return Clazz.superCall (this, javax.swing.JList, "paramString", []) + ",fixedCellHeight=" + this.fixedCellHeight + ",fixedCellWidth=" + this.fixedCellWidth + ",horizontalScrollIncrement=" + this.horizontalScrollIncrement + ",selectionBackground=" + selectionBackgroundString + ",selectionForeground=" + selectionForegroundString + ",visibleRowCount=" + this.visibleRowCount + ",layoutOrientation=" + this.layoutOrientation;
684 });
685 c$.$JList$ListSelectionHandler$ = function () {
686 Clazz.pu$h(self.c$);
687 c$ = Clazz.decorateAsClass (function () {
688 Clazz.prepareCallback (this, arguments);
689 Clazz.instantialize (this, arguments);
690 }, javax.swing.JList, "ListSelectionHandler", null, javax.swing.event.ListSelectionListener);
691 Clazz.overrideMethod (c$, "valueChanged", 
692 function (a) {
693 this.b$["javax.swing.JList"].fireSelectionValueChanged (a.getFirstIndex (), a.getLastIndex (), a.getValueIsAdjusting ());
694 }, "javax.swing.event.ListSelectionEvent");
695 c$ = Clazz.p0p ();
696 };
697 c$.$JList$1$ = function () {
698 Clazz.pu$h(self.c$);
699 c$ = Clazz.declareAnonymous (javax.swing, "JList$1", javax.swing.AbstractListModel);
700 Clazz.defineMethod (c$, "getSize", 
701 function () {
702 return this.f$.listData.length;
703 });
704 Clazz.defineMethod (c$, "getElementAt", 
705 function (i) {
706 return this.f$.listData[i];
707 }, "~N");
708 c$ = Clazz.p0p ();
709 };
710 c$.$JList$2$ = function () {
711 Clazz.pu$h(self.c$);
712 c$ = Clazz.declareAnonymous (javax.swing, "JList$2", javax.swing.AbstractListModel);
713 Clazz.defineMethod (c$, "getSize", 
714 function () {
715 return this.f$.listData.size ();
716 });
717 Clazz.defineMethod (c$, "getElementAt", 
718 function (i) {
719 return this.f$.listData.elementAt (i);
720 }, "~N");
721 c$ = Clazz.p0p ();
722 };
723 c$.$JList$3$ = function () {
724 Clazz.pu$h(self.c$);
725 c$ = Clazz.declareAnonymous (javax.swing, "JList$3", javax.swing.AbstractListModel);
726 Clazz.defineMethod (c$, "getSize", 
727 function () {
728 return 0;
729 });
730 Clazz.defineMethod (c$, "getElementAt", 
731 function (i) {
732 return "No Data Model";
733 }, "~N");
734 c$ = Clazz.p0p ();
735 };
736 c$.$JList$4$ = function () {
737 Clazz.pu$h(self.c$);
738 c$ = Clazz.declareAnonymous (javax.swing, "JList$4", javax.swing.AbstractListModel);
739 Clazz.defineMethod (c$, "getSize", 
740 function () {
741 return this.f$.listData.length;
742 });
743 Clazz.defineMethod (c$, "getElementAt", 
744 function (i) {
745 return this.f$.listData[i];
746 }, "~N");
747 c$ = Clazz.p0p ();
748 };
749 c$.$JList$5$ = function () {
750 Clazz.pu$h(self.c$);
751 c$ = Clazz.declareAnonymous (javax.swing, "JList$5", javax.swing.AbstractListModel);
752 Clazz.defineMethod (c$, "getSize", 
753 function () {
754 return this.f$.listData.size ();
755 });
756 Clazz.defineMethod (c$, "getElementAt", 
757 function (i) {
758 return this.f$.listData.elementAt (i);
759 }, "~N");
760 c$ = Clazz.p0p ();
761 };
762 Clazz.defineStatics (c$,
763 "$uiClassID", "ListUI",
764 "VERTICAL", 0,
765 "VERTICAL_WRAP", 1,
766 "HORIZONTAL_WRAP", 2);
767 });