org.xith3d.ui.hud.base
Class AbstractList

java.lang.Object
  extended by org.xith3d.ui.hud.base.Widget
      extended by org.xith3d.ui.hud.base.BackgroundSettableWidget
          extended by org.xith3d.ui.hud.base.AbstractList
All Implemented Interfaces:
org.jagatoo.datatypes.NamableObject, org.jagatoo.datatypes.NamedObject, org.openmali.types.twodee.Positioned2f, org.openmali.types.twodee.Positioned2fRO, org.openmali.types.twodee.Sized2f, org.openmali.types.twodee.Sized2fRO, PaddingSettable
Direct Known Subclasses:
ComboBox, List

public abstract class AbstractList
extends BackgroundSettableWidget
implements PaddingSettable

This is the base implementation for a List Widget.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.xith3d.ui.hud.base.BackgroundSettableWidget
BackgroundSettableWidget.BackgroundSettableDescriptionBase
 
Nested classes/interfaces inherited from class org.xith3d.ui.hud.base.Widget
Widget.DescriptionBase
 
Field Summary
protected static boolean DEFAULT_HEAVYWEIGHT
           
 
Fields inherited from class org.xith3d.ui.hud.base.Widget
transformHeight_Pixels2HUD, transformWidth_Pixels2HUD
 
Constructor Summary
protected AbstractList(boolean isHeavyWeight, org.openmali.vecmath2.Colorf backgroundColor, Texture2D backgroundTexture, TileMode tileMode, ListModel model)
          Creates a new AbstractList.
protected AbstractList(boolean isHeavyWeight, float width, float height, org.openmali.vecmath2.Colorf backgroundColor, Texture2D backgroundTexture, TileMode tileMode, ListModel model)
          Creates a new AbstractList with the given width and height.
 
Method Summary
 java.lang.Object addItem(int index, java.lang.Object item)
          Adds the given Item to the List (at the given position).
 int addItem(java.lang.Object item)
          Adds the given Item to the List (at the end).
 void addItems(java.util.List<?> items)
          Adds all items from the given List to this List.
 void addItems(java.lang.Object[] items)
          Adds all items from the given array to this List.
abstract  boolean addItemSetsSelectedItem()
          If set to true, the addItem() method sets the selected item to the added one.
abstract  void addSelectionListener(ListSelectionListener l)
          Adds a new ListSelectionListener.
protected  void afterFirstItemAdded()
           
protected  void afterItemAddedToEnd()
           
protected  void afterModelSetWidthItems(ListModel model)
           
 void clear()
          Removes all items from the List.
 int findItem(java.lang.Object item)
          Finds the first item, which's equals() method returns true for the given value.
abstract  TextAlignment getAlignment()
          This alignment is used to render the items, if possible.
abstract  int getBottomIndex()
          The bottom-most item's index visible in the List (or -1, if the List is empty)
abstract  org.openmali.vecmath2.Colorf getHoverBackgroundColor()
           
 java.lang.Object getItem(int index)
          Gets the item from the specified index.
 int getItemsCount()
           
 ListModel getModel()
          Gets the underlying model.
 int getSelectedIndex()
           
 java.lang.Object getSelectedItem()
          Returns the currently selected Item.
abstract  org.openmali.vecmath2.Colorf getSelectionBackgroundColor()
           
abstract  int getTopIndex()
          The top-most item's index visible in the List (or -1, if the List is empty)
protected  Widget getWidget(float contentWidth, int itemIndex)
           
protected  void onAttachedToHUD(HUD hud)
          This event is fired, when this Widget is added to the HUD live Widget hierarchy.
 java.lang.Object removeItem(int index)
          Removes the given Item from the List.
abstract  void removeSelectionListener(ListSelectionListener l)
          Removes a ListSelectionListener.
abstract  void scrollSelectedItemIntoView()
          Scrolls the list, so that the selected item is in the content area.
 int selectNextItem()
          Sets the selected item to the following one of the currently selected item.
 int selectPreviousItem()
          Sets the selected item to the previous one of the currently selected item.
abstract  void setAddItemSetsSelectedItem(boolean b)
          If set to true, the addItem() method sets the selected item to the added one.
abstract  void setAlignment(TextAlignment alignment)
          This alignment is used to render the items, if possible.
abstract  void setHoverBackgroundColor(org.openmali.vecmath2.Colorf color)
          Sets the background-color of the hovered Item.
 void setModel(ListModel model)
          Sets the underlying model.
 boolean setPadding(int padding)
          Sets padding for this PaddingSettable Widget.
 void setSelectedIndex(int itemIndex)
          Sets the currently selected Item.
abstract  void setSelectionBackgroundColor(org.openmali.vecmath2.Colorf color)
          Sets the background-color of the selected Item.
abstract  void setTopIndex(int topIndex)
          Scrolls the list, so that the given index is the top item's index (if possible).
