com.jme.widget.button
Class WidgetImageButton

java.lang.Object
  extended bycom.jme.scene.Spatial
      extended bycom.jme.scene.Node
          extended bycom.jme.widget.WidgetAbstractContainer
              extended bycom.jme.widget.panel.WidgetPanel
                  extended bycom.jme.widget.button.WidgetImageButton
All Implemented Interfaces:
java.io.Serializable, Widget, WidgetMouseHandlerInterface

public class WidgetImageButton
extends WidgetPanel

WidgetImageButton

Version:
$Id: WidgetImageButton.java,v 1.2 2004/09/14 21:52:21 mojomonkey Exp $
Author:
Joel Schuster
See Also:
Serialized Form

Field Summary
protected  WidgetButtonStateType _buttonState
           
protected  WidgetImage _image
           
protected  Image _imageDown
           
protected  Image _imageOver
           
protected  Image _imageUp
           
 
Fields inherited from class com.jme.widget.WidgetAbstractContainer
DEFAULT_INSET_SIZE, insets, layout, panOffset, widgetImpl, widgetList
 
Fields inherited from class com.jme.scene.Node
children
 
Fields inherited from class com.jme.scene.Spatial
currentStates, defaultStateList, forceCull, forceView, frustrumIntersects, geometricalControllers, lightCombineMode, localRotation, localScale, localTranslation, name, parent, queueDistance, renderQueueMode, renderStateList, textureCombineMode, worldBound, worldRotation, worldScale, worldTranslation, zOrder
 
Constructor Summary
WidgetImageButton(java.awt.Image imageUp, java.awt.Image imageDown, java.awt.Image imageOver)
          Constructor that allows the user to pass in the java.awt.Image reference that need to be used to construct this button.
WidgetImageButton(Image imageUp, Image imageDown, Image imageOver)
          Constructor that allows the user to pass in com.jme.image.Image instead of the java.awt.Image reference.
WidgetImageButton(java.lang.String upStr, java.lang.String downStr, java.lang.String overStr)
          WidgetImageButton contructor.
 
Method Summary
 void doMouseButtonDown()
          Handles the down message and changes the internal WidgeImage's underlying image to the down image.
 void doMouseButtonUp()
          Handles when the panel recieves a button up message.
 void doMouseEnter()
          Checks for the mouse state to be correct when the mouse is in the widget TODO: really need to figure out a better way to handle this, right now because of the overridden handleMouseMove this method get's called for every movement of the mouse.
 void doMouseExit()
          Checks for the mouse to be correct state when mouse is NOT in widget TODO: really need to figure out a better way to handle this, right now because of the overridden handleMouseMove this method get's called for every movement of the mouse.
 Vector2f getPreferredSize()
          Needed by the AbsoluteLayout to figure out how big to draw it.
 void handleMouseButtonDown()
          Overridden from WidgetAbstractImpl I don't really know why it's needed, for some reason when using the one in WidgetAbstractImpl the ownership of the mouse is taken by the parent panel or frame and thus the doMouseButtonUp or Down is never called.
 void handleMouseMove()
          Overridden from WidgetAbstractImpl I don't really know why it's needed, for some reason when using the one in WidgetAbstractImpl the ownership of the mouse is taken by the parent panel or frame and thus the doMouseEnter or Exit is never called.
 void init()
          Sets the basic layout and creates the WidgetImage that is going to be used throughout the class
 
Methods inherited from class com.jme.widget.panel.WidgetPanel
draw, initWidgetRenderer
 
