net.datacrow.console.components.lists
Class DcListUI

java.lang.Object
  extended by javax.swing.plaf.ComponentUI
      extended by javax.swing.plaf.ListUI
          extended by javax.swing.plaf.basic.BasicListUI
              extended by net.datacrow.console.components.lists.DcListUI

public class DcListUI
extends javax.swing.plaf.basic.BasicListUI


Nested Class Summary
 class DcListUI.ListSelectionHandler
          The ListSelectionListener that's added to the JLists selection model at installUI time, and whenever the JList.selectionModel property changes.
 class DcListUI.MouseInputHandler
          Mouse input, and focus handling for JList.
 class DcListUI.PropertyChangeHandler
          The PropertyChangeListener that's added to the JList at installUI time.
 
Nested classes/interfaces inherited from class javax.swing.plaf.basic.BasicListUI
javax.swing.plaf.basic.BasicListUI.FocusHandler, javax.swing.plaf.basic.BasicListUI.ListDataHandler
 
Field Summary
protected  int[] cellWidths
           
protected  int columnsPerRow
           
protected static int columnsPerRowChanged
           
 
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
DcListUI()
           
 
Method Summary
protected  int convertItemToX(int index)
           
protected  int convertItemToY(int index)
           
protected  int convertRowToY(int row)
           
protected  int convertXToColumn(int x0)
           
protected  int convertXYToIndex(int x, int y)
           
protected  int convertYToRow(int y0)
          Convert the JList relative coordinate to the row that contains it, based on the current layout.
protected  javax.swing.event.ListDataListener createListDataListener()
          Creates an instance of ListDataListener that's added to the JLists by model as needed.
protected  javax.swing.event.ListSelectionListener createListSelectionListener()
          Creates an instance of ListSelectionHandler that's added to the JLists by selectionModel as needed.
protected  javax.swing.event.MouseInputListener createMouseInputListener()
          Creates a delegate that implements MouseInputListener.
protected  java.beans.PropertyChangeListener createPropertyChangeListener()
          Creates an instance of PropertyChangeHandler that's added to the JList by installUI().
static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent list)
          Returns a new instance of Basic2DListUI.
 java.awt.Rectangle getCellBounds(javax.swing.JList list, int index1, int index2)
           
 java.awt.Rectangle getCellBoundsPerColumnRow(javax.swing.JList list, int column, int row)
           
protected  int getItemHeight(int index)
           
protected  int getItemWidth(int index)
           
protected  int getMaxColumnsPerRow(int width)
           
 java.awt.Dimension getMaximumSize(javax.swing.JComponent c)
           
 java.awt.Dimension getMinimumSize(javax.swing.JComponent c)
           
 java.awt.Dimension getPreferredSize(javax.swing.JComponent c)
          The preferredSize of a list is total height of the rows and the maximum width of the cells.
protected  int getRowHeight(int row)
           
 java.awt.Point indexToLocation(javax.swing.JList list, int index)
           
 int locationToIndex(javax.swing.JList list, java.awt.Point location)
           
 int locationToNearestIndex(DcList list, java.awt.Point p)
           
 void paint(java.awt.Graphics g, javax.swing.JComponent c)
          Paint the rows that intersect the Graphics objects clipRect.
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
createFocusListener, getBaseline, getBaselineResizeBehavior, installDefaults, installKeyboardActions, installListeners, installUI, maybeUpdateLayoutState, paintCell, selectNextIndex, selectPreviousIndex, uninstallDefaults, uninstallKeyboardActions, uninstallListeners, uninstallUI
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

columnsPerRowChanged

protected static final int columnsPerRowChanged
See Also:
Constant Field Values

columnsPerRow

protected int columnsPerRow

cellWidths

protected int[] cellWidths
Constructor Detail

DcListUI

public DcListUI()
Method Detail

paint

