Gerrit Grunwald, aka @hansolo_ on twitter, has just ported his Swing based gauges and meters framework known as SteelSeries to JavaFX as part of the JFXtras-lab project. I can't tell you how many times since Java AWT first came out, that I have had to use meters and gauges in an application. Also, I can't count how many times I have found a dearth of open source gauge frameworks out there in the wild. Needless to say, I have been watching Gerrit's progress for several months now. Finally, he posted his work to jxftras-lab and I have been eagerly testing ever since.
One area I wanted to see is if Gerrit's gauges worked with JavaFX FXML. JavaFX FXML is an XML-based language that provides the structure for building a user interface separate from the application logic of your code. With the numerous options that Gerrit's gauges support, this is a must have. I am happy to report with a little back and forth with Gerrit over a few days, we now have a working version that supports FXML. You'll have to download and build the latest jfxtras-lab bits from github, here.
Here is an FXML snippet showing how to define a Radial gauge in FXML. This matches Gerrit's blog, showing the same settings using Java code, here.
<Radial fx:id="radialGauge" prefWidth="280" prefHeight="280" title="Temperature" >
<Section start="0" stop="37" color="lime"/>
<Section start="37" stop="60" color="yellow"/>
<Section start="60" stop="75" color="orange"/>
<Section start="75" stop="100" color="red"/>
<Marker value="30" color="magenta"/>
<Marker value="75" color="aquamarine"/>
In FXML, you create a Java controller class. For this simple example, in the controller class, Gauge.java, I created a JavaFX Timeline that iterates from the minimum to the maximum value over 10 seconds, alternating with rising and falling values. The actual Radial Gauge is represented by the "radialGauge" member of the controller that is annotated with @FXML. This allows the FXML system to match the actual JavaFX Radial Control instance to the controller member variable based on the FXML"fx:id" attribute. The initialize method of the controller class is called once the FXML system has processed the XML and created all the JavaFX Nodes.
The main JavaFX application is contained in the class SteelFX and it loads the FXML file then assigns it to the JavaFX Scene.
The complete code is here: