org.xith3d.ui.hud.listmodels
Class TextListModel

java.lang.Object
  extended by org.xith3d.ui.hud.base.ListModel
      extended by org.xith3d.ui.hud.listmodels.DefaultAbstractListModel
          extended by org.xith3d.ui.hud.listmodels.TextListModel
Direct Known Subclasses:
StateButtonListModel

public class TextListModel
extends DefaultAbstractListModel

The TextListModel converts all items to String through String.valueOf(Object).
It also honors the font and font-color properties of the List.
A Label is used to render the items to the List.


Constructor Summary
  TextListModel()
           
  TextListModel(java.util.List<java.lang.Object> items)
           
protected TextListModel(java.util.List<java.lang.Object> items, Widget widget)
           
 
Method Summary
protected  void applyValueToWidget(java.lang.Object value, TextWidget widget)
           
protected  void checkWidgetType(Widget widget)
           
 void clear()
          Clears the list.
protected  Widget createWidget()
           
 org.openmali.vecmath2.Colorf getItemColor(int itemIndex)
          Gets an item's color.
 HUDFont getItemFont(int itemIndex)
          Gets an item's font.
protected  float getItemHeightImpl(int itemIndex)
          Gets the item's height in HUD space.
protected  float getMinItemWidthImpl(int itemIndex)
          Gets the item's minimum width in HUD space.
protected  Widget[] getUsedWidgets()
          Gets an array of all Widgets, that are used by this model.
protected  Widget getWidgetImpl(int itemIndex)
          Gets the Widget, that is used to render the specified item.
protected  void prepareWidgetImpl(float listContentWidth, Widget widget, java.lang.Object item, int itemIndex)
          This method is called right before the Widget is used to render a specific item.
 void setItemColor(int itemIndex, org.openmali.vecmath2.Colorf color)
          Sets an item's color.
 void setItemFont(int itemIndex, HUDFont font)
          Sets an item's font.
 
Methods inherited from class org.xith3d.ui.hud.listmodels.DefaultAbstractListModel
addItemImpl, getItemImpl, getItemsCount, getItemUserObject, removeItemImpl, setItemImpl, setItemUserObject
 
Methods inherited from class org.xith3d.ui.hud.base.ListModel
addItem, addItem, addItems, addItems, checkOnMouseButtonPressed, checkOnMouseButtonPressedImpl, getItem, getItemHeight, getList, getMinItemWidth, getSelectedIndex, getSelectedItem, getUsesFixedHeight, getWidget, hoverNeedsRedraw, isSelected, markListDirty, prepareWidget, removeItem, setItem, setSelectedIndex, setUsesFixedHeight
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextListModel

protected TextListModel(java.util.List<java.lang.Object> items,
                        Widget widget)

TextListModel

public TextListModel(java.util.List<java.lang.Object> items)

TextListModel

public TextListModel()
Method Detail

getUsedWidgets

protected Widget[] getUsedWidgets()
Gets an array of all Widgets, that are used by this model.

Specified by:
getUsedWidgets in class ListModel
Returns:
an array of all Widgets, that are used by this model.

getWidgetImpl

protected Widget getWidgetImpl(int itemIndex)
Gets the Widget, that is used to render the specified item. This method should not do anything to the returned Widget. All setup stuff is done in the #prepareWidget(Widget, Object) method.

Specified by:
getWidgetImpl in class ListModel
Returns:
the raw Widget.

setItemColor

public void setItemColor(int itemIndex,
                         org.openmali.vecmath2.Colorf color)
Sets an item's color.

Parameters:
itemIndex -
color - null for list default.

getItemColor

public final org.openmali.vecmath2.Colorf getItemColor(int itemIndex)
Gets an item's color.

Parameters:
itemIndex -
Returns:
the items color (null for list default).

setItemFont

public void setItemFont(int itemIndex,
                        HUDFont font)
Sets an item's font.

Parameters:
itemIndex -
font - null for list default.

getItemFont

public final HUDFont getItemFont(int itemIndex)
Gets an item's font.

Parameters:
itemIndex -
Returns:
the items font (null for list default).

clear

public void clear()
Clears the list.

Overrides:
clear in class DefaultAbstractListModel

applyValueToWidget

protected void applyValueToWidget(java.lang.Object value,
                                  TextWidget widget)

prepareWidgetImpl

protected void prepareWidgetImpl(float listContentWidth,
                                 Widget widget,
                                 java.lang.Object item,
                                 int itemIndex)
This method is called right before the Widget is used to render a specific item.
It must only return the Widget.

Specified by:
prepareWidgetImpl in class ListModel

getItemHeightImpl

protected float getItemHeightImpl(int itemIndex)
Gets the item's height in HUD space. If getUsesFixedHeight() is true, only the value of the first item is used for all.

Specified by:
getItemHeightImpl in class ListModel
Returns:
the item's height.

getMinItemWidthImpl

protected float getMinItemWidthImpl(int itemIndex)
Gets the item's minimum width in HUD space.

Specified by:
getMinItemWidthImpl in class ListModel
Returns:
the item's minimum height.

createWidget

protected Widget createWidget()

checkWidgetType

protected void checkWidgetType(Widget widget)
Parameters:
widget -