Example usage for javafx.scene.paint Color Color

List of usage examples for javafx.scene.paint Color Color

Introduction

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

Prototype

public Color(@NamedArg("red") double red, @NamedArg("green") double green, @NamedArg("blue") double blue,
        @NamedArg(value = "opacity", defaultValue = "1") double opacity) 

Source Link

Document

Creates a new instance of color

Usage

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Text Fonts");
    Group root = new Group();
    Scene scene = new Scene(root, 550, 250, new Color(0, 0, 1, 1.0));

    Text text = new Text(50, 100, "JavaFX 2.0 from Java2s.com");
    Font sanSerif = Font.font("Dialog", 30);
    text.setFont(sanSerif);/* ww w.  j av  a 2 s.  c o m*/
    text.setFill(Color.RED);
    root.getChildren().add(text);

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

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    Group root = new Group();
    Scene scene = new Scene(root, 551, 400);
    Group buttonGroup = new Group();
    Rectangle buttonArea = RectangleBuilder.create().arcWidth(15).arcHeight(20).fill(new Color(0, 0, 0, .55))
            .x(0).y(0).width(60).height(30).stroke(Color.BLACK).build();
    buttonGroup.getChildren().add(buttonArea);
    root.getChildren().add(buttonGroup);

    primaryStage.setScene(scene);/*from  w  w w .j  av  a 2 s . c  o  m*/
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    Group root = new Group();
    Scene scene = new Scene(root, 551, 400, Color.BLACK);
    Group buttonGroup = new Group();
    Arc rightButton = ArcBuilder.create().type(ArcType.ROUND).centerX(12).centerY(16).radiusX(15).radiusY(15)
            .startAngle(180 - 30).length(60).fill(new Color(1, 1, 1, .90)).translateX(40).build();
    buttonGroup.getChildren().add(rightButton);
    root.getChildren().add(buttonGroup);

    primaryStage.setScene(scene);//from   w w w.ja v  a2 s  . c o  m
    primaryStage.show();
}

From source file:net.gazeplay.commons.utils.License.java

private Text licence(double width, double height) {
    Text text = new Text();

    text.setX(width * 0.1);//from w ww.j  a  v a  2 s  .co  m
    text.setY(height * 0.1);
    text.setFont(new Font(20));

    text.setFill(new Color(1, 1, 1, 1));

    String content = loadLicenseContentAsString();
    text.setText(content);

    return text;

}

From source file:de.hs.mannheim.modUro.controller.diagram.fx.ChartViewerSkin.java

/**
 * Creates a new instance./*  w ww  .  j  ava  2 s .  c  o m*/
 *
 * @param control the control ({@code null} not permitted).
 */
public ChartViewerSkin(ChartViewer control) {
    super(control);
    getChildren().add(createNode(control));
    this.zoomRectangle = new Rectangle(0, 0, new Color(0, 0, 1, 0.25));
    this.zoomRectangle.setManaged(false);
    this.zoomRectangle.setVisible(false);
    getChildren().add(this.zoomRectangle);
}

From source file:griffon.javafx.editors.ColorPropertyEditor.java

private void handleAsList(List list) {
    List values = new ArrayList();
    values.addAll(list);//from   w w  w  .  j av a  2 s .  c  om
    switch (list.size()) {
    case 3:
        values.add(1d);
        break;
    case 4:
        // ok
        break;
    default:
        throw illegalValue(list, Color.class);
    }
    for (int i = 0, valuesSize = values.size(); i < valuesSize; i++) {
        Object val = values.get(i);
        if (val instanceof Number) {
            values.set(i, parse((Number) val));
        } else if (val instanceof CharSequence) {
            values.set(i, parse(String.valueOf(val)));
        }
    }
    super.setValueInternal(new Color((Double) values.get(0), (Double) values.get(1), (Double) values.get(2),
            (Double) values.get(3)));
}

From source file:griffon.javafx.editors.ColorPropertyEditor.java

private void handleAsMap(Map map) {
    double r = getMapValue(map, "red", 0d);
    double g = getMapValue(map, "green", 0d);
    double b = getMapValue(map, "blue", 0d);
    double a = getMapValue(map, "alpha", 1d);
    super.setValueInternal(new Color(r, g, b, a));
}

From source file:Main.java

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

    camOffset.getChildren().add(cam);//from  w  ww. j  a va2  s  .  com
    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:griffon.javafx.editors.ColorPropertyEditor.java

private void handleAsNumber(Number value) {
    double c = parse(value);
    super.setValueInternal(new Color(c, c, c, 1d));
}

From source file:edu.kit.trufflehog.model.configdata.FilterDataModelTest.java

/**
 * <p>//w w w.  j  a v a  2s  .c o  m
 *     Generates a single random FilterInput object (that means, random name, random rules and random color).
 * </p>
 *
 * @return A randomly generated FilterInput object.
 */
private FilterInput generateRandomFilterInput() {
    // Generate name
    String name = randomString(10);

    // Generate Rules
    List<String> rules = new ArrayList<>();

    int limit = (int) (Math.random() * 100);
    for (int i = 0; i < limit; i++) {
        int ruleSize = (int) (Math.random() * 1000);
        rules.add(randomString(ruleSize));
    }

    // Generate color;
    double color_r = Math.random();
    double color_g = Math.random();
    double color_b = Math.random();
    double color_a = Math.random();
    Color color = new Color(color_r, color_g, color_b, color_a);

    int priority = (int) (Math.random() * 1000);

    // Generate FilterInput object
    return new FilterInput(name, SelectionModel.SELECTION, FilterType.IP, rules, color, true, priority);
}