JTablet 1.2.0 API

cello.jtablet.event
Class TabletEvent

java.lang.Object
  extended by java.util.EventObject
      extended by java.awt.AWTEvent
          extended by java.awt.event.ComponentEvent
              extended by java.awt.event.InputEvent
                  extended by java.awt.event.MouseEvent
                      extended by cello.jtablet.event.TabletEvent
All Implemented Interfaces:
Serializable

public class TabletEvent
extends MouseEvent
implements Serializable

An event that indicates cursor input occurred on the given component. This class extends MouseEvent and provides a similar and extended API for accessing tablet events.

You likely will not be constructing this class yourself.

Implementation Note: MouseEvent.isPopupTrigger() is unsupported.

Author:
Marcello
See Also:
Serialized Form

Nested Class Summary
static class TabletEvent.Type
          This enum is used to specify the possible types of a TabletEvent.
 
Field Summary
 
Fields inherited from class java.awt.event.MouseEvent
BUTTON1, BUTTON2, BUTTON3, MOUSE_CLICKED, MOUSE_DRAGGED, MOUSE_ENTERED, MOUSE_EXITED, MOUSE_FIRST, MOUSE_LAST, MOUSE_MOVED, MOUSE_PRESSED, MOUSE_RELEASED, MOUSE_WHEEL, NOBUTTON
 
Fields inherited from class java.awt.event.InputEvent
ALT_DOWN_MASK, ALT_GRAPH_DOWN_MASK, ALT_GRAPH_MASK, ALT_MASK, BUTTON1_DOWN_MASK, BUTTON1_MASK, BUTTON2_DOWN_MASK, BUTTON2_MASK, BUTTON3_DOWN_MASK, BUTTON3_MASK, CTRL_DOWN_MASK, CTRL_MASK, META_DOWN_MASK, META_MASK, SHIFT_DOWN_MASK, SHIFT_MASK
 
Fields inherited from class java.awt.event.ComponentEvent
COMPONENT_FIRST, COMPONENT_HIDDEN, COMPONENT_LAST, COMPONENT_MOVED, COMPONENT_RESIZED, COMPONENT_SHOWN
 
Fields inherited from class java.awt.AWTEvent
ACTION_EVENT_MASK, ADJUSTMENT_EVENT_MASK, COMPONENT_EVENT_MASK, consumed, CONTAINER_EVENT_MASK, FOCUS_EVENT_MASK, HIERARCHY_BOUNDS_EVENT_MASK, HIERARCHY_EVENT_MASK, id, INPUT_METHOD_EVENT_MASK, INVOCATION_EVENT_MASK, ITEM_EVENT_MASK, KEY_EVENT_MASK, MOUSE_EVENT_MASK, MOUSE_MOTION_EVENT_MASK, MOUSE_WHEEL_EVENT_MASK, PAINT_EVENT_MASK, RESERVED_ID_MAX, TEXT_EVENT_MASK, WINDOW_EVENT_MASK, WINDOW_FOCUS_EVENT_MASK, WINDOW_STATE_EVENT_MASK
 
Fields inherited from class java.util.EventObject
source
 
Constructor Summary
TabletEvent(Component source, TabletEvent.Type type, long when, int modifiers, int rawTabletButtonMask, TabletDevice device, float x, float y)
          Constructs a new TabletEvent with some of the trimmings...
TabletEvent(Component source, TabletEvent.Type type, long when, int modifiers, int rawTabletButtonMask, TabletDevice device, float x, float y, float pressure, float tiltX, float tiltY, float sidePressure, float rotation, int button)
          Constructs a new TabletEvent with all the trimmings...
TabletEvent(Component source, TabletEvent.Type type, long when, int modifiers, TabletDevice device, float x, float y, float rotation, float deltaX, float deltaY, float zoom)
          Constructs a new TabletEvent with some of the trimmings...
TabletEvent(Component source, TabletEvent.Type type, long when, int modifiers, TabletDevice device, float x, float y, float pressure, float tiltX, float tiltY, float sidePressure, float rotation, float deltaX, float deltaY, float zoom, int button, int rawTabletButtonMask)
          Constructs a new TabletEvent with all the trimmings...
