org.xith3d.ui.hud.base
Class Window

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.base.RectangularContentPaneWrapper
              extended by org.xith3d.ui.hud.base.Window
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, BorderSettable, ContentPaneWrapper, Widget
Direct Known Subclasses:
Frame

public abstract class Window
extends RectangularContentPaneWrapper
implements BorderSettable

This class represents a simple Window above the HUD.


Nested Class Summary
static class Window.CloseOperation
          This enum can be used for the setCloseOperation() method of a Window.
 
Nested classes/interfaces inherited from interface org.xith3d.ui.hud.base.Widget
Widget.DescriptionBase
 
Field Summary
 
Fields inherited from class org.xith3d.ui.hud.base.WidgetBase
containerListeners, transformGroup, translation, Z_INDEX_UNIT, Z_INDEX_UNIT_ASSEMBLER
 
Constructor Summary
Window(ContentPaneWrapper contentPaneWrapper)
          Creates a new undecorated Window.
Window(ContentPaneWrapper contentPaneWrapper, java.lang.String title)
          Creates a new Window.
Window(ContentPaneWrapper contentPaneWrapper, WindowHeaderWidget.Description headerDesc, java.lang.String title)
          Creates a new Window.
Window(ContentPaneWrapper contentPaneWrapper, WindowHeaderWidget headerWidget)
          Creates a new Window.
Window(WidgetContainer contentPane)
          Creates a new undecorated Window.
Window(WidgetContainer contentPane, java.lang.String title)
          Creates a new Window.
Window(WidgetContainer contentPane, WindowHeaderWidget.Description headerDesc, java.lang.String title)
          Creates a new Window.
Window(WidgetContainer contentPane, WindowHeaderWidget headerWidget)
          Creates a new Window.
 
Method Summary
 void addFrameListener(WindowListener l)
          Deprecated. Please use addWindowListener(WindowListener) instead.
 void addWindowListener(WindowListener l)
          Adds a new WindowListener.
protected  boolean checkDragStartCondition(org.openmali.vecmath2.Tuple2f postionOnFrame)
           
protected abstract  WindowHeaderWidget createHeaderWidget(WindowHeaderWidget.Description headerDesc, java.lang.String title)
          Creates the header Widget for this decorated Window.
 void detach(boolean delayed)
          Removes the Widget from its Container.
 WidgetContainer getContentPane()
          
 ContentPaneWrapper getContentPaneWrapper()
           
 Window.CloseOperation getDefaultCloseOperation()
           
 WindowHeaderWidget getHeaderWidget()
           
 float getInnerHeight()
           
 float getInnerWidth()
           
 float getResX()
           
 float getResY()
           
 float getTransparency()
          
protected  void init()
          This method is called when the WidgetContainer is set.
 boolean isCloseButtonVisible()
           
 boolean isDecorated()
           
 boolean isPaneDraggingEnabled()
           
protected  void onCloseButtonClicked()
          This event is fired, if the close button on the Header-Widget was clicked.
 void onDetached()
          This method is called right before the Widget has been detached from its WidgetContainer.
 void onFocusLost()
          This event is fired, when the focus is lost by a Widget.
 void onKeyPressed(org.jagatoo.input.devices.components.Key key, long when)
          This event is fired, when a key is pressed on a focused Widget.
 void onKeyReleased(org.jagatoo.input.devices.components.Key key, long when)
          This event is fired, when a key is released on a focused Widget.
 void onKeyTyped(char ch, long when)
          This event is fired when a key is typed on the keyboard.
 void onMouseButtonPressed(org.jagatoo.input.devices.components.MouseButton button, int x, int y, long when, long lastWhen, boolean isTopMost, boolean hasFocus)
          This event is fired, when a mouse button is pressed on a focused Widget.
 void onMouseButtonReleased(org.jagatoo.input.devices.components.MouseButton button, int x, int y, long when, long lastWhen, boolean isTopMost, boolean hasFocus)
          This event is fired, when a mouse button is released on a focused Widget.
 void onMouseLeft(boolean isTopMost, boolean hasFocus)
          This method is called when the mouse left the Widget area
 void onMouseMoved(int x, int y, int buttonsState, long when, boolean isTopMost, boolean hasFocus)
          This event is fired, when the mouse is moved on a Widget.
 void onMouseUnbound()
          This event is fired, when the mouse is released.
 void onMouseWheelMoved(int delta, boolean isPageMove, int x, int y, long when, boolean isTopMost)
          This event is fired, when the mouse wheel is moved on a Widget.
 void removeFrameListener(WindowListener l)
          Deprecated. Please use removeWindowListener(WindowListener) instead.
 void removeWindowListener(WindowListener l)
          Removes a WindowListener.
 void setCloseButtonVisible(boolean visible)
          Sets the close button visible of hidden.
 void setContainer(WidgetContainer container)
          Sets this Widget's container
 void setDefaultCloseOperation(Window.CloseOperation op)
          Sets the default (if not overridden) CloseOperation to be executed when the close Button was clicked.
 boolean setLocation(float locX, float locY, boolean forced)
          
 void setPaneDraggingEnabled(boolean enabled)
          Sets pane-dragging enabled or disabled.
