Example usage for javafx.scene.paint Color rgb

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

Introduction

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

Prototype

public static Color rgb(int red, int green, int blue, double opacity) 

Source Link

Document

Creates an sRGB color with the specified RGB values in the range 0-255 , and a given opacity.

Usage

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Drawing Text");
    Group root = new Group();
    Scene scene = new Scene(root, 300, 250, Color.WHITE);
    int x = 100;//from   w w w .  j a  v a  2s  . c  o m
    int y = 100;
    int red = 30;
    int green = 40;
    int blue = 50;

    Text text = new Text(x, y, "JavaFX 2.0");

    text.setFill(Color.rgb(red, green, blue, .99));
    text.setRotate(60);
    root.getChildren().add(text);

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

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 ww.j  a  v a 2  s. com*/
    // 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 cycleGrad = new LinearGradient(50, // start X
            50, // start Y
            70, // end X
            70, // end Y
            false, // proportional
            CycleMethod.REFLECT, // cycleMethod
            new Stop(0f, Color.rgb(21, 25, 0, .784)), new Stop(1.0f, Color.rgb(0, 210, 0, .784)));
    rectangle.setFill(cycleGrad);

    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 w  w  .  j a v a 2s .c  om

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

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

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.jav a2  s . co 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) {
        TextArea myTextArea = new TextArea();
        VBox hbox = new VBox();
        hbox.getChildren().add(myTextArea);
        VBox.setVgrow(myTextArea, Priority.ALWAYS);

        Scene scene = new Scene(hbox, 320, 112, Color.rgb(0, 0, 0, 0));
        primaryStage.setScene(scene);/*from w w  w .  j  a v  a 2s. c  om*/
        primaryStage.show();
    }

From source file:User.java

private Rectangle drawRectangleBackground() {
    Rectangle background = new Rectangle(320, 112);
    background.setX(0);//from   ww w . j a  va  2  s .co m
    background.setY(0);
    background.setArcHeight(15);
    background.setArcWidth(15);
    background.setFill(Color.rgb(0, 0, 0, 0.55));
    background.setStrokeWidth(1.5);
    background.setStroke(foregroundColor);

    return background;
}

From source file:User.java

private HBox drawRow2() {
    PasswordField passwordField = new PasswordField();
    passwordField.setFont(Font.font("SanSerif", 20));
    passwordField.setPromptText("Password");
    passwordField.setStyle(// www.  j ava2  s.com
            "-fx-text-fill:black; " + "-fx-prompt-text-fill:gray; " + "-fx-highlight-text-fill:black; "
                    + "-fx-highlight-fill: gray; " + "-fx-background-color: rgba(255, 255, 255, .80); ");

    passwordField.prefWidthProperty().bind(primaryStage.widthProperty().subtract(55));
    user.passwordProperty().bind(passwordField.textProperty());

    // error icon
    SVGPath deniedIcon = new SVGPath();
    deniedIcon.setFill(Color.rgb(255, 0, 0, .9));
    deniedIcon.setStroke(Color.WHITE);//
    deniedIcon.setContent("M24.778,21.419 19.276,15.917 24.777,10.415 21.949,7.585 "
            + "16.447,13.08710.945,7.585 8.117,10.415 13.618,15.917 8.116,21.419 10"
            + ".946,24.248 16.447,18.746 21.948,24.248z");
    deniedIcon.setVisible(false);

    SVGPath grantedIcon = new SVGPath();
    grantedIcon.setFill(Color.rgb(0, 255, 0, .9));
    grantedIcon.setStroke(Color.WHITE);//
    grantedIcon.setContent(
            "M2.379,14.729 5.208,11.899 12.958,19.648 25.877," + "6.733 28.707,9.56112.958,25.308z");
    grantedIcon.setVisible(false);

    //
    StackPane accessIndicator = new StackPane();
    accessIndicator.getChildren().addAll(deniedIcon, grantedIcon);
    accessIndicator.setAlignment(Pos.CENTER_RIGHT);

    grantedIcon.visibleProperty().bind(GRANTED_ACCESS);

    // user hits the enter key
    passwordField.setOnAction(actionEvent -> {
        if (GRANTED_ACCESS.get()) {
            System.out.printf("User %s is granted access.\n", user.getUserName());
            System.out.printf("User %s entered the password: %s\n", user.getUserName(), user.getPassword());
            Platform.exit();
        } else {
            deniedIcon.setVisible(true);
        }

        ATTEMPTS.set(ATTEMPTS.add(1).get());
        System.out.println("Attempts: " + ATTEMPTS.get());
    });

    // listener when the user types into the password field
    passwordField.textProperty().addListener((obs, ov, nv) -> {
        boolean granted = passwordField.getText().equals(MY_PASS);
        GRANTED_ACCESS.set(granted);
        if (granted) {
            deniedIcon.setVisible(false);
        }
    });

    // listener on number of attempts
    ATTEMPTS.addListener((obs, ov, nv) -> {
        if (MAX_ATTEMPTS == nv.intValue()) {
            // failed attempts
            System.out.printf("User %s is denied access.\n", user.getUserName());
            Platform.exit();
        }
    });

    // second row
    HBox row2 = new HBox(3);
    row2.getChildren().addAll(passwordField, accessIndicator);

    return row2;
}

From source file:User.java

