org.xith3d.ui.hud.widgets
Class List

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
              extended by org.xith3d.ui.hud.widgets.List
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

public class List
extends AbstractList

A Scrollable List Widget that renders the contents of a ListModel.


Nested Class Summary
static class List.Description
          This class is used to describe a List Widget.
 
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  org.openmali.vecmath2.Vector2f childrenOffset_HUD
           
protected  org.openmali.vecmath2.Vector2i childrenOffset_PX
           
 
Fields inherited from class org.xith3d.ui.hud.base.AbstractList
DEFAULT_HEAVYWEIGHT
 
Fields inherited from class org.xith3d.ui.hud.base.Widget
transformHeight_Pixels2HUD, transformWidth_Pixels2HUD
 
Constructor Summary
List(boolean isHeavyWeight, float width, float height, ListModel model)
          Creates a new List Widget.
List(boolean isHeavyWeight, float width, float height, ListModel model, List.Description listDesc)
          Creates a new List Widget.
List(float width, float height, ListModel model)
          Creates a new List Widget.
List(float width, float height, ListModel model, List.Description listDesc)
          Creates a new List Widget.
 
Method Summary
 java.lang.Object addItem(int index, java.lang.Object item)
          Adds the given Item to the List (at the given position).
 java.lang.Object addItem(int index, java.lang.Object item, org.openmali.vecmath2.Colorf color)
           
 java.lang.Object addItem(int index, java.lang.Object item, HUDFont font, org.openmali.vecmath2.Colorf color)
           
 java.lang.Object addItem(java.lang.Object item, org.openmali.vecmath2.Colorf color)
           
 java.lang.Object addItem(java.lang.Object item, HUDFont font, org.openmali.vecmath2.Colorf color)
           
 boolean addItemSetsSelectedItem()
          If set to true, the addItem() method sets the selected item to the added one.
 void addSelectionListener(ListSelectionListener l)
          Adds a new ListSelectionListener.
protected  void afterFirstItemAdded()
           
protected  void afterItemAddedToEnd()
           
protected  void afterModelSetWidthItems(ListModel model)
          
protected  boolean blocksFocusMoveDeviceComponent(org.jagatoo.input.devices.components.DeviceComponent dc)
          Checks, if this Widget blocks the given DeviceComponent for focus-moves.
protected  boolean drawHoveredItemBackground(Texture2DCanvas texCanvas, int offsetX, int offsetY, int width, int height)
          Draws the background of a hovered item.
protected  boolean drawSelectedItemBackground(Texture2DCanvas texCanvas, int offsetX, int offsetY, int width, int height)
          Draws the background of a selected item.
protected  void drawWidget(Texture2DCanvas texCanvas, int offsetX, int offsetY, int width, int height, boolean drawsSelf)
          
 TextAlignment getAlignment()
          This alignment is used to render the items, if possible.
 int getBottomIndex()
          The bottom-most item's index visible in the List (or -1, if the List is empty)
 HUDFont getFont()
          Gets the Items' font.
 org.openmali.vecmath2.Colorf getFontColor()
          Gets the text-color of non-selected Items.
 int getHeightByItems()
          Gets the height by items count.
 org.openmali.vecmath2.Colorf getHoverBackgroundColor()
          
 float getMinWidthThatFitsItems()
          Gets the minimum list width, that is able to fully display all items.
 int getPaddingBottom()
          
 int getPaddingLeft()
          
 int getPaddingRight()
          
 int getPaddingTop()
          
 ScrollMode getScrollMode()
          Returns the ScrollBar's ScrollMode.
 org.openmali.vecmath2.Colorf getSelectionBackgroundColor()
          
 org.openmali.vecmath2.Colorf getSelectionFontColor()
          Gets the text-color of the selected Item.
 int getTopIndex()
          The top-most item's index visible in the List (or -1, if the List is empty)
protected  void init()
          This method is called when the WidgetContainer is set.
 boolean isFixedToBottom()
          If true, the List always scrolls to the lowest item, when a new Item is added and the List is currently scrolled to bottom.
 boolean isScrolledToBottom()
           
