Search in sources :

Example 21 with Node

use of javafx.scene.Node in project aima-java by aimacode.

the class SimulationPaneBuilder method getResultFor.

/**
	 * Adds a toolbar, a state view, and a status label to the provided pane and returns
	 * a controller class instance. The toolbar contains combo boxes to control parameter settings
	 * and buttons for simulation control. The controller class instance handles user events and provides
	 * access to user settings (parameter settings, simulation speed, status text, ...).
	 */
public SimulationPaneCtrl getResultFor(BorderPane pane) {
    List<ComboBox<String>> combos = new ArrayList<>();
    parameters.add(createSimSpeedParam());
    for (Parameter param : parameters) {
        ComboBox<String> combo = new ComboBox<>();
        combo.setId(param.getName());
        combo.getItems().addAll(param.getValueNames());
        combo.getSelectionModel().select(param.getDefaultValueIndex());
        combos.add(combo);
    }
    Button simBtn = new Button();
    Node[] tools = new Node[combos.size() + 2];
    for (int i = 0; i < combos.size() - 1; i++) tools[i] = combos.get(i);
    tools[combos.size() - 1] = new Separator();
    tools[combos.size() + 0] = combos.get(combos.size() - 1);
    tools[combos.size() + 1] = simBtn;
    ToolBar toolBar = new ToolBar(tools);
    Label statusLabel = new Label();
    statusLabel.setMaxWidth(Double.MAX_VALUE);
    statusLabel.setAlignment(Pos.CENTER);
    statusLabel.setFont(Font.font(16));
    pane.setTop(toolBar);
    if (stateView.isPresent()) {
        if (stateView.get() instanceof Canvas) {
            // make canvas resizable
            Canvas canvas = (Canvas) stateView.get();
            Pane canvasPane = new Pane();
            canvasPane.getChildren().add(canvas);
            canvas.widthProperty().bind(canvasPane.widthProperty());
            canvas.heightProperty().bind(canvasPane.heightProperty());
            pane.setCenter(canvasPane);
            pane.setStyle("-fx-background-color: white");
        } else
            pane.setCenter(stateView.get());
    }
    pane.setBottom(statusLabel);
    if (!initMethod.isPresent())
        throw new IllegalStateException("No initialization method defined.");
    if (!simMethod.isPresent())
        throw new IllegalStateException("No simulation method defined.");
    return new SimulationPaneCtrl(parameters, combos, initMethod.get(), simMethod.get(), simBtn, statusLabel);
}
Also used : ComboBox(javafx.scene.control.ComboBox) Node(javafx.scene.Node) Canvas(javafx.scene.canvas.Canvas) ArrayList(java.util.ArrayList) Label(javafx.scene.control.Label) BorderPane(javafx.scene.layout.BorderPane) Pane(javafx.scene.layout.Pane) Button(javafx.scene.control.Button) ToolBar(javafx.scene.control.ToolBar) Separator(javafx.scene.control.Separator)

Example 22 with Node

use of javafx.scene.Node in project bitsquare by bitsquare.

the class Transitions method blur.

public void blur(Node node, int duration, double brightness, boolean removeNode, double blurRadius) {
    if (removeEffectTimeLine != null)
        removeEffectTimeLine.stop();
    node.setMouseTransparent(true);
    GaussianBlur blur = new GaussianBlur(0.0);
    Timeline timeline = new Timeline();
    KeyValue kv1 = new KeyValue(blur.radiusProperty(), blurRadius);
    KeyFrame kf1 = new KeyFrame(Duration.millis(getDuration(duration)), kv1);
    ColorAdjust darken = new ColorAdjust();
    darken.setBrightness(0.0);
    blur.setInput(darken);
    KeyValue kv2 = new KeyValue(darken.brightnessProperty(), brightness);
    KeyFrame kf2 = new KeyFrame(Duration.millis(getDuration(duration)), kv2);
    timeline.getKeyFrames().addAll(kf1, kf2);
    node.setEffect(blur);
    if (removeNode)
        timeline.setOnFinished(actionEvent -> UserThread.execute(() -> ((Pane) (node.getParent())).getChildren().remove(node)));
    timeline.play();
}
Also used : EventHandler(javafx.event.EventHandler) Inject(javax.inject.Inject) Preferences(io.bitsquare.user.Preferences) ActionEvent(javafx.event.ActionEvent) Duration(javafx.util.Duration) UserThread(io.bitsquare.common.UserThread) Node(javafx.scene.Node) javafx.animation(javafx.animation) ColorAdjust(javafx.scene.effect.ColorAdjust) GaussianBlur(javafx.scene.effect.GaussianBlur) Pane(javafx.scene.layout.Pane) GaussianBlur(javafx.scene.effect.GaussianBlur) ColorAdjust(javafx.scene.effect.ColorAdjust) Pane(javafx.scene.layout.Pane)

