Search in sources :

Example 6 with Background

use of javafx.scene.layout.Background in project Smartcity-Smarthouse by TechnionYP5777.

the class TempDashboard method start.

@Override
public void start(Stage stage) throws Exception {
    pane = new FlowPane(Orientation.HORIZONTAL, 1, 1, textTile);
    pane.setPadding(new Insets(5));
    pane.setPrefSize(150, 150);
    pane.setBackground(new Background(new BackgroundFill(Tile.BACKGROUND.darker(), CornerRadii.EMPTY, Insets.EMPTY)));
    Scene scene = new Scene(pane);
    stage.setTitle("Dashboard Configuration in Action");
    stage.setScene(scene);
    stage.show();
}
Also used : Insets(javafx.geometry.Insets) Background(javafx.scene.layout.Background) BackgroundFill(javafx.scene.layout.BackgroundFill) FlowPane(javafx.scene.layout.FlowPane) Scene(javafx.scene.Scene)

Example 7 with Background

use of javafx.scene.layout.Background in project Smartcity-Smarthouse by TechnionYP5777.

the class ConfigurationController method initialize.

@Override
public void initialize(URL location, ResourceBundle resources) {
    button.setOnMouseClicked(e -> {
        if (callback != null)
            Platform.runLater(callback);
        timers.values().stream().filter(l -> l != null).flatMap(l -> l.stream()).forEach(t -> t.stop());
        ((Stage) button.getScene().getWindow()).close();
        widgets.values().stream().filter(l -> l != null).flatMap(l -> l.stream()).forEach(w -> w.getTile().setForegroundBaseColor(normalTileColor));
    });
    pane.setPadding(new Insets(5));
    pane.setBackground(new Background(new BackgroundFill(Tile.BACKGROUND.darker(), CornerRadii.EMPTY, Insets.EMPTY)));
    types.setItems(FXCollections.observableArrayList(widgets.keySet()));
    types.getSelectionModel().selectedItemProperty().addListener((options, oldValue, newValue) -> {
        Optional.ofNullable(timers.get(newValue)).ifPresent(l -> l.stream().forEach(t -> t.start()));
        pane.getChildren().setAll(widgets.get(newValue).stream().map(BasicWidget::getTile).collect(Collectors.toList()));
        Optional.ofNullable(timers.get(oldValue)).ifPresent(l -> l.stream().forEach(t -> t.stop()));
        Optional.ofNullable(widgets.get(oldValue)).ifPresent(l -> l.stream().forEach(w -> w.getTile().setForegroundBaseColor(normalTileColor)));
    });
    types.getSelectionModel().select(3);
    ;
// sPane.setHbarPolicy(ScrollBarPolicy.ALWAYS);
// sPane.setVbarPolicy(ScrollBarPolicy.NEVER);
// sPane.setContent(pane);
}
Also used : Button(javafx.scene.control.Button) Initializable(javafx.fxml.Initializable) URL(java.net.URL) LoggerFactory(org.slf4j.LoggerFactory) FXCollections(javafx.collections.FXCollections) HashMap(java.util.HashMap) Random(java.util.Random) BarChartItem(eu.hansolo.tilesfx.skins.BarChartItem) ArrayList(java.util.ArrayList) Insets(javafx.geometry.Insets) ResourceBundle(java.util.ResourceBundle) ComboBox(javafx.scene.control.ComboBox) BackgroundFill(javafx.scene.layout.BackgroundFill) Map(java.util.Map) Tile(eu.hansolo.tilesfx.Tile) ListWidget(il.ac.technion.cs.smarthouse.applications.dashboard.model.widget.ListWidget) Color(javafx.scene.paint.Color) TextField(javafx.scene.control.TextField) Logger(org.slf4j.Logger) GraphWidget(il.ac.technion.cs.smarthouse.applications.dashboard.model.widget.GraphWidget) Collectors(java.util.stream.Collectors) Background(javafx.scene.layout.Background) InvocationTargetException(java.lang.reflect.InvocationTargetException) FXML(javafx.fxml.FXML) Platform(javafx.application.Platform) AnimationTimer(javafx.animation.AnimationTimer) List(java.util.List) Stream(java.util.stream.Stream) FlowPane(javafx.scene.layout.FlowPane) Stage(javafx.stage.Stage) Optional(java.util.Optional) WidgetType(il.ac.technion.cs.smarthouse.applications.dashboard.model.WidgetType) BasicWidget(il.ac.technion.cs.smarthouse.applications.dashboard.model.widget.BasicWidget) LeaderBoardItem(eu.hansolo.tilesfx.skins.LeaderBoardItem) CornerRadii(javafx.scene.layout.CornerRadii) Insets(javafx.geometry.Insets) Background(javafx.scene.layout.Background) BackgroundFill(javafx.scene.layout.BackgroundFill) Stage(javafx.stage.Stage) BasicWidget(il.ac.technion.cs.smarthouse.applications.dashboard.model.widget.BasicWidget)

