Can JavaFX 2.0 serve as a scientific charting package?
Asked Answered
S

5

11

I am writing a scientific experiment control program in java which includes a GUI.

I help choosing a charting library for this task. The program will contain two types of charts:

  1. A line chart with a lot of data points (in the range of 10^4-10^5 points per plot) with a refresh rate of about once every 0.5-1 seconds, so performance is a factor. This chart will have to include to sets of data points with different scaling.

  2. A scatter chart without many data points which must include error-bars, or some way of indicating the error in the points. Preferably both on the X and Y axis, in crosshair style for example.

Logarithmic scale is also a must and a good zoom tool and export tool would also be nice. I would prefer a solution for both charts with a single package of possible.

From the research I have done a nearly perfect option seems to be javaFX 2.0. From what I read, it has good performance and also looks great, but I can't seem to find an option for error-bars. Since I don't know javaFX at all, how simple is it to extend the charting library to include error bars, or is there an open source add on that includes this that I didn't find?

Another option is the Google charting library, which seems to have all the necessary features, however I am afraid that the refresh rate will be a problem in the first chart type. Is this a viable concern?

I have used JFreeChart, but I am concerned about the performance, and also found it very difficult to add small changes. These include a way to change the color of plotted points during run-time after the chart has been created as is possible in matlab. All this requires a lot of extra coding and time consumption which I am trying to avoid.

The last option which seems to be the most practical is JChart2D. It seems to have most of the functionality I need and my only problem with it is that it does not look very nice.

Does anyone have any recommendations for me? I plan to code this in as short a time as possible, and the worst case scenario is for me to discover that bugs in some third party package or that an option I need is unavailable and requires a lot of extra code, though it would be nice to learn something new.

This decision may of course affect the entire GUI package that I choose to use, which currently appears to be Swing.

Thanks,

Sammer answered 12/5, 2012 at 15:32 Comment(0)
C
8

Java FX 2.0 and JFreeChart are not really comparable. JFreeChart is a charting library for Swing, which is a GUI environment in Java. Whereas Java FX 2.0 is an alternative to Swing. Java FX 2.0 happens to provide a few chart objects as part of its standard library but they are definitely not as flexible / customisable as those available in JFreeChart. Of course, Java FX 2.0 being in Java, nothing prevents you from coding the very specific chart you need by extending the available components.

Java FX 2.0

  • Pros: More modern look and feel than Swing (personal subjective opinion), possibly going to be the new GUI standard in Java in a few years
  • Cons: you will have to spend more time enhancing the existing charting components, less widely used = less support + smaller community if you get stuck

Swing:

  • Pros: plenty of charting libraries available (JFreeChart is a very comprehensive one but there are alternatives as you mention). Active and wide community.
  • Cons: I personally don't like the look and feel as much - could become obsolete at some stage, but clearly not tomorrow.
Cockle answered 13/5, 2012 at 13:3 Comment(1)
Thank you! I think this was the answer I was looking for. JavaFX needs to be highly customized before it can serve as a scientific charting library.Sammer
P
5

JFreeChart is ideal for these uses. Because it's open source, it's easy to test in context; FastScatterPlot is discussed here. Changing a plot after it's been created is straightforward, as shown here; and arbitrary color schemes are possible, as shown here and here.

Platonic answered 13/5, 2012 at 0:49 Comment(1)
Also consider jfreechart-fx, mentioned here, "an extension for JFreeChart that allows JFreeChart to be used in JavaFX applications."Platonic
I
3

To enable JFreeChart and Orson Charts (which are Java2D-based) to be used in JavaFX, I have created a new project that provides a Graphics2D API backed by a JavaFX Canvas. The project is FXGraphics2D on GitHub. It could be used for other Java2D libraries as well (the code is under a BSD-style license).

Ingraft answered 20/5, 2014 at 9:9 Comment(0)
M
1

You can use Open Office as a charting engine , there is a java/UNO bridge ... JavaFX is nice but charts are not as flexible as JFreeChart API a solution could be to use JfreeCharts within FX patrick

Microcline answered 29/7, 2012 at 11:5 Comment(0)
P
0

The best scientific Java charting package is provided by The MathWorks. Using MATLAB Builder JA allows you to code the plotting, and if needed the computational part in MATLAB and convert it into Java classes.

There is one drawback. The last time I used the package, there was no option to include the plotting window in your application. The plots are always shown in a separate window.

Another point of concern is the price for this solution.

matplolib is the closest competitor to MATLAB, but there is no Jython implementation so far.

Poly answered 12/5, 2012 at 15:52 Comment(2)
Originally the program I am working on was in Matlab, but unfortunately due to consistent "Out of memory" errors and general package performance. Do you know if performance can be an issue in this solution?Sammer
Showing more than 10^5 data points with 1Hz refresh rate did work without any performance issues. "Out of memory" errors often can be solved by tweaking the JVM settings.Poly

© 2022 - 2024 — McMap. All rights reserved.