Example 23 with Node

use of javafx.scene.Node in project bitsquare by bitsquare.

the class VolumeChart method seriesRemoved.

@Override
protected void seriesRemoved(XYChart.Series<Number, Number> series) {
    for (XYChart.Data<Number, Number> d : series.getData()) {
        final Node volumeBar = d.getNode();
        if (shouldAnimate()) {
            FadeTransition ft = new FadeTransition(Duration.millis(500), volumeBar);
            ft.setToValue(0);
            ft.setOnFinished((ActionEvent actionEvent) -> getPlotChildren().remove(volumeBar));
            ft.play();
        } else {
            getPlotChildren().remove(volumeBar);
        }
    }
}
Also used : FadeTransition(javafx.animation.FadeTransition) ActionEvent(javafx.event.ActionEvent) Node(javafx.scene.Node) XYChart(javafx.scene.chart.XYChart)

Example 24 with Node

use of javafx.scene.Node in project bitsquare by bitsquare.

the class VolumeChart method createCandle.

private Node createCandle(int seriesIndex, final XYChart.Data item, int itemIndex) {
    Node volumeBar = item.getNode();
    if (volumeBar instanceof VolumeBar) {
        ((VolumeBar) volumeBar).setSeriesAndDataStyleClasses("series" + seriesIndex, "data" + itemIndex);
    } else {
        volumeBar = new VolumeBar("series" + seriesIndex, "data" + itemIndex, toolTipStringConverter);
        item.setNode(volumeBar);
    }
    return volumeBar;
}
Also used : Node(javafx.scene.Node)

Example 25 with Node

use of javafx.scene.Node in project bitsquare by bitsquare.

the class VolumeChart method dataItemAdded.

@Override
protected void dataItemAdded(XYChart.Series<Number, Number> series, int itemIndex, XYChart.Data<Number, Number> item) {
    Node volumeBar = createCandle(getData().indexOf(series), item, itemIndex);
    if (getPlotChildren().contains(volumeBar))
        getPlotChildren().remove(volumeBar);
    if (shouldAnimate()) {
        volumeBar.setOpacity(0);
        getPlotChildren().add(volumeBar);
        FadeTransition ft = new FadeTransition(Duration.millis(500), volumeBar);
        ft.setToValue(1);
        ft.play();
    } else {
        getPlotChildren().add(volumeBar);
    }
}
Also used : FadeTransition(javafx.animation.FadeTransition) Node(javafx.scene.Node)

Aggregations

Node (javafx.scene.Node)118 Label (javafx.scene.control.Label)18 Stage (javafx.stage.Stage)17 Parent (javafx.scene.Parent)16 Button (javafx.scene.control.Button)16 ArrayList (java.util.ArrayList)15 ObservableList (javafx.collections.ObservableList)14 FXML (javafx.fxml.FXML)14 List (java.util.List)12 BorderPane (javafx.scene.layout.BorderPane)12 HBox (javafx.scene.layout.HBox)11 IOException (java.io.IOException)10 Platform (javafx.application.Platform)10 Insets (javafx.geometry.Insets)10 Color (javafx.scene.paint.Color)10 FXCollections (javafx.collections.FXCollections)9 MouseEvent (javafx.scene.input.MouseEvent)9 VBox (javafx.scene.layout.VBox)9 FadeTransition (javafx.animation.FadeTransition)8 MenuItem (javafx.scene.control.MenuItem)8