org.xith3d.ui.hud.widgets
Class ComboBox

java.lang.Object
  extended by org.xith3d.ui.hud.base.WidgetBase
      extended by org.xith3d.ui.hud.base.RectangularWidget
          extended by org.xith3d.ui.hud.widgets.ComboBox
All Implemented Interfaces:
org.jagatoo.datatypes.Enableable, 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, AbstractList<Label>, AbstractTextList<Label>, PopUpable, TextWidget, Widget

public class ComboBox
extends RectangularWidget
implements AbstractTextList<Label>, TextWidget, org.jagatoo.datatypes.Enableable, PopUpable

A ComboBox is a bordered Label with a Button on the right, that pops up a List widget and displays the current selected Item's text.


Nested Class Summary
static class ComboBox.Description
           
 
Nested classes/interfaces inherited from interface org.xith3d.ui.hud.base.Widget
Widget.DescriptionBase
 
Field Summary
static float MIN_HEIGHT
           
static float MIN_WIDTH
           
 
Fields inherited from class org.xith3d.ui.hud.base.WidgetBase
containerListeners, transformGroup, translation, Z_INDEX_UNIT, Z_INDEX_UNIT_ASSEMBLER
 
Constructor Summary
ComboBox(float width, float height)
          Creates a new ComboBox.
ComboBox(float width, float height, ComboBox.Description desc)
          Creates a new ComboBox.
ComboBox(float width, float height, int zIndex)
          Creates a new ComboBox.
ComboBox(float width, float height, int zIndex, ComboBox.Description desc)
          Creates a new ComboBox.
ComboBox(org.openmali.types.twodee.Sized2fRO size)
          Creates a new ComboBox.
ComboBox(org.openmali.types.twodee.Sized2fRO size, ComboBox.Description desc)
          Creates a new ComboBox.
ComboBox(org.openmali.types.twodee.Sized2fRO size, int zIndex)
          Creates a new ComboBox.
ComboBox(org.openmali.types.twodee.Sized2fRO size, int zIndex, ComboBox.Description desc)
          Creates a new ComboBox.
 
Method Summary
 Label addItem(int index, Label item)
          Adds the given Item to the List (at the given position).
 Label addItem(int index, java.lang.String text)
          Creates a Label and adds it to the List (at the given position).
 Label addItem(int index, java.lang.String text, org.openmali.vecmath2.Colorf color)
          Creates a Label and adds it to the List (at the given position).
 Label addItem(int index, java.lang.String text, java.awt.Font font, org.openmali.vecmath2.Colorf color)
          Creates a Label and adds it to the List (at the given position).
 Label addItem(Label item)
          Adds the given Item to the List (at the end).
 Label addItem(java.lang.String text)
          Creates a Label and adds it to the List (at the end).
 Label addItem(java.lang.String text, org.openmali.vecmath2.Colorf color)
          Creates a Label and adds it to the List (at the given position).
 Label addItem(java.lang.String text, java.awt.Font font, org.openmali.vecmath2.Colorf color)
          Creates a Label and adds it to the List (at the given position).
 boolean addItemSetsSelectedItem()
          If set to true, the addItem() method sets the selected item to the added one.
 void addSelectionListener(ListSelectionListener<Label> l)
          Adds a new ListSelectionListener.
 void clear()
          Removes all items from the List.
 Label createItem(java.lang.String text)
          Creates a Label and adds it to the List (at the end).
 Label createItem(java.lang.String text, org.openmali.vecmath2.Colorf color)
          Creates a Label and adds it to the List (at the given position).
 Label createItem(java.lang.String text, java.awt.Font font, org.openmali.vecmath2.Colorf color)
          Creates a Label from the parameters.
 TextAlignment getAlignment()
          
 java.awt.Font getFont()
          
 org.openmali.vecmath2.Colorf getFontColor()
          
 int getHeightByItems()
          
 Label getItem(int index)
          
 Label getItem(java.lang.String itemName)
          
 java.util.List<Label> getItems()
          
 int getItemsCount()
          
 int getMaxHeight()
          Returns the maximum height of this List in Items count units.
protected  float getPickHeight()
           
protected  float getPickSGZPosition()
           
 int getSelectedIndex()
          
 Label getSelectedItem()
          
 java.lang.String getText()
          
 float getTransparency()
          