static List newTextList(boolean isHeavyWeight, float width, float height)
          Creates a new List Widget with a TextListModel.
static List newTextList(boolean isHeavyWeight, float width, float height, List.Description listDesc)
          Creates a new List Widget with a TextListModel.
static List newTextList(float width, float height)
          Creates a new List Widget with a TextListModel.
static List newTextList(float width, float height, List.Description listDesc)
          Creates a new List Widget with a TextListModel.
protected  void notifyOnItemClicked(java.lang.Object item, int index)
           
protected  void notifyOnSelectionChanged(java.lang.Object oldSelObj, java.lang.Object newSelObj, int oldSelIdx, int newSelIdx)
           
protected  void onAttachedToHUD(HUD hud)
          This event is fired, when this Widget is added to the HUD live Widget hierarchy.
protected  void onKeyPressed(org.jagatoo.input.devices.components.Key key, int modifierMask, long when)
          This event is fired, when a key is pressed on a focused Widget.
protected  void onMouseButtonPressed(org.jagatoo.input.devices.components.MouseButton button, float x, float y, long when, long lastWhen, boolean isTopMost, boolean hasFocus)
          This event is fired, when a mouse button is pressed on a focused Widget.
protected  void onMouseExited(boolean isTopMost, boolean hasFocus)
          This method is called when the mouse exited the Widget area.
protected  void onMouseMoved(float x, float y, int buttonsState, long when, boolean isTopMost, boolean hasFocus)
          This event is fired, when the mouse is moved on a Widget.
 void removeSelectionListener(ListSelectionListener l)
          Removes a ListSelectionListener.
 void scrollSelectedItemIntoView()
          Scrolls the list, so that the selected item is in the content area.
 void scrollToBottom()
          Scrolls the list to the bottom-most item.
 void setAddItemSetsSelectedItem(boolean b)
          If set to true, the addItem() method sets the selected item to the added one.
 void setAlignment(TextAlignment alignment)
          This alignment is used to render the items, if possible.
protected  void setContentClipRect(Texture2DCanvas texCanvas, int offsetX, int offsetY, int width, int height)
          
 void setFixedToBottom(boolean fixed)
          Fixes or releases this List to always scroll to the lowest item, when a new Item is added and the List is currently scrolled to bottom.
 void setFont(HUDFont font)
          Sets the Items' font.
 void setFontColor(org.openmali.vecmath2.Colorf color)
          Sets the text-color of non-selected Items.
 void setHeightByItems(int numItems)
          Sets the height by items count.
 void setHoverBackgroundColor(org.openmali.vecmath2.Colorf color)
          Sets the background-color of the hovered Item.
 boolean setPadding(int paddingBottom, int paddingRight, int paddingTop, int paddingLeft)
          Sets padding for this PaddingSettable Widget.
 void setScrollMode(ScrollMode mode)
          Sets the ScrollBar's ScrollMode.
 void setSelectionBackgroundColor(org.openmali.vecmath2.Colorf color)
          Sets the background-color of the selected Item.
 void setSelectionFontColor(org.openmali.vecmath2.Colorf color)
          Sets the text-color of the selected Item.
 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.AbstractList
addItem, addItems, addItems, clear, findItem, getItem, getItemsCount, getModel, getSelectedIndex, getSelectedItem, getWidget, removeItem, selectNextItem, selectPreviousItem, setModel, setPadding, setSelectedIndex
 
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, calculateTransformHeight_Pixels2HUD, calculateTransformWidth_Pixels2HUD, compareAbsZIndex, createShape, detach, drawAndUpdateWidget, drawBorder, 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, initSize, isAHostedWidgetDirty, isClickable, isDraggable, isFocussable, isHeavyWeight, isHovered, isInitialized, isInitializing, isPickable, isThisWidgetDirty, isVisible, notifyOnDragStopped, onAttachedToContainer, onControllerAxisChanged, onControllerButtonPressed, onControllerButtonReleased, onDetachedFromContainer, onDetachedFromHUD, onFocusGained, onFocusLost, onInputStateChanged, onKeyReleased, onKeyTyped, onLocationChanged, onMouseButtonReleased, onMouseEntered, onMouseStopped, onMouseWheelMoved, onSizeChanged, onVisibilityChanged, pick, pickConditionsMatch, removeContainerListener, removeControllerListener, removeFocusListener, removeInputListener, removeKeyboardListener, removeLocationListener, removeMouseListener, removeSizeListener, removeVisibilityListener, requestFocus, resetWidgetDirty, setBorder, setBorder, setClickable, 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
 