public void paint(java.awt.Graphics g,
                  javax.swing.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 javax.swing.plaf.basic.BasicListUI
See Also:
BasicListUI.paintCell(java.awt.Graphics, int, java.awt.Rectangle, javax.swing.ListCellRenderer, javax.swing.ListModel, javax.swing.ListSelectionModel, int)

getPreferredSize

public java.awt.Dimension getPreferredSize(javax.swing.JComponent c)
The preferredSize of a 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 JListfixedCellWidth is specified then we just use that plus the horizontal margins.

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

getMinimumSize

public java.awt.Dimension getMinimumSize(javax.swing.JComponent c)
Overrides:
getMinimumSize in class javax.swing.plaf.ComponentUI

getMaximumSize

public java.awt.Dimension getMaximumSize(javax.swing.JComponent c)
Overrides:
getMaximumSize in class javax.swing.plaf.ComponentUI

createUI

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

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

locationToIndex

public int locationToIndex(javax.swing.JList list,
                           java.awt.Point location)
Overrides:
locationToIndex in class javax.swing.plaf.basic.BasicListUI
Returns:
The index of the cell at location, or -1.
See Also:
ListUI.locationToIndex(javax.swing.JList, java.awt.Point)

indexToLocation

public java.awt.Point indexToLocation(javax.swing.JList list,
                                      int index)
Overrides:
indexToLocation in class javax.swing.plaf.basic.BasicListUI
Returns:
The origin of the index'th cell, null if index is invalid.
See Also:
ListUI.indexToLocation(javax.swing.JList, int)

locationToNearestIndex

public int locationToNearestIndex(DcList list,
                                  java.awt.Point p)

getCellBoundsPerColumnRow

public java.awt.Rectangle getCellBoundsPerColumnRow(javax.swing.JList list,
                                                    int column,
                                                    int row)

getCellBounds

public java.awt.Rectangle getCellBounds(javax.swing.JList list,
                                        int index1,
                                        int index2)
Overrides:
getCellBounds in class javax.swing.plaf.basic.BasicListUI
Returns:
The bounds of the index'th cell.
See Also:
ListUI.getCellBounds(javax.swing.JList, int, int)

getRowHeight

protected int getRowHeight(int row)
Overrides:
getRowHeight in class javax.swing.plaf.basic.BasicListUI

getItemHeight

protected int getItemHeight(int index)

getItemWidth

protected int getItemWidth(int index)

convertXYToIndex

protected int convertXYToIndex(int x,
                               int y)

convertYToRow

protected int convertYToRow(int y0)
Convert the JList relative coordinate to the row that contains it, based on the current layout. If y0 doesn't fall within any row, return -1.

Overrides:
convertYToRow in class javax.swing.plaf.basic.BasicListUI
Returns:
The row that contains y0, or -1.
See Also:
getRowHeight(int), updateLayoutState()

convertXToColumn

protected int convertXToColumn(int x0)

convertRowToY

protected int convertRowToY(int row)
Overrides:
convertRowToY in class javax.swing.plaf.basic.BasicListUI

convertItemToY

protected int convertItemToY(int index)

convertItemToX

protected int convertItemToX(int index)

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 javax.swing.plaf.basic.BasicListUI
See Also:
BasicListUI.maybeUpdateLayoutState()

getMaxColumnsPerRow

protected int getMaxColumnsPerRow(int width)

createMouseInputListener

protected javax.swing.event.MouseInputListener createMouseInputListener()
Creates a delegate that implements MouseInputListener. The delegate is added to the corresponding java.awt.Component listener lists at installUI() time. Subclasses can override this method to return a custom MouseInputListener, e.g.

Overrides:
createMouseInputListener in class javax.swing.plaf.basic.BasicListUI
See Also:
DcListUI.MouseInputHandler, BasicListUI.installUI(javax.swing.JComponent)

createListSelectionListener

protected javax.swing.event.ListSelectionListener createListSelectionListener()
Creates an instance of ListSelectionHandler that's added to the JLists by selectionModel as needed. Subclasses can override this method to return a custom ListSelectionListener, e.g.

Overrides:
createListSelectionListener in class javax.swing.plaf.basic.BasicListUI
See Also:
DcListUI.ListSelectionHandler, BasicListUI.installUI(javax.swing.JComponent)

createListDataListener

protected javax.swing.event.ListDataListener createListDataListener()
Creates an instance of ListDataListener that's added to the JLists by model as needed. Subclasses can override this method to return a custom ListDataListener, e.g.

Overrides:
createListDataListener in class javax.swing.plaf.basic.BasicListUI
See Also:
ListDataListener, JList.getModel(), BasicListUI.installUI(javax.swing.JComponent)

createPropertyChangeListener

protected java.beans.PropertyChangeListener createPropertyChangeListener()
Creates an instance of PropertyChangeHandler that's added to the JList by installUI(). Subclasses can override this method to return a custom PropertyChangeListener, e.g.

Overrides:
createPropertyChangeListener in class javax.swing.plaf.basic.BasicListUI
See Also:
PropertyChangeListener, BasicListUI.installUI(javax.swing.JComponent)