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();
}
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);
}
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);
}
}
}
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()));
}
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();
}
};
}
Aggregations