protected  void updateSizesAndMarkDirty()
           
 
Methods inherited from class org.xith3d.ui.hud.base.BackgroundSettableWidget
drawBackground, getBackgroundColor, getBackgroundTexture, getBackgroundTileMode, setBackground, setBackground, setBackground, setBackgroundColor, setBackgroundTexture, setBackgroundTexture, setBackgroundTexture, setBackgroundTexture, setBackgroundTileMode, setNoBackground
 
Methods inherited from class org.xith3d.ui.hud.base.Widget
addContainerListener, addControllerListener, addFocusListener, addInputListener, addKeyboardListener, addLocationListener, addMouseListener, addSizeListener, addVisibilityListener, bindToGlobalMouseMovement, blocksFocusMoveDeviceComponent, calculateTransformHeight_Pixels2HUD, calculateTransformWidth_Pixels2HUD, compareAbsZIndex, createShape, detach, drawAndUpdateWidget, drawBorder, drawWidget, drawWidgetAfterWidgetAssembler, drawWidgetContents, getAbsoluteLocationOnHUD_, getAspect, getAssembly, getBorder, getContainer, getContentAspect, getContentHeight, getContentHeightPX, getContentLeftPX, getContentOffset, getContentTopPX, getContentWidth, getContentWidthPX, getContextMenu, getCursor, getEqualHeight_, getEqualWidth_, getForcedRedrawFrequency, getHeight, getHeightPX, getHUD, getLeft, getLevel, getLocation, getLocation, getLocationHUD2Pixels_, getLocationHUD2SG_, getLocationPixels2HUD_, getLocationSG2HUD_, getMaxRedrawFrequency, getMinHeight, getMinWidth, getName, getParentWindow, getPickHeight, getPickWidth, getRelLocationHUD2Pixels_, getRootHostWidget, getShape, getSize, getSizeHUD2Pixels_, getSizeHUD2SG_, getSizeOfPixels_, getSizePixels2HUD_, getSizeSG2HUD_, getToolTip, getTop, getTransparency, getUserObject, getWidgetAssembler, getWidth, getWidthPX, getZIndex, hasDropShadow, hasFocus, hasFocus, hasToolTip, init, initSize, isAHostedWidgetDirty, isClickable, isDraggable, isFocussable, isHeavyWeight, isHovered, isInitialized, isInitializing, isPickable, isThisWidgetDirty, isVisible, notifyOnDragStopped, onAttachedToContainer, onControllerAxisChanged, onControllerButtonPressed, onControllerButtonReleased, onDetachedFromContainer, onDetachedFromHUD, onFocusGained, onFocusLost, onInputStateChanged, onKeyPressed, onKeyReleased, onKeyTyped, onLocationChanged, onMouseButtonPressed, onMouseButtonReleased, onMouseEntered, onMouseExited, onMouseMoved, onMouseStopped, onMouseWheelMoved, onSizeChanged, onVisibilityChanged, pick, pickConditionsMatch, removeContainerListener, removeControllerListener, removeFocusListener, removeInputListener, removeKeyboardListener, removeLocationListener, removeMouseListener, removeSizeListener, removeVisibilityListener, requestFocus, resetWidgetDirty, setBorder, setBorder, setClickable, setContentClipRect, setContextMenu, setCursor, setDraggable, setFocussable, setForcedRedrawFrequency, setHasDropShadow, setHeight, setHostedWidgetDirty, setHostTextureDirty, setHostTextureDirty, setHostWidget, setLocation, setLocation, setLocation, setMaxRedrawFrequency, setName, setPickable, setSize, setSize, setSize, setSize, setTextureDirty, setTextureDirty, setToolTip, setTransparency, setTransparency, setUserObject, setVisible, setWidgetDirty, setWidth, setZIndex, startDragging, toString, update, updateAbsZIndex, updateSizeFactors, updateTranslation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.xith3d.ui.hud.base.PaddingSettable
getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, setPadding
 

Field Detail

DEFAULT_HEAVYWEIGHT

protected static final boolean DEFAULT_HEAVYWEIGHT
See Also:
Constant Field Values
Constructor Detail

AbstractList

protected AbstractList(boolean isHeavyWeight,
                       org.openmali.vecmath2.Colorf backgroundColor,
                       Texture2D backgroundTexture,
                       TileMode tileMode,
                       ListModel model)
Creates a new AbstractList.

Parameters:
isHeavyWeight -
backgroundColor -
backgroundTexture -
tileMode -
model - the ListModel (null for auto-generation)

AbstractList

protected AbstractList(boolean isHeavyWeight,
                       float width,
                       float height,
                       org.openmali.vecmath2.Colorf backgroundColor,
                       Texture2D backgroundTexture,
                       TileMode tileMode,
                       ListModel model)
Creates a new AbstractList with the given width and height.

Parameters:
isHeavyWeight -
width - the new width of this Widget
height - the new height of this Widget
backgroundColor -
backgroundTexture -
tileMode -
model - the ListModel (null for auto-generation)
Method Detail

afterModelSetWidthItems

protected void afterModelSetWidthItems(ListModel model)
Parameters:
model -

setModel

public void setModel(ListModel model)
Sets the underlying model.

