org.xith3d.ui.hud.widgets.assemblies
Class FPSCounter

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.BackgroundSettableRectangularWidget
              extended by org.xith3d.ui.hud.widgets.assemblies.FPSCounter
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, FPSListener, BackgroundSettable, BackgroundSettableWidget, TextWidget, Widget

public class FPSCounter
extends BackgroundSettableRectangularWidget
implements TextWidget, FPSListener

Simple Widget to display the FPS count of your application. You can easily add it to an instance of ExtRenderLoop.


Nested Class Summary
 
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
FPSCounter(float width, float height)
          Creates a new FPSCounter with the given width and height.
FPSCounter(float width, float height, int zIndex)
          Creates a new FPSCounter with the given width and height.
FPSCounter(float width, float height, int zIndex, java.lang.String texture)
          Creates a new FPSCounter with the given width and height using this DecimalFormat to generate the string from float fps.
FPSCounter(float width, float height, int zIndex, Texture texture)
          Creates a new FPSCounter with the given width and height using this DecimalFormat to generate the string from float fps.
FPSCounter(float width, float height, java.lang.String texture)
          Creates a new FPSCounter with the given width and height using this DecimalFormat to generate the string from float fps.
FPSCounter(float width, float height, Texture texture)
          Creates a new FPSCounter with the given width and height using this DecimalFormat to generate the string from float fps.
FPSCounter(org.openmali.vecmath2.Tuple2f size)
          Creates a new FPSCounter with the given width and height.
FPSCounter(org.openmali.vecmath2.Tuple2f size, int zIndex)
          Creates a new FPSCounter with the given width and height.
FPSCounter(org.openmali.vecmath2.Tuple2f size, int zIndex, java.lang.String texture)
          Creates a new FPSCounter with the given width and height using this DecimalFormat to generate the string from float fps.
FPSCounter(org.openmali.vecmath2.Tuple2f size, int zIndex, Texture texture)
          Creates a new FPSCounter with the given width and height using this DecimalFormat to generate the string from float fps.
FPSCounter(org.openmali.vecmath2.Tuple2f size, java.lang.String texture)
          Creates a new FPSCounter with the given width and height using this DecimalFormat to generate the string from float fps.
FPSCounter(org.openmali.vecmath2.Tuple2f size, Texture texture)
          Creates a new FPSCounter with the given width and height using this DecimalFormat to generate the string from float fps.
 
Method Summary
protected  AbstractImage createBackgroundImage(float width, float height, org.openmali.vecmath2.Colorf color)
          
protected  AbstractImage createBackgroundImage(float width, float height, Texture texture)
          
 TextAlignment getAlignment()
          
 char getDecimalSeparator()
           
 java.awt.Font getFont()
          
 org.openmali.vecmath2.Colorf getFontColor()
          
 float getLastFPS()
           
 java.lang.String getPostfix()
          Sets the postfix to be appended to the FPS value.
 java.lang.String getPrefix()
           
 java.lang.String getText()
          
 float getTransparency()
          
protected  void init()
          This method is called when the WidgetContainer is set.
 void onFPSCountIntervalHit(float fps)
          This method is called by the RenderLoop each FPS-counting interval
 void setAlignment(TextAlignment alignment)
          Sets the horizontal and vertical alignment of the text
 void setDecimalSeparator(char decSep)
          Changes the decimal separator to the given char.
 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 setPostfix(java.lang.String postfix)
          Sets the postfix to be appended to the FPS value.
 void setPrefix(java.lang.String prefix)
          Sets the prefix to be set to the FPS value.
 void setText(java.lang.String text)
          Sets the new text to be displayed
 
Methods inherited from class org.xith3d.ui.hud.base.BackgroundSettableRectangularWidget
getBackground, getBackgroundColor, getBackgroundTileHeight, getBackgroundTileSize, getBackgroundTileWidth, setBackground, setBackground, setBackground, setBackgroundTileSize, setBackgroundTileSize, setContainer
 
Methods inherited from class org.xith3d.ui.hud.base.RectangularWidget
getPickHeight, getPickSGZPosition, 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, onFocusLost, onInputStateChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseButtonPressed, onMouseButtonReleased, onMouseEntered, onMouseLeft, onMouseMoved, onMouseStopped, onMouseUnbound, onMouseWheelMoved, onRemovedFromContainer, pickWidgetAssembler, removeContainerListener, removeFocusListener, removeInputListener, removeLocationListener, removeSizeListener, removeVisibilityListener, requestFocus, setAssembly, setCachedToolTipWidget, setClickable, setContextMenu, setCursor, setDraggable, setFocussable, setHeight, setLocation, setLocation, setLocation, setName, setPickable, setSize, 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, onFocusLost, onInputStateChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseButtonPressed, onMouseButtonReleased, onMouseEntered, onMouseLeft, 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
 

Constructor Detail

FPSCounter

public FPSCounter(float width,
                  float height,
                  int zIndex,
                  Texture texture)
Creates a new FPSCounter with the given width and height using this DecimalFormat to generate the string from float fps.