protected  boolean setSize(float width, float height, boolean forced)
          
 void setVisible(boolean visible)
          Sets wheather this Widget is visible or not
 
Methods inherited from class org.xith3d.ui.hud.base.RectangularContentPaneWrapper
pick
 
Methods inherited from class org.xith3d.ui.hud.base.RectangularWidget
getPickHeight, getPickSGZPosition, getPickWidth
 
Methods inherited from class org.xith3d.ui.hud.base.WidgetBase
addContainerListener, addFocusListener, addInputListener, addLocationListener, addSizeListener, addVisibilityListener, 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, onFocusGained, onInputStateChanged, onMouseEntered, onMouseStopped, onRemovedFromContainer, pickWidgetAssembler, removeContainerListener, removeFocusListener, removeInputListener, removeLocationListener, removeSizeListener, removeVisibilityListener, requestFocus, setAssembly, setCachedToolTipWidget, setClickable, setContextMenu, setCursor, setDraggable, setFocussable, setHeight, setLocation, setLocation, setName, setPickable, setSize, setSize, setSize, setToolTip, setTransparency, setUserObject, 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.BorderSettable
getBorder, setBorder, setBorder
 
Methods inherited from interface org.xith3d.ui.hud.base.Widget
addContainerListener, addFocusListener, addInputListener, addLocationListener, addSizeListener, addVisibilityListener, 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, onFocusGained, onInputStateChanged, onMouseEntered, onMouseStopped, removeContainerListener, removeFocusListener, removeInputListener, removeLocationListener, removeSizeListener, removeVisibilityListener, requestFocus, setAssembly, setCachedToolTipWidget, setClickable, setContextMenu, setCursor, setDraggable, setFocussable, setLocation, setLocation, setName, setPickable, setSize, setSize, setSize, setToolTip, setTransparency, setUserObject, setZIndex, update
 
Methods inherited from interface org.openmali.types.twodee.Sized2f
setHeight, setWidth
 

Constructor Detail

Window

public Window(WidgetContainer contentPane,
              WindowHeaderWidget.Description headerDesc,
              java.lang.String title)
Creates a new Window.

Parameters:
contentPane - the Widget that visually defines the Window.
headerDesc - the description of this Window's header (or null for an undecorated Window)
title - this Window's title

Window

public Window(WidgetContainer contentPane,
              WindowHeaderWidget headerWidget)
Creates a new Window.

Parameters:
contentPane - the Widget that visually defines the Window.
headerWidget - a Widget, that defines this Window's header (or null for an undecorated Window)

Window

public Window(WidgetContainer contentPane,
              java.lang.String title)
Creates a new Window.

Parameters:
contentPane - the Widget that visually defines the Window.
title - this Window's header (or null for an undecorated Window)

Window

public Window(WidgetContainer contentPane)
Creates a new undecorated Window.

Parameters:
contentPane - the Widget that visually defines the Window.

Window

