Top Fields Constructors Methods
com.sun.glass.ui

public abstract Class GlassRobot

extends Object
Class Inheritance
Known Direct Subclasses
com.sun.glass.ui.gtk.GtkRobot, com.sun.glass.ui.ios.IosRobot, com.sun.glass.ui.mac.MacRobot, com.sun.glass.ui.monocle.MonocleRobot, com.sun.glass.ui.win.WinRobot
Imports
java.lang.annotation.Native, java.nio.ByteBuffer, .IntBuffer, java.util.Objects, javafx.scene.image.Image, .PixelWriter, .WritableImage, javafx.scene.input.KeyCode, .MouseButton, javafx.scene.paint.Color, javafx.stage.Screen, com.sun.javafx.image.PixelUtils

Field Summary

Modifier and TypeField and Description
public static final int
public static final int
public static final int
public static final int
public static final int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static int
bgraPreToRgbaPre(int bgraPre)

public static Color
convertFromIntArgb(int color)

protected static WritableImage
public static int
public abstract void
create()

Initializes any state necessary for this Robot.

public abstract void
destroy()

Frees any resources allocated by this Robot.

public abstract double

Returns:

the current mouse x-position
getMouseX
()

Returns the current mouse x-position.

public abstract double

Returns:

the current mouse y-position
getMouseY
()

Returns the current mouse y-position.

public abstract Color

Returns:

the pixel color at the specified screen coordinates
getPixelColor
(double
the x coordinate to get the pixel color from
x
,
double
the y coordinate to get the pixel color from
y
)

Returns the Color of the pixel at the screen coordinates relative to the primary screen specified by location.

public void
getScreenCapture(int
the starting x-position of the rectangular area to capture
x
,
int
the starting y-position of the rectangular area to capture
y
,
int
the width of the rectangular area to capture
width
,
int
the height of the rectangular area to capture
height
,
int[]
the array to fill with the raw pixel data corresponding to the captured region
data
,
boolean
If true the returned Image will be scaled to fit the request dimensions, if necessary. Otherwise the size of the returned image will depend on the output scale (DPI) of the primary screen.
scaleToFit
)

Captures the specified rectangular area of the screen and uses it to fill the given data array with the raw pixel data.

public WritableImage
getScreenCapture(WritableImage image, double
the starting x-position of the rectangular area to capture
x
,
double
the starting y-position of the rectangular area to capture
y
,
double
the width of the rectangular area to capture
width
,
double
the height of the rectangular area to capture
height
,
boolean
If true the returned Image will be scaled to fit the request dimensions, if necessary. Otherwise the size of the returned image will depend on the output scale (DPI) of the primary screen.
scaleToFit
)

Returns an Image containing the specified rectangular area of the screen.

private static int
interp(int[] pixels, int x, int y, int w, int h, int fractx1, int fracty1)

private static int
interp(int rgb0, int rgb1, int fract0, int fract1)

public abstract void
keyPress(KeyCode
the key to press
keyCode
)

Presses the specified KeyCode key.

public abstract void
keyRelease(KeyCode
the key to release
keyCode
)

Releases the specified KeyCode key.

public abstract void
mouseMove(double
screen coordinate x to move the mouse to
x
,
double
screen coordinate y to move the mouse to
y
)

Moves the mouse to the specified (x,y) screen coordinates relative to the primary screen.

public abstract void
mousePress(MouseButton...
the mouse buttons to press
buttons
)

Presses the specified MouseButtons.

public abstract void
mouseRelease(MouseButton...
the mouse buttons to release
buttons
)

Releases the specified MouseButtons.

public abstract void
mouseWheel(int
the (signed) amount of clicks to scroll the wheel
wheelAmt
)

Scrolls the mouse wheel by the specified amount of wheel clicks.

private static void
private static void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

MOUSE_BACK_BTNback to summary
public static final int MOUSE_BACK_BTN
Annotations
@Native
MOUSE_FORWARD_BTNback to summary
public static final int MOUSE_FORWARD_BTN
Annotations
@Native
MOUSE_LEFT_BTNback to summary
public static final int MOUSE_LEFT_BTN
Annotations
@Native
MOUSE_MIDDLE_BTNback to summary
public static final int MOUSE_MIDDLE_BTN
Annotations
@Native
MOUSE_RIGHT_BTNback to summary
public static final int MOUSE_RIGHT_BTN
Annotations
@Native

Constructor Detail

GlassRobotback to summary
public GlassRobot()

Method Detail

bgraPreToRgbaPreback to summary
private static int bgraPreToRgbaPre(int bgraPre)
convertFromIntArgbback to summary
public static Color convertFromIntArgb(int color)
convertFromPixelsback to summary
protected static WritableImage convertFromPixels(WritableImage image, Pixels pixels)
convertToRobotMouseButtonback to summary
public static int convertToRobotMouseButton(MouseButton[] buttons)
createback to summary
public abstract void create()

