Search in sources :

Example 86 with Rectangle

use of javafx.scene.shape.Rectangle in project blue by kunstmusik.

the class BSBObjectViewHolder method resizeDown.

protected void resizeDown(MouseEvent evt) {
    Rectangle r = (Rectangle) evt.getSource();
    Point2D curPoint = r.localToParent(evt.getX(), evt.getY());
    curPoint = localToParent(curPoint);
    GridSettings grid = selection.getGridSettings();
    int diff = (int) (curPoint.getY() - mouseOrigin.getY());
    int newHeight = (int) originBounds.getHeight() + diff;
    if (grid.isSnapEnabled()) {
        double top = getLayoutY();
        double bottom = top + newHeight;
        int h = grid.getHeight();
        newHeight = (int) ((Math.round(bottom / h) * h) - top);
    }
    newHeight = Math.max(newHeight, rView.getWidgetMinimumHeight());
    if (newHeight != rView.getWidgetHeight()) {
        rView.setWidgetHeight(newHeight);
    }
    evt.consume();
}
Also used : Point2D(javafx.geometry.Point2D) Rectangle(javafx.scene.shape.Rectangle) GridSettings(blue.orchestra.blueSynthBuilder.GridSettings)

Example 87 with Rectangle

use of javafx.scene.shape.Rectangle in project blue by kunstmusik.

the class BSBObjectViewHolder method setupResizeHandles.

private void setupResizeHandles(Rectangle rect, BSBEditSelection selection) {
    if (!(bsbObjectView instanceof ResizeableView)) {
        return;
    }
    BooleanBinding visibleBinding = Bindings.createBooleanBinding(() -> rect.isVisible() && selection.selection.size() == 1, rect.visibleProperty(), selection.selection);
    rView = (ResizeableView) bsbObjectView;
    if (rView.canResizeWidgetWidth()) {
        Rectangle resizeLeftHandle = new Rectangle(5, 5);
        resizeLeftHandle.setManaged(false);
        resizeLeftHandle.setFill(Color.rgb(0, 255, 0));
        resizeLeftHandle.setLayoutX(-2);
        resizeLeftHandle.yProperty().bind(rect.heightProperty().divide(2).subtract(2));
        resizeLeftHandle.visibleProperty().bind(visibleBinding);
        resizeLeftHandle.setCursor(Cursor.W_RESIZE);
        resizeLeftHandle.setOnMousePressed(evt -> recordMouseOrigin(evt));
        resizeLeftHandle.setOnMouseDragged(evt -> resizeLeft(evt));
        Rectangle resizeRightHandle = new Rectangle(5, 5);
        resizeRightHandle.setManaged(false);
        resizeRightHandle.setFill(Color.rgb(0, 255, 0));
        resizeRightHandle.xProperty().bind(rect.widthProperty().subtract(2));
        resizeRightHandle.yProperty().bind(rect.heightProperty().divide(2).subtract(2));
        resizeRightHandle.visibleProperty().bind(visibleBinding);
        resizeRightHandle.setCursor(Cursor.E_RESIZE);
        resizeRightHandle.setOnMousePressed(evt -> recordMouseOrigin(evt));
        resizeRightHandle.setOnMouseDragged(evt -> resizeRight(evt));
        getChildren().addAll(resizeLeftHandle, resizeRightHandle);
    }
    if (rView.canResizeWidgetHeight()) {
        Rectangle resizeTopHandle = new Rectangle(5, 5);
        resizeTopHandle.setManaged(false);
        resizeTopHandle.setFill(Color.rgb(0, 255, 0));
        resizeTopHandle.setLayoutY(-2);
        resizeTopHandle.xProperty().bind(rect.widthProperty().divide(2).subtract(2));
        resizeTopHandle.visibleProperty().bind(visibleBinding);
        resizeTopHandle.setCursor(Cursor.N_RESIZE);
        resizeTopHandle.setOnMousePressed(evt -> recordMouseOrigin(evt));
        resizeTopHandle.setOnMouseDragged(evt -> resizeUp(evt));
        Rectangle resizeBottomHandle = new Rectangle(5, 5);
        resizeBottomHandle.setManaged(false);
        resizeBottomHandle.setFill(Color.rgb(0, 255, 0));
        resizeBottomHandle.yProperty().bind(rect.heightProperty().subtract(2));
        resizeBottomHandle.xProperty().bind(rect.widthProperty().divide(2).subtract(2));
        resizeBottomHandle.visibleProperty().bind(visibleBinding);
        resizeBottomHandle.setCursor(Cursor.S_RESIZE);
        resizeBottomHandle.setOnMousePressed(evt -> recordMouseOrigin(evt));
        resizeBottomHandle.setOnMouseDragged(evt -> resizeDown(evt));
        getChildren().addAll(resizeTopHandle, resizeBottomHandle);
    }
}
Also used : BooleanBinding(javafx.beans.binding.BooleanBinding) Rectangle(javafx.scene.shape.Rectangle)

Example 88 with Rectangle

use of javafx.scene.shape.Rectangle in project contentment by GeePawHill.

