Search in sources :

Example 26 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 27 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 28 with Rectangle

use of javafx.scene.shape.Rectangle in project RichTextFX by FXMisc.

the class ManualHighlighting method createColorButton.

private Button createColorButton(Color color, String styleClass) {
    Rectangle rect = new Rectangle(20, 20, color);
    Button button = new Button(null, rect);
    setPushHandler(button, styleClass);
    return button;
}
Also used : Button(javafx.scene.control.Button) Rectangle(javafx.scene.shape.Rectangle)

Example 29 with Rectangle

use of javafx.scene.shape.Rectangle in project KNOBS by ESSICS.

the class Knob method resize.

protected void resize() {
    double width = getWidth() - getInsets().getLeft() - getInsets().getRight();
    double height = getHeight() - getInsets().getTop() - getInsets().getBottom();
    size = width < height ? width : height;
    if (width > 0 && height > 0) {
        pane.setMaxSize(size, size);
        pane.setPrefSize(size, size);
        pane.relocate((getWidth() - size) * 0.5, (getHeight() - size) * 0.5);
        barArc.setCache(false);
        barArc.setCenterX(size * 0.5);
        barArc.setCenterY(size * 0.5);
        barArc.setRadiusX(size * 0.46);
        barArc.setRadiusY(size * 0.46);
        barArc.setStrokeWidth(size * 0.04);
        barArc.setStroke(barGradient.getImagePattern(new Rectangle(0, 0, size, size)));
        barArc.setLength(-(getMaxValue() - getMinValue()) * getAngleStep());
        barArc.setCache(true);
        barArc.setCacheHint(CacheHint.SPEED);
        currentValueBarArc.setCenterX(size * 0.5);
        currentValueBarArc.setCenterY(size * 0.5);
        currentValueBarArc.setRadiusX(size * 0.46);
        currentValueBarArc.setRadiusY(size * 0.46);
        currentValueBarArc.setStrokeWidth(size * 0.03);
        double shadowRadius = clamp(1.0, 2.0, size * 0.004);
        dropShadow.setRadius(shadowRadius);
        dropShadow.setOffsetY(shadowRadius);
        highlight.setRadius(shadowRadius);
        highlight.setOffsetY(shadowRadius);
        innerShadow.setRadius(shadowRadius);
        innerShadow.setOffsetY(-shadowRadius);
        double center = size * 0.5;
        double scaleFactor = size / PREFERRED_WIDTH;
        ring.setCache(false);
        ring.getTransforms().setAll(new Scale(scaleFactor, scaleFactor, 0, 0));
        ring.setCache(true);
        ring.setCacheHint(CacheHint.SPEED);
        mainCircle.setCache(false);
        mainCircle.setRadius(size * 0.3);
        mainCircle.setCenterX(center);
        mainCircle.setCenterY(center);
        mainCircle.setCache(true);
        mainCircle.setCacheHint(CacheHint.SPEED);
        text.setFont(Fonts.robotoMedium(size * 0.216));
        text.relocate((size - text.getLayoutBounds().getWidth()) * 0.5, size * 0.33);
        targetText.setFont(Fonts.robotoLight(size * 0.11));
        targetText.relocate((size - targetText.getLayoutBounds().getWidth()) * 0.5, size * 0.25);
        unitText.setFont(Fonts.robotoLight(size * 0.11));
        unitText.relocate((size - unitText.getLayoutBounds().getWidth()) * 0.5, size * 0.6);
        textMinTag.getPoints().set(0, size * 0.0);
        textMinTag.getPoints().set(1, size * 0.886);
        textMinTag.getPoints().set(2, size * 0.27);
        textMinTag.getPoints().set(3, size * 0.886);
        textMinTag.getPoints().set(4, size * 0.27);
        textMinTag.getPoints().set(5, size * 0.966);
        textMinTag.getPoints().set(6, size * 0.0);
        textMinTag.getPoints().set(7, size * 0.966);
        textMin.setFont(Fonts.robotoRegular(size * 0.072));
        textMin.relocate(size * 0.007, size * 0.878);
        setTextMin(getMinValue());
        textMaxTag.getPoints().set(0, size * 1.0);
        textMaxTag.getPoints().set(1, size * 0.886);
        textMaxTag.getPoints().set(2, size * 0.73);
        textMaxTag.getPoints().set(3, size * 0.886);
        textMaxTag.getPoints().set(4, size * 0.73);
        textMaxTag.getPoints().set(5, size * 0.966);
        textMaxTag.getPoints().set(6, size * 1.0);
        textMaxTag.getPoints().set(7, size * 0.966);
        textMax.setFont(Fonts.robotoRegular(size * 0.072));
        textMax.relocate(size * 0.737, size * 0.878);
        setTextMax(getMaxValue());
        tagBarArc.setCenterX(size * 0.5);
        tagBarArc.setCenterY(size * 0.5);
        tagBarArc.setRadiusX(size * 0.46);
        tagBarArc.setRadiusY(size * 0.46);
        tagBarArc.setStrokeWidth(size * 0.03);
        indicatorGlow.setRadius(size * 0.02);
        indicatorInnerShadow.setRadius(size * 0.008);
        indicatorInnerShadow.setOffsetY(size * 0.006);
        indicatorHighlight.setRadius(size * 0.008);
        indicatorHighlight.setOffsetY(-size * 0.004);
        indicator.setRadius(size * 0.032);
        indicator.setCenterX(center);
        indicator.setCenterY(size * 0.148);
        indicatorRotate.setPivotX(center);
        indicatorRotate.setPivotY(center);
    }
}
Also used : Rectangle(javafx.scene.shape.Rectangle) Scale(javafx.scene.transform.Scale)

