Class Pointer
- java.lang.Object
-
- ej.microui.event.EventGenerator
-
- ej.microui.event.generator.Buttons
-
- ej.microui.event.generator.Pointer
-
public class Pointer extends Buttons
A pointer event generator represents a pointing device that is usually associated to a group of physical buttons. It reports the position of a pointing device as an x, y position within an area called pointer area. The size of the pointer area is set when the pointer is constructed and cannot be modified. When a pointer is pre-configured within a system its area is normally set to be the area of theDisplaywith which it is associated. The associated MicroUI event type isEVENT_TYPE.
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 thesetScale(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 bygetX()andgetX(). 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.
-
-
Field Summary
Fields Modifier and Type Field Description static intDRAGGEDConstant for "dragged" action.static intEVENT_TYPEThe POINTER event type returned bygetEventType().static intMOVEDConstant for "moved" action.
-
Constructor Summary
Constructors Constructor Description Pointer(int width, int height)Constructor with a specified area range (widthandheight) 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 (widthandheight) where elapsedTime, click and doubleClick features are supported and enabled for the firstnbButtons(doubleClick feature is initialized with a 200ms delay).
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetAbsoluteHeight()intgetAbsoluteWidth()intgetAbsoluteX()Returns the last available absolute x coordinate in pointer areaintgetAbsoluteY()Returns the last available absolute y coordinate in pointer areaintgetEventType()Gets the event type associated with the event generatorintgetHeight()intgetWidth()intgetX()Returns the last available x coordinate in scaled area (after applying any origin offset and the scale factor).intgetY()Returns the last available y coordinate in scaled area (after applying any origin offset and the scale factor).static booleanisDragged(int event)Tells if a pointer event is a drag event.static booleanisMoved(int event)Tells if a pointer event is a move event.voidmove(int x, int y)Stores the given position and sends a MicroUI Event to the Pointer's listener.voidreset(int x, int y)Stores the given position.voidsetOrigin(int x0, int y0)Sets an origin offset.voidsetScale(int areaWidth, int areaHeight)Sets a scaled area.-
Methods inherited from class ej.microui.event.generator.Buttons
buildEvent, clickEnabled, doubleClickEnabled, elapsedTime, enableClick, enableDoubleClick, getAction, getButtonId, isClicked, isDoubleClicked, isLong, isPressed, isReleased, isRepeated, send, supportsExtendedFeatures
-
Methods inherited from class ej.microui.event.EventGenerator
addToSystemPool, get, get, get, getEventHandler, getId, removeFromSystemPool, sendEvent, setEventHandler
-
-
-
-
Field Detail
-
EVENT_TYPE
public static final int EVENT_TYPE
The POINTER event type returned bygetEventType().- See Also:
- Constant Field Values
-
MOVED
public static final int MOVED
Constant for "moved" action.- See Also:
- Constant Field Values
-
DRAGGED
public static final int DRAGGED
Constant for "dragged" action.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Pointer
public Pointer(int nbButtons, int width, int height)Constructor with a specified area range (widthandheight) where elapsedTime, click and doubleClick features are supported and enabled for the firstnbButtons(doubleClick feature is initialized with a 200ms delay).- Parameters:
nbButtons- the number of buttons that support the extended featureswidth- area widthheight- area height
-
Pointer
public Pointer(int width, int height)Constructor with a specified area range (widthandheight) that does not support click, doubleClick nor elapsedTime for any of its buttons. The effect is identical to:
new Pointer(0, width, height).- Parameters:
width- area widthheight- area height
-
-
Method Detail
-
getAbsoluteWidth
public int getAbsoluteWidth()
- Returns:
- pointer area width
-
getAbsoluteHeight
public int getAbsoluteHeight()
- Returns:
- pointer area height
-
getEventType
public int getEventType()
Description copied from class:EventGeneratorGets the event type associated with the event generator- Overrides:
getEventTypein classButtons- Returns:
- the event type
-
getX
public int getX()
Returns the last available x coordinate in scaled area (after applying any origin offset and the scale factor).- Returns:
- last available x coordinate
- See Also:
getAbsoluteX()
-
getY
public int getY()
Returns the last available y coordinate in scaled area (after applying any origin offset and the scale factor).- Returns:
- last available y coordinate
- See Also:
getAbsoluteY()
-
getAbsoluteX
public int getAbsoluteX()
Returns the last available absolute x coordinate in pointer area- Returns:
- last available absolute x coordinate
-
getAbsoluteY
public int getAbsoluteY()
Returns the last available absolute y coordinate in pointer area- Returns:
- last available absolute y coordinate
-
setScale
public void setScale(int areaWidth, int areaHeight)Sets a scaled area. The x position returned bygetX()is scaled so that it returns a value between 0 and areaWidth-1. The x position returned bygetY()is scaled so that it returns a value between 0 and areaHeight-1.- Parameters:
areaWidth- the area widthareaHeight- the area height
-
setOrigin
public void setOrigin(int x0, int y0)Sets an origin offset. This offset is subtracted from the absolute position (before applying any scaling) when reporting x and y positions.- Parameters:
x0- the X coordinate of the new originy0- the Y coordinate of the new origin
-
getWidth
public int getWidth()
- Returns:
- the width of the scaled area
- See Also:
getX()
-
getHeight
public int getHeight()
- Returns:
- the height of the scaled area
- See Also:
getY()
-
move
public void move(int x, int y)Stores the given position and sends a MicroUI Event to the Pointer's listener. Coordinates are clipped to the pointer area.- Parameters:
x- the x coordinatey- the y coordinate
-
reset
public void reset(int x, int y)Stores the given position. The Pointer's listener is not notified. Coordinates are clipped to the pointer area.- Parameters:
x- the x coordinatey- the y coordinate
-
isMoved
public static boolean isMoved(int event)
Tells if a pointer event is a move event.- Parameters:
event- the pointer event.- Returns:
- true if the pointer event is a move event.
-
isDragged
public static boolean isDragged(int event)
Tells if a pointer event is a drag event.- Parameters:
event- the pointer event.- Returns:
- true if the pointer event is a drag event.
-
-