Example 8 with Background

use of javafx.scene.layout.Background in project aima-java by aimacode.

the class NQueensViewCtrl method update.

/** Updates the view. */
public void update(NQueensBoard board) {
    int size = board.getSize();
    if (queens.length != size * size) {
        gridPane.getChildren().clear();
        gridPane.getColumnConstraints().clear();
        gridPane.getRowConstraints().clear();
        queens = new Polygon[size * size];
        RowConstraints c1 = new RowConstraints();
        c1.setPercentHeight(100.0 / size);
        ColumnConstraints c2 = new ColumnConstraints();
        c2.setPercentWidth(100.0 / size);
        for (int i = 0; i < board.getSize(); i++) {
            gridPane.getRowConstraints().add(c1);
            gridPane.getColumnConstraints().add(c2);
        }
        for (int i = 0; i < queens.length; i++) {
            StackPane field = new StackPane();
            queens[i] = createQueen();
            field.getChildren().add(queens[i]);
            int col = i % size;
            int row = i / size;
            field.setBackground(new Background(new BackgroundFill((col % 2 == row % 2) ? Color.WHITE : Color.LIGHTGRAY, null, null)));
            gridPane.add(field, col, row);
        }
    }
    double scale = 0.2 * gridPane.getWidth() / gridPane.getColumnConstraints().size();
    for (int i = 0; i < queens.length; i++) {
        Polygon queen = queens[i];
        queen.setScaleX(scale);
        queen.setScaleY(scale);
        XYLocation loc = new XYLocation(i % size, i / size);
        if (board.queenExistsAt(loc)) {
            queen.setVisible(true);
            queen.setFill(board.isSquareUnderAttack(loc) ? Color.RED : Color.BLACK);
        } else {
            queen.setVisible(false);
        }
    }
}
Also used : Background(javafx.scene.layout.Background) XYLocation(aima.core.util.datastructure.XYLocation) ColumnConstraints(javafx.scene.layout.ColumnConstraints) BackgroundFill(javafx.scene.layout.BackgroundFill) Polygon(javafx.scene.shape.Polygon) StackPane(javafx.scene.layout.StackPane) RowConstraints(javafx.scene.layout.RowConstraints)

Example 9 with Background

use of javafx.scene.layout.Background in project Gargoyle by callakrsos.

the class SkinPreviewViewComposite method previewTabInit.

