use of org.csstudio.javafx.rtplot.YAxis in project org.csstudio.display.builder by kasemir.
the class PlotConfigDialog method addAxisContent.
private int addAxisContent(final GridPane layout, int row, final Axis<?> axis) {
if (!axis.getName().trim().isEmpty())
layout.add(new Label('"' + axis.getName() + '"'), 0, row);
// is supposed to handle the 'scrolling'
if (axis instanceof NumericAxis) {
final NumericAxis num_axis = (NumericAxis) axis;
Label label = new Label("Start");
layout.add(label, 1, row);
final TextField start = new TextField(axis.getValueRange().getLow().toString());
layout.add(start, 2, row++);
label = new Label("End");
layout.add(label, 1, row);
final TextField end = new TextField(axis.getValueRange().getHigh().toString());
layout.add(end, 2, row++);
@SuppressWarnings("unchecked") final EventHandler<ActionEvent> update_range = event -> {
try {
num_axis.setValueRange(Double.parseDouble(start.getText()), Double.parseDouble(end.getText()));
} catch (NumberFormatException ex) {
start.setText(axis.getValueRange().getLow().toString());
end.setText(axis.getValueRange().getHigh().toString());
return;
}
if (axis instanceof YAxisImpl)
plot.internalGetPlot().fireYAxisChange((YAxisImpl<XTYPE>) axis);
else if (axis instanceof HorizontalNumericAxis)
plot.internalGetPlot().fireXAxisChange();
};
start.setOnAction(update_range);
end.setOnAction(update_range);
final CheckBox autoscale = new CheckBox("auto-scale");
if (axis.isAutoscale()) {
autoscale.setSelected(true);
start.setDisable(true);
end.setDisable(true);
}
autoscale.setOnAction(event -> {
axis.setAutoscale(autoscale.isSelected());
start.setDisable(autoscale.isSelected());
end.setDisable(autoscale.isSelected());
plot.internalGetPlot().fireAutoScaleChange(axis);
});
layout.add(autoscale, 2, row++);
if (axis instanceof YAxis) {
final CheckBox logscale = new CheckBox("log scale");
logscale.setSelected(num_axis.isLogarithmic());
logscale.setOnAction(event -> {
num_axis.setLogarithmic(logscale.isSelected());
plot.internalGetPlot().fireLogarithmicChange((YAxis<?>) num_axis);
});
layout.add(logscale, 2, row++);
}
}
final CheckBox grid = new CheckBox("grid");
grid.setSelected(axis.isGridVisible());
grid.setOnAction(event -> {
axis.setGridVisible(grid.isSelected());
plot.internalGetPlot().fireGridChange(axis);
});
layout.add(grid, 2, row++);
return row;
}
Aggregations