com.yospace.yae.yogi
Class AbstractTable

java.lang.Object
  |
  +--com.yospace.yae.yogi.YogiComponent
        |
        +--com.yospace.yae.yogi.AbstractTable
Direct Known Subclasses:
YogiList, YogiTable

public abstract class AbstractTable
extends YogiComponent

Abstract Table is the base class for YogiList and YogiTable components. It provides a data model to manage list items, and a selection model to control selection state.


Field Summary
protected  int fixedCellHeight
          The height of a cell in an AbstractTable subclass.
protected  int initialSelected
          keeps track of the initial selected index.
protected  DataModel model
          The data model for an AbstractTable subclass.
static int PROPERTY_CELL_BORDERS
          Property constant for the cell borders.
static int PROPERTY_FIXED_CELL_HEIGHT
          Property constant for the fixed cell height.
static int PROPERTY_ITEMS
          Property constant for the data items.
static int PROPERTY_RENDERER
          Property constant for the renderer.
static int PROPERTY_SELECTED_INDEX
          Property constant for the selected index.
static int PROPERTY_SELECTION_MODE
          Property constant for the selection model.
static int PROPERTY_TOGGLEABLE
          Property constant for the toggleable flag.
protected  SelectionModel selectionModel
          The selection model used to respond to selection events.
 
Fields inherited from class com.yospace.yae.yogi.YogiComponent
ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, BORDER_DOTTED, BORDER_NONE, BORDER_PLAIN, BORDER_ROUNDED, BORDER_SOLID, COLOR_BACKGROUND, COLOR_BORDER, COLOR_FOREGROUND, FOCUS_DEFAULT, FOCUS_OFF, FOCUS_ON, PROPERTY_ALIGN, PROPERTY_BORDER_STYLE, PROPERTY_BOUNDS, PROPERTY_COLOR, PROPERTY_CONTEXT_ENABLED, PROPERTY_ENABLED, PROPERTY_FOCUS, PROPERTY_FOCUS_INDEX, PROPERTY_FOCUS_TRAVERSABLE, PROPERTY_FONT, PROPERTY_HOTKEY, PROPERTY_LOCATION, PROPERTY_OPAQUE, PROPERTY_SIZE, PROPERTY_VISIBLE, PROPERTY_X_INSET, PROPERTY_Y_INSET
 
Constructor Summary
AbstractTable(DataModel model)
          Constructor taking a DataModel object to comprise the data for the list.
 
Method Summary
 void add(YogiComponent component)
          Overridden YogiComponent.add(YogiComponent) method, delegating all component additions to the data model.
 void addItem(java.lang.Object item)
          Adds an item to the data model.
 void clearSelections()
          Clears all selections from the selection model.
abstract  int getCellHeight()
          Convenience method for retrieving the height of an Abstract table cell.
abstract  Rectangle getCellRect(int x, int y)
          Calculates the bounds of the item at the specified position in the AbstractTable.
 int getFixedCellHeight()
          Returns the fixed height of an AbstractTable cell.
 Rectangle getFocusBounds()
          Calculates the region of the table that most needs to be made visible.
 int getFocusX()
          This method retrieves the column index of the current focus, starting from zero.
 int getFocusY()
          This method retrieves the row index of the current focus, starting from zero.
 int getItemCount()
          Convenience method for obtaining the number of elements in the list.
 DataModel getModel()
          Returns the DataModel used to store data.
 int getSelectionMode()
          Returns the mode to which the selection model has been set.
 SelectionModel getSelectionModel()
          Returns the SelectionModel used to store selection state.
 boolean hasCellBorders()
          Returns the state of the table's cell border flag.
protected  void initializeSelectionModel()
          Creates the selection model for use with the YogiList.
 boolean isToggleable()
          Returns whether or not clicking on the AbstractTable will toggle the selected state of a cell, or merely set the selected state to true.
 void removeAll()
          Removes all items from the list and clears all selections.
protected abstract  void resize()
          Implement in subclasses to resize the AbstractTable to the dimensions neccessary to fit its current contents.
 void setCellBorders(boolean cellBorders)
          Sets the AbstractTable's cell border flag on or off.
 void setFixedCellHeight(int fixedCellHeight)
          Fixes the height of the cells.
