use of javafx.geometry.BoundingBox in project contentment by GeePawHill.
the class PointPairTest method constructors.
@Test
public void constructors() {
PointPair[] pairs = new PointPair[] { new PointPair(50d, 150d, 200d, 400d), new PointPair(new Point(50d, 150d), new Point(200d, 400d)), new PointPair(new BoundingBox(50d, 150d, 150d, 250d)), new PointPair(new Rectangle(50d, 150d, 150d, 250d)) };
for (PointPair pair : pairs) {
assertEquals(50d, pair.from.x, 0.0001);
assertEquals(150d, pair.from.y, 0.0001);
assertEquals(200d, pair.to.x, 0.0001);
assertEquals(400d, pair.to.y, 0.0001);
}
}
use of javafx.geometry.BoundingBox in project RichTextFX by FXMisc.
the class GenericStyledArea method getSelectionBoundsOnScreen.
final Optional<Bounds> getSelectionBoundsOnScreen(Selection<PS, SEG, S> selection) {
if (selection.getLength() == 0) {
return Optional.empty();
}
List<Bounds> bounds = new ArrayList<>(selection.getParagraphSpan());
for (int i = selection.getStartParagraphIndex(); i <= selection.getEndParagraphIndex(); i++) {
virtualFlow.getCellIfVisible(i).ifPresent(c -> c.getNode().getSelectionBoundsOnScreen(selection).ifPresent(bounds::add));
}
if (bounds.size() == 0) {
return Optional.empty();
}
double minX = bounds.stream().mapToDouble(Bounds::getMinX).min().getAsDouble();
double maxX = bounds.stream().mapToDouble(Bounds::getMaxX).max().getAsDouble();
double minY = bounds.stream().mapToDouble(Bounds::getMinY).min().getAsDouble();
double maxY = bounds.stream().mapToDouble(Bounds::getMaxY).max().getAsDouble();
return Optional.of(new BoundingBox(minX, minY, maxX - minX, maxY - minY));
}
use of javafx.geometry.BoundingBox in project RichTextFX by FXMisc.
the class GenericStyledArea method getParagraphBoundsOnScreen.
private Bounds getParagraphBoundsOnScreen(Cell<Paragraph<PS, SEG, S>, ParagraphBox<PS, SEG, S>> cell) {
Bounds nodeLocal = cell.getNode().getBoundsInLocal();
Bounds nodeScreen = cell.getNode().localToScreen(nodeLocal);
Bounds areaLocal = getBoundsInLocal();
Bounds areaScreen = localToScreen(areaLocal);
// use area's minX if scrolled right and paragraph's left is not visible
double minX = nodeScreen.getMinX() < areaScreen.getMinX() ? areaScreen.getMinX() : nodeScreen.getMinX();
// use area's minY if scrolled down vertically and paragraph's top is not visible
double minY = nodeScreen.getMinY() < areaScreen.getMinY() ? areaScreen.getMinY() : nodeScreen.getMinY();
// use area's width whether paragraph spans outside of it or not
// so that short or long paragraph takes up the entire space
double width = areaScreen.getWidth();
// use area's maxY if scrolled up vertically and paragraph's bottom is not visible
double maxY = nodeScreen.getMaxY() < areaScreen.getMaxY() ? nodeScreen.getMaxY() : areaScreen.getMaxY();
return new BoundingBox(minX, minY, width, maxY - minY);
}
use of javafx.geometry.BoundingBox in project JavaFXLibrary by eficode.
the class TestDragRobotController method checkCirclePosition.
private boolean checkCirclePosition() {
Bounds windowBounds = new BoundingBox(secondStage.getX(), secondStage.getY(), secondStage.getWidth(), secondStage.getHeight());
Bounds testi = circle.localToScreen(circle.getBoundsInLocal());
return testi.intersects(windowBounds);
}
use of javafx.geometry.BoundingBox in project TestFX by TestFX.
the class BoundsQueryUtilsTest method boundsOnScreen_scene.
@Test
public void boundsOnScreen_scene() {
Bounds bounds = BoundsQueryUtils.boundsOnScreen(new BoundingBox(1, 2, 3, 4), scene);
verifyThat(bounds, hasBounds(stage.getX() + 1, stage.getY() + 2, 3, 4));
}
Aggregations