Initializes any state necessary for this Robot. Called by the Robot constructor.

destroyback to summary
public abstract void destroy()

Frees any resources allocated by this Robot.

getMouseXback to summary
public abstract double getMouseX()

Returns the current mouse x-position.

Returns:double

the current mouse x-position

getMouseYback to summary
public abstract double getMouseY()

Returns the current mouse y-position.

Returns:double

the current mouse y-position

getPixelColorback to summary
public abstract Color getPixelColor(double x, double y)

Returns the Color of the pixel at the screen coordinates relative to the primary screen specified by location. Regardless of the scale of the screen (Screen#getOutputScaleX(), Screen#getOutputScaleY()), this method only samples a single pixel. For example, on a HiDPI screen with output scale 2, the screen unit at the point (x,y) may have 4 pixels. In this case the color returned is the color of the top, left pixel. Color values are not averaged when a screen unit is made up of more than one pixel.

Parameters
x:double

the x coordinate to get the pixel color from

y:double

the y coordinate to get the pixel color from

Returns:Color

the pixel color at the specified screen coordinates

getScreenCaptureback to summary
public void getScreenCapture(int x, int y, int width, int height, int[] data, boolean scaleToFit)

Captures the specified rectangular area of the screen and uses it to fill the given data array with the raw pixel data. The data is in RGBA format where each pixel in the image is encoded as 4 bytes - one for each color component of each pixel. If this method is not overridden by subclasses then getScreenCapture(WritableImage, double, double, double, double, boolean) must be overridden to not call this method.

Parameters
x:int

the starting x-position of the rectangular area to capture

y:int

the starting y-position of the rectangular area to capture

width:int

the width of the rectangular area to capture

height:int

the height of the rectangular area to capture

data:int[]

the array to fill with the raw pixel data corresponding to the captured region

scaleToFit:boolean

If true the returned Image will be scaled to fit the request dimensions, if necessary. Otherwise the size of the returned image will depend on the output scale (DPI) of the primary screen.

getScreenCaptureback to summary
public WritableImage getScreenCapture(WritableImage image, double x, double y, double width, double height, boolean scaleToFit)

Returns an Image containing the specified rectangular area of the screen.

If the scaleToFit argument is false, the returned Image object dimensions may differ from the requested width and height depending on how many physical pixels the area occupies on the screen. E.g. in HiDPI mode on the Mac (aka Retina display) the pixels are doubled, and thus a screen capture of an area of size (10x10) pixels will result in an Image with dimensions (20x20). Calling code should use the returned images's {@link Image#getWidth() and {@link Image#getHeight() methods to determine the actual image size.

If scaleToFit is true, the returned Image is of the requested size. Note that in this case the image will be scaled in order to fit to the requested dimensions if necessary such as when running on a HiDPI display.

Parameters
x:double

the starting x-position of the rectangular area to capture

y:double

the starting y-position of the rectangular area to capture

width:double

the width of the rectangular area to capture

height:double

the height of the rectangular area to capture

scaleToFit:boolean

If true the returned Image will be scaled to fit the request dimensions, if necessary. Otherwise the size of the returned image will depend on the output scale (DPI) of the primary screen.

interpback to summary
private static int interp(int[] pixels, int x, int y, int w, int h, int fractx1, int fracty1)
interpback to summary
private static int interp(int rgb0, int rgb1, int fract0, int fract1)
keyPressback to summary
public abstract void keyPress(KeyCode keyCode)

Presses the specified KeyCode key.

Parameters
keyCode:KeyCode

the key to press

keyReleaseback to summary
public abstract void keyRelease(KeyCode keyCode)

Releases the specified KeyCode key.

Parameters
keyCode:KeyCode

the key to release

mouseMoveback to summary
public abstract void mouseMove(double x, double y)

Moves the mouse to the specified (x,y) screen coordinates relative to the primary screen.

Parameters
x:double

screen coordinate x to move the mouse to

y:double

screen coordinate y to move the mouse to

mousePressback to summary
public abstract void mousePress(MouseButton... buttons)

Presses the specified MouseButtons.

Parameters
buttons:MouseButton[]

the mouse buttons to press

mouseReleaseback to summary
public abstract void mouseRelease(MouseButton... buttons)

Releases the specified MouseButtons.

Parameters
buttons:MouseButton[]

the mouse buttons to release

mouseWheelback to summary
public abstract void mouseWheel(int wheelAmt)

Scrolls the mouse wheel by the specified amount of wheel clicks. A positive wheelAmt scrolls the wheel towards the user (down) whereas negative amounts scrolls the wheel away from the user (up).

Parameters
wheelAmt:int

the (signed) amount of clicks to scroll the wheel

writeByteBufferToImageback to summary
private static void writeByteBufferToImage(ByteBuffer byteBuffer, WritableImage image)
writeIntBufferToImageback to summary
private static void writeIntBufferToImage(IntBuffer intBuffer, WritableImage image)