use of javafx.geometry.Rectangle2D in project TestFX by TestFX.
the class JavafxRobotAdapterTest method getCaptureRegion.
@Test
public void getCaptureRegion() throws InterruptedException {
assumeThat("skipping: screen capture on macOS uses configured display's color profile", System.getenv("TRAVIS_OS_NAME"), is(not(equalTo("osx"))));
// given:
CountDownLatch captureRegionLatch = new CountDownLatch(1);
// when:
Rectangle2D region = new Rectangle2D(regionPoint.getX(), regionPoint.getY(), 10, 20);
CompletableFuture<Image> captureRegionFutureResult = new CompletableFuture<>();
Platform.runLater(() -> captureRegionFutureResult.complete(robotAdapter.getCaptureRegion(region)));
// then:
captureRegionFutureResult.whenComplete((regionImage, throwable) -> {
if (throwable != null) {
fail("JavafxRobotAdapter.getCaptureRegion(..) should not have completed exceptionally");
} else {
assertThat(regionImage.getWidth(), is(10.0));
assertThat(regionImage.getHeight(), is(20.0));
assertThat(regionImage.getPixelReader().getColor(5, 10), is(Color.MAGENTA));
captureRegionLatch.countDown();
}
});
assertThat(captureRegionLatch.await(5, TimeUnit.SECONDS), is(true));
}
use of javafx.geometry.Rectangle2D in project TestFX by TestFX.
the class AwtRobotAdapter method getCapturePixelColor.
@Override
public Color getCapturePixelColor(Point2D location) {
Rectangle2D region = new Rectangle2D(location.getX(), location.getY(), 1, 1);
Image image = getCaptureRegion(region);
return image.getPixelReader().getColor(0, 0);
}
use of javafx.geometry.Rectangle2D in project TestFX by TestFX.
the class FxRobot method capture.
@Override
public Capture capture(Bounds bounds) {
Rectangle2D region = new Rectangle2D(bounds.getMinX(), bounds.getMinY(), bounds.getWidth(), bounds.getHeight());
Image image = context.getCaptureSupport().captureRegion(region);
return () -> image;
}
use of javafx.geometry.Rectangle2D in project FXGL by AlmasB.
the class QuadSample method initGame.
@Override
protected void initGame() {
getGameScene().setBackgroundColor(Color.BLACK);
Texture ship = texture("player2.png");
double h = 7;
System.out.println(h);
for (int i = 0; i < 10; i++) {
Texture quad = ship.subTexture(new Rectangle2D(0, i * h, ship.getImage().getWidth(), h));
quad.setTranslateY(100 + i * h);
originals.add(quad);
textures.add(quad.copy());
textures2.add(quad.toColor(Color.RED));
getGameScene().addUINode(quad);
}
}
use of javafx.geometry.Rectangle2D in project loinc2hpo by monarch-initiative.
the class GitHubPopup method adjustStagePosition.
/**
* Ensure that popup Stage will be displayed on the same monitor as the parent Stage
*
* @param childStage reference to new window that will appear
* @param parentStage reference to the primary stage
* @return a new Stage to display a dialog.
*/
private static Stage adjustStagePosition(Stage childStage, Stage parentStage) {
ObservableList<Screen> screensForParentWindow = Screen.getScreensForRectangle(parentStage.getX(), parentStage.getY(), parentStage.getWidth(), parentStage.getHeight());
Screen actual = screensForParentWindow.get(0);
Rectangle2D bounds = actual.getVisualBounds();
// set top left position to 35%/25% of screen/monitor width & height
childStage.setX(bounds.getWidth() * 0.35);
childStage.setY(bounds.getHeight() * 0.25);
return childStage;
}
Aggregations