rebuild.ui.component
Class GestureField

java.lang.Object
  extended by Field
      extended by rebuild.ui.component.GestureField

public abstract class GestureField
extends Field

Gesture field, various gestures and system events will are processed and handled in this field.

Since:
BBX 1.0.0

Nested Class Summary
 class GestureField.Gesture
          A gesture that was generated by a GestureField.
 
Field Summary
protected  boolean gestureProcessing
          Set to true if gesture processing should occur, false if otherwise.
 
Constructor Summary
GestureField()
           
 
Method Summary
protected  XYPoint getContact(int index)
          Get a created contact.
protected  int getContactCount()
          Get the number of contacts that have occurred.
protected  boolean interactionCanceled()
          Any gesture operation was canceled.
protected  boolean interactionClick(boolean click)
          Any click event.
protected  void interactionComplete()
          Any interaction is complete.
protected  boolean interactionContact(int contact, boolean down)
          Any contact with the screen.
protected  boolean interactionGesture(GestureField.Gesture gesture)
          Any gesture that has occurred.
protected  boolean interactionMove(int x, int y)
          A move event occurred.
protected  boolean interactionRotate(int rad)
          A rotation event occurred.
protected  boolean interactionScale(int x, int y)
          A scale event occurred.
protected abstract  void layout(int width, int height)
           
protected static void matrixSetIdentity(int[] mat, int index)
          Sets a 3x3 matrix to it's identity.
protected static void matrixSetRotate(int[] mat, int index, int rotationInRad)
          Sets a 3x3 matrix to a rotation matrix.
protected static void matrixSetRotate(int[] mat, int index, int rotationInRad, int centerX, int centerY)
          Sets a 3x3 matrix to a rotation matrix.
protected static void matrixSetScale(int[] mat, int index, int x, int y)
          Sets a 3x3 matrix to a scale matrix.
protected static void matrixSetScale(int[] mat, int index, int x, int y, int centerX, int centerY)
          Sets a 3x3 matrix to a scale matrix.
protected static void matrixSetSkew(int[] mat, int index, int x, int y)
          Sets a 3x3 matrix to a skew matrix.
protected static void matrixSetTranslate(int[] mat, int index, int x, int y)
          Sets a 3x3 matrix to a translation matrix.
protected abstract  void paint(Graphics graphics)
           
protected  boolean touchEvent(TouchEvent message)
          Touch Event handles all gesture functions, if you are using any gesture functions then you should not return without invoking this function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

gestureProcessing

protected boolean gestureProcessing
Set to true if gesture processing should occur, false if otherwise. Default is true.

Constructor Detail

GestureField

public GestureField()
Method Detail

layout

protected abstract void layout(int width,
                               int height)

paint

protected abstract void paint(Graphics graphics)

interactionMove

protected boolean interactionMove(int x,
                                  int y)
A move event occurred.

Parameters:
x - The delta-X of the move in Fixed32 format.
y - The delta-Y of the move in Fixed32 format.
Returns:
true if the gesture was handled, false if otherwise.

interactionScale

protected boolean interactionScale(int x,
                                   int y)
A scale event occurred.

Parameters:
x - The delta scale of the X coordinate in Fixed32 format.
y - The delta scale of the Y coordinate in Fixed32 format.
Returns:
true if the gesture was handled, false if otherwise.

interactionRotate

protected boolean interactionRotate(int rad)
A rotation event occurred.

Parameters:
rad - The delta rotation of the event in Fixed32 format.
Returns:
true if the gesture was handled, false if otherwise.

interactionGesture

protected boolean interactionGesture(GestureField.Gesture gesture)
Any gesture that has occurred.

Returns:
true if the gesture was handled, false if otherwise.

interactionCanceled

protected boolean interactionCanceled()
Any gesture operation was canceled.

Returns:
true if the gesture was handled, false if otherwise.

interactionClick

protected boolean interactionClick(boolean click)
Any click event.

Parameters:
click - true if the event was a click, false if it was an unclick.
Returns:
true if the gesture was handled, false if otherwise.

interactionContact

protected boolean interactionContact(int contact,
                                     boolean down)
Any contact with the screen.

Parameters:
contact - The contact that occurred (1 for first contact, 2 for second contact, etc.).
down - true if the contact touched the screen, false if it was removed.
Returns:
true if the gesture was handled, false if otherwise.

interactionComplete

protected void interactionComplete()
Any interaction is complete.


touchEvent

protected boolean touchEvent(TouchEvent message)
Touch Event handles all gesture functions, if you are using any gesture functions then you should not return without invoking this function.

See Also:
Field#touchEvent(TouchEvent)

matrixSetIdentity

protected static void matrixSetIdentity(int[] mat,
                                        int index)
Sets a 3x3 matrix to it's identity.


matrixSetRotate

protected static void matrixSetRotate(int[] mat,
                                      int index,
                                      int rotationInRad)
Sets a 3x3 matrix to a rotation matrix. This function sets the matrix to an identity matrix before setting it to a rotation matrix.

Parameters:
rotationInRad - The rotation in radians.

matrixSetRotate

protected static void matrixSetRotate(int[] mat,
                                      int index,
                                      int rotationInRad,
                                      int centerX,
                                      int centerY)
Sets a 3x3 matrix to a rotation matrix. This function sets the matrix to an identity matrix before setting it to a rotation matrix.

Parameters:
rotationInRad - The rotation in radians.
centerX - The rotation center on the X coordinate in Fixed32 format.
centerY - The rotation center on the Y coordinate in Fixed32 format.

matrixSetSkew

protected static void matrixSetSkew(int[] mat,
                                    int index,
                                    int x,
                                    int y)
Sets a 3x3 matrix to a skew matrix. This function sets the matrix to an identity matrix before setting it to a skew matrix.

Parameters:
x - The angle on the X coordinate to skew in Fixed32 format.
y - The angle on the Y coordinate to skew in Fixed32 format.

matrixSetTranslate

protected static void matrixSetTranslate(int[] mat,
                                         int index,
                                         int x,
                                         int y)
Sets a 3x3 matrix to a translation matrix. This function sets the matrix to an identity matrix before setting it to a translation matrix.

Parameters:
x - The X translation in Fixed32 format.
y - The Y translation in Fixed32 format.

matrixSetScale

protected static void matrixSetScale(int[] mat,
                                     int index,
                                     int x,
                                     int y)
Sets a 3x3 matrix to a scale matrix. This function sets the matrix to an identity matrix before setting it to a scale matrix.

Parameters:
x - The X scale in Fixed32 format.
y - The Y scale in Fixed32 format.

matrixSetScale

protected static void matrixSetScale(int[] mat,
                                     int index,
                                     int x,
                                     int y,
                                     int centerX,
                                     int centerY)
Sets a 3x3 matrix to a scale matrix. This function sets the matrix to an identity matrix before setting it to a scale matrix.

Parameters:
x - The X scale in Fixed32 format.
y - The Y scale in Fixed32 format.
centerX - The scaling center on the X coordinate in Fixed32 format.
centerY - The scaling center on the Y coordinate in Fixed32 format.

getContactCount

protected int getContactCount()
Get the number of contacts that have occurred.


getContact

protected XYPoint getContact(int index)
Get a created contact.

Parameters:
index - The contact to get; 1 would be the first finger, 2 would be the second finger.
Returns:
The contact if it exists or null if it does not or the index is no valid.