A scientific charting library for JavaFX in Java 8+.
This is a new project, and fuller documentation will follow. The best way to explore waterlooFX is to import the distribution jar file form here:
into Oracle's Scene Builder 2.0.
Charts and plots can be drag-and-dropped into a GUI using Scene Builder and both their data and the appearance can be edited.
Charts are subclasses of the standard JavaFX Pane class.
They may be created using the usual constructor methods:
import waterloo.fx.plot.Chart;
Chart chart = new Chart();
Charts may parent other charts. In this case a custom layout will be applied automatically so each chart will have independent axes:
import waterloo.fx.plot.Chart;
Chart chart = new Chart(new Chart());
Each chart has a "view": and area within which the plots will be drawn. The view is a JavaFX StackPane.
Plots can be added to the view directly:
import waterloo.fx.plot.Chart;
import waterloo.fx.plot.ScatterPlot;
Chart chart = new Chart();
chart.getView().getChildren().add(new ScatterPlot());
They may also be added to the chart,
import waterloo.fx.plot.Chart;
import waterloo.fx.plot.ScatterPlot;
Chart chart = new Chart();
chart.getChildren().add(new ScatterPlot());
% Plots may also be added during construction
Chart chart2 = new Chart(new ScatterPlot());
All plots are subclasses of AbstractPlot which, in turn, is a subclass of the standard JavaFX StackPane.
A standard plot has two Panes in its stack: one for drawing the plots and another for annotations such as Text objects associated with the plot elements.
Each plot has a dataModel for storing the data and a visualModel which specifies colours, markers etc.
Both are editable using Scene Builder.
The graphics of the plot are all presented as JavaFX Nodes types such a Line and Polyline. Nodes are added/removed lazily to the graphics Pane for the plot i.e. only when a data change requires that.
During the normal Scene layout pass, the layout constraints of the these nodes will be updated as required.
This method of plotting is fast enough for most purposes (e.g. the CloudPlot in the demo resizes quickly enough even with 20000 data points). The back most element of a Chart's view is a Canvas that may prove faster and be used if needed in the future.
Plots can parent other plots: if you want a scatter plot with lines joining the points create a compound plot.
~~~~~~~~~~~
import waterloo.fx.plot.LinePlot;
import waterloo.fx.plot.ScatterPlot;
ScatterPlot scatter = new ScatterPlot(new LinePLot());
% or
ScatterPlot scatter2 = new ScatterPlot();
scatter2.getChildren().add(new LinePlot());
#### Using FXML ####
Charts and plots can all be created using FXML - the demo was created that way.
Here is a simple example with a line and scatter plot:
<chart xleft="0.0" xright="5.0" ybottom="0.0" ytop="5.0" maxheight="-Infinity" maxwidth="-Infinity" minheight="-Infinity" minwidth="-Infinity" prefheight="400.0" prefwidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<children>
<scatterplot xdata="0.0, 1.0, 2.0, 3.0, 4.0, 5.0" ydata="0.0, 1.0, 2.0, 3.0, 4.0, 5.0">
<children>
<lineplot xdata="0.0, 1.0, 2.0, 3.0, 4.0, 5.0" ydata="0.0, 1.0, 2.0, 3.0, 4.0, 5.0">
</lineplot></children>
</scatterplot>
</children>
</chart>
~~~~~~~~~~~~~