the class AnimationTimerExperiment method start.

@Override
public void start(final Stage primaryStage) {
    for (int i = 0; i < STAR_COUNT; i++) {
        nodes[i] = new Rectangle(1, 1, Color.WHITE);
        angles[i] = 2.0 * Math.PI * random.nextDouble();
        start[i] = random.nextInt(2000000000);
    }
    final Scene scene = new Scene(new Group(nodes), 800, 600, Color.BLACK);
    primaryStage.setScene(scene);
    primaryStage.show();
    new AnimationTimer() {

        @Override
        public void handle(long now) {
            final double width = 0.5 * primaryStage.getWidth();
            final double height = 0.5 * primaryStage.getHeight();
            final double radius = Math.sqrt(2) * Math.max(width, height);
            for (int i = 0; i < STAR_COUNT; i++) {
                final Node node = nodes[i];
                final double angle = angles[i];
                final long t = (now - start[i]) % 2000000000;
                final double d = t * radius / 2000000000.0;
                node.setTranslateX(Math.cos(angle) * d + width);
                node.setTranslateY(Math.sin(angle) * d + height);
            }
        }
    }.start();
}
Also used : Group(javafx.scene.Group) AnimationTimer(javafx.animation.AnimationTimer) Node(javafx.scene.Node) Rectangle(javafx.scene.shape.Rectangle) Scene(javafx.scene.Scene)

Example 89 with Rectangle

use of javafx.scene.shape.Rectangle in project honest-profiler by jvm-profiling-tools.

the class GraphicalShareTableCell method updateItem.

@Override
protected void updateItem(Double share, boolean empty) {
    super.updateItem(share, empty);
    if (empty || share == null) {
        setText(null);
        setGraphic(null);
        return;
    }
    setGraphic(new Rectangle(share * getWidth(), HEIGHT, COLOR));
}
Also used : Rectangle(javafx.scene.shape.Rectangle)

Example 90 with Rectangle

use of javafx.scene.shape.Rectangle in project Malai by arnobl.

the class MoveShape method testCanCancelDnDWithObsList.

@Test
public void testCanCancelDnDWithObsList() {
    new NodeBinder<>(MoveShape.class, new DnD(true, true), instrument).map(i -> new MoveShape((Rectangle) i.getSrcObject().get())).on(widget1.getChildren()).first((c, i) -> Platform.runLater(() -> i.getSrcObject().get().requestFocus())).then((c, i) -> c.setCoord(((Rectangle) i.getSrcObject().get()).getX() + (i.getEndScenePt().getX() - i.getSrcScenePoint().getX()), ((Rectangle) i.getSrcObject().get()).getY() + (i.getEndScenePt().getY() - i.getSrcScenePoint().getY()))).end((c, i) -> fail("")).exec().bind();
    Rectangle rec2 = new Rectangle(200d, 200d, 70d, 50d);
    Platform.runLater(() -> widget1.getChildren().addAll(rec2));
    WaitForAsyncUtils.waitForFxEvents();
    drag(rec2).moveBy(100, 100).type(KeyCode.ESCAPE).sleep(50L);
    assertEquals(0, instrument.exec.get());
}
Also used : Assertions.fail(org.junit.jupiter.api.Assertions.fail) KeyCode(javafx.scene.input.KeyCode) NodeBinder(org.malai.javafx.binding.NodeBinder) Undoable(org.malai.undo.Undoable) Rectangle(javafx.scene.shape.Rectangle) DoubleProperty(javafx.beans.property.DoubleProperty) CommandImpl(org.malai.command.CommandImpl) WaitForAsyncUtils(org.testfx.util.WaitForAsyncUtils) Platform(javafx.application.Platform) Test(org.junit.jupiter.api.Test) Stage(javafx.stage.Stage) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) DnD(org.malai.javafx.interaction.library.DnD) Pane(javafx.scene.layout.Pane) Rectangle(javafx.scene.shape.Rectangle) DnD(org.malai.javafx.interaction.library.DnD) Test(org.junit.jupiter.api.Test)

Aggregations

Rectangle (javafx.scene.shape.Rectangle)190 Point2D (javafx.geometry.Point2D)33 Text (javafx.scene.text.Text)28 Entity (com.almasb.fxgl.entity.Entity)27 Circle (javafx.scene.shape.Circle)20 Color (javafx.scene.paint.Color)18 HitBox (com.almasb.fxgl.physics.HitBox)16 Pane (javafx.scene.layout.Pane)16 Group (javafx.scene.Group)15 Node (javafx.scene.Node)14 PhysicsComponent (com.almasb.fxgl.physics.PhysicsComponent)12 Scene (javafx.scene.Scene)12 EntityView (com.almasb.fxgl.entity.view.EntityView)10 Label (javafx.scene.control.Label)10 List (java.util.List)8 Collectors (java.util.stream.Collectors)8 TextFlow (javafx.scene.text.TextFlow)8 CollidableComponent (com.almasb.fxgl.entity.component.CollidableComponent)7 Bounds (javafx.geometry.Bounds)7 KeyCode (javafx.scene.input.KeyCode)7