Field Detail

childrenOffset_HUD

protected final org.openmali.vecmath2.Vector2f childrenOffset_HUD

childrenOffset_PX

protected final org.openmali.vecmath2.Vector2i childrenOffset_PX
Constructor Detail

List

public List(boolean isHeavyWeight,
            float width,
            float height,
            ListModel model,
            List.Description listDesc)
Creates a new List Widget.

Parameters:
isHeavyWeight -
width - the new width
height - the new height
model - the ListModel (null for auto-generation)
listDesc - the List.Description to describe this new List Widget

List

public List(boolean isHeavyWeight,
            float width,
            float height,
            ListModel model)
Creates a new List Widget.

Parameters:
isHeavyWeight -
width - the new width
height - the new height
model - the ListModel (null for auto-generation)

List

public List(float width,
            float height,
            ListModel model,
            List.Description listDesc)
Creates a new List Widget.

Parameters:
width - the new width
height - the new height
model - the ListModel (null for auto-generation)
listDesc - the List.Description to describe this new List Widget

List

public List(float width,
            float height,
            ListModel model)
Creates a new List Widget.

Parameters:
isHeavyWeight -
width - the new width
height - the new height
model - the ListModel (null for auto-generation)
Method Detail

afterModelSetWidthItems

protected void afterModelSetWidthItems(ListModel model)

Overrides:
afterModelSetWidthItems in class AbstractList

setPadding

public boolean setPadding(int paddingBottom,
                          int paddingRight,
                          int paddingTop,
                          int paddingLeft)
Sets padding for this PaddingSettable Widget.
Padding translates local coordinates and shrinks the clipping area.

Returns:
true, if the padding actually has changed

getPaddingBottom

public final int getPaddingBottom()

Returns:
bottom-padding for this PaddingSettable Widget.
Padding translates local coordinates and shrinks the clipping area.

getPaddingRight

public final int getPaddingRight()

Returns:
right-padding for this PaddingSettable Widget.
Padding translates local coordinates and shrinks the clipping area.

getPaddingTop

public final int getPaddingTop()

Returns:
top-padding for this PaddingSettable Widget.
Padding translates local coordinates and shrinks the clipping area.

getPaddingLeft

public final int getPaddingLeft()

Returns:
left-padding for this PaddingSettable Widget.
Padding translates local coordinates and shrinks the clipping area.

setFontColor

public void setFontColor(org.openmali.vecmath2.Colorf color)
Sets the text-color of non-selected Items.

Parameters:
color -

getFontColor

public final org.openmali.vecmath2.Colorf getFontColor()
Gets the text-color of non-selected Items.

Returns:
the text-color of non-selected Items.

setFont

public void setFont(HUDFont font)
Sets the Items' font.

Parameters:
font -

getFont

public final HUDFont getFont()
Gets the Items' font.

Returns:
the Items' font.

setSelectionFontColor

public void setSelectionFontColor(org.openmali.vecmath2.Colorf color)
Sets the text-color of the selected Item.

Parameters:
color -

getSelectionFontColor

public final org.openmali.vecmath2.Colorf getSelectionFontColor()
Gets the text-color of the selected Item.

Returns:
the text-color of the selected Item.

addItem

public java.lang.Object addItem(int index,
                                java.lang.Object item,
                                HUDFont font,
                                org.openmali.vecmath2.Colorf color)

addItem

public final java.lang.Object addItem(java.lang.Object item,
                                      HUDFont font,
                                      org.openmali.vecmath2.Colorf color)

addItem

public final java.lang.Object addItem(int index,
                                      java.lang.Object item,
                                      org.openmali.vecmath2.Colorf color)

addItem

public final java.lang.Object addItem(java.lang.Object item,
                                      org.openmali.vecmath2.Colorf color)