Parameters:
model -

getModel

public ListModel getModel()
Gets the underlying model.

Returns:
the underlying model.

setPadding

public final boolean setPadding(int padding)
Sets padding for this PaddingSettable Widget.
Padding translates local coordinates and shrinks the clipping area.

Specified by:
setPadding in interface PaddingSettable
Parameters:
padding - padding for bottom, right, top and left
Returns:
true, if the padding actually has changed

setHoverBackgroundColor

public abstract void setHoverBackgroundColor(org.openmali.vecmath2.Colorf color)
Sets the background-color of the hovered Item.

Parameters:
color -

getHoverBackgroundColor

public abstract org.openmali.vecmath2.Colorf getHoverBackgroundColor()
Returns:
the background-color of the hovered Item.

setSelectionBackgroundColor

public abstract void setSelectionBackgroundColor(org.openmali.vecmath2.Colorf color)
Sets the background-color of the selected Item.

Parameters:
color -

getSelectionBackgroundColor

public abstract org.openmali.vecmath2.Colorf getSelectionBackgroundColor()
Returns:
the background-color of the selected Item.

setAlignment

public abstract void setAlignment(TextAlignment alignment)
This alignment is used to render the items, if possible.

Parameters:
alignment -

getAlignment

public abstract TextAlignment getAlignment()
This alignment is used to render the items, if possible.

Returns:
the TextAlignment.

addSelectionListener

public abstract void addSelectionListener(ListSelectionListener l)
Adds a new ListSelectionListener.

Parameters:
l - the new listener

removeSelectionListener

public abstract void removeSelectionListener(ListSelectionListener l)
Removes a ListSelectionListener.

Parameters:
l - the listener to be removed

setSelectedIndex

public void setSelectedIndex(int itemIndex)
Sets the currently selected Item.

Parameters:
itemIndex -

getSelectedIndex

public final int getSelectedIndex()
Returns:
the selected Item's index or null

getSelectedItem

public java.lang.Object getSelectedItem()
Returns the currently selected Item.

Returns:
the currently selected Item.

findItem

public int findItem(java.lang.Object item)
Finds the first item, which's equals() method returns true for the given value.

Parameters:
item -
Returns:
the found item's index (or -1)

selectPreviousItem

public final int selectPreviousItem()
Sets the selected item to the previous one of the currently selected item.

Returns:
the new selected index

selectNextItem

public final int selectNextItem()
Sets the selected item to the following one of the currently selected item.

Returns:
the new selected index

setAddItemSetsSelectedItem

public abstract void setAddItemSetsSelectedItem(boolean b)
If set to true, the addItem() method sets the selected item to the added one.

Parameters:
b -

addItemSetsSelectedItem

public abstract boolean addItemSetsSelectedItem()
If set to true, the addItem() method sets the selected item to the added one.


scrollSelectedItemIntoView

public abstract void scrollSelectedItemIntoView()
Scrolls the list, so that the selected item is in the content area.


afterItemAddedToEnd

protected void afterItemAddedToEnd()

afterFirstItemAdded

protected void afterFirstItemAdded()

addItem

public java.lang.Object addItem(int index,
                                java.lang.Object item)
Adds the given Item to the List (at the given position).

Parameters:
index - the position to add the Item at
item - the new Item to add to the List

addItem

public final int addItem(java.lang.Object item)
Adds the given Item to the List (at the end).

Parameters:
item - the new Item to add to the List
Returns:
the index, at which the item has been added.

addItems

public void addItems(java.util.List<?> items)
Adds all items from the given List to this List.

Parameters:
items -

addItems

public void addItems(java.lang.Object[] items)
Adds all items from the given array to this List.

Parameters:
items -

removeItem

public java.lang.Object removeItem(int index)
Removes the given Item from the List.

Parameters:
index - the position of the Item to be removed
Returns:
the removed Item or null, if there was no item at the given index.

clear

public void clear()
Removes all items from the List.


getItemsCount

public final int getItemsCount()
Returns:
the number of Items in this List

getWidget

protected final Widget getWidget(float contentWidth,
                                 int itemIndex)

getItem

public java.lang.Object getItem(int index)
Gets the item from the specified index.

Parameters:
index - the index to get the Item from
Returns:
the Item at the given index.

setTopIndex

public abstract void setTopIndex(int topIndex)
Scrolls the list, so that the given index is the top item's index (if possible).

Parameters:
topIndex -

getTopIndex

public abstract int getTopIndex()
The top-most item's index visible in the List (or -1, if the List is empty)

Returns:
the top index.

getBottomIndex

public abstract int getBottomIndex()
The bottom-most item's index visible in the List (or -1, if the List is empty)

Returns:
the bottom index.

updateSizesAndMarkDirty

protected void updateSizesAndMarkDirty()

onAttachedToHUD

protected void onAttachedToHUD(HUD hud)
This event is fired, when this Widget is added to the HUD live Widget hierarchy.

Overrides:
onAttachedToHUD in class Widget
Parameters:
hud - the HUD, the Widget is added to