codeanticode.protablet
Class Tablet

java.lang.Object
  extended by codeanticode.protablet.Tablet

public class Tablet
extends java.lang.Object

This class extends the PenListener class of the JPen library by adding getter methods to retrieve the pen values (position, pressure, tilt, pressed buttons, etc.). It also defines event methods that are called inside the Processing sketch when tablet events such as pressure or position changes occur. These methods are penButtonEventMethod, penKindEventMethod, penLevelEventMethod and penScrollEventMethod, and always pass as parameter the Tablet object generating the event:

void penLevelEventMethod(Tablet tablet) {
  println(tablet.getPressure());
}


However, these methods don't need to be implemented.

For more details about the JPen library, check the JPen website.

Author:
Andres Colubri

Field Summary
static int CURSOR
          Constant to identify the mouse.
static int ERASER
          Constant to identify the erasing tip of the pen.
static int STYLUS
          Constant to identify the drawing tip of the pen.
static int UNDEFINED
          Constant to identify an unknown pen kind.
 
Constructor Summary
Tablet(processing.core.PApplet parent)
          The class constructor that takes the parent Processing applet as parameter to initialize the pen manager.
 
Method Summary
 float getAltitude()
          Returns the current altitude of the pen.
 float getAzimuth()
          Returns the current x azimuth of the pen.
 void getAzimuthXAndAltitude(float[] azimuthXAndAltitude)
          Calculates the current x azimuth and altitude values and return them in the azimuthXAndAltitude array.
 int getPenKind()
          Returns the current pen kind: CURSOR is the mouse, STYLUS is the drawing tip of the pen and ERASER is the eraser tip of the pen.
 float getPenX()
          Returns the current X position of the pen.
 float getPenY()
          Returns the current Y position of the pen.
 float getPressure()
          Returns the current pressure.
 float getSavedAltitude()
          Returns the saved altitude of the pen.
 float getSavedAzimuth()
          Returns the saved x azimuth of the pen.
 void getSavedAzimuthXAndAltitude(float[] azimuthXAndAltitude)
          Calculates the x azimuth and altitude values using the saved tablet state and return them in the azimuthXAndAltitude array.
 float getSavedPenX()
          Returns the saved X position of the pen.
 float getSavedPenY()
          Returns the saved Y position of the pen.
 float getSavedPressure()
          Returns the saved pressure.
 float getSavedTiltX()
          Returns the saved X tilt of the pen.
 float getSavedTiltY()
          Returns the saved Y tilt of the pen.
 float getTiltX()
          Returns the current X tilt of the pen.
 float getTiltY()
          Returns the current Y tilt of the pen.
 boolean isCenterDown()
          Returns true if there is the center button is currently pressed.
 boolean isDown()
          Returns true if there is any button being currently pressed.
 boolean isLeftDown()
          Returns true if there is the left button is currently pressed.
 boolean isMovement()
          Returns true if a level event has occurred, meaning that a change in pressure, position or tilt has been detected.
 boolean isRightDown()
          Returns true if there is the right button is currently pressed.
 void penButtonEvent(PButtonEvent ev)
          Invokes penButtonEventMethod in the Processing applet (if exists) when a button event occurs.
 void penKindEvent(PKindEvent ev)
          Invokes penKindEventMethod in the Processing applet (if exists) when a kind event occurs.
 void penLevelEvent(PLevelEvent ev)
          Invokes penLevelEventMethod in the Processing applet (if exists) when a level event occurs.
 void penScrollEvent(PScrollEvent ev)
          Invokes penScrollEventMethod in the Processing applet (if exists) when a scroll event occurs.
 void penTock(long availableMillis)
           
 void saveState()
          Saves the current state of the pen.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNDEFINED

public static final int UNDEFINED
Constant to identify an unknown pen kind.

See Also:
Constant Field Values

CURSOR

public static final int CURSOR
Constant to identify the mouse.

See Also:
Constant Field Values

STYLUS

public static final int STYLUS
Constant to identify the drawing tip of the pen.

See Also:
Constant Field Values

ERASER

