Search in sources :

Example 6 with BackgroundFill

use of javafx.scene.layout.BackgroundFill 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 BackgroundFill

use of javafx.scene.layout.BackgroundFill 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 BackgroundFill

use of javafx.scene.layout.BackgroundFill 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 BackgroundFill

use of javafx.scene.layout.BackgroundFill in project JFoenix by jfoenixadmin.

the class JFXSliderSkin method initListeners.

private void initListeners() {
    // delegate slider mouse events to track node 
    getSkinnable().setOnMousePressed(me -> {
        if (!me.isConsumed()) {
            me.consume();
            track.fireEvent(me);
        }
    });
    getSkinnable().setOnMouseReleased(me -> {
        if (!me.isConsumed()) {
            me.consume();
            track.fireEvent(me);
        }
    });
    getSkinnable().setOnMouseDragged(me -> {
        if (!me.isConsumed()) {
            me.consume();
            track.fireEvent(me);
        }
    });
    // animate value node
    track.addEventHandler(MouseEvent.MOUSE_PRESSED, (event) -> {
        timeline.setRate(1);
        timeline.play();
    });
    track.addEventHandler(MouseEvent.MOUSE_RELEASED, (event) -> {
        timeline.setRate(-1);
        timeline.play();
    });
    thumb.addEventHandler(MouseEvent.MOUSE_PRESSED, (event) -> {
        timeline.setRate(1);
        timeline.play();
    });
    thumb.addEventHandler(MouseEvent.MOUSE_RELEASED, (event) -> {
        timeline.setRate(-1);
        timeline.play();
    });
    track.backgroundProperty().addListener((o, oldVal, newVal) -> {
        // prevent internal color change
        if (!internalChange && newVal != null)
            trackColor = newVal.getFills().get(0).getFill();
    });
    thumb.backgroundProperty().addListener((o, oldVal, newVal) -> {
        // prevent internal color change
        if (!internalChange && newVal != null) {
            thumbColor = newVal.getFills().get(0).getFill();
            if (getSkinnable().getValue() == getSkinnable().getMin()) {
                internalChange = true;
                thumb.setBackground(new Background(new BackgroundFill(trackColor, new CornerRadii(20), Insets.EMPTY)));
                internalChange = false;
            }
        }
    });
    refreshSliderValueBinding();
    getSkinnable().valueProperty().addListener((o, oldVal, newVal) -> {
        internalChange = true;
        if (getSkinnable().getMin() == newVal.doubleValue()) {
            thumb.setBackground(new Background(new BackgroundFill(trackColor, new CornerRadii(20), Insets.EMPTY)));
            animatedThumb.pseudoClassStateChanged(PseudoClass.getPseudoClass("min"), true);
        } else if (oldVal.doubleValue() == getSkinnable().getMin()) {
            thumb.setBackground(new Background(new BackgroundFill(thumbColor, new CornerRadii(20), Insets.EMPTY)));
            animatedThumb.pseudoClassStateChanged(PseudoClass.getPseudoClass("min"), false);
        }
        internalChange = false;
    });
    getSkinnable().orientationProperty().addListener((o, oldVal, newVal) -> initAnimation(newVal));
    animatedThumb.layoutBoundsProperty().addListener((o, oldVal, newVal) -> initAnimation(getSkinnable().getOrientation()));
}
Also used : Background(javafx.scene.layout.Background) BackgroundFill(javafx.scene.layout.BackgroundFill) CornerRadii(javafx.scene.layout.CornerRadii)

Example 10 with BackgroundFill

use of javafx.scene.layout.BackgroundFill in project JFoenix by jfoenixadmin.

the class JFXComboBox method defaultNodeConverter.

private static <T> NodeConverter<T> defaultNodeConverter() {
    return new NodeConverter<T>() {

        @Override
        public Node toNode(T object) {
            if (object == null)
                return null;
            StackPane selectedValueContainer = new StackPane();
            selectedValueContainer.getStyleClass().add("combo-box-selected-value-container");
            selectedValueContainer.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, null, null)));
            Label selectedValueLabel;
            if (object instanceof Label)
                selectedValueLabel = new Label(((Label) object).getText());
            else
                selectedValueLabel = new Label(object.toString());
            selectedValueLabel.setTextFill(Color.BLACK);
            selectedValueContainer.getChildren().add(selectedValueLabel);
            StackPane.setAlignment(selectedValueLabel, Pos.CENTER_LEFT);
            StackPane.setMargin(selectedValueLabel, new Insets(0, 0, 0, 5));
            return selectedValueContainer;
        }

        @SuppressWarnings("unchecked")
        @Override
        public T fromNode(Node node) {
            return (T) node;
        }

        @Override
        public String toString(T object) {
            if (object == null)
                return null;
            if (object instanceof Label)
                return ((Label) object).getText();
            return object.toString();
        }
    };
}
Also used : Insets(javafx.geometry.Insets) Background(javafx.scene.layout.Background) NodeConverter(com.jfoenix.converters.base.NodeConverter) BackgroundFill(javafx.scene.layout.BackgroundFill) Node(javafx.scene.Node) StackPane(javafx.scene.layout.StackPane)

Aggregations

Background (javafx.scene.layout.Background)15 BackgroundFill (javafx.scene.layout.BackgroundFill)15 Insets (javafx.geometry.Insets)6 CornerRadii (javafx.scene.layout.CornerRadii)6 Color (javafx.scene.paint.Color)4 ArrayList (java.util.ArrayList)3 StackPane (javafx.scene.layout.StackPane)3 Tile (eu.hansolo.tilesfx.Tile)2 List (java.util.List)2 Optional (java.util.Optional)2 Collectors (java.util.stream.Collectors)2 Platform (javafx.application.Platform)2 FXCollections (javafx.collections.FXCollections)2 Node (javafx.scene.Node)2 Scene (javafx.scene.Scene)2 Label (javafx.scene.control.Label)2 FlowPane (javafx.scene.layout.FlowPane)2 VBox (javafx.scene.layout.VBox)2 XYLocation (aima.core.util.datastructure.XYLocation)1 NodeConverter (com.jfoenix.converters.base.NodeConverter)1