com.sun.lwuit.list
Class GenericListCellRenderer

java.lang.Object
  extended by com.sun.lwuit.list.GenericListCellRenderer
All Implemented Interfaces:
CellRenderer, ListCellRenderer

public class GenericListCellRenderer
extends java.lang.Object
implements ListCellRenderer, CellRenderer

The generic list cell renderer can display containers or arbitrary LWUIT components as items in a list. It generally relies on the source data being either a hashtable or a list of Strings. It extracts values from the hashtable using the component name as an indication to the hashtable key lookup. This renderer supports label tickering, check boxes/radio buttons etc. seamlessly. Please notice that you must use at least two distinguished instances of the component to render, reusing the same instance WILL NOT WORK. Also the renderer instance cannot be reused for multiple lists, each list will need a new instance of this renderer!


Field Summary
static java.lang.String ENABLED
          If this flag exists in a hashtable of data the renderer will enable/disable the entries, the flag assumes either Boolean.TRUE or Boolean.FALSE.
static java.lang.String SELECT_ALL_FLAG
          Put this flag as a hashtable key to indicate that a checkbox entry rendered by this renderer should act as a "select all" entry and toggle all other entries.
 
Constructor Summary
GenericListCellRenderer(Component selected, Component unselected)
          Constructs a generic renderer with the given selected/unselected components
GenericListCellRenderer(Component odd, Component oddUnselected, Component even, Component evenUnselected)
          Constructs a generic renderer with the given selected/unselected components for odd/even values allowing a "pinstripe" effect
 
Method Summary
 Button extractLastClickedComponent()
          Allows partitioning the renderer into "areas" that can be clicked.
 Component getCellRendererComponent(Component list, java.lang.Object model, java.lang.Object value, int index, boolean isSelected)
          Returns a component instance that is already set to render "value".
 Component getFocusComponent(Component list)
          Returns a component instance that is painted under the currently focused renderer and is animated to provide smooth scrolling.
 Component getListCellRendererComponent(List list, java.lang.Object value, int index, boolean isSelected)
          Returns a component instance that is already set to render "value".
 Component getListFocusComponent(List list)
          Returns a component instance that is painted under the currently focused renderer and is animated to provide smooth scrolling.
 Component getSelected()
           
 Component getSelectedEven()
           
 Component getUnselected()
           
 Component getUnselectedEven()
           
 boolean isFisheye()
          In fisheye rendering mode the renderer maintains selected component drawing
 boolean isSelectionListener()
           
protected  void setComponentValue(Component cmp, java.lang.Object value)
          Initializes the given component with the given value
 void setFisheye(boolean fisheye)
          In fisheye rendering mode the renderer maintains selected component drawing
 void setSelectionListener(boolean selectionListener)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENABLED

public static final java.lang.String ENABLED
If this flag exists in a hashtable of data the renderer will enable/disable the entries, the flag assumes either Boolean.TRUE or Boolean.FALSE. Notice that just setting it to false when necessary will not work, when its used it must be applied to all entries otherwise the reuse of the renderer component will break this feature.

See Also:
Constant Field Values

SELECT_ALL_FLAG

public static final java.lang.String SELECT_ALL_FLAG
Put this flag as a hashtable key to indicate that a checkbox entry rendered by this renderer should act as a "select all" entry and toggle all other entries. The value for this entry is ignored

See Also:
Constant Field Values
Constructor Detail

GenericListCellRenderer

public GenericListCellRenderer(Component selected,
                               Component unselected)
Constructs a generic renderer with the given selected/unselected components

Parameters:
selected - indicates the selected value for the renderer
unselected - indicates the unselected value for the renderer

GenericListCellRenderer

public GenericListCellRenderer(Component odd,
                               Component oddUnselected,
                               Component even,
                               Component evenUnselected)
Constructs a generic renderer with the given selected/unselected components for odd/even values allowing a "pinstripe" effect

Parameters:
odd - indicates the selected value for the renderer
oddUnselected - indicates the unselected value for the renderer
even - indicates the selected value for the renderer
evenUnselected - indicates the unselected value for the renderer
Method Detail

extractLastClickedComponent

public Button extractLastClickedComponent()
Allows partitioning the renderer into "areas" that can be clicked. When receiving an action event in the list this method allows a developer to query the renderer to "see" whether a button within the component was "touched" by the user on a touch screen device. This method will reset the value to null after returning a none-null value!

Returns:
a button or null

getCellRendererComponent

public Component getCellRendererComponent(Component list,
                                          java.lang.Object model,
                                          java.lang.Object value,
                                          int index,
                                          boolean isSelected)
Description copied from interface: CellRenderer
Returns a component instance that is already set to render "value". While it is not a requirement many renderes often derive from a component (such as a label) and return "this". Notice that a null value for the value argument might be sent when refreshing the theme of the list.

Specified by:
getCellRendererComponent in interface CellRenderer
Parameters:
list - the list component
model - the model behind the render
value - the value to render
index - the index in the list
isSelected - whether the entry is selected
Returns:
a component to paint within the list

getListCellRendererComponent

public Component getListCellRendererComponent(List list,
                                              java.lang.Object value,
                                              int index,
                                              boolean isSelected)
Description copied from interface: ListCellRenderer
Returns a component instance that is already set to render "value". While it is not a requirement many renderes often derive from a component (such as a label) and return "this". Notice that a null value for the value argument might be sent when refreshing the theme of the list.

Specified by:
getListCellRendererComponent in interface ListCellRenderer
Parameters:
list - the list component
value - the value to render
index - the index in the list
isSelected - whether the entry is selected
Returns:
a component to paint within the list

setComponentValue

protected void setComponentValue(Component cmp,
                                 java.lang.Object value)
Initializes the given component with the given value

Parameters:
cmp - one of the components that is or is a part of the renderer
value - the value to install into the component

getListFocusComponent

public Component getListFocusComponent(List list)
Description copied from interface: ListCellRenderer
Returns a component instance that is painted under the currently focused renderer and is animated to provide smooth scrolling. When the selection moves, this component is drawn above/bellow the list items - it is recommended to give this component some level of transparency (see above code example). This method is optional an implementation can choose to return null.

Specified by:
getListFocusComponent in interface ListCellRenderer
Parameters:
list - the parent list
Returns:
a component to use as focus
See Also:
Component.setSmoothScrolling(boolean)

getFocusComponent

public Component getFocusComponent(Component list)
Description copied from interface: CellRenderer
Returns a component instance that is painted under the currently focused renderer and is animated to provide smooth scrolling. When the selection moves, this component is drawn above/bellow the list items - it is recommended to give this component some level of transparency (see above code example). This method is optional an implementation can choose to return null.

Specified by:
getFocusComponent in interface CellRenderer
Parameters:
list - the parent list
Returns:
a component to use as focus
See Also:
Component.setSmoothScrolling(boolean)

isSelectionListener

public boolean isSelectionListener()
Returns:
the selectionListener

setSelectionListener

public void setSelectionListener(boolean selectionListener)
Parameters:
selectionListener - the selectionListener to set

getSelected

public Component getSelected()
Returns:
the selected

getUnselected

public Component getUnselected()
Returns:
the unselected

getSelectedEven

public Component getSelectedEven()
Returns:
the selectedEven

getUnselectedEven

public Component getUnselectedEven()
Returns:
the unselectedEven

isFisheye

public boolean isFisheye()
In fisheye rendering mode the renderer maintains selected component drawing

Returns:
the fisheye

setFisheye

public void setFisheye(boolean fisheye)
In fisheye rendering mode the renderer maintains selected component drawing

Parameters:
fisheye - the fisheye to set