public class Pointer extends Buttons
Display
with which it is associated. The associated
MicroUI event type is Event.POINTER
.
The pointer can be asked for the absolute position, expressed in terms of the pointer area with which it was
constructed. It can also be asked for scaled co-ordinates (getX()
, getY()
). The scaled area is set
using the setScale(int, int)
method. By default there is no scaling (scaled area is the pointer area).
It is also possible to specify, using setOrigin(int, int)
, an offset to be applied to the co-ordinates
returned by getX()
and getX()
. For example, if the origin is set to be
(20, 30)
then the x position returned will be the absolute x position - 20, and the y position will be
the absolute y position - 30. By default there is no offset.
If both scaling and origin adjustment are specified then the origin offset is first applied to the absolute position
then the scaling is applied.
If a flying image is associated with the pointer, the generator manages it automatically its location within the scale area when the pointer has moved.
Modifier and Type | Field and Description |
---|---|
static int |
DRAGGED
The "dragged" action.
|
static int |
ENTERED
The "entered" action.
|
static int |
EXITED
The "exited" action.
|
static int |
MOVED
The "move" action.
|
Constructor and Description |
---|
Pointer(int width,
int height)
Constructor with a specified area range (
width and height ) that does not support click,
doubleClick nor elapsedTime for any of its buttons. |
Pointer(int nbButtons,
int width,
int height)
Constructor with a specified area range (
width and height ) where elapsedTime, click and
doubleClick features are supported and enabled for the first nbButtons (doubleClick feature is
initialized with a 200ms delay). |
Modifier and Type | Method and Description |
---|---|
int |
getAbsoluteHeight() |
int |
getAbsoluteWidth() |
int |
getAbsoluteX()
Returns the last available absolute x coordinate in pointer area
|
int |
getAbsoluteY()
Returns the last available absolute y coordinate in pointer area
|
int |
getEventType()
Gets the event type associated with the event generator.
|
FlyingImage |
getFlyingImage()
Gets the
FlyingImage associated to this Pointer . |
int |
getHeight() |
int |
getWidth() |
int |
getX()
Returns the last available x coordinate in scaled area (after applying any origin offset and the scale factor).
|
int |
getY()
Returns the last available y coordinate in scaled area (after applying any origin offset and the scale factor).
|
static boolean |
isDragged(int event)
Tells if a pointer event is a drag event.
|
static boolean |
isEntered(int event)
Tells if a pointer event is an enter event.
|
static boolean |
isExited(int event)
Tells if a pointer event is an exit event.
|
static boolean |
isMoved(int event)
Tells if a pointer event is a move event.
|
void |
move(int x,
int y)
Stores the given position and sends a MicroUI Event to the Pointer's listener.
|
void |
reset(int x,
int y)
Stores the given position.
|
void |
send(int action,
int buttonID)
Sends a MicroUI event for the given action on given button to the listener of the Pointer.
|
void |
setFlyingImage(FlyingImage flyingImage)
A Pointer generator manages positioning an image automatically if such image is set.
|
void |
setFlyingImage(FlyingImage flyingImage,
int anchorX,
int anchorY)
A Pointer generator manages positioning an image automatically if such image is set.
|
void |
setOrigin(int x0,
int y0)
Sets an origin offset.
|
void |
setScale(Display display)
Sets a display area for scaled area.
same as setScale(display.getWidth(), display.getHeight()) |
void |
setScale(int areaWidth,
int areaHeight)
Sets a scaled area.
|
clickEnabled, doubleClickEnabled, elapsedTime, enableClick, enableDoubleClick, getAction, getButtonID, isClicked, isDoubleClicked, isLong, isPressed, isReleased, isRepeated, supportsExtendedFeatures
addToSystemPool, get, get, get, getEventHandler, getID, getList, removeFromSystemPool, sendEvent, setEventHandler
public static final int MOVED
public static final int DRAGGED
public static final int ENTERED
public static final int EXITED
public Pointer(int nbButtons, int width, int height)
width
and height
) where elapsedTime, click and
doubleClick features are supported and enabled for the first nbButtons
(doubleClick feature is
initialized with a 200ms delay).nbButtons
- the number of buttons that support the extended featureswidth
- area widthheight
- area heightpublic Pointer(int width, int height)
width
and height
) that does not support click,
doubleClick nor elapsedTime for any of its buttons. The effect is identical to:new Pointer(0, width, height)
.width
- area widthheight
- area heightpublic int getAbsoluteWidth()
public int getAbsoluteHeight()
public int getEventType()
getEventType
in class Buttons
public int getX()
getAbsoluteX()
public int getY()
getAbsoluteY()
public int getAbsoluteX()
public int getAbsoluteY()
public void setScale(Display display)
setScale(display.getWidth(), display.getHeight())
display
- the display size to take as referencesetScale(int, int)
public void setScale(int areaWidth, int areaHeight)
getX()
is scaled so that it returns a value between 0 and
areaWidth-1. The x position returned by getY()
is scaled so that it returns a value between 0 and
areaHeight-1.areaWidth
- the area widthareaHeight
- the area heightpublic void setOrigin(int x0, int y0)
x0
- the X coordinate of the new originy0
- the Y coordinate of the new originpublic FlyingImage getFlyingImage()
FlyingImage
associated to this Pointer
.FlyingImage
public void setFlyingImage(FlyingImage flyingImage)
setFlyingImage(flyingImage, 0, 0)
flyingImage
- the flying image to update when the pointer changed or null
setFlyingImage(FlyingImage, int, int)
public void setFlyingImage(FlyingImage flyingImage, int anchorX, int anchorY)
FlyingImage.show()
.
Set the anchor of the image to anchorX
and anchorY
. If the pointer already has a flying
image set the old image is hidden and the new image replaces it.
flyingImage
- the flying image to update when the pointer changed or null
anchorX
- the image anchor X coordinateanchorY
- the image anchor Y coordinatepublic int getWidth()
getX()
public int getHeight()
getY()
public void move(int x, int y)
x
- the x coordinatey
- the y coordinatepublic void reset(int x, int y)
x
- the x coordinatey
- the y coordinatepublic void send(int action, int buttonID)
Buttons.CLICKED
and/or Buttons.DOUBLE_CLICKED
events if the matching button's feature is enabled.This method is useful when other input mechanisms wish to simulate button actions.
send
in class Buttons
action
- the button's action: Buttons.PRESSED
, Buttons.RELEASED
, Buttons.LONG
, Buttons.REPEATED
.buttonID
- the button on which the action occurredpublic static boolean isMoved(int event)
event
- the pointer event.public static boolean isDragged(int event)
event
- the pointer event.public static boolean isEntered(int event)
event
- the pointer event.public static boolean isExited(int event)
event
- the pointer event.