public static final int ERASER
Constant to identify the erasing tip of the pen.

See Also:
Constant Field Values
Constructor Detail

Tablet

public Tablet(processing.core.PApplet parent)
The class constructor that takes the parent Processing applet as parameter to initialize the pen manager.

Parameters:
parent - PApplet
Method Detail

getPressure

public float getPressure()
Returns the current pressure.

Returns:
float

getPenX

public float getPenX()
Returns the current X position of the pen.

Returns:
float

getPenY

public float getPenY()
Returns the current Y position of the pen.

Returns:
float

getTiltX

public float getTiltX()
Returns the current X tilt of the pen.

Returns:
float

getTiltY

public float getTiltY()
Returns the current Y tilt of the pen.

Returns:
float

getAzimuth

public float getAzimuth()
Returns the current x azimuth of the pen.

Returns:
float

getAltitude

public float getAltitude()
Returns the current altitude of the pen.

Returns:
float

getAzimuthXAndAltitude

public void getAzimuthXAndAltitude(float[] azimuthXAndAltitude)
Calculates the current x azimuth and altitude values and return them in the azimuthXAndAltitude array.

Parameters:
azimuthXAndAltitude - float[]

isMovement

public boolean isMovement()
Returns true if a level event has occurred, meaning that a change in pressure, position or tilt has been detected.

Returns:
boolean

getPenKind

public int getPenKind()
Returns the current pen kind: CURSOR is the mouse, STYLUS is the drawing tip of the pen and ERASER is the eraser tip of the pen.

Returns:
int

isDown

public boolean isDown()
Returns true if there is any button being currently pressed.

Returns:
boolean

isCenterDown

public boolean isCenterDown()
Returns true if there is the center button is currently pressed.

Returns:
boolean

isLeftDown

public boolean isLeftDown()
Returns true if there is the left button is currently pressed.

Returns:
boolean

isRightDown

public boolean isRightDown()
Returns true if there is the right button is currently pressed. When using the stylus, pressing it agains the tablet surface is considered as a right button click.

Returns:
boolean

saveState

public void saveState()
Saves the current state of the pen.


getSavedPressure

public float getSavedPressure()
Returns the saved pressure.

Returns:
float

getSavedPenX

public float getSavedPenX()
Returns the saved X position of the pen.

Returns:
float

getSavedPenY

public float getSavedPenY()
Returns the saved Y position of the pen.

Returns:
float

getSavedTiltX

public float getSavedTiltX()
Returns the saved X tilt of the pen.

Returns:
float

getSavedTiltY

public float getSavedTiltY()
Returns the saved Y tilt of the pen.

Returns:
float

getSavedAzimuth

public float getSavedAzimuth()
Returns the saved x azimuth of the pen.

Returns:
float

getSavedAltitude

public float getSavedAltitude()
Returns the saved altitude of the pen.

Returns:
float

getSavedAzimuthXAndAltitude

public void getSavedAzimuthXAndAltitude(float[] azimuthXAndAltitude)
Calculates the x azimuth and altitude values using the saved tablet state and return them in the azimuthXAndAltitude array.

Parameters:
azimuthXAndAltitude - float[]

penButtonEvent

public void penButtonEvent(PButtonEvent ev)
Invokes penButtonEventMethod in the Processing applet (if exists) when a button event occurs.

Parameters:
ev - PButtonEvent

penKindEvent

public void penKindEvent(PKindEvent ev)
Invokes penKindEventMethod in the Processing applet (if exists) when a kind event occurs.

Parameters:
ev - PKindEvent

penLevelEvent

public void penLevelEvent(PLevelEvent ev)
Invokes penLevelEventMethod in the Processing applet (if exists) when a level event occurs.

Parameters:
ev - PLevelEvent

penScrollEvent

public void penScrollEvent(PScrollEvent ev)
Invokes penScrollEventMethod in the Processing applet (if exists) when a scroll event occurs.

Parameters:
ev - PScrollEvent

penTock

public void penTock(long availableMillis)


processing library protablet by Andres Colubri. (c) 2008