Class MouseCursor
- All Implemented Interfaces:
IRenderable
The visual representation of the Mouse in the LITIENGINE.
It controls the appearance of the rendered cursor and allows to specify offsets from the actual mouse location.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetImage()Gets the image currently used to render the cursor.intGets the horizontal pixel offset from the actual mouse location to the rendered cursor.intGets the vertical pixel offset from the actual mouse location to the rendered cursor.Gets the affine transform applied to the cursor image when it is rendered.voidHides the native system cursor by replacing it with an empty cursor on the game window.booleanDetermines whether the cursor is currently visible (and will thereby be rendered), by checking thevisibleflag and whether the specified cursor image is null.voidrender(Graphics2D g) Renders the visual contents of this instance onto the provided graphics context.voidSets the cursor image, anchored at its top-left corner.voidSets the cursor image with the supplied pixel offsets.voidSets the cursor image, computing the pixel offset so that the supplied alignment is anchored to the actual mouse location.voidsetOffset(int x, int y) Sets the cursor offsets.voidsetOffsetX(int cursorOffsetX) Sets the horizontal cursor offset.voidsetOffsetY(int cursorOffsetY) Sets the vertical cursor offset.voidsetTransform(AffineTransform transform) Sets the affine transform applied to the cursor image when it is rendered.voidsetVisible(boolean visible) Sets whether the cursor is visible.voidRestores the native system cursor on the game window.
-
Constructor Details
-
MouseCursor
public MouseCursor()Initializes a new instance of theMouseCursorclass.
-
-
Method Details
-
render
Description copied from interface:IRenderableRenders the visual contents of this instance onto the provided graphics context.
If an
Entityimplements this interface, this method will be called right after the entity was rendered from the environment. Allowing for a custom rendering mechanism.This interface can be implemented in general by anything that should be rendered to the game's screen.
- Specified by:
renderin interfaceIRenderable- Parameters:
g- The current graphics object onto which this instance will render its visual contents.- See Also:
-
getImage
Gets the image currently used to render the cursor.- Returns:
- the cursor image, or
nullif none is set
-
getTransform
Gets the affine transform applied to the cursor image when it is rendered.- Returns:
- the cursor transform
-
getOffsetX
public int getOffsetX()Gets the horizontal pixel offset from the actual mouse location to the rendered cursor.- Returns:
- the horizontal offset
-
getOffsetY
public int getOffsetY()Gets the vertical pixel offset from the actual mouse location to the rendered cursor.- Returns:
- the vertical offset
-
isVisible
public boolean isVisible()Determines whether the cursor is currently visible (and will thereby be rendered), by checking thevisibleflag and whether the specified cursor image is null.- Returns:
- True if the cursor is currently visible; otherwise false.
-
set
Sets the cursor image, anchored at its top-left corner.- Parameters:
img- the cursor image
-
set
Sets the cursor image with the supplied pixel offsets. If a non-nullimage is set, the native system cursor is hidden; otherwise it is restored (unless the mouse is grabbed).- Parameters:
img- the cursor image; may benullto clear the cursoroffsetX- the horizontal offsetoffsetY- the vertical offset
-
set
Sets the cursor image, computing the pixel offset so that the supplied alignment is anchored to the actual mouse location.- Parameters:
img- the cursor imagehAlign- the horizontal alignment of the anchorvAlign- the vertical alignment of the anchor
-
setOffset
public void setOffset(int x, int y) Sets the cursor offsets.- Parameters:
x- the horizontal offsety- the vertical offset
-
setOffsetX
public void setOffsetX(int cursorOffsetX) Sets the horizontal cursor offset.- Parameters:
cursorOffsetX- the horizontal offset
-
setOffsetY
public void setOffsetY(int cursorOffsetY) Sets the vertical cursor offset.- Parameters:
cursorOffsetY- the vertical offset
-
setTransform
Sets the affine transform applied to the cursor image when it is rendered.- Parameters:
transform- the transform
-
setVisible
public void setVisible(boolean visible) Sets whether the cursor is visible.- Parameters:
visible-trueto show the cursor
-
showDefaultCursor
public void showDefaultCursor()Restores the native system cursor on the game window. -
hideDefaultCursor
public void hideDefaultCursor()Hides the native system cursor by replacing it with an empty cursor on the game window.
-