Search in sources :

Example 1 with BoundingBox

use of javafx.geometry.BoundingBox in project jphp by jphp-compiler.

the class DndTabPaneFactory method handleOutline.

private static MarkerFeedback handleOutline(Pane layoutNode, FeedbackData data) {
    TabOutlineMarker marker = null;
    for (Node n : layoutNode.getChildren()) {
        if (n instanceof TabOutlineMarker) {
            marker = (TabOutlineMarker) n;
        }
    }
    if (marker == null) {
        marker = new TabOutlineMarker(layoutNode.getBoundsInLocal(), new BoundingBox(data.bounds.getMinX(), data.bounds.getMinY(), data.bounds.getWidth(), data.bounds.getHeight()), data.dropType == DropType.BEFORE);
        marker.setManaged(false);
        marker.setMouseTransparent(true);
        layoutNode.getChildren().add(marker);
    } else {
        marker.updateBounds(layoutNode.getBoundsInLocal(), new BoundingBox(data.bounds.getMinX(), data.bounds.getMinY(), data.bounds.getWidth(), data.bounds.getHeight()), data.dropType == DropType.BEFORE);
        marker.setVisible(true);
    }
    final TabOutlineMarker fmarker = marker;
    return new MarkerFeedback(data) {

        @Override
        public void hide() {
            fmarker.setVisible(false);
        }
    };
}
Also used : Node(javafx.scene.Node) BoundingBox(javafx.geometry.BoundingBox) TabOutlineMarker(org.develnext.jphp.ext.javafx.support.control.markers.TabOutlineMarker)

Example 2 with BoundingBox

use of javafx.geometry.BoundingBox in project FXGL by AlmasB.

the class HitBox method readObject.

private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
    name = (String) in.readObject();
    bounds = new BoundingBox(in.readDouble(), in.readDouble(), in.readDouble(), in.readDouble());
    Dimension2D size = new Dimension2D(in.readDouble(), in.readDouble());
    ShapeType type = (ShapeType) in.readObject();
    switch(type) {
        case CIRCLE:
            shape = BoundingShape.circle(size.getWidth() / 2);
            break;
        case POLYGON:
            shape = BoundingShape.box(size.getWidth(), size.getHeight());
            break;
        case CHAIN:
            int length = in.readInt();
            Point2D[] points = new Point2D[length];
            for (int i = 0; i < length; i++) {
                points[i] = new Point2D(in.readDouble(), in.readDouble());
            }
            shape = BoundingShape.chain(points);
            break;
        default:
            throw new IllegalArgumentException("Unknown shape type");
    }
}
Also used : Point2D(javafx.geometry.Point2D) BoundingBox(javafx.geometry.BoundingBox) Dimension2D(javafx.geometry.Dimension2D) ShapeType(com.almasb.fxgl.physics.box2d.collision.shapes.ShapeType)

Example 3 with BoundingBox

use of javafx.geometry.BoundingBox in project gs-ui-javafx by graphstream.

the class FxTextBox method setText.

/**
 * Changes the text and compute its bounds. This method tries to avoid recomputing bounds
 *  if the text does not really changed.
 */
public void setText(String text, Backend backend) {
    if (text != null && text.length() > 0) {
        if (textData != text || !textData.equals(text)) {
            this.textData = text;
            this.text = new Text(text);
            this.text.setBoundsType(TextBoundsType.LOGICAL);
            this.bounds = this.text.getBoundsInLocal();
        } else {
            this.textData = null;
            this.text = null;
            this.bounds = new BoundingBox(0, 0, 0, 0);
        }
    }
}
Also used : BoundingBox(javafx.geometry.BoundingBox) Text(javafx.scene.text.Text)

Example 4 with BoundingBox

use of javafx.geometry.BoundingBox in project RichTextFX by FXMisc.

the class GenericStyledArea method getCharacterBoundsOnScreen.

