JIDE 3.5.15

com.jidesoft.plaf.basic
Class BasicGroupListUI

java.lang.Object
  extended by javax.swing.plaf.ComponentUI
      extended by javax.swing.plaf.ListUI
          extended by javax.swing.plaf.basic.BasicListUI
              extended by com.jidesoft.plaf.basic.BasicGroupListUI

public class BasicGroupListUI
extends BasicListUI

A Basic L&F implementation of GroupListUI.


Nested Class Summary
 class BasicGroupListUI.ListSelectionHandler
          The ListSelectionListener that's added to the JLists selection model at installUI time, and whenever the JList.selectionModel property changes.
 class BasicGroupListUI.PropertyChangeHandler
          The PropertyChangeListener that's added to the JList at installUI time.
 
Nested classes/interfaces inherited from class javax.swing.plaf.basic.BasicListUI
BasicListUI.FocusHandler, BasicListUI.ListDataHandler, BasicListUI.MouseInputHandler
 
Field Summary
protected  Map<Integer,Rectangle> _headerBounds
          Local cache of bounds of all headers
 
Fields inherited from class javax.swing.plaf.basic.BasicListUI
cellHeight, cellHeights, cellRendererChanged, cellWidth, fixedCellHeightChanged, fixedCellWidthChanged, focusListener, fontChanged, list, listDataListener, listSelectionListener, modelChanged, mouseInputListener, propertyChangeListener, prototypeCellValueChanged, rendererPane, selectionModelChanged, updateLayoutStateNeeded
 
Constructor Summary
BasicGroupListUI()
           
 
Method Summary
static ComponentUI createUI(JComponent list)
          Returns a new instance of BasicGroupListUI.
 Rectangle getCellBounds(JList list, int index)
          Gets the bounds of the specified model index, returning the resulting bounds, or null if index is not valid.
 Rectangle getCellBounds(JList list, int index1, int index2)
           
 int getColumnCount(int row)
           
 Dimension getPreferredSize(JComponent c)
          The preferredSize of the list depends upon the layout orientation.
 int getRowCount()
           
 Point indexToLocation(JList list, int index)
           
protected  void installDefaults()
          Initialize JList properties, e.g.
protected  void installKeyboardActions()
          Registers the keyboard bindings on the JList that the BasicListUI is associated with.
protected  void installListeners()
          Create and install the listeners for the JList, its model, and its selectionModel.
static void loadActionMap(LazyActionMap map)
           
 int locationToIndex(JList list, Point location)
          Convert a point in JList coordinates to the closest index of the cell at that location.
 int locationToRow(JList list, Point location)
           
protected  void maybeUpdateLayoutState()
          If updateLayoutStateNeeded is non zero, call updateLayoutState() and reset updateLayoutStateNeeded.
 void paint(Graphics g, JComponent c)
          Paint the rows that intersect the Graphics objects clipRect.
protected  void uninstallDefaults()
          Set the JList properties that haven't been explicitly overridden to null.
protected  void uninstallKeyboardActions()
          Unregisters keyboard actions installed from installKeyboardActions.
protected  void uninstallListeners()
          Remove the listeners for the JList, its model, and its selectionModel.
 void uninstallUI(JComponent c)
          Uninitializes this.list by calling uninstallListeners(), uninstallKeyboardActions(), and uninstallDefaults() in order.
protected  void updateCellLayoutState(int fixedCellWidth, int fixedCellHeight)
          Invoked when the list is laid out horizontally to determine how many columns to create.
protected  void updateGroupLayoutState(int fixedCellWidth, int fixedCellHeight)
           
protected  void updateLayoutState()
          Recompute the value of cellHeight or cellHeights based and cellWidth, based on the current font and the current values of fixedCellWidth, fixedCellHeight, and prototypeCellValue.
 
