com.yospace.yae.yogi
Class YogiList

java.lang.Object
  |
  +--com.yospace.yae.yogi.YogiComponent
        |
        +--com.yospace.yae.yogi.AbstractTable
              |
              +--com.yospace.yae.yogi.YogiList

public class YogiList
extends AbstractTable

A list component. Extends AbstractTable from which it inherits a data model and a selection model. To this the YogiList adds a RendererFactory renderer which it uses to custom render all elements in the YogiList that are not YogiComponents. A variety of accessor methods are also provided to manipulate the data and selection models.


Field Summary
protected  RendererFactory rendererFactory
          The RendererFactory object used to customise the appearance of YogiList cell.
 
Fields inherited from class com.yospace.yae.yogi.AbstractTable
fixedCellHeight, initialSelected, model, PROPERTY_CELL_BORDERS, PROPERTY_FIXED_CELL_HEIGHT, PROPERTY_ITEMS, PROPERTY_RENDERER, PROPERTY_SELECTED_INDEX, PROPERTY_SELECTION_MODE, PROPERTY_TOGGLEABLE, selectionModel
 
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
YogiList()
          Default constructor.
YogiList(DataModel model)
          Constructor taking a DataModel object to comprise the data for the list.
 
Method Summary
 int getCellHeight()
          A convenience method for getting the cell height of items in the list.
 Rectangle getCellRect(int x, int y)
          Returns a Rectangle denoting the bounds of the specifed YogiList cell.
 java.lang.Object getItem(int index)
          Convenience method for extracting a value from model.
 int getItemCount()
          Convenience method for obtaining the number of elements in the list.
 RendererFactory getRenderer()
          Returns the RendererFactory object used to provide custom rendered cells for the list.
 int getSelectedIndex()
          Convenience method for obtaining the index of the currently selected element.
 int[] getSelectedIndices()
          Convenience method for obtaining the indices of the currently selected elements.
 boolean isSelected(int index)
          Returns whether the element at the specified index has been selected.
 void removeAll()
          Removes all elements from the list and clears all selections.
 void removeItem(int index)
          Removes an item from the list.
 void removeItem(int[] indices)
          Removes an array of indexes from the list.
protected  void resize()
          Used internally to resize the list.
 boolean setFocus(int x, int y)
          Sets the current x,y focus index of a YogiList.
 void setItem(java.lang.Object item, int index)
          Sets the object at the specified index to the new value supplied.
 void setRenderer(RendererFactory rendererFactory)
          Sets the cell renderer to be used for this list.
 void setSelected(int index, boolean newState)
          Sets the state of the selected element to newState.
 void toggleSelected(int index)
          Toggles the state of the specified index.
 void update(int start, int end)
          Updates individual cells in a YogiList by setting the clipping area.
 
Methods inherited from class com.yospace.yae.yogi.AbstractTable
add, addItem, clearSelections, getFixedCellHeight, getFocusBounds, getFocusX, getFocusY, getModel, getSelectionMode, getSelectionModel, hasCellBorders, initializeSelectionModel, isToggleable, setCellBorders, setFixedCellHeight, setModel, setSelectionMode, setSelectionModel, setToggleable
 
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

rendererFactory

protected RendererFactory rendererFactory
The RendererFactory object used to customise the appearance of YogiList cell.
Constructor Detail

YogiList

public YogiList()
Default constructor. Creates a DefaultDataModel to store the YogiList's data items.

YogiList

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

isSelected

public boolean isSelected(int index)
Returns whether the element at the specified index has been selected.
Parameters:
index - the specified element.
Returns:
the selection state of the specified element.

toggleSelected

public void toggleSelected(int index)
Toggles the state of the specified index.
Parameters:
index - the index of the element to toggle.

setSelected

public void setSelected(int index,
                        boolean newState)
Sets the state of the selected element to newState.
Parameters:
index - the index of the element to set.
newState - the new selection state.

setRenderer

public void setRenderer(RendererFactory rendererFactory)
Sets the cell renderer to be used for this list. The cell renderer allows each cell in the list that is not a YogiComponent to be custom-rendered.
Parameters:
rendererFactory - the factory to be set for this list.

getRenderer

public RendererFactory getRenderer()
Returns the RendererFactory object used to provide custom rendered cells for the list.
Returns:
the renderer factory.

getCellRect

public Rectangle getCellRect(int x,
                             int y)
Returns a Rectangle denoting the bounds of the specifed YogiList cell.
Overrides:
getCellRect in class AbstractTable
Parameters:
x - column index of the cell, must be 0 for YogiList else null is returned.
y - row index of the cell.
Returns:
a Rectangle that bounds this cell. Null if the co-ordinates supplied are invalid.

update

public void update(int start,
                   int end)
Updates individual cells in a YogiList by setting the clipping area. Updates will only be called if these elements lie within the current clip.
Overrides:
update in class AbstractTable
Parameters:
start - first element from which to update.
end - last element to update.

setItem

public void setItem(java.lang.Object item,
                    int index)
Sets the object at the specified index to the new value supplied. The index must be a value greater than or equal to 0 and less than the current size of the list.
Parameters:
item - new value of the item.
index - the position in the list at which to set the new element.

getItem

public java.lang.Object getItem(int index)
Convenience method for extracting a value from model.
Parameters:
index - the index of the required object.
Returns:
the required object.

getItemCount

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

getSelectedIndex

public int getSelectedIndex()
Convenience method for obtaining the index of the currently selected element. NB Will return only the first item selected if multiple items are selected.
Returns:
the index of the currently selected element, -1 if no items have been selected.

getSelectedIndices

public int[] getSelectedIndices()
Convenience method for obtaining the indices of the currently selected elements.
Returns:
the indices of the currently selected elements, or an array of 0 size if no items have been selected.

removeItem

public void removeItem(int index)
Removes an item from the list.
Parameters:
index - the index of the object to be removed.

removeItem

public void removeItem(int[] indices)
Removes an array of indexes from the list.
Parameters:
indices - the elements to be removed.

removeAll

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

getCellHeight

public int getCellHeight()
A convenience method for getting the cell height of items in the list.
Overrides:
getCellHeight in class AbstractTable
Returns:
the fixed cell height if this has been set, otherwise the average height of a list cell.

setFocus

public boolean setFocus(int x,
                        int y)
Sets the current x,y focus index of a YogiList.
Overrides:
setFocus in class AbstractTable
Parameters:
x - horizontal focus index, must be 0.
y - vertical focus index.
Returns:
True if the focus has changed, False if the specified indexes were already those with focus.

resize

protected void resize()
Used internally to resize the list.
Overrides:
resize in class AbstractTable

Copyright 2002 Yospace Holdings Ltd. All Rights Reserved.