public Window(ContentPaneWrapper contentPaneWrapper,
              WindowHeaderWidget.Description headerDesc,
              java.lang.String title)
Creates a new Window.

Parameters:
contentPaneWrapper - the Widget that visually defines the Window.
headerDesc - the description of this Widget's header (or null for an undecorated Window)
title - this Frame's title (unappreciated, if titleDesc is null)

Window

public Window(ContentPaneWrapper contentPaneWrapper,
              WindowHeaderWidget headerWidget)
Creates a new Window.

Parameters:
contentPaneWrapper - the Widget that visually defines the Window.
headerWidget - a Widget, that defines this Window's header (or null for an undecorated Window)

Window

public Window(ContentPaneWrapper contentPaneWrapper,
              java.lang.String title)
Creates a new Window.

Parameters:
contentPaneWrapper - the Widget that visually defines the Window.
title - this Frame's title (or null for an undecorated Frame)

Window

public Window(ContentPaneWrapper contentPaneWrapper)
Creates a new undecorated Window.

Parameters:
contentPaneWrapper - the Widget that visually defines the Window.
Method Detail

isDecorated

public boolean isDecorated()
Returns:
true, if this Frame is decorated (has a title bar).

getHeaderWidget

public WindowHeaderWidget getHeaderWidget()
Returns:
the title bar's Widget

getTransparency

public float getTransparency()

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

setLocation

public boolean setLocation(float locX,
                           float locY,
                           boolean forced)

Overrides:
setLocation in class WidgetBase

setDefaultCloseOperation

public void setDefaultCloseOperation(Window.CloseOperation op)
Sets the default (if not overridden) CloseOperation to be executed when the close Button was clicked.

Parameters:
op - the default close operation or null for no operation

getDefaultCloseOperation

public Window.CloseOperation getDefaultCloseOperation()
Returns:
the default (if not overridden) CloseOperation to be executed when the close Button was clicked.

setCloseButtonVisible

public void setCloseButtonVisible(boolean visible)
Sets the close button visible of hidden.

Parameters:
visible -
Throws:
java.lang.UnsupportedOperationException - if this is an undecorated Window

isCloseButtonVisible

public boolean isCloseButtonVisible()
Returns:
if the close button is visible of hidden.
Throws:
java.lang.UnsupportedOperationException - if this is an undecorated Window

setPaneDraggingEnabled

public void setPaneDraggingEnabled(boolean enabled)
Sets pane-dragging enabled or disabled. If pane-dragging is enabled, you can hold the mouse button on the content pane and drag the Frame.


isPaneDraggingEnabled

public boolean isPaneDraggingEnabled()
Returns:
true, if pane-dragging is enabled. If pane-dragging is enabled, you can hold the mouse button on the content pane and drag the Frame.

checkDragStartCondition

protected boolean checkDragStartCondition(org.openmali.vecmath2.Tuple2f postionOnFrame)
Returns:
true, if pane-dragging is enabled. If pane-dragging is enabled, you can hold the mouse button on the content pane and drag the Frame.

onMouseButtonPressed

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

Specified by:
onMouseButtonPressed in interface Widget
Overrides:
onMouseButtonPressed in class WidgetBase
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

onMouseUnbound

public void onMouseUnbound()
This event is fired, when the mouse is released. onMouseMoved will not be called on the Widget anymore, when the mouse is not over it.

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

onMouseButtonReleased

public void onMouseButtonReleased(org.jagatoo.input.devices.components.MouseButton button,
                                  int x,
                                  int y,
                                  long when,
                                  long lastWhen,
                                  boolean isTopMost,
                                  boolean hasFocus)
This event is fired, when a mouse button is released on a focused Widget.

Specified by:
onMouseButtonReleased in interface Widget
Overrides:
onMouseButtonReleased in class WidgetBase
Parameters:
button - the button that was released
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

onMouseMoved

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

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

onMouseWheelMoved

public void onMouseWheelMoved(int delta,
                              boolean isPageMove,
                              int x,
                              int y,
                              long when,
                              boolean isTopMost)
This event is fired, when the mouse wheel is moved on a Widget.

