use of javafx.scene.layout.BackgroundFill 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);
});
}
Aggregations