com.jmex.swt.input
Class SWTMouseInput

java.lang.Object
  extended by com.jme.input.Input
      extended by com.jme.input.MouseInput
          extended by com.jmex.swt.input.SWTMouseInput
All Implemented Interfaces:
java.util.EventListener, org.eclipse.swt.events.DragDetectListener, org.eclipse.swt.events.MouseListener, org.eclipse.swt.events.MouseMoveListener, org.eclipse.swt.internal.SWTEventListener, org.eclipse.swt.widgets.Listener

public class SWTMouseInput
extends MouseInput
implements org.eclipse.swt.events.MouseListener, org.eclipse.swt.events.MouseMoveListener, org.eclipse.swt.widgets.Listener, org.eclipse.swt.events.DragDetectListener

Note: portions originally from the jme-swt source.


Nested Class Summary
(package private) static class SWTMouseInput.EventType
           
 
Field Summary
 
Fields inherited from class com.jme.input.MouseInput
INPUT_AWT, INPUT_LWJGL, listeners
 
Constructor Summary
protected SWTMouseInput()
           
 
Method Summary
 void clear()
           
 void clearButton(int buttonCode)
           
protected  void destroy()
          destroy cleans up the native mouse interface.
 void dragDetected(org.eclipse.swt.events.DragDetectEvent e)
           
 int getButtonCount()
           
 int getButtonIndex(java.lang.String buttonName)
          getButtonIndex gets the button code for a given button name.
 java.lang.String getButtonName(int buttonIndex)
          getButtonName gets the button name for a given button code.
 int getWheelDelta()
          getWheelDelta gets the change in the mouse wheel.
 int getWheelRotation()
           
 int getXAbsolute()
          getXAbsolute gets the absolute x axis value.
 int getXDelta()
          getXDelta gets the change along the x axis.
 int getYAbsolute()
          getYAbsolute gets the absolute y axis value.
 int getYDelta()
          getYDelta gets the change along the y axis.
 void handleEvent(org.eclipse.swt.widgets.Event e)
           
 boolean isButtonDown(int buttonCode)
          isButtonDown returns true if a given button is pressed, false if it is not pressed.
 boolean isCursorVisible()
          isCursorVisible
 boolean isDragOnly()
           
 boolean isEnabled()
           
 void mouseDoubleClick(org.eclipse.swt.events.MouseEvent e)
           
 void mouseDown(org.eclipse.swt.events.MouseEvent e)
           
 void mouseMove(org.eclipse.swt.events.MouseEvent e)
           
 void mouseUp(org.eclipse.swt.events.MouseEvent e)
           
 void setCursorPosition(int x, int y)
           
 void setCursorVisible(boolean v)
          setCursorVisible sets the visiblity of the hardware cursor.
 void setDragOnly(boolean dragOnly)
           
 void setEnabled(boolean enabled)
           
 void setHardwareCursor(java.net.URL file)
          setHardwareCursor sets the image to use for the hardware cursor.
 void setHardwareCursor(java.net.URL file, Image[] images, int[] delays, int xHotspot, int yHotspot)
          This method will set an animated harware cursor.
 void setHardwareCursor(java.net.URL file, int xHotspot, int yHotspot)
          setHardwareCursor sets the image and hotspot position to use for the hardware cursor.
static void setup(org.eclipse.swt.widgets.Composite canvas, boolean dragOnly)
          Set up a canvas to fire mouse events via the input system.
 void update()
          Updates the state of the mouse (position and button states).
 
Methods inherited from class com.jme.input.MouseInput
addListener, containsListener, destroyIfInitalized, get, getListeners, getProvider, isInited, removeListener, removeListeners, setProvider, setProvider
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SWTMouseInput

protected SWTMouseInput()
Method Detail

destroy

protected void destroy()
Description copied from class: MouseInput
destroy cleans up the native mouse interface. Destroy is protected now - please is MouseInput.destroyIfInitalized().

Specified by:
destroy in class MouseInput

getButtonIndex

public int getButtonIndex(java.lang.String buttonName)
Description copied from class: MouseInput
getButtonIndex gets the button code for a given button name.

Specified by:
getButtonIndex in class MouseInput
Parameters:
buttonName - the name to get the code for.
Returns:
the code for the given button name.

isButtonDown

public boolean isButtonDown(int buttonCode)
Description copied from class: MouseInput
isButtonDown returns true if a given button is pressed, false if it is not pressed.

Specified by:
isButtonDown in class MouseInput
Parameters:
buttonCode - the button code to check.
Returns:
true if the button is pressed, false otherwise.

getButtonName

public java.lang.String getButtonName(int buttonIndex)
Description copied from class: MouseInput
getButtonName gets the button name for a given button code.

Specified by:
getButtonName in class MouseInput
Parameters:
buttonIndex - the code to get the name for.
Returns:
the name for the given button code.

getWheelDelta

public int getWheelDelta()
Description copied from class: MouseInput
getWheelDelta gets the change in the mouse wheel.