Specified by:
onMouseWheelMoved in interface Widget
Overrides:
onMouseWheelMoved in class WidgetBase
Parameters:
delta - a positive value when the wheel was moved up
x - the current mouse x position
y - the current mouse y position
isTopMost - is this Widget topMost

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

onKeyPressed

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

Specified by:
onKeyPressed in interface Widget
Overrides:
onKeyPressed in class WidgetBase
Parameters:
key - the key that was pressed
when - the keyevent's timestamp

onKeyReleased

public void onKeyReleased(org.jagatoo.input.devices.components.Key key,
                          long when)
This event is fired, when a key is released on a focused Widget.

Specified by:
onKeyReleased in interface Widget
Overrides:
onKeyReleased in class WidgetBase
Parameters:
key - the key that was released
when - the keyevent's timestamp

onKeyTyped

public void onKeyTyped(char ch,
                       long when)
This event is fired when a key is typed on the keyboard.

Specified by:
onKeyTyped in interface Widget
Overrides:
onKeyTyped in class WidgetBase
Parameters:
ch - the typed key's character
when - the keyevent's timestamp

addFrameListener

@Deprecated
public void addFrameListener(WindowListener l)
Deprecated. Please use addWindowListener(WindowListener) instead.

Adds a new WindowListener.

Parameters:
l - the new WindowListener

removeFrameListener

@Deprecated
public void removeFrameListener(WindowListener l)
Deprecated. Please use removeWindowListener(WindowListener) instead.

Removes a WindowListener.

Parameters:
l - the WindowListener to remove

addWindowListener

public void addWindowListener(WindowListener l)
Adds a new WindowListener.

Parameters:
l - the new WindowListener

removeWindowListener

public void removeWindowListener(WindowListener l)
Removes a WindowListener.

Parameters:
l - the WindowListener to remove

getContentPaneWrapper

public final ContentPaneWrapper getContentPaneWrapper()
Specified by:
getContentPaneWrapper in interface ContentPaneWrapper
Returns:
the ContentPaneWrapper of this Window

getContentPane

public final WidgetContainer getContentPane()

Specified by:
getContentPane in interface ContentPaneWrapper
Returns:
the ContentPane of this Frame

getInnerWidth

public final float getInnerWidth()
Returns:
the ContentPane's width.

getInnerHeight

public final float getInnerHeight()
Returns:
the ContentPane's height.

getResX

public final float getResX()
Returns:
the ContentPane's x-resolution.

getResY

public final float getResY()
Returns:
the ContentPane's y-resolution.

detach

public void detach(boolean delayed)
Removes the Widget from its Container. The onFrameClosed() event will be fired after it has been removed from its parent.

Specified by:
detach in interface Widget
Overrides:
detach in class WidgetBase
Parameters:
delayed - if true, the widget is detached with the next frame, but not instantly.

onDetached

public void onDetached()
This method is called right before the Widget has been detached from its WidgetContainer.

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

onCloseButtonClicked

protected void onCloseButtonClicked()
This event is fired, if the close button on the Header-Widget was clicked.
It simply calls detach() by default. Override it to change this behaviour.

See Also:
WidgetBase.detach()

setVisible

public void setVisible(boolean visible)
Sets wheather this Widget is visible or not

Specified by:
setVisible in interface Widget
Overrides:
setVisible in class WidgetBase
Parameters:
visible - visible?

setSize

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

Overrides:
setSize in class WidgetBase

createHeaderWidget

protected abstract WindowHeaderWidget createHeaderWidget(WindowHeaderWidget.Description headerDesc,
                                                         java.lang.String title)
Creates the header Widget for this decorated Window. It is only called, if the Window is decorated. It MUST NOT return null. It MUST NOT add it to the WidgetAssembler.

Parameters:
headerDesc - the description for the header Widget
title - the Window's title
Returns:
the create WindowHeaderWidget instance

init

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

Specified by:
init in class WidgetBase

setContainer

public void setContainer(WidgetContainer container)
Sets this Widget's container

Specified by:
setContainer in interface Widget
Overrides:
setContainer in class WidgetBase
Parameters:
container - the new Container