Parameters:
width - the new width of this Widget
height - the new height of this Widget
zIndex - the new z-index of this Widget
texture - the texture to use as background image for this FPSCounter

FPSCounter

public FPSCounter(org.openmali.vecmath2.Tuple2f size,
                  int zIndex,
                  Texture texture)
Creates a new FPSCounter with the given width and height using this DecimalFormat to generate the string from float fps.

Parameters:
size - the new size of this Widget
zIndex - the new z-index of this Widget
texture - the texture to use as background image for this FPSCounter

FPSCounter

public FPSCounter(float width,
                  float height,
                  int zIndex,
                  java.lang.String texture)
Creates a new FPSCounter with the given width and height using this DecimalFormat to generate the string from float fps.

Parameters:
width - the new width of this Widget
height - the new height of this Widget
zIndex - the new z-index of this Widget
texture - the texture resource to use as background image for this FPSCounter

FPSCounter

public FPSCounter(org.openmali.vecmath2.Tuple2f size,
                  int zIndex,
                  java.lang.String texture)
Creates a new FPSCounter with the given width and height using this DecimalFormat to generate the string from float fps.

Parameters:
size - the new size of this Widget
zIndex - the new z-index of this Widget
texture - the texture resource to use as background image for this FPSCounter

FPSCounter

public FPSCounter(org.openmali.vecmath2.Tuple2f size,
                  Texture texture)
Creates a new FPSCounter with the given width and height using this DecimalFormat to generate the string from float fps.

Parameters:
size - the new size of this Widget
texture - the texture to use as background image for this FPSCounter

FPSCounter

public FPSCounter(float width,
                  float height,
                  Texture texture)
Creates a new FPSCounter with the given width and height using this DecimalFormat to generate the string from float fps.

Parameters:
width - the new width of this Widget
height - the new height of this Widget
texture - the texture to use as background image for this FPSCounter

FPSCounter

public FPSCounter(org.openmali.vecmath2.Tuple2f size,
                  java.lang.String texture)
Creates a new FPSCounter with the given width and height using this DecimalFormat to generate the string from float fps.

Parameters:
size - the new size of this Widget
texture - the texture to use as background image for this FPSCounter

FPSCounter

public FPSCounter(float width,
                  float height,
                  java.lang.String texture)
Creates a new FPSCounter with the given width and height using this DecimalFormat to generate the string from float fps.

Parameters:
width - the new width of this Widget
height - the new height of this Widget
texture - the texture to use as background image for this FPSCounter

FPSCounter

public FPSCounter(float width,
                  float height,
                  int zIndex)
Creates a new FPSCounter with the given width and height.

Parameters:
width - the new width of this Widget
height - the new height of this Widget
zIndex - the new z-index of this Widget

FPSCounter

public FPSCounter(org.openmali.vecmath2.Tuple2f size,
                  int zIndex)
Creates a new FPSCounter with the given width and height.

Parameters:
size - the new size of this Widget
zIndex - the new z-index of this Widget

FPSCounter

public FPSCounter(float width,
                  float height)
Creates a new FPSCounter with the given width and height.

Parameters:
width - the new width of this Widget
height - the new height of this Widget

FPSCounter

public FPSCounter(org.openmali.vecmath2.Tuple2f size)
Creates a new FPSCounter with the given width and height.

Parameters:
size - the new size of this Widget
Method Detail

getTransparency

public float getTransparency()

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

setPrefix

public void setPrefix(java.lang.String prefix)
Sets the prefix to be set to the FPS value.


getPrefix

public java.lang.String getPrefix()
Returns:
the postfix to be appended to the FPS value

setPostfix

public void setPostfix(java.lang.String postfix)
Sets the postfix to be appended to the FPS value.


getPostfix

public java.lang.String getPostfix()
Sets the postfix to be appended to the FPS value.


setDecimalSeparator

public void setDecimalSeparator(char decSep)
Changes the decimal separator to the given char.
Use '\0' to not display any decimal places.

Parameters:
decSep -

getDecimalSeparator

public char getDecimalSeparator()

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

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

getFont

public java.awt.Font getFont()

Specified by:
getFont in interface TextWidget
Returns:
the used 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

getLastFPS

public float getLastFPS()
Returns:
the last notified FPS value

onFPSCountIntervalHit

public void onFPSCountIntervalHit(float fps)
This method is called by the RenderLoop each FPS-counting interval

Specified by:
onFPSCountIntervalHit in interface FPSListener
Parameters:
fps - the average frames per second during the last interval

createBackgroundImage

protected AbstractImage createBackgroundImage(float width,
                                              float height,
                                              org.openmali.vecmath2.Colorf color)

Specified by:
createBackgroundImage in class BackgroundSettableRectangularWidget
Returns:
a new instance of AbstractImage to be used as the background image.

createBackgroundImage

protected AbstractImage createBackgroundImage(float width,
                                              float height,
                                              Texture texture)

Specified by:
createBackgroundImage in class BackgroundSettableRectangularWidget
Returns:
a new instance of AbstractImage to be used as the background image.

init

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

Specified by:
init in class WidgetBase