com.jogamp.newt.event
Class MouseEvent

java.lang.Object
  extended by java.util.EventObject
      extended by com.jogamp.newt.event.NEWTEvent
          extended by com.jogamp.newt.event.InputEvent
              extended by com.jogamp.newt.event.MouseEvent
All Implemented Interfaces:
Serializable

public class MouseEvent
extends InputEvent

Pointer event of type MouseEvent.PointerType.

In case an instance represents multi-touch events, i.e. getPointerCount() is > 1, the first data element represents the pointer which triggered the action if individual to one pointer.
For example e.getX(0) at EVENT_MOUSE_PRESSED returns the data of the pressed pointer, etc.

See Also:
Serialized Form

Nested Class Summary
static class MouseEvent.PointerClass
          Class of pointer types
static class MouseEvent.PointerType
          Type of pointer devices
 
Field Summary
static short BUTTON_NUMBER
          Maximum number of buttons, value 16
static short BUTTON1
          ID for button 1, value 1
static short BUTTON2
          ID for button 2, value 2
static short BUTTON3
          ID for button 3, value 3
static short BUTTON4
          ID for button 4, value 4
static short BUTTON5
          ID for button 5, value 5
static short BUTTON6
          ID for button 6, value 6
static short BUTTON7
          ID for button 6, value 7
static short BUTTON8
          ID for button 6, value 8
static short BUTTON9
          ID for button 6, value 9
static short EVENT_MOUSE_CLICKED
           
static short EVENT_MOUSE_DRAGGED
           
static short EVENT_MOUSE_ENTERED
           
static short EVENT_MOUSE_EXITED
           
static short EVENT_MOUSE_MOVED
           
static short EVENT_MOUSE_PRESSED
           
static short EVENT_MOUSE_RELEASED
           
static short EVENT_MOUSE_WHEEL_MOVED
           
 
Fields inherited from class com.jogamp.newt.event.InputEvent
ALT_GRAPH_MASK, ALT_MASK, AUTOREPEAT_MASK, BUTTON1_MASK, BUTTON2_MASK, BUTTON3_MASK, BUTTON4_MASK, BUTTON5_MASK, BUTTON6_MASK, BUTTON7_MASK, BUTTON8_MASK, BUTTON9_MASK, BUTTONLAST_MASK, CONFINED_MASK, CTRL_MASK, INVISIBLE_MASK, META_MASK, SHIFT_MASK
 
Fields inherited from class com.jogamp.newt.event.NEWTEvent
consumedTag
 
Constructor Summary
MouseEvent(short eventType, Object source, long when, int modifiers, int[] x, int[] y, float[] pressure, float maxPressure, MouseEvent.PointerType[] pointerTypes, short[] pointerids, short clickCount, short button, float[] rotationXYZ, float rotationScale)
          Constructor for multi-touch pointer events.
MouseEvent(short eventType, Object source, long when, int modifiers, int x, int y, short clickCount, short button, float[] rotationXYZ, float rotationScale)
          Constructor for tradition 1-pointer mouse events.
 
Method Summary
 short getButton()
           
 short getClickCount()
           
static short getClickTimeout()
           
static String getEventTypeString(short type)
           
 float getMaxPressure()
          Returns the maximum pressure known for the input device generating this event.
 int getPointerCount()
           
 short getPointerId(int index)
           
 MouseEvent.PointerType getPointerType(int index)
           
 float getPressure(boolean normalized)
           
 float getPressure(int index, boolean normalized)
           
 float[] getRotation()
          Returns a 3-component float array filled with the values of the rotational axis in the following order: horizontal-, vertical- and z-axis.
 float getRotationScale()
          Returns the scale used to determine the rotation value, which semantics depends on the pointer type's MouseEvent.PointerClass.
static float[] getRotationXYZ(float rotationXorY, int mods)
          Returns the 3-axis XYZ rotation array by given rotation on Y axis or X axis (if SHIFT_MASK is given in mods).
 float getWheelRotation()
          Deprecated. Use getRotation()
 int getX()
           
 int getX(int index)
           
 int getY()
           
 int getY(int index)
           
 String toString()
           
 StringBuilder toString(StringBuilder sb)
           
 