@Override
public void start(Stage primaryStage) {
    this.primaryStage = primaryStage;
    user = new User();

    primaryStage.initStyle(StageStyle.TRANSPARENT);

    root = new Group();
    Scene scene = new Scene(root, 320, 112, Color.rgb(0, 0, 0, 0));

    primaryStage.setScene(scene);/*ww w .j av  a  2s  .com*/

    Rectangle background = this.drawRectangleBackground();
    HBox row1 = this.drawRow1();
    HBox row2 = this.drawRow2();

    VBox formLayout = new VBox(4); // spacing
    formLayout.setLayoutX(12);
    formLayout.setLayoutY(12);

    formLayout.getChildren().addAll(row1, row2);

    root.getChildren().addAll(background, formLayout);

    primaryStage.show();
}

From source file:Main.java

static Node blendMode() {
    Rectangle r = new Rectangle();
    r.setX(590);/*from   w  w w  .j  a va  2  s. c  om*/
    r.setY(50);
    r.setWidth(50);
    r.setHeight(50);
    r.setFill(Color.BLUE);

    Circle c = new Circle();
    c.setFill(Color.rgb(255, 0, 0, 0.5f));
    c.setCenterX(590);
    c.setCenterY(50);
    c.setRadius(25);

    Group g = new Group();
    g.setBlendMode(BlendMode.MULTIPLY);
    g.getChildren().add(r);
    g.getChildren().add(c);
    return g;
}

From source file:editeurpanovisu.EditeurPanovisu.java

/**
 *
 * @param iLargeur// w  w  w  .jav  a 2 s  . c o  m
 * @param iHauteur
 * @param bMasqueZones
 * @param strIdZone
 * @param mouseEvent
 */
private static void choixZone(int iLargeur, int iHauteur, boolean bMasqueZones, String strIdZone,
        MouseEvent mouseEvent) {
    ComboBox cbTouchesBarre = new ComboBox();
    cbTouchesBarre.getItems().clear();
    for (int i = 0; i < strTouchesBarre.length; i++) {
        cbTouchesBarre.getItems().add(i, strTouchesBarre[i]);
    }
    cbTouchesBarre.setLayoutX(200);
    cbTouchesBarre.setLayoutX(40);

    final int iNumeroZone = Integer.parseInt(strIdZone.split("-")[1]);
    if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) {
        if (mouseEvent.getClickCount() == 2) {
            for (int ij = iNumeroZone; ij < iNombreZones - 1; ij++) {
                zones[ij] = zones[ij + 1];
            }
            iNombreZones--;
            afficheBarrePersonnalisee(iLargeur, iHauteur, bMasqueZones);
        } else {
            afficheBarrePersonnalisee(iLargeur, iHauteur, bMasqueZones);
            apZoneBarrePersonnalisee.getChildren().clear();
            apZoneBarrePersonnalisee.getChildren().add(cbTouchesBarre);
            ZoneTelecommande zone = zones[iNumeroZone];
            int index = -1;
            for (int ij = 0; ij < strCodeBarre.length; ij++) {
                if (strCodeBarre[ij].equals(zone.getStrIdZone())) {
                    index = ij;
                }
            }
            if (index != -1) {
                cbTouchesBarre.getSelectionModel().select(index);
            }

            cbTouchesBarre.valueProperty().addListener((ov, ancienneValeur, nouvelleValeur) -> {
                if (nouvelleValeur != null) {
                    String strId = strCodeBarre[cbTouchesBarre.getSelectionModel().getSelectedIndex()];
                    zones[iNumeroZone].setStrIdZone(strId);
                }
            });

            Label lblTypeBarre = new Label(zone.getStrTypeZone());
            lblTypeBarre.setLayoutX(20);
            lblTypeBarre.setLayoutY(40);
            Label lblCoordsBarre = new Label(zone.getStrCoordonneesZone());
            lblCoordsBarre.setLayoutX(20);
            lblCoordsBarre.setLayoutY(70);
            lblCoordsBarre.setPrefWidth(260);
            lblCoordsBarre.setMaxWidth(260);
            lblCoordsBarre.setWrapText(true);
            apZoneBarrePersonnalisee.getChildren().addAll(lblTypeBarre, lblCoordsBarre);
            switch (zone.getStrTypeZone()) {
            case "poly":
                Polygon poly = (Polygon) apImgBarrePersonnalisee.lookup("#" + strIdZone);
                poly.setFill(Color.rgb(255, 0, 0, 0.5));
                poly.setStroke(Color.YELLOW);
                apImgBarrePersonnalisee.getChildren()
                        .addAll(olCreeAncresPourPolygone(iNumeroZone, poly.getPoints()));
                break;
            case "rect":
                Rectangle rect = (Rectangle) apImgBarrePersonnalisee.lookup("#" + strIdZone);
                rect.setFill(Color.rgb(255, 0, 0, 0.5));
                rect.setStroke(Color.YELLOW);
                apImgBarrePersonnalisee.getChildren().addAll(olCreeAncresPourRectangle(iNumeroZone, rect));
                break;
            case "circle":
                Circle cercle = (Circle) apImgBarrePersonnalisee.lookup("#" + strIdZone);
                cercle.setFill(Color.rgb(255, 0, 0, 0.5));
                cercle.setStroke(Color.YELLOW);
                apImgBarrePersonnalisee.getChildren().addAll(olCreeAncresPourCercle(iNumeroZone, cercle));
                break;
            }

        }
    }

}