List of usage examples for javafx.scene.paint Color rgb
public static Color rgb(int red, int green, int blue)
From source file:TwoButtons.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); final RowLayout layout = new RowLayout(); shell.setLayout(layout);//from w w w .j a v a 2 s . com /* Create the SWT button */ final org.eclipse.swt.widgets.Button swtButton = new org.eclipse.swt.widgets.Button(shell, SWT.PUSH); swtButton.setText("SWT Button"); /* Create an FXCanvas */ final FXCanvas fxCanvas = new FXCanvas(shell, SWT.NONE) { public Point computeSize(int wHint, int hHint, boolean changed) { getScene().getWindow().sizeToScene(); int width = (int) getScene().getWidth(); int height = (int) getScene().getHeight(); return new Point(width, height); } }; /* Create a JavaFX Group node */ Group group = new Group(); /* Create a JavaFX button */ final Button jfxButton = new Button("JFX Button"); /* Assign the CSS ID ipad-dark-grey */ jfxButton.setId("ipad-dark-grey"); /* Add the button as a child of the Group node */ group.getChildren().add(jfxButton); /* Create the Scene instance and set the group node as root */ Scene scene = new Scene(group, Color.rgb(shell.getBackground().getRed(), shell.getBackground().getGreen(), shell.getBackground().getBlue())); /* Attach an external stylesheet */ scene.getStylesheets().add("twobuttons/Buttons.css"); fxCanvas.setScene(scene); /* Add Listeners */ swtButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { jfxButton.setText("JFX Button: Hello from SWT"); shell.layout(); } }); jfxButton.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { swtButton.setText("SWT Button: Hello from JFX"); shell.layout(); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:Main.java
public static void startValueSetAnimation(final Pane parent) { final javafx.scene.shape.Rectangle rectangle = new javafx.scene.shape.Rectangle(); Insets margin = BorderPane.getMargin(parent); if (margin == null) { margin = new Insets(0); }/* w w w. jav a2s. co m*/ rectangle.widthProperty().bind(parent.widthProperty().subtract(margin.getLeft() + margin.getRight())); rectangle.heightProperty().bind(parent.heightProperty().subtract(margin.getTop() + margin.getBottom())); rectangle.setFill(Color.rgb(0, 150, 201)); parent.getChildren().add(rectangle); BoxBlur bb = new BoxBlur(); bb.setWidth(5); bb.setHeight(5); bb.setIterations(3); rectangle.setEffect(bb); FadeTransition ft = new FadeTransition(Duration.millis(250), rectangle); ft.setFromValue(0.2); ft.setToValue(0.8); ft.setCycleCount(2); ft.setAutoReverse(true); ft.play(); ft.setOnFinished(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { parent.getChildren().remove(rectangle); } }); }
From source file:Main.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle("Shapes"); Group root = new Group(); Scene scene = new Scene(root, 300, 300, Color.WHITE); Ellipse bigCircle = EllipseBuilder.create().centerX(100).centerY(100).radiusX(50).radiusY(75 / 2) .strokeWidth(3).stroke(Color.BLACK).fill(Color.WHITE).build(); Ellipse smallCircle = EllipseBuilder.create().centerX(100).centerY(100).radiusX(35 / 2).radiusY(25 / 2) .build();//w w w .j av a 2 s . co m Shape shape = Path.subtract(bigCircle, smallCircle); shape.setStrokeWidth(1); shape.setStroke(Color.BLACK); shape.setFill(Color.rgb(255, 200, 0)); root.getChildren().add(shape); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle("Shapes"); Group root = new Group(); Scene scene = new Scene(root, 300, 300, Color.WHITE); Ellipse bigCircle = EllipseBuilder.create().centerX(100).centerY(100).radiusX(50).radiusY(75 / 2) .strokeWidth(3).stroke(Color.BLACK).fill(Color.WHITE).build(); Ellipse smallCircle = EllipseBuilder.create().centerX(100).centerY(100).radiusX(35 / 2).radiusY(25 / 2) .build();// w ww. j a va 2 s .c om Shape shape = Path.subtract(bigCircle, smallCircle); shape.setStrokeWidth(1); shape.setStroke(Color.BLACK); shape.setFill(Color.rgb(255, 200, 0)); DropShadow dropShadow = DropShadowBuilder.create().offsetX(2.0f).offsetY(2.0f) .color(Color.rgb(50, 50, 50, .588)).build(); shape.setEffect(dropShadow); root.getChildren().add(shape); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Group p = new Group(); Scene scene = new Scene(p); stage.setScene(scene);// ww w . j av a 2 s .c o m stage.setWidth(500); stage.setHeight(500); p.setTranslateX(80); p.setTranslateY(80); //create a circle with effect final Circle circle = new Circle(20, Color.rgb(156, 216, 255)); circle.setEffect(new Lighting()); //create a text inside a circle final Text text = new Text(i.toString()); text.setStroke(Color.BLACK); //create a layout for circle with text inside final StackPane stack = new StackPane(); stack.getChildren().addAll(circle, text); stack.setLayoutX(30); stack.setLayoutY(30); p.getChildren().add(stack); stage.show(); //create a timeline for moving the circle timeline = new Timeline(); timeline.setCycleCount(Timeline.INDEFINITE); timeline.setAutoReverse(true); //You can add a specific action when each frame is started. timer = new AnimationTimer() { @Override public void handle(long l) { text.setText(i.toString()); i++; } }; //create a keyValue with factory: scaling the circle 2times KeyValue keyValueX = new KeyValue(stack.scaleXProperty(), 2); KeyValue keyValueY = new KeyValue(stack.scaleYProperty(), 2); //create a keyFrame, the keyValue is reached at time 2s Duration duration = Duration.millis(2000); //one can add a specific action when the keyframe is reached EventHandler onFinished = new EventHandler<ActionEvent>() { public void handle(ActionEvent t) { stack.setTranslateX(java.lang.Math.random() * 200 - 100); //reset counter i = 0; } }; KeyFrame keyFrame = new KeyFrame(duration, onFinished, keyValueX, keyValueY); //add the keyframe to the timeline timeline.getKeyFrames().add(keyFrame); timeline.play(); timer.start(); }
From source file:de.scoopgmbh.copper.monitoring.client.context.ApplicationContext.java
public ApplicationContext() { mainStackPane = new StackPane(); mainPane = new BorderPane(); mainPane.setId("background");//important for css mainStackPane.getChildren().add(mainPane); messageProvider = new MessageProvider(ResourceBundle.getBundle("de.scoopgmbh.copper.gui.message")); final Preferences prefs = Preferences.userRoot().node("de.scoopgmbh.coppermonitor"); SettingsModel defaultSettings = new SettingsModel(); AuditralColorMapping newItem = new AuditralColorMapping(); newItem.color.setValue(Color.rgb(255, 128, 128)); newItem.loglevelRegEx.setValue("1"); defaultSettings.auditralColorMappings.add(newItem); byte[] defaultModelbytes; ByteArrayOutputStream os = null; try {// w w w. java2s.c om os = new ByteArrayOutputStream(); ObjectOutputStream o = new ObjectOutputStream(os); o.writeObject(defaultSettings); defaultModelbytes = os.toByteArray(); } catch (IOException e) { throw new RuntimeException(e); } finally { if (os != null) { try { os.close(); } catch (IOException e) { throw new RuntimeException(e); } } } settingsModelSingleton = defaultSettings; ByteArrayInputStream is = null; try { is = new ByteArrayInputStream(prefs.getByteArray(SETTINGS_KEY, defaultModelbytes)); ObjectInputStream o = new ObjectInputStream(is); Object object = o.readObject(); if (object instanceof SettingsModel) { settingsModelSingleton = (SettingsModel) object; } } catch (Exception e) { logger.error("", e); getIssueReporterSingleton() .reportWarning("Can't load settings from (Preferences: " + prefs + ") use defaults instead", e); } finally { if (is != null) { try { is.close(); } catch (IOException e) { throw new RuntimeException(e); } } } Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { @Override public void run() { ByteArrayOutputStream os = null; try { os = new ByteArrayOutputStream(); ObjectOutputStream o = new ObjectOutputStream(os); o.writeObject(settingsModelSingleton); prefs.putByteArray(SETTINGS_KEY, os.toByteArray()); } catch (IOException e) { throw new RuntimeException(e); } finally { if (os != null) { try { os.close(); } catch (IOException e) { throw new RuntimeException(e); } } } } })); }
From source file:Main.java
@Override public void start(Stage stage) { String message = "Earthrise at Christmas: " + "[Forty] years ago this Christmas, a turbulent world " + "looked to the heavens for a unique view of our home " + "planet. This photo of Earthrise over the lunar horizon " + "was taken by the Apollo 8 crew in December 1968, showing " + "Earth for the first time as it appears from deep space. " + "Astronauts Frank Borman, Jim Lovell and William Anders " + "had become the first humans to leave Earth orbit, " + "entering lunar orbit on Christmas Eve. In a historic live " + "broadcast that night, the crew took turns reading from " + "the Book of Genesis, closing with a holiday wish from " + "Commander Borman: \"We close with good night, good luck, " + "a Merry Christmas, and God bless all of you -- all of " + "you on the good Earth.\""; // Reference to the Text Text textRef = TextBuilder.create().layoutY(100).textOrigin(VPos.TOP).textAlignment(TextAlignment.JUSTIFY) .wrappingWidth(400).text(message).fill(Color.rgb(187, 195, 107)) .font(Font.font("SansSerif", FontWeight.BOLD, 24)).build(); // Provides the animated scrolling behavior for the text TranslateTransition transTransition = TranslateTransitionBuilder.create().duration(new Duration(75000)) .node(textRef).toY(-820).interpolator(Interpolator.LINEAR).cycleCount(Timeline.INDEFINITE).build(); Scene scene = SceneBuilder//from www. j a v a 2 s . c o m .create().width(516).height( 387) .root(GroupBuilder.create().children( ImageViewBuilder.create().image(new Image("http://projavafx.com/images/earthrise.jpg")) .build(), ScrollPaneBuilder.create().layoutX(50).layoutY(180).prefWidth(440).prefHeight(85) .hbarPolicy(ScrollBarPolicy.NEVER).vbarPolicy(ScrollBarPolicy.NEVER).pannable(true) .content(textRef).style("-fx-background-color: transparent;").build()) .build()) .build(); stage.setScene(scene); stage.setTitle("Hello Earthrise"); stage.show(); // Start the text animation transTransition.play(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = SceneBuilder.create().width(320).height(343) .root(GroupBuilder.create()//from w w w . j a v a 2 s . com .children( RectangleBuilder.create().width(320).height(45) .fill(LinearGradientBuilder.create().endX(0.0).endY(1.0) .stops(new Stop(0, Color.web("0xAEBBCC")), new Stop(1, Color.web("0x6D84A3"))) .build()) .build(), TextBuilder .create().layoutX(65).layoutY(12).textOrigin(VPos.TOP).fill(Color.WHITE) .text("Audio Configuration") .font(Font.font("SansSerif", FontWeight.BOLD, 20)).build(), RectangleBuilder .create().x(0).y(43).width(320).height(300).fill(Color.rgb(199, 206, 213)) .build(), RectangleBuilder .create().x(9).y(54).width(300).height(130).arcWidth(20).arcHeight(20) .fill(Color.WHITE).stroke(Color.color(0.66, 0.67, 0.69)).build(), textDb = TextBuilder.create().layoutX(18).layoutY(69).textOrigin(VPos.TOP) .fill(Color.web("#131021")) .font(Font.font("SansSerif", FontWeight.BOLD, 18)).build(), slider = SliderBuilder.create().layoutX(135).layoutY(69).prefWidth(162) .min(acModel.minDecibels).max(acModel.maxDecibels).build(), LineBuilder .create().startX(9).startY(97).endX(309).endY(97) .stroke(Color.color(0.66, 0.67, 0.69)).build(), TextBuilder.create().layoutX(18).layoutY(113).textOrigin(VPos.TOP) .fill(Color.web("#131021")).text("Muting") .font(Font.font("SanSerif", FontWeight.BOLD, 18)).build(), mutingCheckBox = CheckBoxBuilder.create().layoutX(280).layoutY(113).build(), LineBuilder.create().startX(9).startY(141).endX(309).endY(141) .stroke(Color.color(0.66, 0.67, 0.69)).build(), TextBuilder.create().layoutX(18).layoutY(154).textOrigin(VPos.TOP) .fill(Color.web("#131021")).text("Genre") .font(Font.font("SanSerif", FontWeight.BOLD, 18)).build(), genreChoiceBox = ChoiceBoxBuilder.create().layoutX(204).layoutY(154).prefWidth(93) .items(acModel.genres).build()) .build()) .build(); textDb.textProperty().bind(acModel.selectedDBs.asString().concat(" dB")); slider.valueProperty().bindBidirectional(acModel.selectedDBs); slider.disableProperty().bind(acModel.muting); mutingCheckBox.selectedProperty().bindBidirectional(acModel.muting); acModel.genreSelectionModel = genreChoiceBox.getSelectionModel(); acModel.addListenerToGenreSelectionModel(); acModel.genreSelectionModel.selectFirst(); stage.setScene(scene); stage.setTitle("Audio Configuration"); stage.show(); }
From source file:deincraftlauncher.InstallController.java
@Override public void initialize(URL url, ResourceBundle rb) { instance = this; System.out.println("Starting Installer UI..."); int saveX = 393; int cancelY = 165; int saveY = 200; int sizeX = 481; Rectangle separator = new Rectangle(); separator.setWidth(sizeX);//from w w w . j a v a 2 s . c om separator.setHeight(separatorSizeY); separator.setLayoutY(separatorY); separator.setFill(blueColor); mainPanel.getChildren().add(separator); mainPanel.setBackground(Background.EMPTY); TextButton cancel = new TextButton(saveX, cancelY, "cancel", Color.RED, mainPanel); cancel.setOnClick((TextButton tile) -> { cancel(); }); save = new TextButton(saveX, saveY, "Weiter", Color.GRAY, mainPanel); save.setFocusable(false); save.setOnClick((TextButton tile) -> { Continue(); }); login = new TextButton(14, 151, "Login", Color.BLUE, mainPanel); login.setOnClick((TextButton tile) -> { doLogin(null); }); Label Title = new Label(); Title.setText("Installer"); Title.setPrefSize(sizeX, separatorY); Title.setTextFill(Color.WHITESMOKE); Title.setTextAlignment(TextAlignment.CENTER); Title.setFont(DesignHelpers.getFocusFont(42)); Title.setAlignment(Pos.CENTER); mainPanel.getChildren().add(Title); pathLabel.setBackground(new Background(new BackgroundFill(Color.rgb(170, 170, 170), radii, insets))); //ContinueButton.setBackground(new Background(new BackgroundFill(Color.rgb(100, 190, 100), radii, insets))); //Green Version setDefaultPath(); System.out.println("starting done"); }
From source file:de.unibw.inf2.fishification.FishWorld.java
/** * Draws the background of the aquarium. *///w ww. j a va 2 s. co m private void fillAquariumBackground() { RadialGradientBuilder gradientBuilder = RadialGradientBuilder.create(); gradientBuilder.centerX(getWorldCanvas().getWidth() / 2); gradientBuilder.centerY(50); gradientBuilder.radius(1000); gradientBuilder.proportional(false); gradientBuilder.stops(new Stop(0.0, Color.WHITE), new Stop(0.05, Color.rgb(245, 251, 251)), new Stop(0.1, Color.rgb(220, 242, 239)), new Stop(0.2, Color.rgb(164, 214, 211)), new Stop(0.3, Color.rgb(142, 195, 199)), new Stop(0.4, Color.rgb(111, 170, 184)), new Stop(0.5, Color.rgb(84, 145, 166)), new Stop(0.6, Color.rgb(61, 125, 152)), new Stop(0.7, Color.rgb(50, 111, 140)), new Stop(0.8, Color.rgb(33, 96, 129)), new Stop(0.9, Color.rgb(25, 85, 121)), new Stop(1.0, Color.rgb(19, 77, 115))); RadialGradient gradient = gradientBuilder.build(); getWorldCanvas().setFill(gradient); }