TabletEvent(Component source, TabletEvent.Type type, long when, TabletDevice device, int modifiers, float x, float y, int button)
          Constructs a new TabletEvent with some of the trimmings...
TabletEvent(MouseEvent e, TabletEvent.Type type, TabletDevice device)
          Wrap a MouseEvent as a TabletEvent.
TabletEvent(MouseEvent e, TabletEvent.Type type, TabletDevice device, Component c, float x, float y)
          Wrap a MouseEvent as a TabletEvent.
TabletEvent(TabletEvent original, Component newComponent, float newX, float newY)
          Constructs a TabletEvent based on another with a new component and coordinates.
TabletEvent(TabletEvent original, float newX, float newY)
          Constructs a TabletEvent based on another with new coordinates.
TabletEvent(TabletEvent original, TabletEvent.Type newType)
          Constructs a TabletEvent based on another with a new event TabletEvent.Type.
 
Method Summary
 void fireEvent(TabletListener listener)
          Triggers this event on the given TabletListener.
 TabletDevice getDevice()
          Returns the tablet device associated with this event.
 float getFloatX()
          Returns the fractional x position of the mouse/tablet cursor (if available).
 float getFloatY()
          Returns the fractional y position of the mouse/tablet cursor (if available).
 Point2D.Float getPoint2D()
          Returns the fractional Point2D of the mouse/tablet cursor (if available).
 float getPressure()
          Returns the current pressure value of the tablet pressure.
 int getRawTabletButtonMask()
          Returns the raw tablet button mask independent of any user mapping with regards to "left" or "right." This may return zero for emulated devices.
 float getRotation()
          Returns either the rotational position of a tablet, or the rotational amount for a TabletEvent.Type.ROTATED gesture event.
 float getScrollX()
          Returns the amount scrolled in the x direction for a TabletEvent.Type.SCROLLED gesture event.
 float getScrollY()
          Returns the amount scrolled in the y direction for a TabletEvent.Type.SCROLLED gesture event.
 float getSidePressure()
          Returns the current tablet side pressure.
 float getTiltX()
          Returns the current horizontal tilt angle in radians.
 float getTiltY()
          Returns the current horizontal tilt angle in radians.
 TabletEvent.Type getType()
          Returns the TabletEvent.Type for this event.
 float getZoomFactor()
          Returns the magnification amount for a TabletEvent.Type.ZOOMED gesture event.
 String toString()
           
 TabletEvent translated(Component c, float deltaX, float deltaY)
          Returns a copy of this TabletEvent with translated coordinates.
 TabletEvent translated(float deltaX, float deltaY)
          Returns a copy of this TabletEvent with translated coordinates.
 TabletEvent withPoint(Component component, float x, float y)
          Returns a copy of this TabletEvent with the given component and coordinates.
 TabletEvent withPoint(float x, float y)
          Returns a copy of this TabletEvent with the given coordinates.
 TabletEvent withType(TabletEvent.Type type)
          Returns a copy of this TabletEvent with a new event TabletEvent.Type.
 
Methods inherited from class java.awt.event.MouseEvent
getButton, getClickCount, getLocationOnScreen, getMouseModifiersText, getPoint, getX, getXOnScreen, getY, getYOnScreen, isPopupTrigger, paramString, translatePoint
 
Methods inherited from class java.awt.event.InputEvent
consume, getModifiers, getModifiersEx, getModifiersExText, getWhen, isAltDown, isAltGraphDown, isConsumed, isControlDown, isMetaDown, isShiftDown
 
Methods inherited from class java.awt.event.ComponentEvent
getComponent
 
Methods inherited from class java.awt.AWTEvent
getID, setSource
 
Methods inherited from class java.util.EventObject
getSource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TabletEvent

public TabletEvent(Component source,
                   TabletEvent.Type type,
                   long when,
                   int modifiers,
                   TabletDevice device,
                   float x,
                   float y,
                   float pressure,
                   float tiltX,
                   float tiltY,
                   float sidePressure,
                   float rotation,
                   float deltaX,
                   float deltaY,
                   float zoom,
                   int button,
                   int rawTabletButtonMask)