protected  void init()
          This method is called when the WidgetContainer is set.
 boolean isEnabled()
          
 boolean isPoppedUp()
          
 boolean isScrollBarForced()
          Returns the ScrollBar's forced visibility.
 boolean isScrollBarVisible()
          Returns the ScrollBar's visibility.
 void onFocusLost()
          This event is fired, when the focus is lost by a Widget.
 void onMouseLeft(boolean isTopMost, boolean hasFocus)
          This method is called when the mouse left the Widget area
 void popUp(boolean p)
          Pops up the popupable Widget (or un-pops it)
 void removeItem(int index)
          Removes the given Item from the List
 void removeItem(Label item)
          Removes the given Item from the List
 void removeSelectionListener(ListSelectionListener<Label> l)
          Removes a ListSelectionListener.
 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.
 void setAddItemSetsSelectedItem(boolean b)
          If set to true, the addItem() method sets the selected item to the added one.
 void setAlignment(TextAlignment alignment)
          Sets the horizontal and vertical alignment of the text
 void setEnabled(boolean enabled)
          
protected  void setEnabledImpl(boolean enabled)
           
 void setFont(java.awt.Font font)
          Sets the new Font to be used
 void setFontColor(org.openmali.vecmath2.Colorf color)
          Sets the new color to be used
 void setHeightByItems(int height)
          Sets the height by items count.
 void setMaxHeight(int maxHeight)
          Sets the maximum height of this List in Items count units.
 void setScrollBarForced(boolean forced)
          Sets the ScrollBar's forced visibility.
 void setScrollBarVisible(boolean visible)
          Sets the ScrollBar's visibility.
 void setSelectedItem(Label item)
          Sets the currently selected Item.
 void setSelectedItem(java.lang.String itemName)
          Sets the currently selected Item.
protected  boolean setSize(float width, float height, boolean forced)
          
 void setText(java.lang.String text)
          Sets the new text to be displayed
 
Methods inherited from class org.xith3d.ui.hud.base.RectangularWidget
getPickWidth, pick
 
Methods inherited from class org.xith3d.ui.hud.base.WidgetBase
addContainerListener, addFocusListener, addInputListener, addLocationListener, addSizeListener, addVisibilityListener, detach, detach, getAspect, getAssembly, getCachedToolTipWidget, getContainer, getContextMenu, getCursor, getHeight, getHUD, getInheritedCursor, getLeft, getLocation, getName, getSGNode, getSGZPosition, getSize, getToolTip, getTop, getUserObject, getWidgetAssembler, getWidth, getZIndex, hasFocus, hasFocus, hasToolTip, isClickable, isDraggable, isFocussable, isInitialized, isInitializing, isPickable, isVisible, onAddedToContainer, onAddedToHUD, onControllerAxisChanged, onControllerButtonPressed, onControllerButtonReleased, onDetached, onFocusGained, onInputStateChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseButtonPressed, onMouseButtonReleased, onMouseEntered, onMouseMoved, onMouseStopped, onMouseUnbound, onMouseWheelMoved, onRemovedFromContainer, pickWidgetAssembler, removeContainerListener, removeFocusListener, removeInputListener, removeLocationListener, removeSizeListener, removeVisibilityListener, requestFocus, setAssembly, setCachedToolTipWidget, setClickable, setContainer, setContextMenu, setCursor, setDraggable, setFocussable, setHeight, setLocation, setLocation, setLocation, setName, setPickable, setSize, setSize, setSize, setToolTip, setTransparency, setUserObject, setVisible, setWidth, setZIndex, toString, update, 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.Widget
addContainerListener, addFocusListener, addInputListener, addLocationListener, addSizeListener, addVisibilityListener, detach, detach, getAspect, getAssembly, getCachedToolTipWidget, getContainer, getContextMenu, getCursor, getHeight, getHUD, getInheritedCursor, getLeft, getLocation, getName, getSGNode, getSGZPosition, getSize, getToolTip, getTop, getUserObject, getWidth, getZIndex, hasFocus, hasFocus, hasToolTip, isClickable, isDraggable, isFocussable, isPickable, isVisible, onControllerAxisChanged, onControllerButtonPressed, onControllerButtonReleased, onDetached, onFocusGained, onInputStateChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseButtonPressed, onMouseButtonReleased, onMouseEntered, onMouseMoved, onMouseStopped, onMouseUnbound, onMouseWheelMoved, pick, removeContainerListener, removeFocusListener, removeInputListener, removeLocationListener, removeSizeListener, removeVisibilityListener, requestFocus, setAssembly, setCachedToolTipWidget, setClickable, setContainer, setContextMenu, setCursor, setDraggable, setFocussable, setLocation, setLocation, setName, setPickable, setSize, setSize, setSize, setToolTip, setTransparency, setUserObject, setVisible, setZIndex, update
 