protected  boolean setFocus(int column, int row)
          Sets the current x,y focus index of an AbstractTable.
 void setModel(DataModel newModel)
          Sets this list's model to be as specified.
 void setSelectionMode(int selectionMode)
          Sets the selection mode to be used for this list.
 void setSelectionModel(SelectionModel selectionModel)
          Sets the SelectionModel to be used for this list.
 void setToggleable(boolean toggleable)
          Sets the AbstractTable's toggleable flag on or off.
abstract  void update(int start, int end)
          Implement in subclasses to repaint the AbstractTable within the specified range.
 
Methods inherited from class com.yospace.yae.yogi.YogiComponent
_debugPrintComponents, addPropertyChangeListener, bringForwards, bringInFrontOf, bringToFront, contains, containsComponent, ensureVisible, ensureVisible, findComponentAt, findCurrentFocus, findFirstFocus, findFocusDomainRoot, findFocusDomainRootImpl, findHotkeyComponent, findNextFocus, fireActionPerformedEvent, firePropertyChangeEvent, getAlign, getBorderStyle, getBounds, getColor, getColors, getComponent, getComponent, getComponentCount, getComponentIndex, getComponents, getFocusIndex, getFont, getGlobalLocation, getHeight, getHotkey, getId, getParent, getParent, getTreeLock, getUI, getWidth, getX, getXInset, getY, getYInset, hasFocus, isActive, isContextEnabled, isEnabled, isFocusDomainRoot, isFocusTraversable, isOpaque, isVisible, keyPressed, keyReleased, keyRepeated, paint, paintBackground, paintBorder, paintForeground, pointerDragged, pointerPressed, pointerReleased, remove, remove, removePropertyChangeListener, repaint, repaint, repaintAfterRebounding, requestFocus, requestFocus, sendBackwards, sendBehind, sendToBack, setActionListener, setActive, setAlign, setBorderStyle, setBounds, setColor, setColors, setContextEnabled, setDefaultColor, setEnabled, setFocusDomainRoot, setFocusIndex, setFocusTraversable, setFont, setHotkey, setId, setLocation, setNoFocus, setOpaque, setProperty, setSize, setUI, setVisible, setXInset, setYInset, updateUI
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_FIXED_CELL_HEIGHT

public static final int PROPERTY_FIXED_CELL_HEIGHT
Property constant for the fixed cell height.

PROPERTY_SELECTED_INDEX

public static final int PROPERTY_SELECTED_INDEX
Property constant for the selected index.

PROPERTY_SELECTION_MODE

public static final int PROPERTY_SELECTION_MODE
Property constant for the selection model.

PROPERTY_CELL_BORDERS

public static final int PROPERTY_CELL_BORDERS
Property constant for the cell borders.

PROPERTY_RENDERER

public static final int PROPERTY_RENDERER
Property constant for the renderer.

PROPERTY_ITEMS

public static final int PROPERTY_ITEMS
Property constant for the data items.

PROPERTY_TOGGLEABLE

public static final int PROPERTY_TOGGLEABLE
Property constant for the toggleable flag.

model

protected DataModel model
The data model for an AbstractTable subclass.

selectionModel

protected SelectionModel selectionModel
The selection model used to respond to selection events.

fixedCellHeight

protected int fixedCellHeight
The height of a cell in an AbstractTable subclass.

initialSelected

protected int initialSelected
keeps track of the initial selected index.
Constructor Detail

AbstractTable

public AbstractTable(DataModel model)
Constructor taking a DataModel object to comprise the data for the list.
Parameters:
model - the list data to create the AbstractTable with.
Method Detail

initializeSelectionModel

protected void initializeSelectionModel()
Creates the selection model for use with the YogiList. Override this method to change the default selection model.

setFixedCellHeight

public void setFixedCellHeight(int fixedCellHeight)
Fixes the height of the cells. If unset, the height of each cell defaults to the average component height.
Parameters:
fixedCellHeight - the height of each cell in a YogiList.

getCellHeight

public abstract int getCellHeight()
Convenience method for retrieving the height of an Abstract table cell.
Returns:
the fixed cell height if this has been set, otherwise the average height of an element.

setCellBorders

public void setCellBorders(boolean cellBorders)
Sets the AbstractTable's cell border flag on or off. On will cause a border to be drawn around each item.
Parameters:
cellBorders - state of the table's cell borders

