ListUI.java revision 0
893N/A/*
2362N/A * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved.
893N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
893N/A *
893N/A * This code is free software; you can redistribute it and/or modify it
893N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Sun designates this
893N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Sun in the LICENSE file that accompanied this code.
893N/A *
893N/A * This code is distributed in the hope that it will be useful, but WITHOUT
893N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
893N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
893N/A * version 2 for more details (a copy is included in the LICENSE file that
893N/A * accompanied this code).
893N/A *
893N/A * You should have received a copy of the GNU General Public License version
893N/A * 2 along with this work; if not, write to the Free Software Foundation,
893N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
893N/A *
2362N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
2362N/A * CA 95054 USA or visit www.sun.com if you need additional information or
2362N/A * have any questions.
893N/A */
893N/A
893N/Apackage javax.swing.plaf;
893N/A
893N/Aimport javax.swing.JList;
893N/Aimport java.awt.Point;
893N/Aimport java.awt.Rectangle;
893N/A
893N/A
893N/A/**
893N/A * The {@code JList} pluggable look and feel delegate.
893N/A *
893N/A * @author Hans Muller
893N/A */
3471N/A
3471N/Apublic abstract class ListUI extends ComponentUI
893N/A{
893N/A /**
893N/A * Returns the cell index in the specified {@code JList} closest to the
893N/A * given location in the list's coordinate system. To determine if the
* cell actually contains the specified location, compare the point against
* the cell's bounds, as provided by {@code getCellBounds}.
* This method returns {@code -1} if the list's model is empty.
*
* @param list the list
* @param location the coordinates of the point
* @return the cell index closest to the given location, or {@code -1}
* @throws NullPointerException if {@code location} is null
*/
public abstract int locationToIndex(JList list, Point location);
/**
* Returns the origin in the given {@code JList}, of the specified item,
* in the list's coordinate system.
* Returns {@code null} if the index isn't valid.
*
* @param list the list
* @param index the cell index
* @return the origin of the cell, or {@code null}
*/
public abstract Point indexToLocation(JList list, int index);
/**
* Returns the bounding rectangle, in the given list's coordinate system,
* for the range of cells specified by the two indices.
* The indices can be supplied in any order.
* <p>
* If the smaller index is outside the list's range of cells, this method
* returns {@code null}. If the smaller index is valid, but the larger
* index is outside the list's range, the bounds of just the first index
* is returned. Otherwise, the bounds of the valid range is returned.
*
* @param list the list
* @param index1 the first index in the range
* @param index2 the second index in the range
* @return the bounding rectangle for the range of cells, or {@code null}
*/
public abstract Rectangle getCellBounds(JList list, int index1, int index2);
}