Search in sources :

Example 16 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 17 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)

Aggregations

Background (javafx.scene.layout.Background)17 BackgroundFill (javafx.scene.layout.BackgroundFill)15 Insets (javafx.geometry.Insets)6 CornerRadii (javafx.scene.layout.CornerRadii)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 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 FXML (javafx.fxml.FXML)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