Search in sources :

Example 11 with BoundingBox

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);
    }
}
Also used : BoundingBox(javafx.geometry.BoundingBox) Rectangle(javafx.scene.shape.Rectangle) Test(org.junit.Test)

Example 12 with BoundingBox

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));
}
Also used : Bounds(javafx.geometry.Bounds) BoundingBox(javafx.geometry.BoundingBox) ArrayList(java.util.ArrayList) Paint(javafx.scene.paint.Paint)

Example 13 with BoundingBox

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);
}
Also used : Bounds(javafx.geometry.Bounds) BoundingBox(javafx.geometry.BoundingBox)

Example 14 with BoundingBox

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);
}
Also used : Bounds(javafx.geometry.Bounds) BoundingBox(javafx.geometry.BoundingBox)

Example 15 with BoundingBox

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));
}
Also used : Bounds(javafx.geometry.Bounds) BoundingBox(javafx.geometry.BoundingBox) Test(org.junit.Test)

Aggregations

BoundingBox (javafx.geometry.BoundingBox)23 Bounds (javafx.geometry.Bounds)11 Test (org.junit.Test)7 Point2D (javafx.geometry.Point2D)6 Node (javafx.scene.Node)4 ArrayList (java.util.ArrayList)3 List (java.util.List)2 DoubleProperty (javafx.beans.property.DoubleProperty)2 ObjectProperty (javafx.beans.property.ObjectProperty)2 SimpleDoubleProperty (javafx.beans.property.SimpleDoubleProperty)2 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)2 Rectangle2D (javafx.geometry.Rectangle2D)2 Paint (javafx.scene.paint.Paint)2 Rectangle (javafx.scene.shape.Rectangle)2 JavaFXLibraryNonFatalException (javafxlibrary.exceptions.JavaFXLibraryNonFatalException)2 RobotKeyword (org.robotframework.javalib.annotation.RobotKeyword)2 BSBObject (blue.orchestra.blueSynthBuilder.BSBObject)1 ShapeType (com.almasb.fxgl.physics.box2d.collision.shapes.ShapeType)1 CachedTransition (com.jfoenix.transitions.CachedTransition)1 RectBounds (com.sun.javafx.geom.RectBounds)1