Methods inherited from interface org.openmali.types.twodee.Sized2f
setHeight, setWidth
 

Field Detail

MIN_WIDTH

public static final float MIN_WIDTH
See Also:
Constant Field Values

MIN_HEIGHT

public static final float MIN_HEIGHT
See Also:
Constant Field Values
Constructor Detail

ComboBox

public ComboBox(float width,
                float height,
                int zIndex,
                ComboBox.Description desc)
Creates a new ComboBox.

Parameters:
width - the new width
height - the new height
zIndex - the new z-index

ComboBox

public ComboBox(float width,
                float height,
                ComboBox.Description desc)
Creates a new ComboBox.

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

ComboBox

public ComboBox(org.openmali.types.twodee.Sized2fRO size,
                int zIndex,
                ComboBox.Description desc)
Creates a new ComboBox.

Parameters:
size - the new size
zIndex - the new z-index

ComboBox

public ComboBox(float width,
                float height,
                int zIndex)
Creates a new ComboBox.

Parameters:
width - the new width
height - the new height
zIndex - the new z-index

ComboBox

public ComboBox(org.openmali.types.twodee.Sized2fRO size,
                ComboBox.Description desc)
Creates a new ComboBox.

Parameters:
size - the new size

ComboBox

public ComboBox(org.openmali.types.twodee.Sized2fRO size,
                int zIndex)
Creates a new ComboBox.

Parameters:
size - the new size
zIndex - the new z-index

ComboBox

public ComboBox(float width,
                float height)
Creates a new ComboBox.

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

ComboBox

public ComboBox(org.openmali.types.twodee.Sized2fRO size)
Creates a new ComboBox.

Parameters:
size - the new size
Method Detail

setSize

protected boolean setSize(float width,
                          float height,
                          boolean forced)

Overrides:
setSize in class WidgetBase

getTransparency

public float getTransparency()

Specified by:
getTransparency in interface Widget
Returns:
the whole Widget's Transparency.

getPickHeight

protected float getPickHeight()
Overrides:
getPickHeight in class RectangularWidget
Returns:
the height on which to pick. By default this is exactly getHeight().

getPickSGZPosition

protected float getPickSGZPosition()
Overrides:
getPickSGZPosition in class RectangularWidget
Returns:
the scenegraph-z-position to store in the HUDPickResult. By default this is exactly getSGZPosition().

popUp

public void popUp(boolean p)
Pops up the popupable Widget (or un-pops it)

Specified by:
popUp in interface PopUpable
Parameters:
p - if true, the pop-up will be visible

isPoppedUp

public boolean isPoppedUp()

Specified by:
isPoppedUp in interface PopUpable
Returns:
whether the pop-up is currently visible

onFocusLost

public void onFocusLost()
This event is fired, when the focus is lost by a Widget.

Specified by:
onFocusLost in interface Widget
Overrides:
onFocusLost in class WidgetBase

onMouseLeft

public void onMouseLeft(boolean isTopMost,
                        boolean hasFocus)
This method is called when the mouse left the Widget area

Specified by:
onMouseLeft in interface Widget
Overrides:
onMouseLeft in class WidgetBase
Parameters:
isTopMost - is this Widget topMost
hasFocus - is this Widget focused

addSelectionListener

public void addSelectionListener(ListSelectionListener<Label> l)
Adds a new ListSelectionListener.

Specified by:
addSelectionListener in interface AbstractList<Label>
Parameters:
l - the new listener

removeSelectionListener

public void removeSelectionListener(ListSelectionListener<Label> l)
Removes a ListSelectionListener.

Specified by:
removeSelectionListener in interface AbstractList<Label>
Parameters:
l - the listener to be removed

createItem

public Label createItem(java.lang.String text,
                        java.awt.Font font,
                        org.openmali.vecmath2.Colorf color)
Creates a Label from the parameters.

Specified by:
createItem in interface AbstractTextList<Label>
Parameters:
text - the text content for the new Item
Returns:
the created Label

createItem