Specified by:
getWheelDelta in class MouseInput
Returns:
the change in the mouse wheel.

getXDelta

public int getXDelta()
Description copied from class: MouseInput
getXDelta gets the change along the x axis.

Specified by:
getXDelta in class MouseInput
Returns:
the change along the x axis.

getYDelta

public int getYDelta()
Description copied from class: MouseInput
getYDelta gets the change along the y axis.

Specified by:
getYDelta in class MouseInput
Returns:
the change along the y axis.

getXAbsolute

public int getXAbsolute()
Description copied from class: MouseInput
getXAbsolute gets the absolute x axis value.

Specified by:
getXAbsolute in class MouseInput
Returns:
the absolute x axis value.

getYAbsolute

public int getYAbsolute()
Description copied from class: MouseInput
getYAbsolute gets the absolute y axis value.

Specified by:
getYAbsolute in class MouseInput
Returns:
the absolute y axis value.

update

public void update()
Description copied from class: MouseInput
Updates the state of the mouse (position and button states). Invokes event listeners synchronously.

Specified by:
update in class MouseInput

setCursorVisible

public void setCursorVisible(boolean v)
Description copied from class: MouseInput
setCursorVisible sets the visiblity of the hardware cursor.

Specified by:
setCursorVisible in class MouseInput
Parameters:
v - true turns the cursor on false turns it off

isCursorVisible

public boolean isCursorVisible()
Description copied from class: MouseInput
isCursorVisible

Specified by:
isCursorVisible in class MouseInput
Returns:
the visibility of the hardware cursor

setHardwareCursor

public void setHardwareCursor(java.net.URL file)
Description copied from class: MouseInput
setHardwareCursor sets the image to use for the hardware cursor.

Specified by:
setHardwareCursor in class MouseInput
Parameters:
file - URL to cursor image

setHardwareCursor

public void setHardwareCursor(java.net.URL file,
                              int xHotspot,
                              int yHotspot)
Description copied from class: MouseInput
setHardwareCursor sets the image and hotspot position to use for the hardware cursor.

Specified by:
setHardwareCursor in class MouseInput
Parameters:
file - URL to cursor image
xHotspot - Cursor X hotspot position
yHotspot - Cursor Y hotspot position

setHardwareCursor

public void setHardwareCursor(java.net.URL file,
                              Image[] images,
                              int[] delays,
                              int xHotspot,
                              int yHotspot)
Description copied from class: MouseInput
This method will set an animated harware cursor.

Specified by:
setHardwareCursor in class MouseInput
Parameters:
file - in this method file is only used as a key for cursor cashing
images - the animation frames
delays - delays between changing each frame
xHotspot - from image left
yHotspot - from image bottom

setCursorPosition

public void setCursorPosition(int x,
                              int y)
Specified by:
setCursorPosition in class MouseInput

getWheelRotation

public int getWheelRotation()
Specified by:
getWheelRotation in class MouseInput
Returns:
absolte wheel rotation

getButtonCount

public int getButtonCount()
Specified by:
getButtonCount in class MouseInput
Returns:
number of mouse buttons

isEnabled

public boolean isEnabled()

setEnabled

public void setEnabled(boolean enabled)
Parameters:
enabled - The enabled to set.

isDragOnly

public boolean isDragOnly()
Returns:
Returns the dragOnly.

setDragOnly

public void setDragOnly(boolean dragOnly)
Parameters:
dragOnly - The dragOnly to set.

mouseDoubleClick

public void mouseDoubleClick(org.eclipse.swt.events.MouseEvent e)
Specified by:
mouseDoubleClick in interface org.eclipse.swt.events.MouseListener

mouseDown

public void mouseDown(org.eclipse.swt.events.MouseEvent e)
Specified by:
mouseDown in interface org.eclipse.swt.events.MouseListener

mouseUp

public void mouseUp(org.eclipse.swt.events.MouseEvent e)
Specified by:
mouseUp in interface org.eclipse.swt.events.MouseListener

mouseMove

public void mouseMove(org.eclipse.swt.events.MouseEvent e)
Specified by:
mouseMove in interface org.eclipse.swt.events.MouseMoveListener

dragDetected

public void dragDetected(org.eclipse.swt.events.DragDetectEvent e)
Specified by:
dragDetected in interface org.eclipse.swt.events.DragDetectListener

handleEvent

public void handleEvent(org.eclipse.swt.widgets.Event e)
Specified by:
handleEvent in interface org.eclipse.swt.widgets.Listener

setup

public static void setup(org.eclipse.swt.widgets.Composite canvas,
                         boolean dragOnly)
Set up a canvas to fire mouse events via the input system.

Parameters:
glCanvas - canvas that should be listened to
dragOnly - true to enable mouse input to jME only when the mouse is dragged

clear

public void clear()
Specified by:
clear in class MouseInput

clearButton

public void clearButton(int buttonCode)
Specified by:
clearButton in class MouseInput