Search in sources :

Example 51 with Background

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();
    }
}
Also used : BackgroundImage(javafx.scene.layout.BackgroundImage) Background(javafx.scene.layout.Background) BackgroundImage(javafx.scene.layout.BackgroundImage) Image(javafx.scene.image.Image)

Example 52 with Background

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();
}
Also used : BorderPane(javafx.scene.layout.BorderPane) HBox(jfxtras.scene.layout.HBox) Insets(javafx.geometry.Insets) Background(javafx.scene.layout.Background) ColorPicker(javafx.scene.control.ColorPicker) BackgroundFill(javafx.scene.layout.BackgroundFill) ArrayList(java.util.ArrayList) Label(javafx.scene.control.Label) Scene(javafx.scene.Scene) Region(javafx.scene.layout.Region)

Example 53 with Background

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);
    });
}
Also used : MouseButton(javafx.scene.input.MouseButton) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) MouseEvent(javafx.scene.input.MouseEvent) IGargoyleChartAdapter(com.kyj.fx.voeditor.visual.framework.adapter.IGargoyleChartAdapter) FXCollections(javafx.collections.FXCollections) StackPane(javafx.scene.layout.StackPane) VBox(javafx.scene.layout.VBox) LineChart(javafx.scene.chart.LineChart) Line(javafx.scene.shape.Line) Insets(javafx.geometry.Insets) BorderWidths(javafx.scene.layout.BorderWidths) BackgroundFill(javafx.scene.layout.BackgroundFill) Color(javafx.scene.paint.Color) ObjectProperty(javafx.beans.property.ObjectProperty) Node(javafx.scene.Node) Border(javafx.scene.layout.Border) Event(javafx.event.Event) Rectangle(javafx.scene.shape.Rectangle) ValueUtil(com.kyj.fx.voeditor.visual.util.ValueUtil) CategoryAxis(javafx.scene.chart.CategoryAxis) Collectors(java.util.stream.Collectors) Background(javafx.scene.layout.Background) BorderStrokeStyle(javafx.scene.layout.BorderStrokeStyle) BorderStroke(javafx.scene.layout.BorderStroke) Platform(javafx.application.Platform) Text(javafx.scene.text.Text) List(java.util.List) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Optional(java.util.Optional) ObservableList(javafx.collections.ObservableList) NumberAxis(javafx.scene.chart.NumberAxis) StringProperty(javafx.beans.property.StringProperty) CornerRadii(javafx.scene.layout.CornerRadii) Insets(javafx.geometry.Insets) Background(javafx.scene.layout.Background) BackgroundFill(javafx.scene.layout.BackgroundFill) Node(javafx.scene.Node) Text(javafx.scene.text.Text) Line(javafx.scene.shape.Line) BorderWidths(javafx.scene.layout.BorderWidths) BorderStroke(javafx.scene.layout.BorderStroke) VBox(javafx.scene.layout.VBox) Border(javafx.scene.layout.Border) StackPane(javafx.scene.layout.StackPane)

Example 54 with Background

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));
    }
}
Also used : VEnumArray(org.diirt.vtype.VEnumArray) ListInt(org.diirt.util.array.ListInt) Background(javafx.scene.layout.Background) BackgroundFill(javafx.scene.layout.BackgroundFill) VNumber(org.diirt.vtype.VNumber) VBoolean(org.diirt.vtype.VBoolean) VEnum(org.diirt.vtype.VEnum) VNumberArray(org.diirt.vtype.VNumberArray) ListNumber(org.diirt.util.array.ListNumber) VString(org.diirt.vtype.VString)

Example 55 with Background

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();
    }
}
Also used : Background(javafx.scene.layout.Background) Tab(javafx.scene.control.Tab) BackgroundFill(javafx.scene.layout.BackgroundFill) Label(javafx.scene.control.Label) TabPane(javafx.scene.control.TabPane) Pane(javafx.scene.layout.Pane)

Aggregations

Background (javafx.scene.layout.Background)86 BackgroundFill (javafx.scene.layout.BackgroundFill)82 Insets (javafx.geometry.Insets)30 CornerRadii (javafx.scene.layout.CornerRadii)24 Scene (javafx.scene.Scene)18 StackPane (javafx.scene.layout.StackPane)15 Color (javafx.scene.paint.Color)15 Label (javafx.scene.control.Label)14 Border (javafx.scene.layout.Border)14 BorderStroke (javafx.scene.layout.BorderStroke)14 BorderWidths (javafx.scene.layout.BorderWidths)12 Pane (javafx.scene.layout.Pane)12 Text (javafx.scene.text.Text)9 BorderPane (javafx.scene.layout.BorderPane)8 Region (javafx.scene.layout.Region)8 HBox (javafx.scene.layout.HBox)7 ArrayList (java.util.ArrayList)6 MouseEvent (javafx.scene.input.MouseEvent)6 VBox (javafx.scene.layout.VBox)6 Rectangle (javafx.scene.shape.Rectangle)5