Methods inherited from class javax.swing.plaf.basic.BasicListUI
convertRowToY, convertYToRow, createFocusListener, createListDataListener, createListSelectionListener, createMouseInputListener, createPropertyChangeListener, getBaseline, getBaselineResizeBehavior, getRowHeight, installUI, paintCell, selectNextIndex, selectPreviousIndex
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, getMaximumSize, getMinimumSize, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_headerBounds

protected Map<Integer,Rectangle> _headerBounds
Local cache of bounds of all headers

Constructor Detail

BasicGroupListUI

public BasicGroupListUI()
Method Detail

loadActionMap

public static void loadActionMap(LazyActionMap map)

uninstallUI

public void uninstallUI(JComponent c)
Uninitializes this.list by calling uninstallListeners(), uninstallKeyboardActions(), and uninstallDefaults() in order. Sets this.list to null.

Overrides:
uninstallUI in class BasicListUI
See Also:
uninstallListeners(), uninstallKeyboardActions(), uninstallDefaults()

installDefaults

protected void installDefaults()
Initialize JList properties, e.g. font, foreground, and background, and add the CellRendererPane. The font, foreground, and background properties are only set if their current value is either null or a UIResource, other properties are set if the current value is null.

Overrides:
installDefaults in class BasicListUI
See Also:
uninstallDefaults(), BasicListUI.installUI(javax.swing.JComponent)

uninstallDefaults

protected void uninstallDefaults()
Set the JList properties that haven't been explicitly overridden to null. A property is considered overridden if its current value is not a UIResource.

Overrides:
uninstallDefaults in class BasicListUI
See Also:
installDefaults(), uninstallUI(javax.swing.JComponent)

installListeners

protected void installListeners()
Create and install the listeners for the JList, its model, and its selectionModel. This method is called at installUI() time.

Overrides:
installListeners in class BasicListUI
See Also:
BasicListUI.installUI(javax.swing.JComponent), uninstallListeners()

uninstallListeners

protected void uninstallListeners()
Remove the listeners for the JList, its model, and its selectionModel. All of the listener fields, are reset to null here. This method is called at uninstallUI() time, it should be kept in sync with installListeners.

Overrides:
uninstallListeners in class BasicListUI
See Also:
uninstallUI(javax.swing.JComponent), installListeners()

paint

public void paint(Graphics g,
                  JComponent c)
Paint the rows that intersect the Graphics objects clipRect. This method calls paintCell as necessary. Subclasses may want to override these methods.

Overrides:
paint in class BasicListUI
See Also:
BasicListUI.paintCell(java.awt.Graphics, int, java.awt.Rectangle, javax.swing.ListCellRenderer, javax.swing.ListModel, javax.swing.ListSelectionModel, int)

getPreferredSize

public Dimension getPreferredSize(JComponent c)
The preferredSize of the list depends upon the layout orientation.
Layout OrientationPreferred Size
JList.VERTICAL The preferredSize of the list is total height of the rows and the maximum width of the cells. If JList.fixedCellHeight is specified then the total height of the rows is just (cellVerticalMargins + fixedCellHeight) * model.getSize() where rowVerticalMargins is the space we allocate for drawing the yellow focus outline. Similarly if fixedCellWidth is specified then we just use that.
JList.VERTICAL_WRAP If the visible row count is greater than zero, the preferredHeight is the maximum cell height * visibleRowCount. If the visible row count is <= 0, the preferred height is either the current height of the list, or the maximum cell height, whichever is bigger. The preferred width is than the maximum cell width * number of columns needed. Where the number of columns needs is list.height / max cell height. Max cell height is either the fixed cell height, or is determined by iterating through all the cells to find the maximum height from the ListCellRenderer.
JList.HORIZONTAL_WRAP If the visible row count is greater than zero, the preferredHeight is the maximum cell height * adjustedRowCount. Where visibleRowCount is used to determine the number of columns. Because this lays out horizontally the number of rows is then determined from the column count. For example, lets say you have a model with 10 items and the visible row count is 8. The number of columns needed to display this is 2, but you no longer need 8 rows to display this, you only need 5, thus the adjustedRowCount is 5.

