use of org.csstudio.javafx.rtplot.internal.ImagePlot in project org.csstudio.display.builder by kasemir.
the class ImagePlotDemo method start.
@Override
public void start(final Stage stage) throws Exception {
final Level level = Level.CONFIG;
Logger.getLogger("").setLevel(level);
for (Handler handler : Logger.getLogger("").getHandlers()) handler.setLevel(level);
final ImagePlot plot = new ImagePlot(true);
plot.setColorMapping(RAINBOW);
plot.setAutoscale(true);
plot.setValueRange(0.0, 2.0);
plot.getXAxis().setGridVisible(true);
plot.getYAxis().setGridVisible(true);
plot.getYAxis().setScaleFont(Font.font("Liberation Sans", FontPosture.ITALIC, 25));
final RegionOfInterest roi = plot.addROI("R.O.I.", javafx.scene.paint.Color.BLUEVIOLET, true, true);
roi.setRegion(new Rectangle2D(20, 40, 20, 10));
plot.setListener(new RTImagePlotListener() {
@Override
public void changedCursorInfo(double x, double y, int xi, int yi, double value) {
System.out.println("Cursor at " + x + ", " + y);
}
@Override
public void changedROI(int index, String name, Rectangle2D region) {
System.out.println("ROI " + name + " now at " + region);
}
});
timer.scheduleAtFixedRate(() -> plot.setValue(WIDTH, HEIGHT, computeData(), false), 200, 100, TimeUnit.MILLISECONDS);
timer.scheduleAtFixedRate(() -> {
show_colorbar = !show_colorbar;
plot.showColorMap(show_colorbar);
}, 5000, 5000, TimeUnit.MILLISECONDS);
final Pane root = new Pane(plot);
final ChangeListener<? super Number> resize_listener = (p, o, n) -> plot.setSize(root.getWidth(), root.getHeight());
root.widthProperty().addListener(resize_listener);
root.heightProperty().addListener(resize_listener);
final Scene scene = new Scene(root, 800, 600);
Styles.setSceneStyle(scene);
stage.setScene(scene);
stage.setTitle("Image Plot Demo");
stage.show();
stage.setOnCloseRequest((event) -> {
timer.shutdown();
try {
timer.awaitTermination(2, TimeUnit.SECONDS);
} catch (Exception e) {
e.printStackTrace();
}
plot.dispose();
});
}
Aggregations