@FxPostInitialize
public void previewTabInit() {
    Task<Void> task = new Task<Void>() {

        @Override
        protected Void call() throws Exception {
            Thread.sleep(5000L);
            Platform.runLater(() -> {
                //메뉴바 배경.
                {
                    Background background = mbSample.getBackground();
                    Color fill = (Color) background.getFills().get(0).getFill();
                    colorMbSample.setValue(fill);
                    //메뉴바 텍스트
                    {
                        Label lookup = (Label) mbSample.lookup(".label");
                        Color textFill = (Color) lookup.getTextFill();
                        colorMbLabelSample.setValue(textFill);
                    }
                }
                //Hbox 배경.
                {
                    Background background = hboxSample.getBackground();
                    Color fill = (Color) background.getFills().get(0).getFill();
                    colorHboxSample.setValue(fill);
                }
                {
                    //선택디지않는 탭 색상 처리.
                    Set<Node> lookupAll = tabpaneSample.lookupAll(".tab:top");
                    lookupAll.forEach(lookup -> {
                        Optional<PseudoClass> findFirst = lookup.getPseudoClassStates().stream().filter(v -> {
                            return "selected".equals(v.getPseudoClassName());
                        }).findFirst();
                        if (findFirst.isPresent()) {
                            Label selectedTabLabel = (Label) lookup.lookup(".tab-label");
                            Color textFill = (Color) selectedTabLabel.getTextFill();
                            colorSelectedTabText.setValue(textFill);
                        } else {
                            Label selectedTabLabel = (Label) lookup.lookup(".tab-label");
                            Color textFill = (Color) selectedTabLabel.getTextFill();
                            colorUnSelectedTabText.setValue(textFill);
                        }
                    });
                    {
                        lookupAll.stream().findFirst().ifPresent(n -> {
                            Pane p = (Pane) n;
                            Background background = p.getBackground();
                            Color fill = (Color) background.getFills().get(0).getFill();
                            colorTabSample1Selected.setValue(fill);
                        });
                    }
                }
            });
            return null;
        }
    };
    Window window = this.getScene().getWindow();
    if (window != null) {
        FxUtil.showLoading(window, task);
    } else
        FxUtil.showLoading(task);
}
Also used : Button(javafx.scene.control.Button) TextArea(javafx.scene.control.TextArea) PseudoClass(javafx.css.PseudoClass) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) DialogUtil(com.kyj.fx.voeditor.visual.util.DialogUtil) TableColumn(javafx.scene.control.TableColumn) Task(javafx.concurrent.Task) TabPane(javafx.scene.control.TabPane) Map(java.util.Map) FileUtil(com.kyj.fx.voeditor.visual.util.FileUtil) TableView(javafx.scene.control.TableView) Pane(javafx.scene.layout.Pane) ColorPicker(javafx.scene.control.ColorPicker) HBox(javafx.scene.layout.HBox) Color(javafx.scene.paint.Color) Pair(javafx.util.Pair) Logger(org.slf4j.Logger) Label(javafx.scene.control.Label) MenuBar(javafx.scene.control.MenuBar) Node(javafx.scene.Node) FXMLController(com.kyj.fx.voeditor.visual.framework.annotation.FXMLController) Set(java.util.Set) IOException(java.io.IOException) ValueUtil(com.kyj.fx.voeditor.visual.util.ValueUtil) JFXToggleButton(com.jfoenix.controls.JFXToggleButton) Background(javafx.scene.layout.Background) File(java.io.File) FxPostInitialize(com.kyj.fx.voeditor.visual.framework.annotation.FxPostInitialize) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) List(java.util.List) Stage(javafx.stage.Stage) Optional(java.util.Optional) Window(javafx.stage.Window) SkinManager(com.kyj.fx.voeditor.visual.momory.SkinManager) ObservableList(javafx.collections.ObservableList) BorderPane(javafx.scene.layout.BorderPane) StringProperty(javafx.beans.property.StringProperty) Window(javafx.stage.Window) Task(javafx.concurrent.Task) Set(java.util.Set) Background(javafx.scene.layout.Background) Optional(java.util.Optional) Color(javafx.scene.paint.Color) Label(javafx.scene.control.Label) TabPane(javafx.scene.control.TabPane) Pane(javafx.scene.layout.Pane) BorderPane(javafx.scene.layout.BorderPane) FxPostInitialize(com.kyj.fx.voeditor.visual.framework.annotation.FxPostInitialize)

Example 10 with Background

use of javafx.scene.layout.Background in project PretendYoureXyzzyReborn by devgianlu.

the class PyxCard method initialize.

@FXML
public void initialize() {
    this.text.setText(card.text);
    this.watermark.setText(card.watermark);
    if (card instanceof BlackCard) {
        // Black card
        setBackground(new Background(new BackgroundFill(Color.BLACK, new CornerRadii(8), Insets.EMPTY)));
        this.text.setTextFill(Color.WHITE);
        this.watermark.setTextFill(Color.WHITE);
    } else {
        // White card
        setBackground(new Background(new BackgroundFill(Color.WHITE, new CornerRadii(8), Insets.EMPTY)));
        this.text.setTextFill(Color.BLACK);
        this.watermark.setTextFill(Color.BLACK);
    }
}
Also used : Background(javafx.scene.layout.Background) BackgroundFill(javafx.scene.layout.BackgroundFill) BlackCard(com.gianlu.pyxreborn.Models.BlackCard) CornerRadii(javafx.scene.layout.CornerRadii) FXML(javafx.fxml.FXML)

Aggregations

Background (javafx.scene.layout.Background)18 BackgroundFill (javafx.scene.layout.BackgroundFill)16 CornerRadii (javafx.scene.layout.CornerRadii)7 Insets (javafx.geometry.Insets)6 Color (javafx.scene.paint.Color)5 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Optional (java.util.Optional)3 Platform (javafx.application.Platform)3 FXML (javafx.fxml.FXML)3 ValueUtil (com.kyj.fx.voeditor.visual.util.ValueUtil)2 Tile (eu.hansolo.tilesfx.Tile)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Node (javafx.scene.Node)2 Button (javafx.scene.control.Button)2 Label (javafx.scene.control.Label)2 Image (javafx.scene.image.Image)2 FlowPane (javafx.scene.layout.FlowPane)2 StackPane (javafx.scene.layout.StackPane)2