@Override public void start(Stage stage) { this.stage = stage; stage.initStyle(StageStyle.TRANSPARENT); VBox box = new VBox(20); box.setMaxWidth(Region.USE_PREF_SIZE); box.setMaxHeight(Region.USE_PREF_SIZE); box.setBackground(Background.EMPTY); String style = "-fx-background-color: rgba(255, 255, 255, 0.5);"; box.setStyle(style); box.setPadding(new Insets(50)); BorderPane root = new BorderPane(box); root.setStyle(style); root.setBackground(Background.EMPTY); Scene scene = new Scene(root); scene.setFill(Color.TRANSPARENT); stage.setScene(scene); ImageView splashView = new ImageView(splashImage); box.getChildren().addAll(splashView, new Label("ST Verification Studio is loading..")); stage.show(); Rectangle2D primScreenBounds = Screen.getPrimary().getVisualBounds(); stage.setX((primScreenBounds.getWidth() - stage.getWidth()) / 2); stage.setY((primScreenBounds.getHeight() - stage.getHeight()) / 2); }
public void majColorButton(){ switch(state){ case Consts.WHITE: colorPlayer1.setBackground(new Background(new BackgroundFill(new ImagePattern(new Image(getClass().getClassLoader().getResource("main/resources/img/misc/whitestart.png").toString())), CornerRadii.EMPTY, Insets.EMPTY))); colorPlayer2.setBackground(new Background(new BackgroundFill(new ImagePattern(new Image(getClass().getClassLoader().getResource("main/resources/img/misc/blackstart.png").toString())), CornerRadii.EMPTY, Insets.EMPTY))); break; case Consts.BLACK: colorPlayer2.setBackground(new Background(new BackgroundFill(new ImagePattern(new Image(getClass().getClassLoader().getResource("main/resources/img/misc/whitestart.png").toString())), CornerRadii.EMPTY, Insets.EMPTY))); colorPlayer1.setBackground(new Background(new BackgroundFill(new ImagePattern(new Image(getClass().getClassLoader().getResource("main/resources/img/misc/blackstart.png").toString())), CornerRadii.EMPTY, Insets.EMPTY))); break; case Consts.RANDOM: colorPlayer1.setBackground(new Background(new BackgroundFill(new ImagePattern(new Image(getClass().getClassLoader().getResource("main/resources/img/misc/rngstart.png").toString())), CornerRadii.EMPTY, Insets.EMPTY))); colorPlayer2.setBackground(new Background(new BackgroundFill(new ImagePattern(new Image(getClass().getClassLoader().getResource("main/resources/img/misc/rngstart.png").toString())), CornerRadii.EMPTY, Insets.EMPTY))); break; default: break; } }
@FXML public void handleLaunchGameClick() { String player = "Anonyme"; Core core = new Core(-1, -1); String host = choiceClient.isSelected() ? hostName.getText() : null; int mode = choiceHost.isSelected() ? (state == Consts.WHITE ? Consts.PVEX : Consts.EXVP) : -1; if(!playerName.getText().equals("")) player = playerName.getText(); int error = core.connect(host, mode, player); if (error == 0) { core.playNextTurn(); main.showGameScreen(core,false); } else if (choiceClient.isSelected()) { hostName.setBackground( new Background(new BackgroundFill(Color.ORANGERED, new CornerRadii(2), new Insets(2)))); hostName.clear(); hostName.setText(error==1?"Host inconnnu":"Erreur de connexion"); } else { playerName.setBackground( new Background(new BackgroundFill(Color.ORANGERED, new CornerRadii(2), new Insets(2)))); playerName.clear(); playerName.setText("Erreur de connexion"); } // hostName.setBorder(new Border(new BorderStroke(Color.RED, // BorderStrokeStyle.SOLID, new CornerRadii(10), BorderWidths.FULL))); }
public void majColorButton() { switch (state) { case Consts.WHITE: colorHost.setBackground(new Background(new BackgroundFill( new ImagePattern(new Image(getClass().getClassLoader() .getResource("main/resources/img/misc/whitestart.png").toString())), CornerRadii.EMPTY, Insets.EMPTY))); break; case Consts.BLACK: colorHost.setBackground(new Background(new BackgroundFill( new ImagePattern(new Image(getClass().getClassLoader() .getResource("main/resources/img/misc/blackstart.png").toString())), CornerRadii.EMPTY, Insets.EMPTY))); break; case Consts.RANDOM: colorHost.setBackground(new Background(new BackgroundFill( new ImagePattern(new Image(getClass().getClassLoader() .getResource("main/resources/img/misc/rngstart.png").toString())), CornerRadii.EMPTY, Insets.EMPTY))); break; default: break; } }
public void setLegendSymbolFill(final Series<X, Y> SERIES, final Paint LEGEND_SYMBOL_FILL) { if (getData().isEmpty()) { return; } if (!getData().contains(SERIES)) { return; } int seriesIndex = getData().indexOf(SERIES); if (seriesIndex == -1) { return; } Legend legend = (Legend) getLegend(); if (null == legend) { return; } LegendItem item = legend.getItems().get(seriesIndex); if (null == item) { return; } Region symbol = (Region) item.getSymbol(); if (null == symbol) { return; } symbol.setBackground(new Background(new BackgroundFill(LEGEND_SYMBOL_FILL, new CornerRadii(6), Insets.EMPTY))); }
@Override public void start(Stage stage) { GridPane pane = new GridPane(); pane.setBackground(new Background(new BackgroundFill(Color.DARKGRAY, CornerRadii.EMPTY, Insets.EMPTY))); pane.setPadding(new Insets(10)); pane.setHgap(10); pane.setVgap(10); pane.add(lineChartNotSmoothed, 0, 0); pane.add(lineChartSmoothed, 1, 0); pane.add(areaChartNotSmoothed, 0, 1); pane.add(areaChartSmoothed, 1, 1); pane.add(tweakedChart, 0, 2); pane.add(tweaked2Chart, 1, 2); Scene scene = new Scene(pane); stage.setTitle("Smooth Charts"); stage.setScene(scene); stage.show(); }
@Override public void initialize(URL location, ResourceBundle resources) { logoImg.setImage(UIUtils.getImage("logo.png")); Dialog diag = new Dialog(); diag.getDialogPane().setContent(borderPane); diag.getDialogPane().setBackground(Background.EMPTY); diag.setResizable(true); UIUtils.setIcon(diag); ButtonType closeButton = new ButtonType("Close", ButtonBar.ButtonData.OK_DONE); diag.getDialogPane().getButtonTypes().addAll(closeButton); diag.setTitle("About HueSense"); Optional<ButtonType> opt = diag.showAndWait(); if (opt.isPresent() && opt.get().getButtonData() == ButtonBar.ButtonData.OK_DONE) { // nothing } }
/** * 将自己的对话添加到对话列表中 * @param content */ public void addYourMessges(String content){ Platform.runLater(() ->{ //寻找用户的头像名 Image image = new Image("images/" + userPic); ImageView profileImage = new ImageView(image); profileImage.setFitHeight(32); profileImage.setFitWidth(32); BubbledTextFlow yourBubbled = new BubbledTextFlow(EmojiDisplayer.createEmojiAndTextNode(content)); yourBubbled.setBackground(new Background(new BackgroundFill(Color.LIGHTGREEN, null, null))); HBox x = new HBox(); x.setMaxWidth(chatPaneListView.getWidth() - 20); x.setAlignment(Pos.TOP_RIGHT); yourBubbled.setBubbleSpec(BubbleSpec.FACE_RIGHT_CENTER); x.getChildren().addAll(yourBubbled, profileImage); chatPaneListView.getItems().add(x); }); }
/** * 处理通知信息的显示 * @param notice */ public void addNotification(String notice){ Platform.runLater(() ->{ SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");//设置日期格式 String timer = df.format(new Date());// new Date()为获取当前系统时间 String content = timer + ": " + notice; BubbledTextFlow noticeBubbled = new BubbledTextFlow(EmojiDisplayer.createEmojiAndTextNode(content)); //noticeBubbled.setTextFill(Color.web("#031c30")); noticeBubbled.setBackground(new Background(new BackgroundFill(Color.WHITE, null, null))); HBox x = new HBox(); //x.setMaxWidth(chatPaneListView.getWidth() - 20); x.setAlignment(Pos.TOP_CENTER); noticeBubbled.setBubbleSpec(BubbleSpec.FACE_TOP); x.getChildren().addAll(noticeBubbled); chatPaneListView.getItems().add(x); }); }
private void initGraphics() { if (Double.compare(getPrefWidth(), 0.0) <= 0 || Double.compare(getPrefHeight(), 0.0) <= 0 || Double.compare(getWidth(), 0.0) <= 0 || Double.compare(getHeight(), 0.0) <= 0) { if (getPrefWidth() > 0 && getPrefHeight() > 0) { setPrefSize(getPrefWidth(), getPrefHeight()); } else { setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT); } } segmentPane = new Pane(); chartCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT); chartCanvas.setMouseTransparent(true); chartCtx = chartCanvas.getGraphicsContext2D(); pane = new Pane(segmentPane, chartCanvas); pane.setBackground(new Background(new BackgroundFill(backgroundPaint, CornerRadii.EMPTY, Insets.EMPTY))); pane.setBorder(new Border(new BorderStroke(borderPaint, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(borderWidth)))); getChildren().setAll(pane); prepareData(); }
public HighlightCell(StringProperty textToHighlight) { super(); this.backgroundProperty().bind(Bindings.when(Bindings.and(Bindings.isNotNull(textToHighlight), Bindings.equal(itemProperty(), textToHighlight))) .then(HIGHLIGHT_BACKGROUND) .otherwise(Background.EMPTY)); }
/** * Generates a panel image form char. * <p>First, this function converts ch to upper case if ch is lower case.</p> * <p>Then, this generates javafx's image from ch.And return it.</p> * You can fix the resolution of image through {@link capslock.CharPanelGenerator#PANEL_IMAGE_SIZE} * and {@link capslock.CharPanelGenerator#FONT_SIZE}. * @param ch パネルの生成に使う1文字. * @param color 背景色. * @return 生成されたパネル. */ static final Image generate(char ch, Color color){ final Label label = new Label(Character.toString(Character.toUpperCase(ch))); label.setMinSize(PANEL_IMAGE_SIZE, PANEL_IMAGE_SIZE); label.setMaxSize(PANEL_IMAGE_SIZE, PANEL_IMAGE_SIZE); label.setPrefSize(PANEL_IMAGE_SIZE, PANEL_IMAGE_SIZE); label.setFont(Font.font(FONT_SIZE)); label.setAlignment(Pos.CENTER); label.setTextFill(Color.WHITE); label.setBackground(new Background(new BackgroundFill(color, CornerRadii.EMPTY, Insets.EMPTY))); final Scene scene = new Scene(new Group(label)); final WritableImage img = new WritableImage(PANEL_IMAGE_SIZE, PANEL_IMAGE_SIZE); scene.snapshot(img); return img ; }
@Override protected void redraw() { pane.setBorder(new Border(new BorderStroke(clock.getBorderPaint(), BorderStrokeStyle.SOLID, new CornerRadii(1024), new BorderWidths(clock.getBorderWidth() / 250 * size)))); pane.setBackground(new Background(new BackgroundFill(clock.getBackgroundPaint(), new CornerRadii(1024), Insets.EMPTY))); secondBackgroundCircle.setStroke(Helper.getTranslucentColorFrom(clock.getSecondColor(), 0.2)); secondArc.setStroke(clock.getSecondColor()); hour.setFill(clock.getHourColor()); minute.setFill(clock.getMinuteColor()); dateText.setFill(clock.getDateColor()); dateNumbers.setFill(clock.getDateColor()); hour.setFill(clock.getHourColor()); minute.setFill(clock.getMinuteColor()); ZonedDateTime time = clock.getTime(); updateTime(time); }
private void initGraphics() { if (Double.compare(getPrefWidth(), 0.0) <= 0 || Double.compare(getPrefHeight(), 0.0) <= 0 || Double.compare(getWidth(), 0.0) <= 0 || Double.compare(getHeight(), 0.0) <= 0) { if (getPrefWidth() > 0 && getPrefHeight() > 0) { setPrefSize(getPrefWidth(), getPrefHeight()); } else { setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT); } } nameText = new Text(getName()); nameText.setTextOrigin(VPos.TOP); valueText = new Text(String.format(locale, formatString, getValue())); valueText.setTextOrigin(VPos.TOP); barBackground = new Rectangle(); bar = new Rectangle(); pane = new Pane(nameText, valueText, barBackground, bar); pane.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY))); getChildren().setAll(pane); }
public JfxSimpleEdit() { layout.setLeft(propertyZone); layout.setCenter(bodyZone); layout.setRight(jfxExtToolbarPanel); layout.setBottom(jfxToolbarPanel); layout.setBackground(Background.EMPTY); propertyZone.getStyleClass().add(StyleConstants.CLASS_HVBOX); bodyZone.setBackground(Background.EMPTY); bodyZone.getChildren().addAll(editPanel, editPanelBinder); // editPanelBinder要放上面,以响应拖放事件 editPanelBinder.setVisible(false); editPanelBinder.setStyle(STYLE_EDIT_PANEL); editPanelBinder.setOnDragOver(this::onDragOver); editPanelBinder.setOnDragDropped(this::onDragDropped); jfxToolbarPanel.setPadding(Insets.EMPTY); jfxToolbarPanel.getStyleClass().add(StyleConstants.CLASS_HVBOX); // 只有在有扩展工具栏的时候才应该显示 jfxExtToolbarPanel.managedProperty().bind(jfxExtToolbarPanel.visibleProperty()); jfxExtToolbarPanel.setVisible(false); jfxExtToolbarPanel.setPadding(Insets.EMPTY); }
private void resize() { double width = getWidth() - getInsets().getLeft() - getInsets().getRight(); double height = getHeight() - getInsets().getTop() - getInsets().getBottom(); size = width < height ? width : height; if (size > 0) { pane.setMaxSize(size, size); pane.relocate((getWidth() - size) * 0.5, (getHeight() - size) * 0.5); pane.setBackground(new Background(new BackgroundFill(getChartBackgroundColor(), new CornerRadii(1024), Insets.EMPTY))); chartCanvas.setWidth(size); chartCanvas.setHeight(size); overlayCanvas.setWidth(size); overlayCanvas.setHeight(size); redraw(); } }
private void initGraphics() { bars = new Region[] { createBar(20, "gray-bar"), createBar(24, "gray-bar"), createBar(28, "gray-bar"), createBar(32, "gray-bar"), createBar(36, "gray-bar"), createBar(40, "gray-bar"), createBar(44, "gray-bar"), createBar(48, "gray-bar"), createBar(52, "gray-bar"), createBar(56, "gray-bar"), createBar(60, "gray-bar"), createBar(64, "gray-bar")}; pane = new HBox(bars); pane.setSpacing(PREFERRED_WIDTH * 0.01960784); pane.setAlignment(Pos.BOTTOM_CENTER); pane.setFillHeight(false); pane.setBackground(new Background(new BackgroundFill(backgroundPaint, new CornerRadii(1024), Insets.EMPTY))); pane.setBorder(new Border(new BorderStroke(borderPaint, BorderStrokeStyle.SOLID, new CornerRadii(1024), new BorderWidths(borderWidth)))); getChildren().setAll(pane); }
@Override protected void initGraphics() { // Set initial size if (Double.compare(clock.getPrefWidth(), 0.0) <= 0 || Double.compare(clock.getPrefHeight(), 0.0) <= 0 || Double.compare(clock.getWidth(), 0.0) <= 0 || Double.compare(clock.getHeight(), 0.0) <= 0) { if (clock.getPrefWidth() > 0 && clock.getPrefHeight() > 0) { clock.setPrefSize(clock.getPrefWidth(), clock.getPrefHeight()); } else { clock.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT); } } timeText = new Text(); timeText.setTextOrigin(VPos.CENTER); timeText.setFill(textColor); dateText = new Text(); dateText.setTextOrigin(VPos.CENTER); dateText.setFill(dateColor); pane = new Pane(timeText, dateText); pane.setBorder(new Border(new BorderStroke(clock.getBorderPaint(), BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(clock.getBorderWidth())))); pane.setBackground(new Background(new BackgroundFill(clock.getBackgroundPaint(), CornerRadii.EMPTY, Insets.EMPTY))); getChildren().setAll(pane); }
@Override protected void redraw() { locale = gauge.getLocale(); formatString = new StringBuilder("%.").append(Integer.toString(gauge.getDecimals())).append("f%%").toString(); // Background stroke and fill pane.setBorder(new Border(new BorderStroke(gauge.getBorderPaint(), BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(gauge.getBorderWidth() / PREFERRED_WIDTH * width)))); pane.setBackground(new Background(new BackgroundFill(gauge.getBackgroundPaint(), CornerRadii.EMPTY, Insets.EMPTY))); fluidBody.setFill(gauge.getBarColor()); fluidTop.setFill(gauge.getBarColor().darker()); valueText.setFill(gauge.getValueColor()); titleText.setFill(gauge.getTitleColor()); resizeText(); setBar(gauge.getCurrentValue()); }
protected String describeBackground(Background b) { SB sb = new SB(); sb.a("Background<"); boolean sep = false; for(BackgroundFill f: b.getFills()) { if(sep) { sb.a(","); } else { sep = true; } sb.a(describe(f)); } sb.a(">"); return sb.toString(); }
@Override protected void redraw() { pane.setBorder(new Border(new BorderStroke(gauge.getBorderPaint(), BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(gauge.getBorderWidth() / PREFERRED_WIDTH * size)))); pane.setBackground(new Background(new BackgroundFill(gauge.getBackgroundPaint(), CornerRadii.EMPTY, Insets.EMPTY))); locale = gauge.getLocale(); titleText.setText(gauge.getTitle()); minValueText.setText(String.format(locale, "%." + gauge.getTickLabelDecimals() + "f", gauge.getMinValue())); maxValueText.setText(String.format(locale, "%." + gauge.getTickLabelDecimals() + "f", gauge.getMaxValue())); thresholdText.setText(String.format(locale, "%." + gauge.getTickLabelDecimals() + "f", gauge.getThreshold())); resizeStaticText(); barBackground.setStroke(gauge.getBarColor()); thresholdBar.setStroke(gauge.getThresholdColor()); needle.setFill(gauge.getNeedleColor()); titleText.setFill(gauge.getTitleColor()); minValueText.setFill(gauge.getTitleColor()); maxValueText.setFill(gauge.getTitleColor()); thresholdText.setFill(gauge.getTitleColor()); valueText.setFill(gauge.getValueColor()); thresholdText.setVisible(Double.compare(gauge.getThreshold(), gauge.getMinValue()) != 0 && Double.compare(gauge.getThreshold(), gauge.getMaxValue()) != 0); }
public final static void initializeLayout(Pane jfxRoot) { ZONE_EDIT.setBackground(Background.EMPTY); ZONE_TEXT.getTabs().addListener((ListChangeListener.Change<? extends Tab> c) -> { if (mainLayout != null) mainLayout.setTextZoneVisible(!c.getList().isEmpty()); }); // 加载样式文件 Jfx.getJfxRoot().getStylesheets().add("resources/style/gray_style.css"); Jfx.getJfxRoot().getStylesheets().add("resources/style/gray_scroll_bar.css"); // 创建主编辑器布器 initMainLayout(jfxRoot); // 将JFX中的UndoRedo按键转换到JME场景中 JfxUndoRedoKeyEventToJme(); }
public TitleSlideView(TitleSlide slide) { this.slide = slide; Background background = new Background(new BackgroundFill(ColorUtils.fromInt(slide.getColor()), null, null)); Label label = new Label(slide.getCaption()); setBackground(background); label.setMaxWidth(Double.MAX_VALUE); label.setMaxHeight(Double.MAX_VALUE); label.setAlignment(Pos.CENTER); label.setWrapText(true); HBox.setHgrow(label, Priority.ALWAYS); HBox box = new HBox(); box.getChildren().add(label); getChildren().add(box); label.setTextFill(Paint.valueOf("white")); label.setStyle("-fx-text-fill: white !important;"); label.setStyle("-fx-font-weight: bold"); label.setStyle("-fx-text-alignment: center"); label.setStyle("-fx-font-size: 70px"); }
@Override public void start(final Stage primaryStage) { final StackPane root = new StackPane(); final TextFlow tf = new TextFlow(); final Text t0 = new Text("First part"); final Text t1 = new Text(", second"); final TextField t2 = new TextField(" and very, very, very long third"); t2.setEditable(false); t2.setBackground(Background.EMPTY); t2.setFocusTraversable(false); tf.getChildren().addAll(t0, t1, t2); root.getChildren().add(tf); final Scene scene = new Scene(root, 300, 250); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show(); }
@Override protected void redraw() { pane.setBorder(new Border(new BorderStroke(clock.getBorderPaint(), BorderStrokeStyle.SOLID, new CornerRadii(1024), new BorderWidths(clock.getBorderWidth() / PREFERRED_WIDTH * size)))); pane.setBackground(new Background(new BackgroundFill(clock.getBackgroundPaint(), new CornerRadii(1024), Insets.EMPTY))); ZonedDateTime time = clock.getTime(); hourColor = clock.getHourColor(); minuteColor = clock.getMinuteColor(); fiveMinuteColor = minuteColor.darker(); secondColor = clock.getSecondColor(); titleColor = clock.getTitleColor(); textColor = clock.getTextColor(); dateColor = clock.getDateColor(); alarmColor = clock.getAlarmColor(); drawBackground(); drawForeground(time); drawHours(time); drawMinutes(time); drawSeconds(time); }
@Override protected void redraw() { pane.setBorder(new Border(new BorderStroke(gauge.getBorderPaint(), BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(gauge.getBorderWidth() / 250 * size)))); pane.setBackground(new Background(new BackgroundFill(gauge.getBackgroundPaint(), CornerRadii.EMPTY, Insets.EMPTY))); colorGradientEnabled = gauge.isGradientBarEnabled(); noOfGradientStops = gauge.getGradientBarStops().size(); sectionsVisible = gauge.getSectionsVisible(); barBackground.setFill(gauge.getBarBackgroundColor()); barBackground.setEffect(gauge.isShadowsEnabled() ? innerShadow : null); setBarColor(gauge.getCurrentValue()); dataBar.setEffect(gauge.isShadowsEnabled() ? innerShadow : null); threshold.setStroke(gauge.getThresholdColor()); double thresholdInnerRadius = 0.3 * height; double thresholdOuterRadius = 0.675 * height; double thresholdAngle = Helper.clamp(90.0, 270.0, (gauge.getThreshold() - minValue) * angleStep + 90.0); threshold.setStartX(centerX + thresholdInnerRadius * Math.sin(-Math.toRadians(thresholdAngle))); threshold.setStartY(centerX + thresholdInnerRadius * Math.cos(-Math.toRadians(thresholdAngle))); threshold.setEndX(centerX + thresholdOuterRadius * Math.sin(-Math.toRadians(thresholdAngle))); threshold.setEndY(centerX + thresholdOuterRadius * Math.cos(-Math.toRadians(thresholdAngle))); redrawText(); }
@Override protected void redraw() { pane.setBackground(new Background(new BackgroundFill(gauge.getBackgroundPaint(), new CornerRadii(1024), Insets.EMPTY))); pane.setBorder(new Border(new BorderStroke(gauge.getBorderPaint(), BorderStrokeStyle.SOLID, new CornerRadii(1024), new BorderWidths(gauge.getBorderWidth() / PREFERRED_WIDTH * size)))); locale = gauge.getLocale(); barColor = gauge.getBarColor(); valueColor = gauge.getValueColor(); titleColor = gauge.getTitleColor(); subTitleColor = gauge.getSubTitleColor(); unitColor = gauge.getUnitColor(); sectionsVisible = gauge.getSectionsVisible(); drawBackground(); setBar(gauge.getCurrentValue()); valueBkgText.setFill(Helper.getTranslucentColorFrom(valueColor, 0.1)); valueText.setFill(valueColor); }
@Override public void start(Stage stage) throws Exception { StackPane pane = new StackPane(canvas); pane.setBackground(new Background(new BackgroundFill(Color.BLACK, CornerRadii.EMPTY, Insets.EMPTY))); Scene scene = new Scene(pane); stage.setTitle("Canvas Bubbles"); stage.setScene(scene); stage.show(); // Calculate number of nodes calcNoOfNodes(pane); System.out.println(noOfNodes + " Nodes in SceneGraph"); System.out.println(NO_OF_PARTICLES + " Particles"); timer.start(); }
@Override public void start(Stage stage) throws Exception { try { // Chargement de l'interface FXML GridPane root = FXMLLoader.load(getClass().getResource("Home.fxml")); root.setBackground(new Background(new BackgroundFill(Color.WHITE, CornerRadii.EMPTY, Insets.EMPTY))); // Création de la scène Scene scene = new Scene(root); stage.setTitle("Jeu des 6 couleurs"); stage.setScene(scene); stage.show(); mainStage = stage; } catch(Exception e) { e.printStackTrace(); } }
@FXML protected void showAbout(ActionEvent event) { try { FXMLLoader loader = new FXMLLoader(getClass().getResource("About.fxml")); GridPane aboutRoot = loader.load(); About aboutController = loader.getController(); aboutController.setHostServices(getHostServices()); aboutRoot.setBackground(new Background(new BackgroundFill(Color.WHITE, CornerRadii.EMPTY, Insets.EMPTY))); Stage dialog = new Stage(); dialog.setTitle("Jeu des 6 couleurs - A propos"); dialog.setScene(new Scene(aboutRoot)); dialog.show(); } catch (Exception e) { e.printStackTrace(); } }
private void initGraphics() { if (Double.compare(getSkinnable().getPrefWidth(), 0.0) <= 0 || Double.compare(getSkinnable().getPrefHeight(), 0.0) <= 0 || Double.compare(getSkinnable().getWidth(), 0.0) <= 0 || Double.compare(getSkinnable().getHeight(), 0.0) <= 0) { if (getSkinnable().getPrefWidth() > 0 && getSkinnable().getPrefHeight() > 0) { getSkinnable().setPrefSize(getSkinnable().getPrefWidth(), getSkinnable().getPrefHeight()); } else { getSkinnable().setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT); } } node = new Region(); node.getStyleClass().setAll("node"); pane = new Pane(node); pane.setBackground(new Background(new BackgroundFill(backgroundPaint, CornerRadii.EMPTY, Insets.EMPTY))); pane.setBorder(new Border(new BorderStroke(borderPaint, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(borderWidth)))); getChildren().setAll(pane); }
@Override public void init() { ImageView splash = new ImageView(new Image( SPLASH_IMAGE, SPLASH_WIDTH, SPLASH_HEIGHT, true, true )); loadProgress = new ProgressBar(0); loadProgress.setPrefWidth(SPLASH_WIDTH); progressText = new Label("Initializing . . ."); progressText.setBackground(new Background(new BackgroundFill(Color.GHOSTWHITE,new CornerRadii(5),new Insets(0)))); splashLayout = new VBox(); splashLayout.getChildren().addAll(splash, loadProgress, progressText); progressText.setAlignment(Pos.CENTER); splashLayout.setBackground(Background.EMPTY); }
@Override protected void redraw() { pane.setBorder(new Border(new BorderStroke(clock.getBorderPaint(), BorderStrokeStyle.SOLID, new CornerRadii(1024), new BorderWidths(clock.getBorderWidth() / PREFERRED_WIDTH * size)))); pane.setBackground(new Background(new BackgroundFill(clock.getBackgroundPaint(), new CornerRadii(1024), Insets.EMPTY))); shadowGroup.setEffect(clock.getShadowsEnabled() ? dropShadow : null); // Tick Marks tickCanvas.setCache(false); drawTicks(); tickCanvas.setCache(true); tickCanvas.setCacheHint(CacheHint.QUALITY); needle.setStroke(clock.getHourColor()); ZonedDateTime time = clock.getTime(); updateTime(time); }
private void initGraphics() { // Set initial size if (Double.compare(getSkinnable().getPrefWidth(), 0.0) <= 0 || Double.compare(getSkinnable().getPrefHeight(), 0.0) <= 0 || Double.compare(getSkinnable().getWidth(), 0.0) <= 0 || Double.compare(getSkinnable().getHeight(), 0.0) <= 0) { if (getSkinnable().getPrefWidth() > 0 && getSkinnable().getPrefHeight() > 0) { getSkinnable().setPrefSize(getSkinnable().getPrefWidth(), getSkinnable().getPrefHeight()); } else { getSkinnable().setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT); } } pane = new Pane(); pane.setBorder(new Border(new BorderStroke(getSkinnable().getBorderPaint(), BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(1)))); pane.setBackground(new Background(new BackgroundFill(getSkinnable().getBackgroundPaint(), CornerRadii.EMPTY, Insets.EMPTY))); getChildren().setAll(pane); }
@Override protected void redraw() { pane.setBorder(new Border(new BorderStroke(gauge.getBorderPaint(), BorderStrokeStyle.SOLID, new CornerRadii(size * 0.025), new BorderWidths(gauge.getBorderWidth() / PREFERRED_WIDTH * size)))); pane.setBackground(new Background(new BackgroundFill(gauge.getBackgroundPaint(), new CornerRadii(size * 0.025), Insets.EMPTY))); locale = gauge.getLocale(); formatString = new StringBuilder("%.").append(Integer.toString(gauge.getDecimals())).append("f").toString(); titleText.setText(gauge.getTitle()); subTitleText.setText(gauge.getSubTitle()); resizeStaticText(); titleText.setFill(gauge.getTitleColor()); valueText.setFill(gauge.getValueColor()); averageText.setFill(gauge.getAverageColor()); highText.setFill(gauge.getValueColor()); lowText.setFill(gauge.getValueColor()); subTitleText.setFill(gauge.getSubTitleColor()); sparkLine.setStroke(gauge.getBarColor()); stdDeviationArea.setFill(Helper.getTranslucentColorFrom(gauge.getAverageColor(), 0.1)); averageLine.setStroke(gauge.getAverageColor()); dot.setFill(gauge.getBarColor()); }
@Override public void init() { Label title = new Label("December 2015"); title.setFont(Font.font(24)); revenue = getBulletChart("Revenue", "($'000)", 600, 500, new Section(0, 200, RED), new Section(200, 400, YELLOW), new Section(400, 600, GREEN)); profit = getBulletChart("Profit", "($'000)", 100, 70, new Section(0, 20, RED), new Section(20, 60, YELLOW), new Section(60, 100, GREEN)); sales = getBulletChart("Sales", "(unit)", 1000, 700, new Section(0, 300, RED), new Section(300, 500, YELLOW), new Section(500, 1000, GREEN)); HBox legend = new HBox(getLegendBox(RED, "Poor", 10), getLegendBox(YELLOW, "Average", 10), getLegendBox(GREEN, "Good", 10), getLegendBox(GRAY, "Target", 5)); legend.setSpacing(20); legend.setAlignment(Pos.CENTER); pane = new VBox(title, revenue, profit, sales, legend); pane.setBackground(new Background(new BackgroundFill(Color.WHITE, CornerRadii.EMPTY, Insets.EMPTY))); pane.setPadding(new Insets(20, 20, 20, 20)); pane.setSpacing(10); }
private void initGraphics() { backgroundCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT); backgroundCtx = backgroundCanvas.getGraphicsContext2D(); foregroundCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT); foregroundCtx = foregroundCanvas.getGraphicsContext2D(); ledInnerShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.BLACK, 0.2 * PREFERRED_WIDTH, 0, 0, 0); ledDropShadow = new DropShadow(BlurType.TWO_PASS_BOX, getSkinnable().getBarColor(), 0.3 * PREFERRED_WIDTH, 0, 0, 0); pane = new Pane(backgroundCanvas, foregroundCanvas); pane.setBorder(new Border(new BorderStroke(getSkinnable().getBorderPaint(), BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(1)))); pane.setBackground(new Background(new BackgroundFill(getSkinnable().getBackgroundPaint(), CornerRadii.EMPTY, Insets.EMPTY))); getChildren().setAll(pane); }
@Override public void start(Stage stage) { HBox pane = new HBox(gauge0, gauge1, gauge2, gauge3, gauge4, gauge5, gauge6, gauge7, gauge8, gauge9); pane.setBackground(new Background(new BackgroundFill(Gauge.DARK_COLOR, CornerRadii.EMPTY, Insets.EMPTY))); pane.setPadding(new Insets(10)); Scene scene = new Scene(pane); stage.setTitle("Medusa Custom Gauge Skin"); stage.setScene(scene); stage.show(); timer.start(); // Calculate number of nodes calcNoOfNodes(pane); System.out.println(noOfNodes + " Nodes in SceneGraph"); }
/** * 创建JWindow,该Window用于作为Jfx组件的容器,这个window始终覆盖在frame上。 * @param ms * @param mainFrame * @param jfxRoot * @return */ private static JWindow createJWindow(JFrame parent, final Pane jfxRoot) { JWindow jwin = new JWindow(parent); jwin.setLocationRelativeTo(null); jwin.setVisible(true); jfxPanel = new JFXPanel(); jwin.getContentPane().add(jfxPanel); Platform.runLater(() -> { // 设置JFX主场景,并让JFX主界面变得透明,这样不会覆盖整个Canvas. jfxRoot.setBackground(Background.EMPTY); jfxPanel.setScene(new Scene(jfxRoot, Color.TRANSPARENT)); }); return jwin; }
@Override protected void redraw() { pane.setBorder(new Border(new BorderStroke(gauge.getBorderPaint(), BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(gauge.getBorderWidth() / PREFERRED_WIDTH * width)))); pane.setBackground(new Background(new BackgroundFill(gauge.getBackgroundPaint(), CornerRadii.EMPTY, Insets.EMPTY))); barColor = gauge.getBarColor(); thresholdColor = gauge.getThresholdColor(); barBackgroundColor = gauge.getBarBackgroundColor(); thresholdBackgroundColor = Color.color(thresholdColor.getRed(), thresholdColor.getGreen(), thresholdColor.getBlue(), 0.25); barBackground.setFill(barBackgroundColor); thresholdBar.setFill(thresholdBackgroundColor); dataBar.setFill(barColor); dataBarThreshold.setFill(thresholdColor); titleText.setFill(gauge.getTitleColor()); titleText.setText(gauge.getTitle()); valueText.setFill(gauge.getValueColor()); valueText.setText(formatNumber(gauge.getLocale(), gauge.getFormatString(), gauge.getDecimals(), gauge.getCurrentValue())); valueText.relocate((width - valueText.getLayoutBounds().getWidth()), 0.58064516 * height); unitText.setFill(gauge.getUnitColor()); unitText.setText(gauge.getUnit()); unitText.relocate((width - unitText.getLayoutBounds().getWidth()), 0.79 * height); }