com.arsdigita.bebop
Class GridTableModel

java.lang.Object
  extended bycom.arsdigita.bebop.GridTableModel
All Implemented Interfaces:
TableModel

public class GridTableModel
extends Object
implements TableModel

Converts a linear ListModel to a grid of items. For example, A B C D E F G becomes:

 A D G
 B E .
 C F .
 
The extraneous cells in the table are filled with GridTableModel.PLACEHOLDER.


Field Summary
static String versionId
           
 
Constructor Summary
GridTableModel(ListModel items, int cols)
          Constructs a new GridTableModel.
 
Method Summary
 int getColumnCount()
          Return the number of columns this table model has.
 Object getElementAt(int columnIndex)
          Return the data element for the given column and the current row.
 Object getKeyAt(int columnIndex)
          Return the key for the given column and the current row.
 boolean nextRow()
          Move to the next row and return true if the model is now positioned on a valid row.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values
Constructor Detail

GridTableModel

public GridTableModel(ListModel items,
                      int cols)
Constructs a new GridTableModel.

Parameters:
items - a ListModel that represents the items
cols - the number of columns in the grid
Method Detail

getColumnCount

public int getColumnCount()
Description copied from interface: TableModel
Return the number of columns this table model has.

Specified by:
getColumnCount in interface TableModel
Returns:
the number of columns in the table model

nextRow

public boolean nextRow()
Description copied from interface: TableModel
Move to the next row and return true if the model is now positioned on a valid row. Initially, the table model is positioned before the first row. The table will call this method before it retrieves the data for the row with calls to getElementAt and getKeyAt.

If this method returns true, subsequent calls to getElementAt and getKeyAt have to succeed and return non-null objects. If this method returns false, the table assumes that it has traversed all the data contained in this model.

Specified by:
nextRow in interface TableModel
Returns:
true if the model is positioned on a valid row

getElementAt

public Object getElementAt(int columnIndex)
Description copied from interface: TableModel
Return the data element for the given column and the current row. The returned object will be passed to the table cell renderer as the value argument without modifications.

Specified by:
getElementAt in interface TableModel
Parameters:
columnIndex - the number of the column for which to get data
Returns:
the object to pass to the table cell renderer for display
See Also:
TableCellRenderer

getKeyAt

public Object getKeyAt(int columnIndex)
Description copied from interface: TableModel
Return the key for the given column and the current row. The key has to be unique for each row in the table model, but does not need to be unique for each row and column, though it may. The key is passed to the table cell renderer as the key argument.

Specified by:
getKeyAt in interface TableModel
Parameters:
columnIndex - the number of the column for which to get data
Returns:
the key for the given column and the current row.
See Also:
TableCellRenderer


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 20 2004:2337 UTC