use of javafx.geometry.Rectangle2D in project TestFX by TestFX.
the class GlassRobotAdapterTest method getCaptureRegion.
@Test
public void getCaptureRegion() {
// given:
assumeThat(System.getenv("TRAVIS_OS_NAME"), is(not(equalTo("osx"))));
// when:
Bounds bounds = BoundsQueryUtils.boundsOnScreen(region);
Image regionImage = robotAdapter.getCaptureRegion(new Rectangle2D(bounds.getMinX(), bounds.getMinY(), bounds.getWidth(), bounds.getHeight()));
assertThat(regionImage.getPixelReader().getColor((int) regionImage.getWidth() / 2, (int) regionImage.getHeight() / 2), is(Color.web("magenta")));
}
use of javafx.geometry.Rectangle2D in project JavaFXLibrary by eficode.
the class TestMultipleWindowsController method openOtherWindows.
private void openOtherWindows() {
Parent root;
try {
secondWindow = new Stage();
thirdWindow = new Stage();
Rectangle2D screenBounds = Screen.getPrimary().getVisualBounds();
// Load FXML for secondWindow
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/javafxlibrary/ui/MultipleWindowsSubUIs/SecondUI.fxml"));
root = fxmlLoader.load();
// Second window settings
secondWindow.setScene(new Scene(root));
secondWindow.setTitle("Second window");
secondWindow.setX(screenBounds.getMinX() + 200);
secondWindow.initStyle(StageStyle.DECORATED);
secondWindow.getScene().setOnKeyPressed(event -> keyCombinationListener(event));
secondWindow.getScene().setOnKeyReleased(event -> keyReleaseListener(event));
secondWindow.show();
// Load FXML for thirdWindow
fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/javafxlibrary/ui/MultipleWindowsSubUIs/ThirdUI.fxml"));
root = fxmlLoader.load();
// Third window settings
thirdWindow.setScene(new Scene(root));
thirdWindow.setTitle("Third window");
thirdWindow.setX(screenBounds.getMinX() + 600);
thirdWindow.initStyle(StageStyle.DECORATED);
thirdWindow.getScene().setOnKeyPressed(event -> keyCombinationListener(event));
thirdWindow.getScene().setOnKeyReleased(event -> keyReleaseListener(event));
thirdWindow.show();
} catch (IOException | NullPointerException e) {
e.printStackTrace();
}
}
use of javafx.geometry.Rectangle2D in project JavaFXLibrary by eficode.
the class ConvenienceKeywords method getPrimaryScreenBounds.
@RobotKeyword("Returns the bounds of primary screen. \n")
public Object getPrimaryScreenBounds() {
try {
robotLog("INFO", "Getting the primary screen bounds");
Rectangle2D bounds = Screen.getPrimary().getVisualBounds();
return mapObject(new BoundingBox(bounds.getMinX(), bounds.getMinY(), bounds.getWidth(), bounds.getHeight()));
} catch (Exception e) {
throw new JavaFXLibraryNonFatalException("Unable to get primary screen bounds.", e);
}
}
use of javafx.geometry.Rectangle2D in project FXGL by AlmasB.
the class NoiseSample method initGame.
@Override
protected void initGame() {
Entities.builder().at(100, 100).viewFromNodeWithBBox(new Rectangle(40, 40)).with(new RandomMoveControl(100, 50, 350, new Rectangle2D(0, 0, X_MAX - 0, Y_MAX - 0))).buildAndAttach(getGameWorld());
Entities.builder().at(50, 350).viewFromNode(new Rectangle(15, 15, Color.DARKCYAN)).buildAndAttach(getGameWorld());
}
use of javafx.geometry.Rectangle2D in project FXGL by AlmasB.
the class BoundingBoxComponentTest method testRange.
@Test
public void testRange() throws Exception {
bbox.addHitBox(new HitBox("ARM", new Point2D(15, 15), BoundingShape.box(40, 60)));
Rectangle2D range = bbox.range(10, 10);
assertThat(range.getMinX(), is(15.0 - 10));
assertThat(range.getMinY(), is(15.0 - 10));
assertThat(range.getMaxX(), is(15.0 + 40 + 10));
assertThat(range.getMaxY(), is(15.0 + 60 + 10));
}
Aggregations