Constructs a new TabletEvent with all the trimmings... yourself.

Parameters:
source -
type -
when -
device -
x -
y -
modifiers -
button -
pressure -
tiltX -
tiltY -
sidePressure -
rotation -
deltaX -
deltaY -
zoom -
rawTabletButtonMask -

TabletEvent

public TabletEvent(MouseEvent e,
                   TabletEvent.Type type,
                   TabletDevice device)
Wrap a MouseEvent as a TabletEvent.

Parameters:
e -
type -
device -

TabletEvent

public TabletEvent(MouseEvent e,
                   TabletEvent.Type type,
                   TabletDevice device,
                   Component c,
                   float x,
                   float y)
Wrap a MouseEvent as a TabletEvent.

Parameters:
e -
type -
device -
c -
x -
y -

TabletEvent

public TabletEvent(Component source,
                   TabletEvent.Type type,
                   long when,
                   int modifiers,
                   int rawTabletButtonMask,
                   TabletDevice device,
                   float x,
                   float y,
                   float pressure,
                   float tiltX,
                   float tiltY,
                   float sidePressure,
                   float rotation,
                   int button)
Constructs a new TabletEvent with all the trimmings...

Parameters:
source -
type -
when -
modifiers -
rawTabletButtonMask -
device -
x -
y -
pressure -
tiltX -
tiltY -
sidePressure -
rotation -
button -

TabletEvent

public TabletEvent(Component source,
                   TabletEvent.Type type,
                   long when,
                   int modifiers,
                   int rawTabletButtonMask,
                   TabletDevice device,
                   float x,
                   float y)
Constructs a new TabletEvent with some of the trimmings...

Parameters:
source -
type -
when -
modifiers -
rawTabletButtonMask -
device -
x -
y -

TabletEvent

public TabletEvent(Component source,
                   TabletEvent.Type type,
                   long when,
                   int modifiers,
                   TabletDevice device,
                   float x,
                   float y,
                   float rotation,
                   float deltaX,
                   float deltaY,
                   float zoom)
Constructs a new TabletEvent with some of the trimmings...

Parameters:
source -
type -
when -
modifiers -
device -
x -
y -
rotation -
deltaX -
deltaY -
zoom -

TabletEvent

public TabletEvent(Component source,
                   TabletEvent.Type type,
                   long when,
                   TabletDevice device,
                   int modifiers,
                   float x,
                   float y,
                   int button)
Constructs a new TabletEvent with some of the trimmings...

Parameters:
source -
type -
when -
device -
modifiers -
x -
y -
button -

TabletEvent

public TabletEvent(TabletEvent original,
                   Component newComponent,
                   float newX,
                   float newY)
Constructs a TabletEvent based on another with a new component and coordinates.

Parameters:
original -
newComponent -
newX - x-coordinate
newY - y-coordinate
See Also:
withPoint(float, float)

TabletEvent

public TabletEvent(TabletEvent original,
                   float newX,
                   float newY)
Constructs a TabletEvent based on another with new coordinates.

Parameters:
original -
newX - x-coordinate
newY - y-coordinate
See Also:
withPoint(Component, float, float)

TabletEvent

public TabletEvent(TabletEvent original,
                   TabletEvent.Type newType)
Constructs a TabletEvent based on another with a new event TabletEvent.Type.

Parameters:
original -
newType - the new event type
Method Detail

toString

public String toString()
Overrides:
toString in class AWTEvent

fireEvent

public void fireEvent(TabletListener listener)
Triggers this event on the given TabletListener.

Parameters:
listener - the listener to trigger on

getPoint2D

public Point2D.Float getPoint2D()
Returns the fractional Point2D of the mouse/tablet cursor (if available).

Returns:
the (possibly) fractional point

getFloatX

public float getFloatX()
Returns the fractional x position of the mouse/tablet cursor (if available).

You can determine if the current device supports fractional points with TabletDevice.getFloatSupport() via getDevice().

Returns:
the (possibly) fractional x coordinate

getFloatY