public final Label createItem(java.lang.String text,
                              org.openmali.vecmath2.Colorf color)
Creates a Label and adds it to the List (at the given position).

Specified by:
createItem in interface AbstractTextList<Label>
Parameters:
text - the text content for the new Item
Returns:
the created Label

createItem

public final Label createItem(java.lang.String text)
Creates a Label and adds it to the List (at the end).

Specified by:
createItem in interface AbstractTextList<Label>
Parameters:
text - the text content for the new Item
Returns:
the created Label

addItem

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

Specified by:
addItem in interface AbstractList<Label>
Parameters:
index - the position to add the Item at
item - the new Item to add to the List

addItem

public Label addItem(Label item)
Adds the given Item to the List (at the end).

Specified by:
addItem in interface AbstractList<Label>
Parameters:
item - the new Item to add to the List

addItem

public Label addItem(int index,
                     java.lang.String text,
                     java.awt.Font font,
                     org.openmali.vecmath2.Colorf color)
Creates a Label and adds it to the List (at the given position).

Specified by:
addItem in interface AbstractTextList<Label>
Parameters:
index - the position to add the Item at
text - the text content for the new Item
Returns:
the created Label

addItem

public Label addItem(java.lang.String text,
                     java.awt.Font font,
                     org.openmali.vecmath2.Colorf color)
Creates a Label and adds it to the List (at the given position).

Specified by:
addItem in interface AbstractTextList<Label>
Parameters:
text - the text content for the new Item
Returns:
the created Label

addItem

public Label addItem(int index,
                     java.lang.String text,
                     org.openmali.vecmath2.Colorf color)
Creates a Label and adds it to the List (at the given position).

Specified by:
addItem in interface AbstractTextList<Label>
Parameters:
index - the position to add the Item at
text - the text content for the new Item
Returns:
the created Label

addItem

public Label addItem(java.lang.String text,
                     org.openmali.vecmath2.Colorf color)
Creates a Label and adds it to the List (at the given position).

Specified by:
addItem in interface AbstractTextList<Label>
Parameters:
text - the text content for the new Item
Returns:
the created Label

addItem

public Label addItem(int index,
                     java.lang.String text)
Creates a Label and adds it to the List (at the given position).

Specified by:
addItem in interface AbstractTextList<Label>
Parameters:
index - the position to add the Item at
text - the text content for the new Item
Returns:
the created Label

addItem

public Label addItem(java.lang.String text)
Creates a Label and adds it to the List (at the end).

Specified by:
addItem in interface AbstractTextList<Label>
Parameters:
text - the text content for the new Item
Returns:
the created Label

removeItem

public void removeItem(int index)
Removes the given Item from the List

Specified by:
removeItem in interface AbstractList<Label>
Parameters:
index - the position of the Item to be removed

removeItem

public void removeItem(Label item)
Removes the given Item from the List

Specified by:
removeItem in interface AbstractList<Label>
Parameters:
item - the Item to be removed from the List

clear

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

Specified by:
clear in interface AbstractList<Label>

getItem

public Label getItem(int index)

Specified by:
getItem in interface AbstractList<Label>
Parameters:
index - the index to get the Item from
Returns:
the Item at the given index

getItem

public Label getItem(java.lang.String itemName)

Specified by:
getItem in interface AbstractList<Label>
Parameters:
itemName - the name to get the Item from
Returns:
the Item with the given name

getItems

public java.util.List<Label> getItems()

Specified by:
getItems in interface AbstractList<Label>
Returns:
a java.util.List of all Items in this List

getItemsCount

public int getItemsCount()

Specified by:
getItemsCount in interface AbstractList<Label>
Returns:
the number of Items in this List

setSelectedItem

public void setSelectedItem(Label item)
Sets the currently selected Item.

Specified by:
setSelectedItem in interface AbstractList<Label>

setSelectedItem

public void setSelectedItem(java.lang.String itemName)
Sets the currently selected Item.

Specified by:
setSelectedItem in interface AbstractList<Label>

getSelectedIndex

public final int getSelectedIndex()

Specified by:
getSelectedIndex in interface AbstractList<Label>
Returns:
the selected Item's index or null

getSelectedItem

public final Label getSelectedItem()

Specified by:
getSelectedItem in interface AbstractList<Label>
Returns:
the currently selected Item

selectPreviousItem

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

Specified by:
selectPreviousItem in interface AbstractList<Label>
Returns:
the new selected index