Example 30 with Rectangle

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

the class ViewShape method getActivatedGroupNodes.

private static Collection<Shape> getActivatedGroupNodes(final Group gp) {
    // Adding all the shape children
    final Collection<Shape> shapes = gp.getChildren().stream().filter(node -> node instanceof Shape && node.isVisible() && !node.isDisable()).map(node -> (Shape) node).collect(Collectors.toList());
    // Adding all the view shape children
    shapes.addAll(gp.getChildren().stream().filter(node -> node instanceof ViewShape<?> && node.isVisible() && !node.isDisable()).map(vs -> ((ViewShape<?>) vs).getActivatedShapes()).flatMap(st -> st.stream()).collect(Collectors.toList()));
    // Adding the shapes contained in groups that are not view shapes
    shapes.addAll(gp.getChildren().stream().filter(node -> node instanceof Group && !(node instanceof ViewShape<?>)).map(node -> getActivatedGroupNodes((Group) node)).flatMap(st -> st.stream()).collect(Collectors.toList()));
    // Adding the images contained in the group
    shapes.addAll(gp.getChildren().stream().filter(node -> node instanceof ImageView && node.isVisible() && !node.isDisable()).map(node -> {
        final Bounds bounds = node.getBoundsInParent();
        Rectangle rec = new Rectangle(bounds.getMinX(), bounds.getMinY(), bounds.getWidth(), bounds.getHeight());
        rec.setFill(Color.WHITE);
        rec.getTransforms().setAll(gp.getLocalToSceneTransform());
        return rec;
    }).collect(Collectors.toList()));
    return shapes;
}
Also used : Platform(javafx.application.Platform) Parent(javafx.scene.Parent) Color(javafx.scene.paint.Color) IShape(net.sf.latexdraw.models.interfaces.shape.IShape) ImageView(javafx.scene.image.ImageView) Collection(java.util.Collection) Optional(java.util.Optional) Rectangle(javafx.scene.shape.Rectangle) Group(javafx.scene.Group) Collectors(java.util.stream.Collectors) Shape(javafx.scene.shape.Shape) Bounds(javafx.geometry.Bounds) Group(javafx.scene.Group) IShape(net.sf.latexdraw.models.interfaces.shape.IShape) Shape(javafx.scene.shape.Shape) Bounds(javafx.geometry.Bounds) Rectangle(javafx.scene.shape.Rectangle) ImageView(javafx.scene.image.ImageView)

Aggregations

Rectangle (javafx.scene.shape.Rectangle)135 Text (javafx.scene.text.Text)23 Entity (com.almasb.fxgl.entity.Entity)21 Point2D (javafx.geometry.Point2D)17 Circle (javafx.scene.shape.Circle)16 Group (javafx.scene.Group)13 Pane (javafx.scene.layout.Pane)13 Scene (javafx.scene.Scene)11 Color (javafx.scene.paint.Color)11 EntityView (com.almasb.fxgl.entity.view.EntityView)10 Label (javafx.scene.control.Label)10 HitBox (com.almasb.fxgl.physics.HitBox)8 TextFlow (javafx.scene.text.TextFlow)8 CollidableComponent (com.almasb.fxgl.entity.component.CollidableComponent)7 Node (javafx.scene.Node)7 PlayerControl (common.PlayerControl)6 Timeline (javafx.animation.Timeline)6 StackPane (javafx.scene.layout.StackPane)6 Stage (javafx.stage.Stage)6 Region (javafx.scene.layout.Region)5