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);
}
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();
}
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);
}
}
}
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;
}
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);
}
}
Aggregations