If the visible row count is <= 0, the preferred height is dictated by the number of columns, which will be as many as can fit in the width of the JList (width / max cell width), with at least one column. The preferred height then becomes the model size / number of columns * maximum cell height. Max cell height is either the fixed cell height, or is determined by iterating through all the cells to find the maximum height from the ListCellRenderer.

The above specifies the raw preferred width and height. The resulting preferred width is the above width + insets.left + insets.right and the resulting preferred height is the above height + insets.top + insets.bottom. Where the Insets are determined from list.getInsets().

Overrides:
getPreferredSize in class BasicListUI
Parameters:
c - The JList component.
Returns:
The total size of the list.

createUI

public static ComponentUI createUI(JComponent list)
Returns a new instance of BasicGroupListUI. BasicGroupListUI delegates are allocated one per JList.

Returns:
A new ListUI implementation for the Windows look and feel.

locationToIndex

public int locationToIndex(JList list,
                           Point location)
Convert a point in JList coordinates to the closest index of the cell at that location. To determine if the cell actually contains the specified location use a combination of this method and getCellBounds. Returns -1 if the model is empty.

Overrides:
locationToIndex in class BasicListUI
Returns:
The index of the cell at location, or -1.

locationToRow

public int locationToRow(JList list,
                         Point location)

indexToLocation

public Point indexToLocation(JList list,
                             int index)
Overrides:
indexToLocation in class BasicListUI
Returns:
The origin of the index'th cell, null if index is invalid.

getCellBounds

public Rectangle getCellBounds(JList list,
                               int index1,
                               int index2)
Overrides:
getCellBounds in class BasicListUI

getCellBounds

public Rectangle getCellBounds(JList list,
                               int index)
Gets the bounds of the specified model index, returning the resulting bounds, or null if index is not valid.

If the index >= 0, it returns the bounds of index'th element If the index <= 2, it returns the bounds of one group's header


getRowCount

public int getRowCount()

getColumnCount

public int getColumnCount(int row)

maybeUpdateLayoutState

protected void maybeUpdateLayoutState()
If updateLayoutStateNeeded is non zero, call updateLayoutState() and reset updateLayoutStateNeeded. This method should be called by methods before doing any computation based on the geometry of the list. For example it's the first call in paint() and getPreferredSize().

Overrides:
maybeUpdateLayoutState in class BasicListUI
See Also:
updateLayoutState()

updateLayoutState

protected void updateLayoutState()
Recompute the value of cellHeight or cellHeights based and cellWidth, based on the current font and the current values of fixedCellWidth, fixedCellHeight, and prototypeCellValue.

Overrides:
updateLayoutState in class BasicListUI
See Also:
maybeUpdateLayoutState()

updateGroupLayoutState

protected void updateGroupLayoutState(int fixedCellWidth,
                                      int fixedCellHeight)

updateCellLayoutState

protected void updateCellLayoutState(int fixedCellWidth,
                                     int fixedCellHeight)
Invoked when the list is laid out horizontally to determine how many columns to create.

This updates the rowsPerColumn, columnCount, preferredHeight and potentially cellHeight instance variables.


installKeyboardActions

protected void installKeyboardActions()
Registers the keyboard bindings on the JList that the BasicListUI is associated with. This method is called at installUI() time.

Overrides:
installKeyboardActions in class BasicListUI
See Also:
BasicListUI.installUI(javax.swing.JComponent)

uninstallKeyboardActions

protected void uninstallKeyboardActions()
Unregisters keyboard actions installed from installKeyboardActions. This method is called at uninstallUI() time - subclasses should ensure that all of the keyboard actions registered at installUI time are removed here.

Overrides:
uninstallKeyboardActions in class BasicListUI
See Also:
BasicListUI.installUI(javax.swing.JComponent)

JIDE 3.5.15