Methods inherited from class com.jme.widget.WidgetAbstractContainer
add, add, addMouseButtonDownObserver, addMouseButtonUpObserver, addMouseDragObserver, addMouseEnterObserver, addMouseExitObserver, addMouseMoveObserver, calcViewport, canClose, close, contains, deleteMouseButtonDownObserver, deleteMouseButtonDownObservers, deleteMouseButtonUpObserver, deleteMouseButtonUpObservers, deleteMouseDragObserver, deleteMouseDragObservers, deleteMouseEnterObserver, deleteMouseEnterObservers, deleteMouseExitObserver, deleteMouseExitObservers, deleteMouseMoveObserver, deleteMouseMoveObservers, dispose, doAlignment, doLayout, doMouseDrag, doMouseMove, doParentLayout, getAbsoluteLocation, getAlignment, getBgColor, getBorder, getExtents, getFgColor, getHeight, getInputHandler, getInsets, getLastWidgetUnderMouse, getLayout, getLocation, getMouseInput, getMouseOwner, getNotifierMouseButtonDown, getNotifierMouseButtonUp, getNotifierMouseDrag, getNotifierMouseEnter, getNotifierMouseExit, getNotifierMouseMove, getOwner, getPanOffset, getPanOffsetX, getPanOffsetY, getSize, getTextureCoords, getViewRectangle, getWidget, getWidgetCount, getWidgetParent, getWidgetRenderer, getWidgetUnderMouse, getWidth, getWorldBound, getX, getXOffset, getY, getYOffset, getZOrder, handleMouseButtonUp, handleMouseDrag, handleMouseEnter, handleMouseExit, isApplyOffsetX, isApplyOffsetY, isCantOwnMouse, isMouseInWidget, isOpaque, isVisible, pack, remove, remove, removeAll, setAlignment, setApplyOffsetX, setApplyOffsetY, setBgColor, setBorder, setCantOwnMouse, setFgColor, setForceView, setHeight, setInputHandler, setInsets, setLastWidgetUnderMouse, setLayout, setLocation, setLocation, setMouseOwner, setOwner, setPanOffset, setPanOffset, setPanXOffset, setPanYOffset, setPreferredSize, setPreferredSize, setSize, setSize, setTextureCoords, setViewRectangle, setVisible, setWidgetParent, setWidgetRenderer, setWidgetUnderMouse, setWidth, setX, setY, setZOrder, toString, update, updateChildrenViewports, updateWorldBound
 
Methods inherited from class com.jme.scene.Node
applyRenderState, attachChild, detachAllChildren, detachChild, detachChildAt, detachChildNamed, drawBounds, findCollisions, findPick, getChild, getChild, getChildren, getQuantity, hasChild, hasCollision, putClone, setChild, updateCollisionTree, updateWorldData
 
Methods inherited from class com.jme.scene.Spatial
addController, applyDefaultStates, calculateCollisions, calculatePick, clearCurrentState, clearCurrentStates, clearRenderState, getController, getControllers, getCurrentState, getLastFrustumIntersection, getLightCombineMode, getLocalRotation, getLocalScale, getLocalTranslation, getName, getParent, getRenderQueueMode, getRenderStateList, getTextureCombineMode, getWorldRotation, getWorldScale, getWorldTranslation, isForceCulled, isForceView, onDraw, onDrawBounds, propagateBoundToRoot, propagateStatesFromRoot, removeController, removeFromParent, setForceCull, setLightCombineMode, setLocalRotation, setLocalRotation, setLocalScale, setLocalScale, setLocalTranslation, setName, setParent, setRenderQueueMode, setRenderState, setTextureCombineMode, setWorldBound, updateGeometricState, updateRenderState, updateRenderState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_imageUp

protected Image _imageUp

_imageDown

protected Image _imageDown

_imageOver

protected Image _imageOver

_image

protected WidgetImage _image

_buttonState

protected WidgetButtonStateType _buttonState
Constructor Detail

WidgetImageButton

public WidgetImageButton(java.lang.String upStr,
                         java.lang.String downStr,
                         java.lang.String overStr)
                  throws java.io.IOException
WidgetImageButton contructor. This allows the user to just specify the up, down and over file locations.

