Example usage for javafx.scene.paint CycleMethod NO_CYCLE

List of usage examples for javafx.scene.paint CycleMethod NO_CYCLE

Introduction

In this page you can find the example usage for javafx.scene.paint CycleMethod NO_CYCLE.

Prototype

CycleMethod NO_CYCLE

To view the source code for javafx.scene.paint CycleMethod NO_CYCLE.

Click Source Link

Document

Defines the cycle method that uses the terminal colors to fill the remaining area.

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    VBox box = new VBox();
    final Scene scene = new Scene(box, 300, 250);
    scene.setFill(null);//from   w w w  .  j  a va2 s .c  o m
    Stop[] stops = new Stop[] { new Stop(0, Color.BLACK), new Stop(1, Color.RED) };
    LinearGradient lg1 = new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, stops);

    Rectangle r1 = new Rectangle(0, 0, 100, 100);
    r1.setFill(lg1);

    box.getChildren().add(r1);

    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    final Group group = new Group();
    Scene scene = new Scene(group, 300, 150);
    stage.setScene(scene);/*w  w  w .j av  a 2s  .  c  o m*/
    stage.setTitle("Sample");

    Stop[] stops = { new Stop(0, Color.WHITE), new Stop(1, Color.BLACK) };
    LinearGradient lg = new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, stops);
    Rectangle r = new Rectangle(20, 20, 200, 200);
    r.setFill(lg);

    group.getChildren().add(r);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Colors");
    Group root = new Group();
    Scene scene = new Scene(root, 350, 300, Color.WHITE);

    Ellipse ellipse = new Ellipse(100, 50 + 70 / 2, 50, 70 / 2);
    RadialGradient gradient1 = RadialGradientBuilder.create().focusAngle(0).focusDistance(.1).centerX(80)
            .centerY(45).radius(120).proportional(false).cycleMethod(CycleMethod.NO_CYCLE)
            .stops(new Stop(0, Color.RED), new Stop(1, Color.BLACK)).build();

    ellipse.setFill(gradient1);/*from  w  ww  .j a  v a 2 s  .com*/
    root.getChildren().add(ellipse);

    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

private void addBouncyBall(final Scene scene) {
    final Circle ball = new Circle(100, 100, 20);

    RadialGradient gradient1 = new RadialGradient(0, .1, 100, 100, 20, false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.RED), new Stop(1, Color.BLACK));

    ball.setFill(gradient1);//w  w  w  .  j  a v  a 2 s .  c  om

    final Group root = (Group) scene.getRoot();
    root.getChildren().add(ball);

}

From source file:Main.java