addItem

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

Overrides:
addItem in class AbstractList
Parameters:
index - the position to add the Item at
item - the new Item to add to the List

setHoverBackgroundColor

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

Specified by:
setHoverBackgroundColor in class AbstractList

getHoverBackgroundColor

public final org.openmali.vecmath2.Colorf getHoverBackgroundColor()

Specified by:
getHoverBackgroundColor in class AbstractList
Returns:
the background-color of the hovered Item.

setSelectionBackgroundColor

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

Specified by:
setSelectionBackgroundColor in class AbstractList

getSelectionBackgroundColor

public final org.openmali.vecmath2.Colorf getSelectionBackgroundColor()

Specified by:
getSelectionBackgroundColor in class AbstractList
Returns:
the background-color of the selected Item.

setAlignment

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

Specified by:
setAlignment in class AbstractList

getAlignment

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

Specified by:
getAlignment in class AbstractList
Returns:
the TextAlignment.

addSelectionListener

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

Specified by:
addSelectionListener in class AbstractList
Parameters:
l - the new listener

removeSelectionListener

public void removeSelectionListener(ListSelectionListener l)
Removes a ListSelectionListener.

Specified by:
removeSelectionListener in class AbstractList
Parameters:
l - the listener to be removed

notifyOnSelectionChanged

protected void notifyOnSelectionChanged(java.lang.Object oldSelObj,
                                        java.lang.Object newSelObj,
                                        int oldSelIdx,
                                        int newSelIdx)

notifyOnItemClicked

protected void notifyOnItemClicked(java.lang.Object item,
                                   int index)

setAddItemSetsSelectedItem

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

Specified by:
setAddItemSetsSelectedItem in class AbstractList

addItemSetsSelectedItem

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

Specified by:
addItemSetsSelectedItem in class AbstractList

scrollSelectedItemIntoView

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

Specified by:
scrollSelectedItemIntoView in class AbstractList

afterItemAddedToEnd

protected void afterItemAddedToEnd()
Overrides:
afterItemAddedToEnd in class AbstractList

afterFirstItemAdded

protected void afterFirstItemAdded()
Overrides:
afterFirstItemAdded in class AbstractList

setTopIndex

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

Specified by:
setTopIndex in class AbstractList

getTopIndex

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

Specified by:
getTopIndex in class AbstractList
Returns:
the top index.

getBottomIndex

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

Specified by:
getBottomIndex in class AbstractList
Returns:
the bottom index.

setHeightByItems

public void setHeightByItems(int numItems)
Sets the height by items count.

Parameters:
numItems - the new height by items unit

getHeightByItems

public int getHeightByItems()
Gets the height by items count.

Returns:
the height by items count.

setScrollMode

public void setScrollMode(ScrollMode mode)
Sets the ScrollBar's ScrollMode.

The ScrollBar is visible, if (||)

Parameters:
mode - the ScrollBar's ScrollMode

getScrollMode

public ScrollMode getScrollMode()
Returns the ScrollBar's ScrollMode.

The ScrollBar is visible, if (||)

Returns:
the ScrollBar's ScrollMode.

isScrolledToBottom

public boolean isScrolledToBottom()
Returns:
true, if the List is currently scrollt to the bottom-most item.

scrollToBottom

public void scrollToBottom()
Scrolls the list to the bottom-most item.


setFixedToBottom

public void setFixedToBottom(boolean fixed)
Fixes or releases this List to always scroll to the lowest item, when a new Item is added and the List is currently scrolled to bottom.

Parameters:
fixed -

isFixedToBottom

public boolean isFixedToBottom()
If true, the List always scrolls to the lowest item, when a new Item is added and the List is currently scrolled to bottom.


getMinWidthThatFitsItems

public float getMinWidthThatFitsItems()
Gets the minimum list width, that is able to fully display all items.

Returns:
the minimum width.

blocksFocusMoveDeviceComponent

protected boolean blocksFocusMoveDeviceComponent(org.jagatoo.input.devices.components.DeviceComponent dc)
Checks, if this Widget blocks the given DeviceComponent for focus-moves.