public float getFloatY()
Returns the fractional y position of the mouse/tablet cursor (if available).

You can determine if the current device supports fractional points with TabletDevice.getFloatSupport() via getDevice().

Returns:
the (possibly) fractional y coordinate

getPressure

public float getPressure()
Returns the current pressure value of the tablet pressure.

You can determine if the current device supports pressure with TabletDevice.getPressureSupport() via getDevice().

Returns:
the pressure from 0 to 1
See Also:
TabletDevice.getPressureSupport()

getDevice

public TabletDevice getDevice()
Returns the tablet device associated with this event. You can determine capabilities available by inspecting the device object.

Returns:
the device
See Also:
TabletDevice

getType

public TabletEvent.Type getType()
Returns the TabletEvent.Type for this event.

Returns:
the event type
See Also:
TabletEvent.Type

getSidePressure

public float getSidePressure()
Returns the current tablet side pressure. (E.g. the side wheel on a Wacom airbrush tool.)

You can determine if the current device supports side pressure with TabletDevice.getSidePressureSupport() via getDevice().

Returns:
side pressure from 0 to 1.

getTiltX

public float getTiltX()
Returns the current horizontal tilt angle in radians.

You can determine if the current device supports side pressure with TabletDevice.getTiltSupport() via getDevice().

Returns:
tilt X in radians

getTiltY

public float getTiltY()
Returns the current horizontal tilt angle in radians.

You can determine if the current device supports side pressure with TabletDevice.getTiltSupport() via getDevice().

Returns:
tilt Y in radians

getRotation

public float getRotation()
Returns either the rotational position of a tablet, or the rotational amount for a TabletEvent.Type.ROTATED gesture event.

You can determine if the current device supports side pressure with TabletDevice.getRotationSupport() via getDevice().

Returns:
rotation in radians

getRawTabletButtonMask

public int getRawTabletButtonMask()
Returns the raw tablet button mask independent of any user mapping with regards to "left" or "right." This may return zero for emulated devices.

Returns:
a bitset given by the tablet driver

getScrollX

public float getScrollX()
Returns the amount scrolled in the x direction for a TabletEvent.Type.SCROLLED gesture event.

Returns:
the amount scrolled in the x direction

getScrollY

public float getScrollY()
Returns the amount scrolled in the y direction for a TabletEvent.Type.SCROLLED gesture event.

Returns:
the amount scrolled in the y direction

getZoomFactor

public float getZoomFactor()
Returns the magnification amount for a TabletEvent.Type.ZOOMED gesture event.

Returns:
the zoom

withPoint

public TabletEvent withPoint(Component component,
                             float x,
                             float y)
Returns a copy of this TabletEvent with the given component and coordinates.

Parameters:
component -
x - x-coordinate
y - y-coordinate
Returns:
a new TabletEvent with the new component and coordinates
See Also:
withPoint(float, float)

withPoint

public TabletEvent withPoint(float x,
                             float y)
Returns a copy of this TabletEvent with the given coordinates.

Parameters:
x - x-coordinate
y - y-coordinate
Returns:
a new TabletEvent with the new coordinates
See Also:
withPoint(Component, float, float)

translated

public TabletEvent translated(Component c,
                              float deltaX,
                              float deltaY)
Returns a copy of this TabletEvent with translated coordinates.

Parameters:
c - component for translated event
deltaX - the amount to translate the x-coordinate
deltaY - the amount to translate the y-coordinate
Returns:
a new TabletEvent with the new component and coordinates
See Also:
translated(float, float)

translated

public TabletEvent translated(float deltaX,
                              float deltaY)
Returns a copy of this TabletEvent with translated coordinates.

Parameters:
deltaX - the amount to translate the x-coordinate
deltaY - the amount to translate the y-coordinate
Returns:
a new TabletEvent with the new coordinates
See Also:
translated(Component, float, float)

withType

public TabletEvent withType(TabletEvent.Type type)
Returns a copy of this TabletEvent with a new event TabletEvent.Type.

Parameters:
type - the new event type
Returns:
a new TabletEvent with the given type

JTablet 1.2.0 API