Package org.testfx.service.adapter.impl
Class AwtRobotAdapter
java.lang.Object
org.testfx.service.adapter.impl.AwtRobotAdapter
- All Implemented Interfaces:
RobotAdapter<Robot>
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate intconvertToAwtButton(javafx.scene.input.MouseButton button) private Robotjavafx.scene.paint.ColorgetCapturePixelColor(javafx.geometry.Point2D location) Gets the color of a pixel at the given JavaFx coordinates.javafx.scene.image.ImagegetCaptureRegion(javafx.geometry.Rectangle2D region) Captures a region of the screen.javafx.scene.image.ImagegetCaptureRegionRaw(javafx.geometry.Rectangle2D region) javafx.geometry.Point2DReturns the current position of the cursor in JavaFx coordinatesvoidkeyPress(javafx.scene.input.KeyCode key) Function used to make the robot press a key.voidkeyRelease(javafx.scene.input.KeyCode key) Function used to make the robot release a key.voidmouseMove(javafx.geometry.Point2D location) Moves the mouse cursor to the given position in JavaFx coordinatesvoidmousePress(javafx.scene.input.MouseButton button) Makes the robot press a mouse button.voidmouseRelease(javafx.scene.input.MouseButton button) Makes the robot release a mouse button.voidmouseWheel(int wheelAmount) Makes the robot to simulate a action of the mouse wheel.
Negative values indicate movement up/away from the user, positive values indicate movement down/towards the user.voidCreates a robot.voidDestroys the robotprivate javafx.geometry.Point2DscaleInverseRect(javafx.geometry.Point2D pt) private javafx.geometry.Rectangle2DscaleRect(javafx.geometry.Rectangle2D rect) private booleanprivate RobotuseRobot()
-
Field Details
-
awtRobot
-
-
Constructor Details
-
AwtRobotAdapter
public AwtRobotAdapter()
-
-
Method Details
-
robotCreate
public void robotCreate()Description copied from interface:RobotAdapterCreates a robot.- Specified by:
robotCreatein interfaceRobotAdapter<Robot>
-
robotDestroy
public void robotDestroy()Description copied from interface:RobotAdapterDestroys the robot- Specified by:
robotDestroyin interfaceRobotAdapter<Robot>
-
keyPress
public void keyPress(javafx.scene.input.KeyCode key) Description copied from interface:RobotAdapterFunction used to make the robot press a key. The key must be a physical existing key on the keyboard.- Specified by:
keyPressin interfaceRobotAdapter<Robot>- Parameters:
key- the key to press (must exist on a keyboard)
-
keyRelease
public void keyRelease(javafx.scene.input.KeyCode key) Description copied from interface:RobotAdapterFunction used to make the robot release a key. The key must be a physical existing key on the keyboard.- Specified by:
keyReleasein interfaceRobotAdapter<Robot>- Parameters:
key- the key to press (must exist on a keyboard)
-
getMouseLocation
public javafx.geometry.Point2D getMouseLocation()Description copied from interface:RobotAdapterReturns the current position of the cursor in JavaFx coordinates- Specified by:
getMouseLocationin interfaceRobotAdapter<Robot>- Returns:
- the current position of the mouse cursor
-
mouseMove
public void mouseMove(javafx.geometry.Point2D location) Description copied from interface:RobotAdapterMoves the mouse cursor to the given position in JavaFx coordinates- Specified by:
mouseMovein interfaceRobotAdapter<Robot>- Parameters:
location- the location in JavaFx coordinates to move the cursor to
-
mousePress
public void mousePress(javafx.scene.input.MouseButton button) Description copied from interface:RobotAdapterMakes the robot press a mouse button.- Specified by:
mousePressin interfaceRobotAdapter<Robot>- Parameters:
button- the button to press
-
mouseRelease
public void mouseRelease(javafx.scene.input.MouseButton button) Description copied from interface:RobotAdapterMakes the robot release a mouse button.- Specified by:
mouseReleasein interfaceRobotAdapter<Robot>- Parameters:
button- the button to release
-
mouseWheel
public void mouseWheel(int wheelAmount) Description copied from interface:RobotAdapterMakes the robot to simulate a action of the mouse wheel.
Negative values indicate movement up/away from the user, positive values indicate movement down/towards the user.- Specified by:
mouseWheelin interfaceRobotAdapter<Robot>- Parameters:
wheelAmount- the amount to scroll
-
getCapturePixelColor
public javafx.scene.paint.Color getCapturePixelColor(javafx.geometry.Point2D location) Description copied from interface:RobotAdapterGets the color of a pixel at the given JavaFx coordinates. The returned Color is in the JavaFx color space. //TODO Due to technical reasons, there might be a deviation in color.- Specified by:
getCapturePixelColorin interfaceRobotAdapter<Robot>- Parameters:
location- of the pixel in JavaFx coordinates, to retrieve the color for- Returns:
- the Color of the given Pixel in the JavaFx color space
-
getCaptureRegion
public javafx.scene.image.Image getCaptureRegion(javafx.geometry.Rectangle2D region) Description copied from interface:RobotAdapterCaptures a region of the screen. The returned Image is in the JavaFx color space. //TODO Due to technical reasons, there might be a deviation.- Specified by:
getCaptureRegionin interfaceRobotAdapter<Robot>- Parameters:
region- the region to capture in JavaFx coordinates- Returns:
- a image of the region
-
getCaptureRegionRaw
public javafx.scene.image.Image getCaptureRegionRaw(javafx.geometry.Rectangle2D region) -
useRobot
-
createAwtRobot
-
convertToAwtButton
private int convertToAwtButton(javafx.scene.input.MouseButton button) -
scaleRect
private javafx.geometry.Rectangle2D scaleRect(javafx.geometry.Rectangle2D rect) -
scaleInverseRect
private javafx.geometry.Point2D scaleInverseRect(javafx.geometry.Point2D pt) -
scaleRequired
private boolean scaleRequired()
-