01 /*
02 * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved.
03 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04 *
05 * This code is free software; you can redistribute it and/or modify it
06 * under the terms of the GNU General Public License version 2 only, as
07 * published by the Free Software Foundation. Sun designates this
08 * particular file as subject to the "Classpath" exception as provided
09 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26 package javax.swing.plaf;
27
28 import javax.swing.JList;
29 import java.awt.Point;
30 import java.awt.Rectangle;
31
32 /**
33 * The {@code JList} pluggable look and feel delegate.
34 *
35 * @version 1.21 05/05/07
36 * @author Hans Muller
37 */
38
39 public abstract class ListUI extends ComponentUI {
40 /**
41 * Returns the cell index in the specified {@code JList} closest to the
42 * given location in the list's coordinate system. To determine if the
43 * cell actually contains the specified location, compare the point against
44 * the cell's bounds, as provided by {@code getCellBounds}.
45 * This method returns {@code -1} if the list's model is empty.
46 *
47 * @param list the list
48 * @param location the coordinates of the point
49 * @return the cell index closest to the given location, or {@code -1}
50 * @throws NullPointerException if {@code location} is null
51 */
52 public abstract int locationToIndex(JList list, Point location);
53
54 /**
55 * Returns the origin in the given {@code JList}, of the specified item,
56 * in the list's coordinate system.
57 * Returns {@code null} if the index isn't valid.
58 *
59 * @param list the list
60 * @param index the cell index
61 * @return the origin of the cell, or {@code null}
62 */
63 public abstract Point indexToLocation(JList list, int index);
64
65 /**
66 * Returns the bounding rectangle, in the given list's coordinate system,
67 * for the range of cells specified by the two indices.
68 * The indices can be supplied in any order.
69 * <p>
70 * If the smaller index is outside the list's range of cells, this method
71 * returns {@code null}. If the smaller index is valid, but the larger
72 * index is outside the list's range, the bounds of just the first index
73 * is returned. Otherwise, the bounds of the valid range is returned.
74 *
75 * @param list the list
76 * @param index1 the first index in the range
77 * @param index2 the second index in the range
78 * @return the bounding rectangle for the range of cells, or {@code null}
79 */
80 public abstract Rectangle getCellBounds(JList list, int index1,
81 int index2);
82 }
|