setToggleable

public void setToggleable(boolean toggleable)
Sets the AbstractTable's toggleable flag on or off. If true is specified, clicking on a cell will toggle the selected state on and off. If false is specified, clicking on a cell will always set the selected state to true.
Parameters:
toggleable - new toggleable setting

isToggleable

public boolean isToggleable()
Returns whether or not clicking on the AbstractTable will toggle the selected state of a cell, or merely set the selected state to true.
Returns:
True if the list is toggleable, False if not.

hasCellBorders

public boolean hasCellBorders()
Returns the state of the table's cell border flag.
Returns:
True if cell borders are turned on, false if not.

getFixedCellHeight

public int getFixedCellHeight()
Returns the fixed height of an AbstractTable cell.
Returns:
the fixed cell height if one has been specified, or -1 if not.

add

public void add(YogiComponent component)
Overridden YogiComponent.add(YogiComponent) method, delegating all component additions to the data model.
Overrides:
add in class YogiComponent
Parameters:
component - the component to add to the data model.

addItem

public void addItem(java.lang.Object item)
Adds an item to the data model.
Parameters:
item - the object to be added to the list.

setSelectionModel

public void setSelectionModel(SelectionModel selectionModel)
Sets the SelectionModel to be used for this list.
Parameters:
selectionModel - the model

setSelectionMode

public void setSelectionMode(int selectionMode)
Sets the selection mode to be used for this list.
Parameters:
selectionMode - the mode

getSelectionMode

public int getSelectionMode()
Returns the mode to which the selection model has been set.
Returns:
the current selection mode.

getModel

public DataModel getModel()
Returns the DataModel used to store data.
Returns:
the data model.

getSelectionModel

public SelectionModel getSelectionModel()
Returns the SelectionModel used to store selection state.
Returns:
the selection model.

setModel

public final void setModel(DataModel newModel)
Sets this list's model to be as specified.
Parameters:
newModel - a DataModel containing the data items to be used by the AbstractTable.

getFocusX

public int getFocusX()
This method retrieves the column index of the current focus, starting from zero. This is the same as the current selection for single selection models. For lists and other single column components, this will always be zero (or -1 to indicate that there is no current focus).
Returns:
the x offset (the column of the current focus) or -1 to indicate no focus (both focus indices must be non-negative if there is to be a focus)

getFocusY

public int getFocusY()
This method retrieves the row index of the current focus, starting from zero. This is the same as the current selection for single selection models.
Returns:
the y offset (the row of the current focus) or -1 to indicate no focus (both focus indices must be non-negative if there is to be a focus)

setFocus

protected boolean setFocus(int column,
                           int row)
Sets the current x,y focus index of an AbstractTable.
Parameters:
column - Horizontal focus index.
row - Vertical focus index.
Returns:
True if the focus has changed, False if the specified indexes were already those with focus.

getItemCount

public int getItemCount()
Convenience method for obtaining the number of elements in the list.
Returns:
the number of elements in the list.

removeAll

public void removeAll()
Removes all items from the list and clears all selections.
Overrides:
removeAll in class YogiComponent

clearSelections

public void clearSelections()
Clears all selections from the selection model.

resize

protected abstract void resize()
Implement in subclasses to resize the AbstractTable to the dimensions neccessary to fit its current contents.

update

public abstract void update(int start,
                            int end)
Implement in subclasses to repaint the AbstractTable within the specified range.
Parameters:
start - The cell from which to start repainting.
end - The cell up to which to repaint.

getCellRect

public abstract Rectangle getCellRect(int x,
                                      int y)
Calculates the bounds of the item at the specified position in the AbstractTable.
Parameters:
x - Horizontal index
y - Vertical index
Returns:
the bounds of the cell at the specified position, or null if this position is invalid.

getFocusBounds

public Rectangle getFocusBounds()
Calculates the region of the table that most needs to be made visible. This is the cell-rectangle that is currently focussed, if any; if there is none, it returns the bounds of the table itself.
Overrides:
getFocusBounds in class YogiComponent
Following copied from class: com.yospace.yae.yogi.YogiComponent
Returns:
the bounding rectangle of this component.

Copyright 2002 Yospace Holdings Ltd. All Rights Reserved.