Overrides:
blocksFocusMoveDeviceComponent in class Widget
Returns:
Widget blocks the queried DeviceComponent?

onKeyPressed

protected void onKeyPressed(org.jagatoo.input.devices.components.Key key,
                            int modifierMask,
                            long when)
This event is fired, when a key is pressed on a focused Widget.

Overrides:
onKeyPressed in class Widget
Parameters:
key - the key that was pressed
modifierMask - the mask of modifier keys
when - the keyevent's timestamp

onMouseExited

protected void onMouseExited(boolean isTopMost,
                             boolean hasFocus)
This method is called when the mouse exited the Widget area.

Overrides:
onMouseExited in class Widget
Parameters:
isTopMost - is this Widget topMost
hasFocus - is this Widget focused

onMouseMoved

protected void onMouseMoved(float x,
                            float y,
                            int buttonsState,
                            long when,
                            boolean isTopMost,
                            boolean hasFocus)
This event is fired, when the mouse is moved on a Widget.

Overrides:
onMouseMoved in class Widget
Parameters:
x - the new X coordinate
y - the new Y coordinate
isTopMost - is this Widget topMost
hasFocus - is this Widget focused

onMouseButtonPressed

protected void onMouseButtonPressed(org.jagatoo.input.devices.components.MouseButton button,
                                    float x,
                                    float y,
                                    long when,
                                    long lastWhen,
                                    boolean isTopMost,
                                    boolean hasFocus)
This event is fired, when a mouse button is pressed on a focused Widget.

Overrides:
onMouseButtonPressed in class Widget
Parameters:
button - the button that was pressed
x - the current mouse x position
y - the current mouse y position
isTopMost - is this Widget topMost
hasFocus - is this Widget focused
See Also:
net.jtank.input.MouseCode

updateSizesAndMarkDirty

protected void updateSizesAndMarkDirty()

Overrides:
updateSizesAndMarkDirty in class AbstractList

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 AbstractList
Parameters:
hud - the HUD, the Widget is added to

setContentClipRect

protected void setContentClipRect(Texture2DCanvas texCanvas,
                                  int offsetX,
                                  int offsetY,
                                  int width,
                                  int height)

Overrides:
setContentClipRect in class Widget

drawHoveredItemBackground

protected boolean drawHoveredItemBackground(Texture2DCanvas texCanvas,
                                            int offsetX,
                                            int offsetY,
                                            int width,
                                            int height)
Draws the background of a hovered item.

Parameters:
texCanvas -
offsetX -
offsetY -
width -
height -
Returns:
true, if a hovered background has been drawn.

drawSelectedItemBackground

protected boolean drawSelectedItemBackground(Texture2DCanvas texCanvas,
                                             int offsetX,
                                             int offsetY,
                                             int width,
                                             int height)
Draws the background of a selected item.

Parameters:
texCanvas -
offsetX -
offsetY -
width -
height -
Returns:
true, if a selected background has been drawn.

drawWidget

protected void drawWidget(Texture2DCanvas texCanvas,
                          int offsetX,
                          int offsetY,
                          int width,
                          int height,
                          boolean drawsSelf)

Specified by:
drawWidget in class Widget

init

protected void init()
This method is called when the WidgetContainer is set.

Specified by:
init in class Widget

newTextList

public static final List newTextList(boolean isHeavyWeight,
                                     float width,
                                     float height,
                                     List.Description listDesc)
Creates a new List Widget with a TextListModel.

Parameters:
isHeavyWeight -
width - the new width
height - the new height
listDesc - the List.Description to describe this new List Widget

newTextList

public static final List newTextList(float width,
                                     float height,
                                     List.Description listDesc)
Creates a new List Widget with a TextListModel.

Parameters:
width - the new width
height - the new height
listDesc - the List.Description to describe this new List Widget

newTextList

public static final List newTextList(boolean isHeavyWeight,
                                     float width,
                                     float height)
Creates a new List Widget with a TextListModel.

Parameters:
isHeavyWeight -
width - the new width
height - the new height

newTextList

public static final List newTextList(float width,
                                     float height)
Creates a new List Widget with a TextListModel.

Parameters:
width - the new width
height - the new height