Parameters:
upStr - the location of the image to be used to the up button state. Based on using the getResource call of ClassLoader
downStr - the location of the image to be used to the down button state. Based on using the getResource call of ClassLoader
overStr - the location of the image to be used to the over button state. Based on using the getResource call of ClassLoader
Throws:
java.lang.Exception - Important: this is the only constructor that throws an IOException, this is because calling the this constructor with the ImageIO.read within it make it needed since you can't put a try/catch block around it.
java.io.IOException

WidgetImageButton

public WidgetImageButton(java.awt.Image imageUp,
                         java.awt.Image imageDown,
                         java.awt.Image imageOver)
Constructor that allows the user to pass in the java.awt.Image reference that need to be used to construct this button. Allows the user more freedom how and were the images are handled.

Parameters:
imageUp -
imageDown -
imageOver -

WidgetImageButton

public WidgetImageButton(Image imageUp,
                         Image imageDown,
                         Image imageOver)
Constructor that allows the user to pass in com.jme.image.Image instead of the java.awt.Image reference.

Parameters:
imageUp -
imageDown -
imageOver -
Method Detail

init

public void init()
Sets the basic layout and creates the WidgetImage that is going to be used throughout the class


doMouseButtonUp

public void doMouseButtonUp()
Handles when the panel recieves a button up message. If the mouse is still within the widget's boundries then the image will be switched to the over image, otherwise will use the up image.

Specified by:
doMouseButtonUp in interface WidgetMouseHandlerInterface
Overrides:
doMouseButtonUp in class WidgetAbstractContainer

doMouseButtonDown

public void doMouseButtonDown()
Handles the down message and changes the internal WidgeImage's underlying image to the down image.

Specified by:
doMouseButtonDown in interface WidgetMouseHandlerInterface
Overrides:
doMouseButtonDown in class WidgetAbstractContainer

doMouseEnter

public void doMouseEnter()
Checks for the mouse state to be correct when the mouse is in the widget TODO: really need to figure out a better way to handle this, right now because of the overridden handleMouseMove this method get's called for every movement of the mouse.

Specified by:
doMouseEnter in interface WidgetMouseHandlerInterface
Overrides:
doMouseEnter in class WidgetAbstractContainer

doMouseExit

public void doMouseExit()
Checks for the mouse to be correct state when mouse is NOT in widget TODO: really need to figure out a better way to handle this, right now because of the overridden handleMouseMove this method get's called for every movement of the mouse.

Specified by:
doMouseExit in interface WidgetMouseHandlerInterface
Overrides:
doMouseExit in class WidgetAbstractContainer

handleMouseButtonDown

public void handleMouseButtonDown()
Overridden from WidgetAbstractImpl I don't really know why it's needed, for some reason when using the one in WidgetAbstractImpl the ownership of the mouse is taken by the parent panel or frame and thus the doMouseButtonUp or Down is never called. TODO: need to take a better look at how ownership of the mouse is determined.

Specified by:
handleMouseButtonDown in interface WidgetMouseHandlerInterface
Overrides:
handleMouseButtonDown in class WidgetAbstractContainer

handleMouseMove

public void handleMouseMove()
Overridden from WidgetAbstractImpl I don't really know why it's needed, for some reason when using the one in WidgetAbstractImpl the ownership of the mouse is taken by the parent panel or frame and thus the doMouseEnter or Exit is never called. TODO: need to take a better look at how ownership of the mouse is determined.

Specified by:
handleMouseMove in interface WidgetMouseHandlerInterface
Overrides:
handleMouseMove in class WidgetAbstractContainer

getPreferredSize

public Vector2f getPreferredSize()
Needed by the AbsoluteLayout to figure out how big to draw it. As with this entire widget, the image size determines widget size. This required a change in the WidgetImage to be able to get the Preferred size correctly.

Specified by:
getPreferredSize in interface Widget
Overrides:
getPreferredSize in class WidgetAbstractContainer