This Package Previous Next Index
Class CoffeeTable.Grid.GridData
java.lang.Object
|
+----CoffeeTable.Grid.GridData
- public class GridData
- extends Object
GridAttributes is a class holds the data for the GridPanel. This class contains data
for the Grid's cells, and the Row and Column headers. An instance of this class is
stored in the GridPanel and it's methods are called to get or set the data, as well
as to resize the GridData as and when needed.
The Grid's data can be accessed as Objects or as Strings (uses toString() to get the
String representation). The default implementation of the GridPanel and
particularly the drawCell() method, always accesses and stores
the GridData as Strings using the get/setCellText(), get/setRowHeaderText() and
get/setColHeaderText() methods. If an implementation stores the data as any other objects
such as Integers, Images etc., then get/setCellDate(), get/setRowHeaderDate() and
get/setColHeaderData() methods can be used. In addition, the compare() method may also
need to be overridden to deal with non-string data types.
- Version:
- 1.2.10 of September 15, 1999 Copyright © 1996-1999 3magic
- Author:
- Anil Bajaj
-
GridData()
- Constructs a new empty GridData Object.
-
GridData(int, int)
- Constructs a new GridData Object.
-
GridData(int, int, boolean, boolean)
- Constructs a new GridData Object.
-
compare(Object, Object, int)
- The default compare method used by sortRows().
-
deleteCols(int, int)
- Delete a specified number of columns from a specified position.
-
deleteRows(int, int)
- Delete a specified number of rows from a specified position.
-
finalize()
- Remove all the elements in the internal lists.
-
getCellData(int, int)
- Return the data for a cell.
-
getCellText(int, int)
- Return the text for a cell.
-
getColHeaderData(int)
- Return the data for a column header.
-
getColHeaderText(int)
- Return the text for a column header.
-
getNumCols()
- Return the number columns in this object.
-
getNumRows()
- Return the number rows in this object.
-
getRowHeaderData(int)
- Return the data for a row header.
-
getRowHeaderText(int)
- Return the text for a row header.
-
insertCols(int, int)
- Insert a specified number of columns at a specified position.
-
insertRows(int, int)
- Insert a specified number of rows at a specified position.
-
setCellData(int, int, Object)
- Sets the data for a cell.
-
setCellText(int, int, String)
- Sets the text data for a cell.
-
setColHeaderData(int, Object)
- Sets the data for a column header.
-
setColHeaderText(int, String)
- Sets the text data for a column header.
-
setNumCols(int)
- Adjusts the number columns in this object.
-
setNumRows(int)
- Adjusts the number rows in this object.
-
setRowHeaderData(int, Object)
- Sets the data for a row header.
-
setRowHeaderText(int, String)
- Sets the text data for a row header.
GridData
public GridData()
- Constructs a new empty GridData Object.
GridData
public GridData(int numRows,
int numCols)
- Constructs a new GridData Object. It's internal data structures are allocated
based on the passed in values for the number of rows and columns.
- Parameters:
- numRows - the number of rows
- numCols - the number of columns
GridData
public GridData(int numRows,
int numCols,
boolean needRowHeaders,
boolean needColHeaders)
- Constructs a new GridData Object. It's internal data structures are allocated
based on the passed in values for the number of rows and columns.
- Parameters:
- numRows - the number of rows
- numCols - the number of columns
- needRowHeaders - whether or not to allocate data for row headers
- needColHeaders - whether or not to allocate data for column headers
finalize
protected void finalize()
- Remove all the elements in the internal lists. Called when this object is
garbage collected.
- Overrides:
- finalize in class Object
setNumRows
public void setNumRows(int numRows)
- Adjusts the number rows in this object. This method is called by the GridPanel's
setNumRows() method when the Grid's number of rows change.
- Parameters:
- numRows - the number of rows
- See Also:
- setNumRows
getNumRows
public int getNumRows()
- Return the number rows in this object.
- Returns:
- the number of rows
setNumCols
public void setNumCols(int numCols)
- Adjusts the number columns in this object. This method is called by the GridPanel's
setNumCols() method when the Grid's number of columns change.
- Parameters:
- numRows - the number of rows
- See Also:
- setNumCols
getNumCols
public int getNumCols()
- Return the number columns in this object.
- Returns:
- the number of columns
insertRows
public void insertRows(int atRow,
int count)
- Insert a specified number of rows at a specified position. This method is called by the GridPanel's
insertRows() method. This method adjusts the Vectors that store the Grid's data and row header data.
- Parameters:
- atRow - the index at which new rows will be inserted
- count - the number of rows to be inserted
- See Also:
- insertRows
deleteRows
public void deleteRows(int atRow,
int count)
- Delete a specified number of rows from a specified position. This method is called by the GridPanel's
deleteRows() method. This method adjusts the Vectors that store the Grid's data and row header data.
- Parameters:
- atRow - the index from which new rows will be deleted
- count - the number of rows to be deleted
- See Also:
- deleteRows
insertCols
public void insertCols(int atCol,
int count)
- Insert a specified number of columns at a specified position. This method is called by the GridPanel's
insertCols() method. This method adjusts the Vectors that store the Grid's data and row header data.
- Parameters:
- atCol - the index at which new columns will be inserted
- count - the number of columns to be inserted
- See Also:
- insertCols
deleteCols
public void deleteCols(int atCol,
int count)
- Delete a specified number of columns from a specified position. This method is called by the GridPanel's
deleteCols() method. This method adjusts the Vectors that store the Grid's data and row header data.
- Parameters:
- atCol - the index from which new columns will be deleted
- count - the number of columns to be deleted
- See Also:
- deleteCols
getCellText
public String getCellText(int col,
int row)
- Return the text for a cell. This method is called by the GridPanel's getCellText()
method, and calls the getCellData() method and returns a string version of the data
(using toString()).
- Parameters:
- col - the column
- row - the row
- Returns:
- a string version of the cell data or an empty string (if null)
- See Also:
- getCellText, getCellData
getCellData
public Object getCellData(int col,
int row)
- Return the data for a cell. The method returns a reference to the data object
will need to be converted or displayed appropriately.
- Parameters:
- col - the column
- row - the row
- Returns:
- the data for a cell
getRowHeaderText
public String getRowHeaderText(int row)
- Return the text for a row header. This method is called by the
GridPanel's getRowHeaderText() method, and calls the getRowHeaderData() method and returns
a string version of the data (using toString()).
- Parameters:
- row - the row
- Returns:
- a string version of the row header data or an empty string (if null)
- See Also:
- getRowHeaderText, getRowHeaderData
getRowHeaderData
public Object getRowHeaderData(int row)
- Return the data for a row header. The method returns a reference to the data object
will need to be converted or displayed appropriately.
- Parameters:
- row - the row
- Returns:
- the data for a row header
getColHeaderText
public String getColHeaderText(int col)
- Return the text for a column header. This method is called by the
GridPanel's getColHeaderText() method, and calls the getColHeaderData() method and returns
a string version of the data (using toString()).
- Parameters:
- col - the column
- Returns:
- a string version of the column header data or an empty string (if null)
- See Also:
- getColHeaderText, getColHeaderData
getColHeaderData
public Object getColHeaderData(int col)
- Return the data for a column header. The method returns a reference to the data object
will need to be converted or displayed appropriately.
- Parameters:
- col - the column
- Returns:
- the data for a column header
setCellText
public void setCellText(int col,
int row,
String cellText)
- Sets the text data for a cell. This method is called by the GridPanel's setCellText()
method, and sets the text data for the cell by calling the setCellData() method.
- Parameters:
- col - the column
- row - the row
- cellText - the text data for the cell
- See Also:
- setCellText, setCellData
setCellData
public void setCellData(int col,
int row,
Object cellData)
- Sets the data for a cell. This method stores a reference to the data Object
in the GridData structure.
- Parameters:
- col - the column
- row - the row
- cellData - a reference to the data for a cell
setRowHeaderText
public void setRowHeaderText(int row,
String rowHeaderText)
- Sets the text data for a row header. This method is called by the GridPanel's
setRowHeaderText() method, and sets the text data for the row header by calling the
setRowHeaderData() method.
- Parameters:
- row - the row
- rowHeaderText - the text data for the row header
- See Also:
- setRowHeaderText, setRowHeaderData
setRowHeaderData
public void setRowHeaderData(int row,
Object rowHeaderData)
- Sets the data for a row header. This method stores a reference to the data Object
in the GridData structure.
- Parameters:
- row - the row
- rowHeaderData - a reference to the data for a row header
setColHeaderText
public void setColHeaderText(int col,
String colHeaderText)
- Sets the text data for a column header. This method is called by the GridPanel's
setColHeaderText() method, and sets the text data for the column header by calling the
setColHeaderData() method.
- Parameters:
- col - the column
- colHeaderText - the text data for the column header
- See Also:
- setColHeaderText, setColHeaderData
setColHeaderData
public void setColHeaderData(int col,
Object colHeaderData)
- Sets the data for a column header. This method stores a reference to the data Object
in the GridData structure.
- Parameters:
- col - the column
- colHeaderData - a reference to the data for a row header
compare
public int compare(Object aData,
Object bData,
int col)
- The default compare method used by sortRows(). This method compares two
cell data objects. If the Objects implement the Comparable interface, the compareTo
method is called to compare the Objects, otherwise they Objects are compared
by comparing their string representations and return 0 if they're
equal, a value less than 0 if aData.toString() is less than bData.toString(),
and a value greater than 0 if aData.toString() is greater than bData.toString().
This method can be overridden if they cells need to be compared differently.
- Parameters:
- aData - the first data object
- bData - the second data object
- col - the column whose data objects are being compared for the sort
- See Also:
- sortRows
This Package Previous Next Index