use of javafx.scene.layout.StackPane in project Gargoyle by callakrsos.
the class DateChooserExam method start.
@Override
public void start(final Stage primaryStage) {
primaryStage.setTitle("Hello Calendar!");
StackPane root = new StackPane();
final DateChooser dateChooser = new DateChooser();
root.getChildren().add(dateChooser);
Scene scene = new Scene(root, 300, 250);
primaryStage.setScene(scene);
primaryStage.setOnHiding(new EventHandler<WindowEvent>() {
public void handle(WindowEvent event) {
System.out.println("date " + dateChooser.getDate());
}
});
primaryStage.show();
}
use of javafx.scene.layout.StackPane in project bitsquare by bitsquare.
the class BitsquareApp method showFPSWindow.
private void showFPSWindow() {
Label label = new Label();
EventStreams.animationTicks().latestN(100).map(ticks -> {
int n = ticks.size() - 1;
return n * 1_000_000_000.0 / (ticks.get(n) - ticks.get(0));
}).map(d -> String.format("FPS: %.3f", d)).feedTo(label.textProperty());
Pane root = new StackPane();
root.getChildren().add(label);
Stage stage = new Stage();
stage.setScene(new Scene(root));
stage.setTitle("FPS");
stage.initModality(Modality.NONE);
stage.initStyle(StageStyle.UTILITY);
stage.initOwner(scene.getWindow());
stage.setX(primaryStage.getX() + primaryStage.getWidth() + 10);
stage.setY(primaryStage.getY());
stage.setWidth(200);
stage.setHeight(100);
stage.show();
}
use of javafx.scene.layout.StackPane 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.StackPane in project bisq-api by mrosseel.
the class BisqApiWithUI method showErrorPopup.
private void showErrorPopup(Throwable throwable, boolean doShutDown) {
if (!shutDownRequested) {
if (scene == null) {
log.warn("Scene not available yet, we create a new scene. The bug might be caused by an exception in a constructor or by a circular dependency in guice. throwable=" + throwable.toString());
scene = new Scene(new StackPane(), 1000, 650);
scene.getStylesheets().setAll("/io/bisq/gui/bisq.css", "/io/bisq/gui/images.css");
primaryStage.setScene(scene);
primaryStage.show();
}
try {
try {
if (!popupOpened) {
String message = throwable.getMessage();
popupOpened = true;
if (message != null)
new Popup<>().error(message).onClose(() -> popupOpened = false).show();
else
new Popup<>().error(throwable.toString()).onClose(() -> popupOpened = false).show();
}
} catch (Throwable throwable3) {
log.error("Error at displaying Throwable.");
throwable3.printStackTrace();
}
if (doShutDown)
stop();
} catch (Throwable throwable2) {
// If printStackTrace cause a further exception we don't pass the throwable to the Popup.
log.error(throwable2.toString());
if (doShutDown)
stop();
}
}
}
use of javafx.scene.layout.StackPane in project bisq-api by mrosseel.
the class BisqApiWithUI method showFPSWindow.
private void showFPSWindow() {
Label label = new Label();
EventStreams.animationTicks().latestN(100).map(ticks -> {
int n = ticks.size() - 1;
return n * 1_000_000_000.0 / (ticks.get(n) - ticks.get(0));
}).map(// Don't translate, just for dev
d -> String.format("FPS: %.3f", d)).feedTo(label.textProperty());
Pane root = new StackPane();
root.getChildren().add(label);
Stage stage = new Stage();
stage.setScene(new Scene(root));
// Don't translate, just for dev
stage.setTitle("FPS");
stage.initModality(Modality.NONE);
stage.initStyle(StageStyle.UTILITY);
stage.initOwner(scene.getWindow());
stage.setX(primaryStage.getX() + primaryStage.getWidth() + 10);
stage.setY(primaryStage.getY());
stage.setWidth(200);
stage.setHeight(100);
stage.show();
}
Aggregations