@Override
public void start(Stage stage) {
    VBox box = new VBox();
    final Scene scene = new Scene(box, 300, 250);
    scene.setFill(null);/*  ww w .  j  a v a  2s  .c o m*/
    // A rectangle filled with a linear gradient with a translucent color.
    Rectangle rectangle = new Rectangle();
    rectangle.setX(50);
    rectangle.setY(50);
    rectangle.setWidth(100);
    rectangle.setHeight(70);

    LinearGradient linearGrad = new LinearGradient(0, // start X 
            0, // start Y
            0, // end X
            1, // end Y
            true, // proportional
            CycleMethod.NO_CYCLE, // cycle colors
            // stops
            new Stop(0.1f, Color.rgb(25, 200, 0, .4)), new Stop(1.0f, Color.rgb(0, 0, 0, .1)));
    rectangle.setFill(linearGrad);

    box.getChildren().add(rectangle);

    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Colors");
    Group root = new Group();
    Scene scene = new Scene(root, 350, 300, Color.WHITE);
    Rectangle rectangle = RectangleBuilder.create().x(50).y(50).width(100).height(70).translateY(10).build();

    LinearGradient linearGrad = LinearGradientBuilder.create().startX(50).startY(50).endX(50)
            .endY(50 + rectangle.prefHeight(-1) + 25).proportional(false).cycleMethod(CycleMethod.NO_CYCLE)
            .stops(new Stop(0.1f, Color.rgb(255, 200, 0, .784)), new Stop(1.0f, Color.rgb(0, 0, 0, .784)))
            .build();//from w ww .ja  va 2s  . co  m

    rectangle.setFill(linearGrad);
    root.getChildren().add(rectangle);

    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(final Stage stage) {
    stage.setTitle("Xylophone");

    camOffset.getChildren().add(cam);/*ww w.  j  a  v  a  2  s .  c o m*/
    resetCam();

    final Scene scene = new Scene(camOffset, 800, 600, true);
    scene.setFill(new RadialGradient(225, 0.85, 300, 300, 500, false, CycleMethod.NO_CYCLE,
            new Stop[] { new Stop(0f, Color.BLUE), new Stop(1f, Color.LIGHTBLUE) }));
    scene.setCamera(new PerspectiveCamera());

    final AudioClip bar1Note = new AudioClip(Main.class.getResource("audio/Note1.wav").toString());
    final AudioClip bar2Note = new AudioClip(Main.class.getResource("audio/Note2.wav").toString());
    final AudioClip bar3Note = new AudioClip(Main.class.getResource("audio/Note3.wav").toString());
    final AudioClip bar4Note = new AudioClip(Main.class.getResource("audio/Note4.wav").toString());
    final AudioClip bar5Note = new AudioClip(Main.class.getResource("audio/Note5.wav").toString());
    final AudioClip bar6Note = new AudioClip(Main.class.getResource("audio/Note6.wav").toString());
    final AudioClip bar7Note = new AudioClip(Main.class.getResource("audio/Note7.wav").toString());
    final AudioClip bar8Note = new AudioClip(Main.class.getResource("audio/Note8.wav").toString());

    Group rectangleGroup = new Group();
    rectangleGroup.getTransforms().add(shear);
    rectangleGroup.setDepthTest(DepthTest.ENABLE);

    double xStart = 260.0;
    double xOffset = 30.0;
    double yPos = 300.0;
    double zPos = 0.0;
    double barWidth = 22.0;
    double barDepth = 7.0;

    // Base1
    Cube base1Cube = new Cube(1.0, new Color(0.2, 0.12, 0.1, 1.0), 1.0);
    base1Cube.setTranslateX(xStart + 135);
    base1Cube.setTranslateZ(yPos + 20.0);
    base1Cube.setTranslateY(11.0);
    base1Cube.setScaleX(barWidth * 11.5);
    base1Cube.setScaleZ(10.0);
    base1Cube.setScaleY(barDepth * 2.0);

    // Base2
    Cube base2Cube = new Cube(1.0, new Color(0.2, 0.12, 0.1, 1.0), 1.0);
    base2Cube.setTranslateX(xStart + 135);
    base2Cube.setTranslateZ(yPos - 20.0);
    base2Cube.setTranslateY(11.0);
    base2Cube.setScaleX(barWidth * 11.5);
    base2Cube.setScaleZ(10.0);
    base2Cube.setScaleY(barDepth * 2.0);

    // Bar1
    Cube bar1Cube = new Cube(1.0, Color.PURPLE, 1.0);
    bar1Cube.setTranslateX(xStart + 1 * xOffset);
    bar1Cube.setTranslateZ(yPos);
    bar1Cube.setScaleX(barWidth);
    bar1Cube.setScaleZ(100.0);
    bar1Cube.setScaleY(barDepth);

    // Bar2
    Cube bar2Cube = new Cube(1.0, Color.BLUEVIOLET, 1.0);
    bar2Cube.setTranslateX(xStart + 2 * xOffset);
    bar2Cube.setTranslateZ(yPos);
    bar2Cube.setScaleX(barWidth);
    bar2Cube.setScaleZ(95.0);
    bar2Cube.setScaleY(barDepth);

    // Bar3
    Cube bar3Cube = new Cube(1.0, Color.BLUE, 1.0);
    bar3Cube.setTranslateX(xStart + 3 * xOffset);
    bar3Cube.setTranslateZ(yPos);
    bar3Cube.setScaleX(barWidth);
    bar3Cube.setScaleZ(90.0);
    bar3Cube.setScaleY(barDepth);

    // Bar4
    Cube bar4Cube = new Cube(1.0, Color.GREEN, 1.0);
    bar4Cube.setTranslateX(xStart + 4 * xOffset);
    bar4Cube.setTranslateZ(yPos);
    bar4Cube.setScaleX(barWidth);
    bar4Cube.setScaleZ(85.0);
    bar4Cube.setScaleY(barDepth);

    // Bar5
    Cube bar5Cube = new Cube(1.0, Color.GREENYELLOW, 1.0);
    bar5Cube.setTranslateX(xStart + 5 * xOffset);
    bar5Cube.setTranslateZ(yPos);
    bar5Cube.setScaleX(barWidth);
    bar5Cube.setScaleZ(80.0);
    bar5Cube.setScaleY(barDepth);

    // Bar6
    Cube bar6Cube = new Cube(1.0, Color.YELLOW, 1.0);
    bar6Cube.setTranslateX(xStart + 6 * xOffset);
    bar6Cube.setTranslateZ(yPos);
    bar6Cube.setScaleX(barWidth);
    bar6Cube.setScaleZ(75.0);
    bar6Cube.setScaleY(barDepth);

    // Bar7
    Cube bar7Cube = new Cube(1.0, Color.ORANGE, 1.0);
    bar7Cube.setTranslateX(xStart + 7 * xOffset);
    bar7Cube.setTranslateZ(yPos);
    bar7Cube.setScaleX(barWidth);
    bar7Cube.setScaleZ(70.0);
    bar7Cube.setScaleY(barDepth);

    // Bar8
    Cube bar8Cube = new Cube(1.0, Color.RED, 1.0);
    bar8Cube.setTranslateX(xStart + 8 * xOffset);
    bar8Cube.setTranslateZ(yPos);
    bar8Cube.setScaleX(barWidth);
    bar8Cube.setScaleZ(65.0);
    bar8Cube.setScaleY(barDepth);

    bar1Cube.setOnMousePressed(new EventHandler<MouseEvent>() {
        public void handle(MouseEvent me) {
            bar1Note.play();
        }
    });
    bar2Cube.setOnMousePressed(new EventHandler<MouseEvent>() {
        public void handle(MouseEvent me) {
            bar2Note.play();
        }
    });
    bar3Cube.setOnMousePressed(new EventHandler<MouseEvent>() {
        public void handle(MouseEvent me) {
            bar3Note.play();
        }
    });
    bar4Cube.setOnMousePressed(new EventHandler<MouseEvent>() {
        public void handle(MouseEvent me) {
            bar4Note.play();
        }
    });
    bar5Cube.setOnMousePressed(new EventHandler<MouseEvent>() {
        public void handle(MouseEvent me) {
            bar5Note.play();
        }
    });
    bar6Cube.setOnMousePressed(new EventHandler<MouseEvent>() {
        public void handle(MouseEvent me) {
            bar6Note.play();
        }
    });
    bar7Cube.setOnMousePressed(new EventHandler<MouseEvent>() {
        public void handle(MouseEvent me) {
            bar7Note.play();
        }
    });
    bar8Cube.setOnMousePressed(new EventHandler<MouseEvent>() {
        public void handle(MouseEvent me) {
            bar8Note.play();
        }
    });

    rectangleGroup.getChildren().addAll(base1Cube, base2Cube, bar1Cube, bar2Cube, bar3Cube, bar4Cube, bar5Cube,
            bar6Cube, bar7Cube, bar8Cube);
    rectangleGroup.setScaleX(2.5);
    rectangleGroup.setScaleY(2.5);
    rectangleGroup.setScaleZ(2.5);
    cam.getChildren().add(rectangleGroup);

    double halfSceneWidth = 375; // scene.getWidth()/2.0;
    double halfSceneHeight = 275; // scene.getHeight()/2.0;
    cam.p.setX(halfSceneWidth);
    cam.ip.setX(-halfSceneWidth);
    cam.p.setY(halfSceneHeight);
    cam.ip.setY(-halfSceneHeight);

    frameCam(stage, scene);

    scene.setOnMousePressed(new EventHandler<MouseEvent>() {
        public void handle(MouseEvent me) {
            mousePosX = me.getX();
            mousePosY = me.getY();
            mouseOldX = me.getX();
            mouseOldY = me.getY();
            //System.out.println("scene.setOnMousePressed " + me);
        }
    });
    scene.setOnMouseDragged(new EventHandler<MouseEvent>() {
        public void handle(MouseEvent me) {
            mouseOldX = mousePosX;
            mouseOldY = mousePosY;
            mousePosX = me.getX();
            mousePosY = me.getY();
            mouseDeltaX = mousePosX - mouseOldX;
            mouseDeltaY = mousePosY - mouseOldY;
            if (me.isAltDown() && me.isShiftDown() && me.isPrimaryButtonDown()) {
                double rzAngle = cam.rz.getAngle();
                cam.rz.setAngle(rzAngle - mouseDeltaX);
            } else if (me.isAltDown() && me.isPrimaryButtonDown()) {
                double ryAngle = cam.ry.getAngle();
                cam.ry.setAngle(ryAngle - mouseDeltaX);
                double rxAngle = cam.rx.getAngle();
                cam.rx.setAngle(rxAngle + mouseDeltaY);
            } else if (me.isShiftDown() && me.isPrimaryButtonDown()) {
                double yShear = shear.getY();
                shear.setY(yShear + mouseDeltaY / 1000.0);
                double xShear = shear.getX();
                shear.setX(xShear + mouseDeltaX / 1000.0);
            } else if (me.isAltDown() && me.isSecondaryButtonDown()) {
                double scale = cam.s.getX();
                double newScale = scale + mouseDeltaX * 0.01;
                cam.s.setX(newScale);
                cam.s.setY(newScale);
                cam.s.setZ(newScale);
            } else if (me.isAltDown() && me.isMiddleButtonDown()) {
                double tx = cam.t.getX();
                double ty = cam.t.getY();
                cam.t.setX(tx + mouseDeltaX);
                cam.t.setY(ty + mouseDeltaY);
            }
        }
    });
    scene.setOnKeyPressed(new EventHandler<KeyEvent>() {
        public void handle(KeyEvent ke) {
            if (KeyCode.A.equals(ke.getCode())) {
                resetCam();
                shear.setX(0.0);
                shear.setY(0.0);
            }
            if (KeyCode.F.equals(ke.getCode())) {
                frameCam(stage, scene);
                shear.setX(0.0);
                shear.setY(0.0);
            }
            if (KeyCode.SPACE.equals(ke.getCode())) {
                if (stage.isFullScreen()) {
                    stage.setFullScreen(false);
                    frameCam(stage, scene);
                } else {
                    stage.setFullScreen(true);
                    frameCam(stage, scene);
                }
            }
        }
    });

    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    Group root = new Group();
    Scene scene = new Scene(root, 800, 600, Color.BLACK);
    primaryStage.setScene(scene);//w w  w .j a v a2  s.c  o m
    Group circles = new Group();
    for (int i = 0; i < 30; i++) {
        Circle circle = new Circle(150, Color.web("white", 0.05));
        circle.setStrokeType(StrokeType.OUTSIDE);
        circle.setStroke(Color.web("white", 0.16));
        circle.setStrokeWidth(4);
        circles.getChildren().add(circle);
    }
    Rectangle colors = new Rectangle(scene.getWidth(), scene.getHeight(),
            new LinearGradient(0f, 1f, 1f, 0f, true, CycleMethod.NO_CYCLE,
                    new Stop[] { new Stop(0, Color.web("#f8bd55")), new Stop(0.14, Color.web("#c0fe56")),
                            new Stop(0.28, Color.web("#5dfbc1")), new Stop(0.43, Color.web("#64c2f8")),
                            new Stop(0.57, Color.web("#be4af7")), new Stop(0.71, Color.web("#ed5fc2")),
                            new Stop(0.85, Color.web("#ef504c")), new Stop(1, Color.web("#f2660f")), }));
    Group blendModeGroup = new Group(
            new Group(new Rectangle(scene.getWidth(), scene.getHeight(), Color.BLACK), circles), colors);
    colors.setBlendMode(BlendMode.OVERLAY);
    root.getChildren().add(blendModeGroup);
    circles.setEffect(new BoxBlur(10, 10, 3));
    Timeline timeline = new Timeline();
    for (Node circle : circles.getChildren()) {
        timeline.getKeyFrames().addAll(new KeyFrame(Duration.ZERO, // set start position at 0
                new KeyValue(circle.translateXProperty(), random() * 800),
                new KeyValue(circle.translateYProperty(), random() * 600)),
                new KeyFrame(new Duration(40000), // set end position at 40s
                        new KeyValue(circle.translateXProperty(), random() * 800),
                        new KeyValue(circle.translateYProperty(), random() * 600)));
    }
    // play 40s of animation
    timeline.play();

    primaryStage.show();
}

From source file:Main.java

private void addStackPane(HBox hb) {

    StackPane stack = new StackPane();
    Rectangle helpIcon = new Rectangle(30.0, 25.0);
    helpIcon.setFill(new LinearGradient(0, 0, 0, 1, true, CycleMethod.NO_CYCLE,
            new Stop[] { new Stop(0, Color.web("#4977A3")), new Stop(0.5, Color.web("#B0C6DA")),
                    new Stop(1, Color.web("#9CB6CF")), }));
    helpIcon.setStroke(Color.web("#D0E6FA"));
    helpIcon.setArcHeight(3.5);/*w w  w. jav a2s.  co  m*/
    helpIcon.setArcWidth(3.5);

    Text helpText = new Text("?");
    helpText.setFont(Font.font("Verdana", FontWeight.BOLD, 18));
    helpText.setFill(Color.WHITE);
    helpText.setStroke(Color.web("#7080A0"));

    stack.getChildren().addAll(helpIcon, helpText);
    stack.setAlignment(Pos.CENTER_RIGHT);
    // Add offset to right for question mark to compensate for RIGHT 
    // alignment of all nodes
    StackPane.setMargin(helpText, new Insets(0, 10, 0, 0));

    hb.getChildren().add(stack);
    HBox.setHgrow(stack, Priority.ALWAYS);

}

From source file:spacetrader.controller.EncounterScreenController.java

/**
 * Initializes the controller class./*from   w  ww. j a v  a  2s . com*/
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    minuteMatrix = new Array2DRowRealMatrix(MINUTE_ARROW);
    hourMatrix = new Array2DRowRealMatrix(HOUR_ARROW);
    context = canvas.getGraphicsContext2D();
    context.translate(375, 275);
    context.setFill(Color.CORNFLOWERBLUE);
    context.fillPolygon(minuteMatrix.getColumn(0), minuteMatrix.getColumn(1), 10);
    context.setFill(Color.MEDIUMAQUAMARINE);
    context.fillPolygon(hourMatrix.getColumn(0), hourMatrix.getColumn(1), 8);
    timeline = new Timeline();
    timeline.setCycleCount(Timeline.INDEFINITE);
    inCount = 0;
    upDown = true;
    KeyFrame frame = new KeyFrame(Duration.seconds(1.0 / 24), new EventHandler<ActionEvent>() {
        public void handle(ActionEvent event) {
            System.out.println(inCount);
            context.clearRect(-375, -275, 750, 550);
            context.setStroke(Color.rgb(0, outCount, 127 + outCount));
            context.setLineWidth(61);
            context.strokeOval(-230, -230, 460, 460);
            context.setStroke(Color.rgb(0, (outCount + 30) % 128, 127 + (outCount + 30) % 128));
            context.strokeOval(-290, -290, 580, 580);
            context.setStroke(Color.rgb(0, (outCount + 60) % 128, 127 + (outCount + 60) % 128));
            context.strokeOval(-350, -350, 700, 700);
            context.setStroke(Color.rgb(0, (outCount + 90) % 128, 127 + (outCount + 90) % 128));
            context.setLineWidth(100);
            context.strokeOval(-430, -430, 860, 860);

            context.setFill(new LinearGradient(-200, -200, 200, 200, false, CycleMethod.NO_CYCLE,
                    new Stop(0, Color.rgb(255, 255 - inCount, inCount)),
                    new Stop(1, Color.rgb(255 - inCount, 0, 255))));
            context.fillOval(-200, -200, 400, 400);
            minuteMatrix = minuteMatrix.multiply(minuteRotateMatrix);
            hourMatrix = hourMatrix.multiply(hourRotateMatrix);
            context.setFill(Color.CORNFLOWERBLUE);
            context.fillPolygon(minuteMatrix.getColumn(0), minuteMatrix.getColumn(1), 10);
            context.setFill(Color.MEDIUMAQUAMARINE);
            context.fillPolygon(hourMatrix.getColumn(0), hourMatrix.getColumn(1), 8);
            if (inCount % 20 < 10) {
                context.drawImage(
                        new Image(Paths.get("image/star.png").toUri().toString(), 360, 360, false, false), -180,
                        -180);
            } else {
                context.drawImage(
                        new Image(Paths.get("image/star.png").toUri().toString(), 300, 300, false, false), -150,
                        -150);
            }
            if (upDown) {
                inCount += 3;
                if (inCount >= 255) {
                    upDown = false;
                }
            } else {
                inCount -= 3;
                if (inCount <= 0) {
                    upDown = true;
                }
            }
            if (outCount >= 128) {
                outCount = 0;
            } else {
                outCount += 8;
            }
        }
    });
    timeline.getKeyFrames().add(frame);
    timeline.play();
}