Methods inherited from class com.jogamp.newt.event.InputEvent
getButtonMask, getButtonsDown, getModifiers, getModifiersString, isAltDown, isAltGraphDown, isAutoRepeat, isButtonDown, isConfined, isControlDown, isInvisible, isMetaDown, isShiftDown
 
Methods inherited from class com.jogamp.newt.event.NEWTEvent
getAttachment, getEventType, getWhen, isConsumed, setAttachment, setConsumed, toHexString
 
Methods inherited from class java.util.EventObject
getSource
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BUTTON1

public static final short BUTTON1
ID for button 1, value 1

See Also:
Constant Field Values

BUTTON2

public static final short BUTTON2
ID for button 2, value 2

See Also:
Constant Field Values

BUTTON3

public static final short BUTTON3
ID for button 3, value 3

See Also:
Constant Field Values

BUTTON4

public static final short BUTTON4
ID for button 4, value 4

See Also:
Constant Field Values

BUTTON5

public static final short BUTTON5
ID for button 5, value 5

See Also:
Constant Field Values

BUTTON6

public static final short BUTTON6
ID for button 6, value 6

See Also:
Constant Field Values

BUTTON7

public static final short BUTTON7
ID for button 6, value 7

See Also:
Constant Field Values

BUTTON8

public static final short BUTTON8
ID for button 6, value 8

See Also:
Constant Field Values

BUTTON9

public static final short BUTTON9
ID for button 6, value 9

See Also:
Constant Field Values

BUTTON_NUMBER

public static final short BUTTON_NUMBER
Maximum number of buttons, value 16

See Also:
Constant Field Values

EVENT_MOUSE_CLICKED

public static final short EVENT_MOUSE_CLICKED
See Also:
Constant Field Values

EVENT_MOUSE_ENTERED

public static final short EVENT_MOUSE_ENTERED
See Also:
Constant Field Values

EVENT_MOUSE_EXITED

public static final short EVENT_MOUSE_EXITED
See Also:
Constant Field Values

EVENT_MOUSE_PRESSED

public static final short EVENT_MOUSE_PRESSED
See Also:
Constant Field Values

EVENT_MOUSE_RELEASED

public static final short EVENT_MOUSE_RELEASED
See Also:
Constant Field Values

EVENT_MOUSE_MOVED

public static final short EVENT_MOUSE_MOVED
See Also:
Constant Field Values

EVENT_MOUSE_DRAGGED

public static final short EVENT_MOUSE_DRAGGED
See Also:
Constant Field Values

EVENT_MOUSE_WHEEL_MOVED

public static final short EVENT_MOUSE_WHEEL_MOVED
See Also:
Constant Field Values
Constructor Detail

MouseEvent

public MouseEvent(short eventType,
                  Object source,
                  long when,
                  int modifiers,
                  int x,
                  int y,
                  short clickCount,
                  short button,
                  float[] rotationXYZ,
                  float rotationScale)
Constructor for tradition 1-pointer mouse events.


MouseEvent

public MouseEvent(short eventType,
                  Object source,
                  long when,
                  int modifiers,
                  int[] x,
                  int[] y,
                  float[] pressure,
                  float maxPressure,
                  MouseEvent.PointerType[] pointerTypes,
                  short[] pointerids,
                  short clickCount,
                  short button,
                  float[] rotationXYZ,
                  float rotationScale)
Constructor for multi-touch pointer events.

Method Detail

getRotationXYZ

public static final float[] getRotationXYZ(float rotationXorY,
                                           int mods)
Returns the 3-axis XYZ rotation array by given rotation on Y axis or X axis (if SHIFT_MASK is given in mods).


getClickTimeout

public static final short getClickTimeout()

getPointerCount

public int getPointerCount()
Returns:
the count of pointers involved in this event

getPointerType

public MouseEvent.PointerType getPointerType(int index)
Returns:
the MouseEvent.PointerType for the data at index. return null if index not available.

getPointerId

public short getPointerId(int index)
Returns:
the pointer id for the data at index. return -1 if index not available.