@Override
public Optional<Bounds> getCharacterBoundsOnScreen(int from, int to) {
    if (from < 0) {
        throw new IllegalArgumentException("From is negative: " + from);
    }
    if (from > to) {
        throw new IllegalArgumentException(String.format("From is greater than to. from=%s to=%s", from, to));
    }
    if (to > getLength()) {
        throw new IllegalArgumentException(String.format("To is greater than area's length. length=%s, to=%s", getLength(), to));
    }
    // no bounds exist if range is just a newline character
    if (getText(from, to).equals("\n")) {
        return Optional.empty();
    }
    // if 'from' is the newline character at the end of a multi-line paragraph, it returns a Bounds that whose
    // minX & minY are the minX and minY of the paragraph itself, not the newline character. So, ignore it.
    int realFrom = getText(from, from + 1).equals("\n") ? from + 1 : from;
    Position startPosition = offsetToPosition(realFrom, Bias.Forward);
    int startRow = startPosition.getMajor();
    Position endPosition = startPosition.offsetBy(to - realFrom, Bias.Forward);
    int endRow = endPosition.getMajor();
    if (startRow == endRow) {
        return getRangeBoundsOnScreen(startRow, startPosition.getMinor(), endPosition.getMinor());
    } else {
        Optional<Bounds> rangeBounds = getRangeBoundsOnScreen(startRow, startPosition.getMinor(), getParagraph(startRow).length());
        for (int i = startRow + 1; i <= endRow; i++) {
            Optional<Bounds> nextLineBounds = getRangeBoundsOnScreen(i, 0, i == endRow ? endPosition.getMinor() : getParagraph(i).length());
            if (nextLineBounds.isPresent()) {
                if (rangeBounds.isPresent()) {
                    Bounds lineBounds = nextLineBounds.get();
                    rangeBounds = rangeBounds.map(b -> {
                        double minX = Math.min(b.getMinX(), lineBounds.getMinX());
                        double minY = Math.min(b.getMinY(), lineBounds.getMinY());
                        double maxX = Math.max(b.getMaxX(), lineBounds.getMaxX());
                        double maxY = Math.max(b.getMaxY(), lineBounds.getMaxY());
                        return new BoundingBox(minX, minY, maxX - minX, maxY - minY);
                    });
                } else {
                    rangeBounds = nextLineBounds;
                }
            }
        }
        return rangeBounds;
    }
}
Also used : EventHandler(javafx.event.EventHandler) NamedArg(javafx.beans.NamedArg) SuspendableNo(org.reactfx.SuspendableNo) IntUnaryOperator(java.util.function.IntUnaryOperator) PseudoClass(javafx.css.PseudoClass) Cell(org.fxmisc.flowless.Cell) BiFunction(java.util.function.BiFunction) TextOps(org.fxmisc.richtext.model.TextOps) SuspendableEventStream(org.reactfx.SuspendableEventStream) PlainTextChange(org.fxmisc.richtext.model.PlainTextChange) StyleConverter(javafx.css.StyleConverter) ContextMenu(javafx.scene.control.ContextMenu) GenericEditableStyledDocument(org.fxmisc.richtext.model.GenericEditableStyledDocument) Duration(java.time.Duration) TwoDimensional(org.fxmisc.richtext.model.TwoDimensional) Point2D(javafx.geometry.Point2D) UndoManager(org.fxmisc.undo.UndoManager) VirtualFlowHit(org.fxmisc.flowless.VirtualFlowHit) SubscribeableContentsObsSet(org.fxmisc.richtext.util.SubscribeableContentsObsSet) Guard(org.reactfx.Guard) ObservableSet(javafx.collections.ObservableSet) UndoUtils(org.fxmisc.richtext.util.UndoUtils) LiveList(org.reactfx.collection.LiveList) CssMetaData(javafx.css.CssMetaData) Event(javafx.event.Event) Virtualized(org.fxmisc.flowless.Virtualized) List(java.util.List) BooleanProperty(javafx.beans.property.BooleanProperty) Region(javafx.scene.layout.Region) TwoLevelNavigator(org.fxmisc.richtext.model.TwoLevelNavigator) Subscription(org.reactfx.Subscription) Tuple2(org.reactfx.util.Tuple2) Paint(javafx.scene.paint.Paint) EventStreams(org.reactfx.EventStreams) Optional(java.util.Optional) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) Suspendable(org.reactfx.Suspendable) Styleable(javafx.css.Styleable) Bounds(javafx.geometry.Bounds) CornerRadii(javafx.scene.layout.CornerRadii) Val(org.reactfx.value.Val) BoundingBox(javafx.geometry.BoundingBox) MouseEvent(javafx.scene.input.MouseEvent) StyleSpans(org.fxmisc.richtext.model.StyleSpans) FXCollections(javafx.collections.FXCollections) Codec(org.fxmisc.richtext.model.Codec) DoubleProperty(javafx.beans.property.DoubleProperty) TextFlow(javafx.scene.text.TextFlow) Function(java.util.function.Function) MouseOverTextEvent(org.fxmisc.richtext.event.MouseOverTextEvent) ArrayList(java.util.ArrayList) IndexRange(javafx.scene.control.IndexRange) Paragraph(org.fxmisc.richtext.model.Paragraph) Insets(javafx.geometry.Insets) BackgroundFill(javafx.scene.layout.BackgroundFill) BiConsumer(java.util.function.BiConsumer) IntSupplier(java.util.function.IntSupplier) IntFunction(java.util.function.IntFunction) Color(javafx.scene.paint.Color) ObjectProperty(javafx.beans.property.ObjectProperty) ReadOnlyStyledDocument(org.fxmisc.richtext.model.ReadOnlyStyledDocument) Node(javafx.scene.Node) RichTextChange(org.fxmisc.richtext.model.RichTextChange) Replacement(org.fxmisc.richtext.model.Replacement) Tuples(org.reactfx.util.Tuples) Background(javafx.scene.layout.Background) Consumer(java.util.function.Consumer) StyledDocument(org.fxmisc.richtext.model.StyledDocument) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) StyleableObjectProperty(javafx.css.StyleableObjectProperty) VirtualizedScrollPane(org.fxmisc.flowless.VirtualizedScrollPane) StyledSegment(org.fxmisc.richtext.model.StyledSegment) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) SuspendableList(org.reactfx.collection.SuspendableList) ObservableValue(javafx.beans.value.ObservableValue) EditableStyledDocument(org.fxmisc.richtext.model.EditableStyledDocument) VirtualFlow(org.fxmisc.flowless.VirtualFlow) Var(org.reactfx.value.Var) EventStream(org.reactfx.EventStream) Collections(java.util.Collections) Bounds(javafx.geometry.Bounds) BoundingBox(javafx.geometry.BoundingBox) Paint(javafx.scene.paint.Paint)

Example 5 with BoundingBox

use of javafx.geometry.BoundingBox in project TestFX by TestFX.

the class BoundsLocatorImpl method limitToVisibleBounds.

private Bounds limitToVisibleBounds(Bounds boundsInScene, Scene scene) {
    Bounds sceneBounds = new BoundingBox(0, 0, scene.getWidth(), scene.getHeight());
    Bounds visibleBounds = intersectBounds(boundsInScene, sceneBounds);
    if (!areBoundsVisible(visibleBounds)) {
        throw new BoundsLocatorException("bounds are not visible in Scene");
    }
    return visibleBounds;
}
Also used : BoundsLocatorException(org.testfx.service.locator.BoundsLocatorException) Bounds(javafx.geometry.Bounds) BoundingBox(javafx.geometry.BoundingBox)

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