selectNextItem

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

Specified by:
selectNextItem in interface AbstractList<Label>
Returns:
the new selected 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 interface AbstractList<Label>

addItemSetsSelectedItem

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

Specified by:
addItemSetsSelectedItem in interface AbstractList<Label>

setHeightByItems

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

Specified by:
setHeightByItems in interface AbstractList<Label>
Parameters:
height - the new height by items unit

getHeightByItems

public int getHeightByItems()

Specified by:
getHeightByItems in interface AbstractList<Label>
Returns:
the height by items count

setMaxHeight

public void setMaxHeight(int maxHeight)
Sets the maximum height of this List in Items count units.

If the List has more Items than this number, the ScrollBar shown.
If getScrollBarForced() is true, the ScrollBar is always visible.
If getScrollBarVisible() is false, the ScrollBar is never visible.
As a result the ScrollBar is visible, if (&&) or if (getScrollBarForced() == true).

Specified by:
setMaxHeight in interface AbstractList<Label>
Parameters:
maxHeight - the maximum height of this List or (-1) for no limit

getMaxHeight

public int getMaxHeight()
Returns the maximum height of this List in Items count units.

If the List has more Items than this number, the ScrollBar shown.
If getScrollBarForced() is true, the ScrollBar is always visible.
If getScrollBarVisible() is false, the ScrollBar is never visible.
As a result the ScrollBar is visible, if (&&) or if (getScrollBarForced() == true).

Specified by:
getMaxHeight in interface AbstractList<Label>
Returns:
the maximum height of this List in Items count units (or -1 for no limit).

setScrollBarVisible

public void setScrollBarVisible(boolean visible)
Sets the ScrollBar's visibility.

The ScrollBar is visible, if (&&) or if (getScrollBarForced() == true).

Specified by:
setScrollBarVisible in interface AbstractList<Label>
Parameters:
visible - the ScrollBar's possible visibility

isScrollBarVisible

public boolean isScrollBarVisible()
Returns the ScrollBar's visibility.

The ScrollBar is visible, if (&&) or if (getScrollBarForced() == true).

Specified by:
isScrollBarVisible in interface AbstractList<Label>
Returns:
the ScrollBar's visibility.

setScrollBarForced

public void setScrollBarForced(boolean forced)
Sets the ScrollBar's forced visibility.

The ScrollBar is visible, if (&&) or if (getScrollBarForced() == true).

Specified by:
setScrollBarForced in interface AbstractList<Label>
Parameters:
forced - the ScrollBar's forced visibility

isScrollBarForced

public boolean isScrollBarForced()
Returns the ScrollBar's forced visibility.

The ScrollBar is visible, if (&&) or if (getScrollBarForced() == true).

Specified by:
isScrollBarForced in interface AbstractList<Label>
Returns:
the ScrollBar's forced visibility.

setText

public void setText(java.lang.String text)
Sets the new text to be displayed

Specified by:
setText in interface TextWidget
Parameters:
text - the new Text

getText

public java.lang.String getText()

Specified by:
getText in interface TextWidget
Returns:
the text that is displayed

getFont

public java.awt.Font getFont()

Specified by:
getFont in interface TextWidget
Returns:
the used Font

setFont

public void setFont(java.awt.Font font)
Sets the new Font to be used

Specified by:
setFont in interface TextWidget
Parameters:
font - the new Font

setFontColor

public void setFontColor(org.openmali.vecmath2.Colorf color)
Sets the new color to be used

Specified by:
setFontColor in interface TextWidget
Parameters:
color - the new color

getFontColor

public org.openmali.vecmath2.Colorf getFontColor()

Specified by:
getFontColor in interface TextWidget
Returns:
the used color

setAlignment

public void setAlignment(TextAlignment alignment)
Sets the horizontal and vertical alignment of the text

Specified by:
setAlignment in interface TextWidget

getAlignment

public TextAlignment getAlignment()

Specified by:
getAlignment in interface TextWidget
Returns:
the horizontal and vertical alignment of the text

setEnabledImpl

protected void setEnabledImpl(boolean enabled)

setEnabled

public final void setEnabled(boolean enabled)

Specified by:
setEnabled in interface org.jagatoo.datatypes.Enableable

isEnabled

public final boolean isEnabled()

Specified by:
isEnabled in interface org.jagatoo.datatypes.Enableable

init

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

Specified by:
init in class WidgetBase