getButton

public short getButton()

getClickCount

public short getClickCount()

getX

public int getX()

getY

public int getY()

getX

public int getX(int index)
Parameters:
index - pointer-index within [0 .. getPointerCount()-1]
Returns:
X-Coord associated with the pointer-index.
See Also:
getPointerId(index)

getY

public int getY(int index)
Parameters:
index - pointer-index within [0 .. getPointerCount()-1]
Returns:
Y-Coord associated with the pointer-index.
See Also:
getPointerId(index)

getPressure

public float getPressure(boolean normalized)
Parameters:
normalized - if true, method returns the normalized pressure, i.e. pressure / maxPressure
Returns:
The pressure associated with the pointer-index 0. The value of zero is return if not available.
See Also:
getMaxPressure()

getMaxPressure

public float getMaxPressure()
Returns the maximum pressure known for the input device generating this event.

This value may be self calibrating on devices/OS, where no known maximum pressure is known. Hence subsequent events may return a higher value.

Self calibrating maximum pressure is performed on:


getPressure

public float getPressure(int index,
                         boolean normalized)
Parameters:
index - pointer-index within [0 .. getPointerCount()-1]
normalized - if true, method returns the normalized pressure, i.e. pressure / maxPressure
Returns:
The pressure associated with the pointer-index. The value of zero is return if not available.
See Also:
getMaxPressure()

getWheelRotation

public float getWheelRotation()
Deprecated. Use getRotation()

Usually a wheel rotation of > 0.0f is up, and < 0.0f is down.

Usually a wheel rotations is considered a vertical scroll.
If InputEvent.isShiftDown(), a wheel rotations is considered a horizontal scroll, where shift-up = left = > 0.0f, and shift-down = right = < 0.0f.

However, on some OS this might be flipped due to the OS default behavior. The latter is true for OS X 10.7 (Lion) for example.

The events will be send usually in steps of one, ie. -1.0f and 1.0f. Higher values may result due to fast scrolling. Fractional values may result due to slow scrolling with high resolution devices.

The button number refers to the wheel number.


getRotation

public float[] getRotation()
Returns a 3-component float array filled with the values of the rotational axis in the following order: horizontal-, vertical- and z-axis.

A vertical rotation of > 0.0f is up and < 0.0f is down.

A horizontal rotation of > 0.0f is left and < 0.0f is right.

A z-axis rotation of > 0.0f is back and < 0.0f is front.

However, on some OS this might be flipped due to the OS default behavior. The latter is true for OS X 10.7 (Lion) for example.

On PointerClass onscreen devices, i.e. touch screens, rotation events are usually produced by a 2-finger movement, where horizontal and vertical rotation values are filled.

On PointerClass offscreen devices, i.e. mouse, either the horizontal or the vertical rotation value is filled.

The InputEvent.SHIFT_MASK modifier is set in case |horizontal| > |vertical| value.
This can be utilized to implement only one 2d rotation direction, you may use InputEvent.isShiftDown() to query it.

In case the pointer type is mouse, events are usually send in steps of one, ie. -1.0f and 1.0f. Higher values may result due to fast scrolling. Fractional values may result due to slow scrolling with high resolution devices.
Here the button number refers to the wheel number.

In case the pointer type is of class MouseEvent.PointerClass.Onscreen, e.g. touch screen, see getRotationScale() for semantics.


getRotationScale

public float getRotationScale()
Returns the scale used to determine the rotation value, which semantics depends on the pointer type's MouseEvent.PointerClass.

For MouseEvent.PointerClass.Offscreen, the scale is usually 1.0f and denominates an abstract value without association to a physical value.

For MouseEvent.PointerClass.Onscreen, the scale varies and denominates the divisor of the distance the finger[s] have moved on the screen. Hence scale * rotation reproduces the screen distance in pixels the finger[s] have moved.


toString

public String toString()
Overrides:
toString in class InputEvent

toString

public StringBuilder toString(StringBuilder sb)
Overrides:
toString in class InputEvent

getEventTypeString

public static String getEventTypeString(short type)


Copyright 2010 JogAmp Community.