use of javafx.scene.layout.Background in project Smartcity-Smarthouse by TechnionYP5777.
the class MainSystemGuiController method init.
@Override
public void init(final SystemCore model, final URL location, final ResourceBundle __) {
try {
// home tab:
homeTab.setContent(homeTabHBox);
homePageImageView.setImage(new Image(getClass().getResourceAsStream("/icons/smarthouse-icon-logo.png")));
homePageImageView.setFitHeight(200);
// homePageImageView.fitHeightProperty().bind(homeTabHBox.heightProperty().divide(2));
final BackgroundImage myBI = new BackgroundImage(new Image(getClass().getResourceAsStream("/backgrounds/bg_4.png"), 0, 200, false, false), BackgroundRepeat.REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.DEFAULT, BackgroundSize.DEFAULT);
homeTabHBox.setBackground(new Background(myBI));
// user tab:
userTab.setContent(createChildPresenter("user information.fxml").getRootViewNode());
// sensors tab:
sensorsTab.setContent(createChildPresenter("house_mapping.fxml").getRootViewNode());
// applications tab:
appsPresenterInfo = createChildPresenter("application_view.fxml");
appsTab.setContent(appsPresenterInfo.getRootViewNode());
} catch (final Exception ¢) {
¢.printStackTrace();
}
}
use of javafx.scene.layout.Background in project Gargoyle by callakrsos.
the class ColorAnalysisExam method start.
/*
* (non-Javadoc)
*
* @see javafx.application.Application#start(javafx.stage.Stage)
*/
@Override
public void start(Stage primaryStage) throws Exception {
BorderPane root = new BorderPane();
ColorPicker value = new ColorPicker();
root.setTop(value);
List<Label> arrayList = new ArrayList<>();
for (int i = 0; i < 7; i++) {
Label region = new Label();
region.setPrefWidth(100);
region.setPrefHeight(100);
String text = "";
switch(i) {
case 0:
text = "Default";
break;
case 1:
text = "Brigher";
break;
case 2:
text = "darker";
break;
case 3:
text = "desaturate";
break;
case 4:
text = "grayscale";
break;
case 5:
text = "invert";
break;
case 6:
text = "saturate";
break;
}
region.setText(text);
arrayList.add(region);
}
Region region2 = new Region();
region2.setPrefWidth(100);
region2.setPrefHeight(100);
value.valueProperty().addListener((oba, o, n) -> {
arrayList.get(0).setBackground(new Background(new BackgroundFill(n, CornerRadii.EMPTY, new Insets(0))));
arrayList.get(1).setBackground(new Background(new BackgroundFill(n.brighter(), CornerRadii.EMPTY, new Insets(0))));
arrayList.get(2).setBackground(new Background(new BackgroundFill(n.darker(), CornerRadii.EMPTY, new Insets(0))));
arrayList.get(3).setBackground(new Background(new BackgroundFill(n.desaturate(), CornerRadii.EMPTY, new Insets(0))));
arrayList.get(4).setBackground(new Background(new BackgroundFill(n.grayscale(), CornerRadii.EMPTY, new Insets(0))));
arrayList.get(5).setBackground(new Background(new BackgroundFill(n.invert(), CornerRadii.EMPTY, new Insets(0))));
arrayList.get(6).setBackground(new Background(new BackgroundFill(n.saturate(), CornerRadii.EMPTY, new Insets(0))));
});
HBox value2 = new HBox();
value2.getChildren().addAll(arrayList);
root.setCenter(value2);
primaryStage.setScene(new Scene(root));
primaryStage.show();
}
use of javafx.scene.layout.Background in project Gargoyle by callakrsos.
the class AbstractGoogleTrendChart method action.
/**
* @작성자 : KYJ
* @작성일 : 2016. 11. 4.
*/
private void action() {
Line e = new Line();
e.getStyleClass().add("google-chart-flow-line");
e.setStyle("-fx-fill:gray");
e.setOpacity(0.3d);
// getChildren().add(e);
getPlotChildren().add(e);
Text label = new Text(" \n\n\n\n\n\n\n\n\n\n ");
// label.setStyle("-fx-fill:red");
// StackPane s = new StackPane(label);
VBox s = new VBox(label);
// s.getStyleClass().add("google-chart-guide-box");
// s.setStyle("-fx-background-color : green;");
s.setPrefSize(VBox.USE_COMPUTED_SIZE, VBox.USE_COMPUTED_SIZE);
s.setPadding(new Insets(10));
s.setBorder(new Border(new BorderStroke(Color.GREEN, BorderStrokeStyle.DASHED, CornerRadii.EMPTY, new BorderWidths(3d))));
s.setBackground(new Background(new BackgroundFill(Color.GREEN, CornerRadii.EMPTY, new Insets(5))));
getPlotChildren().add(s);
this.addEventHandler(MouseEvent.MOUSE_CLICKED, ev -> {
if (ev.getButton() == MouseButton.PRIMARY) {
List<Node> collect = lookupAll(".chart-line-symbol").stream().filter(v -> v != null).filter(n -> {
if (n instanceof StackPane) {
StackPane sp = (StackPane) n;
sp.setStyle(null);
if (e.intersects(n.getBoundsInParent())) {
sp.setStyle("-fx-background-color:green");
return true;
}
}
return false;
}).filter(v -> v.getUserData() != null).collect(Collectors.toList());
if (!collect.isEmpty()) {
GoogleTrendChartEvent intersectNodeClickEvent = new GoogleTrendChartEvent(this, GoogleTrendChartEvent.NULL_SOURCE_TARGET, GoogleTrendChartEvent.GOOGLE_CHART_INTERSECT_NODE_CLICK, ev.getX(), ev.getY(), ev.getScreenX(), ev.getScreenY(), null, ev.getClickCount(), collect);
Event.fireEvent(this, intersectNodeClickEvent);
}
}
});
this.addEventHandler(MouseEvent.MOUSE_MOVED, ev -> {
double sceneX = Math.abs(getYAxis().getLayoutX() + getYAxis().getWidth() - ev.getX() - getYAxis().getPadding().getLeft() - getYAxis().getPadding().getRight() - getYAxis().getInsets().getLeft() - getYAxis().getInsets().getRight());
e.setStartX(sceneX);
e.setStartY(0d);
e.setEndX(sceneX);
e.setEndY(this.getHeight());
Optional<String> reduce = lookupAll(".chart-line-symbol").stream().filter(v -> v != null).filter(n -> {
if (n instanceof StackPane) {
StackPane sp = (StackPane) n;
sp.setStyle(null);
if (e.intersects(n.getBoundsInParent())) {
sp.setStyle("-fx-background-color:green");
return true;
}
}
return false;
}).filter(v -> v.getUserData() != null).map(v -> v.getUserData().toString()).reduce((a, b) -> {
return a + "\n" + b;
});
if (reduce.isPresent()) {
label.setText(reduce.get());
s.setOpacity(1d);
if ((label.getBoundsInParent().getWidth() + label.getBoundsInParent().getMaxX() + sceneX) > this.getWidth()) {
s.setLayoutX(sceneX - label.getBoundsInParent().getWidth() - label.getBoundsInParent().getMinX());
} else {
s.setLayoutX(sceneX);
}
if ((label.getBoundsInParent().getMaxY() + label.getBoundsInLocal().getHeight() + ev.getSceneY()) > getYAxis().getBoundsInParent().getMaxY()) {
s.setLayoutY(getYAxis().getBoundsInParent().getMaxY() - label.getBoundsInLocal().getHeight() - label.getBoundsInParent().getMaxY());
} else {
s.setLayoutY(ev.getY());
}
} else
s.setOpacity(0.3d);
});
}
use of javafx.scene.layout.Background in project org.csstudio.display.builder by kasemir.
the class SymbolRepresentation method updateChanges.
@Override
public void updateChanges() {
super.updateChanges();
Object value;
if (dirtyGeometry.checkAndClear()) {
value = model_widget.propVisible().getValue();
if (!Objects.equals(value, jfx_node.isVisible())) {
jfx_node.setVisible((boolean) value);
}
value = model_widget.propAutoSize().getValue();
if (!Objects.equals(value, autoSize)) {
autoSize = (boolean) value;
}
if (autoSize) {
model_widget.propWidth().setValue((int) Math.round(maxSize.getWidth()));
model_widget.propHeight().setValue((int) Math.round(maxSize.getHeight()));
}
double w = model_widget.propWidth().getValue();
double h = model_widget.propHeight().getValue();
jfx_node.setLayoutX(model_widget.propX().getValue());
jfx_node.setLayoutY(model_widget.propY().getValue());
jfx_node.setPrefWidth(w);
jfx_node.setPrefHeight(h);
double minSize = Math.min(w, h);
indexLabelBackground.setRadius(Math.min(minSize / 2, 16.0));
}
if (dirtyIndex.checkAndClear()) {
setImageIndex(Math.min(Math.max(model_widget.propInitialIndex().getValue(), 0), imagesList.size() - 1));
}
if (dirtyContent.checkAndClear()) {
value = model_widget.propArrayIndex().getValue();
if (!Objects.equals(value, arrayIndex)) {
arrayIndex = Math.max(0, (int) value);
}
setImageIndex(Math.min(Math.max(getImageIndex(), 0), imagesList.size() - 1));
}
if (dirtyStyle.checkAndClear()) {
value = model_widget.propPreserveRatio().getValue();
if (!Objects.equals(value, imageView.isPreserveRatio())) {
imageView.setPreserveRatio((boolean) value);
}
value = model_widget.propEnabled().getValue();
if (!Objects.equals(value, enabled)) {
enabled = (boolean) value;
Styles.update(jfx_node, Styles.NOT_ENABLED, !enabled);
}
value = model_widget.propShowIndex().getValue();
if (!Objects.equals(value, indexLabel.isVisible())) {
indexLabel.setVisible((boolean) value);
indexLabelBackground.setVisible((boolean) value);
}
if (model_widget.propTransparent().getValue()) {
jfx_node.setBackground(null);
} else {
jfx_node.setBackground(new Background(new BackgroundFill(JFXUtil.convert(model_widget.propBackgroundColor().getValue()), CornerRadii.EMPTY, Insets.EMPTY)));
}
value = model_widget.propRotation().getValue();
if (!Objects.equals(value, imagePane.getRotate())) {
imagePane.setRotate((double) value);
}
}
if (dirtyValue.checkAndClear() && updatingValue.compareAndSet(false, true)) {
int idx = -1;
try {
value = model_widget.runtimePropValue().getValue();
if (value != null) {
if (value instanceof VBoolean) {
idx = ((VBoolean) value).getValue() ? 1 : 0;
} else if (value instanceof VString) {
try {
idx = Integer.parseInt(((VString) value).getValue());
} catch (NumberFormatException nfex) {
logger.log(Level.FINE, "Failure parsing the string value: {0} [{1}].", new Object[] { ((VString) value).getValue(), nfex.getMessage() });
}
} else if (value instanceof VNumber) {
idx = ((VNumber) value).getValue().intValue();
} else if (value instanceof VEnum) {
idx = ((VEnum) value).getIndex();
} else if (value instanceof VNumberArray) {
ListNumber array = ((VNumberArray) value).getData();
if (array.size() > 0) {
idx = array.getInt(Math.min(arrayIndex, array.size() - 1));
}
} else if (value instanceof VEnumArray) {
ListInt array = ((VEnumArray) value).getIndexes();
if (array.size() > 0) {
idx = array.getInt(Math.min(arrayIndex, array.size() - 1));
}
}
}
} finally {
updatingValue.set(false);
}
setImageIndex(Math.min(Math.max(idx, 0), imagesList.size() - 1));
}
}
use of javafx.scene.layout.Background in project org.csstudio.display.builder by kasemir.
the class TabsRepresentation method updateChanges.
@Override
public void updateChanges() {
super.updateChanges();
if (dirty_layout.checkAndClear()) {
final String style = JFXUtil.shadedStyle(model_widget.propBackgroundColor().getValue());
final Background background = new Background(new BackgroundFill(JFXUtil.convert(model_widget.propBackgroundColor().getValue()), null, null));
for (Tab tab : jfx_node.getTabs()) {
// Set the font of the 'graphic' that's used to represent the tab
final Label label = (Label) tab.getGraphic();
label.setFont(tab_font);
// Set colors
tab.setStyle(style);
final Pane content = (Pane) tab.getContent();
content.setBackground(background);
}
final Integer width = model_widget.propWidth().getValue();
final Integer height = model_widget.propHeight().getValue();
jfx_node.setPrefSize(width, height);
jfx_node.setTabMinHeight(model_widget.propTabHeight().getValue());
refreshHack();
}
}
Aggregations