- java.lang.Object
-
- org.testfx.service.adapter.impl.JavafxRobotAdapter
-
- All Implemented Interfaces:
RobotAdapter<JavafxRobotAdapter>
public class JavafxRobotAdapter extends Object implements RobotAdapter<JavafxRobotAdapter>
ARobotAdapterimplementation that uses the only the JavaFX public API.Developer's Note: Forcing the type parameter to be
JavafxRobotAdapteris a bit of a kludge. Ideally we would use aJavafxRobotinstead but such a type does not exist.
-
-
Constructor Summary
Constructors Constructor Description JavafxRobotAdapter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ColorgetCapturePixelColor(Point2D location)Gets the color of a pixel at the given JavaFx coordinates.ImagegetCaptureRegion(Rectangle2D region)Captures a region of the screen.Point2DgetMouseLocation()Returns the current position of the cursor in JavaFx coordinatesvoidkeyPress(KeyCode key)Function used to make the robot press a key.voidkeyRelease(KeyCode key)Function used to make the robot release a key.voidkeyType(KeyCode key, String character)voidmouseClick(MouseButton button)voidmouseClick(MouseButton button, int clickCount)voidmouseDrag(MouseButton button)voidmouseMove(Point2D location)Moves the mouse cursor to the given position in JavaFx coordinatesvoidmousePress(MouseButton button)Makes the robot press a mouse button.voidmousePress(MouseButton button, int clickCount)voidmouseRelease(MouseButton button)Makes the robot release a mouse button.voidmouseRelease(MouseButton button, int clickCount)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.voidrobotCreate()Creates a robot.voidrobotCreate(Scene scene)voidrobotDestroy()Destroys the robot
-
-
-
Method Detail
-
robotCreate
public void robotCreate(Scene scene)
-
robotCreate
public void robotCreate()
Description copied from interface:RobotAdapterCreates a robot.- Specified by:
robotCreatein interfaceRobotAdapter<JavafxRobotAdapter>
-
robotDestroy
public void robotDestroy()
Description copied from interface:RobotAdapterDestroys the robot- Specified by:
robotDestroyin interfaceRobotAdapter<JavafxRobotAdapter>
-
keyPress
public void keyPress(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<JavafxRobotAdapter>- Parameters:
key- the key to press (must exist on a keyboard)
-
keyRelease
public void keyRelease(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<JavafxRobotAdapter>- Parameters:
key- the key to press (must exist on a keyboard)
-
getMouseLocation
public Point2D getMouseLocation()
Description copied from interface:RobotAdapterReturns the current position of the cursor in JavaFx coordinates- Specified by:
getMouseLocationin interfaceRobotAdapter<JavafxRobotAdapter>- Returns:
- the current position of the mouse cursor
-
mouseMove
public void mouseMove(Point2D location)
Description copied from interface:RobotAdapterMoves the mouse cursor to the given position in JavaFx coordinates- Specified by:
mouseMovein interfaceRobotAdapter<JavafxRobotAdapter>- Parameters:
location- the location in JavaFx coordinates to move the cursor to
-
mousePress
public void mousePress(MouseButton button, int clickCount)
-
mouseRelease
public void mouseRelease(MouseButton button, int clickCount)
-
mouseClick
public void mouseClick(MouseButton button, int clickCount)
-
mousePress
public void mousePress(MouseButton button)
Description copied from interface:RobotAdapterMakes the robot press a mouse button.- Specified by:
mousePressin interfaceRobotAdapter<JavafxRobotAdapter>- Parameters:
button- the button to press
-
mouseRelease
public void mouseRelease(MouseButton button)
Description copied from interface:RobotAdapterMakes the robot release a mouse button.- Specified by:
mouseReleasein interfaceRobotAdapter<JavafxRobotAdapter>- Parameters:
button- the button to release
-
mouseClick
public void mouseClick(MouseButton button)
-
mouseDrag
public void mouseDrag(MouseButton button)
-
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<JavafxRobotAdapter>- Parameters:
wheelAmount- the amount to scroll
-
getCapturePixelColor
public Color getCapturePixelColor(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<JavafxRobotAdapter>- 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 Image getCaptureRegion(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<JavafxRobotAdapter>- Parameters:
region- the region to capture in JavaFx coordinates- Returns:
- a image of the region
-
-