Fast graphics library

I use Incanter for my graphic needs, which were adequate but slow for my previous needs.

Now I need to embed the graph in JPanel. Users will need to interact with the schedule (for example, by clicking on certain items that the program will need to receive and solve) by dragging and clicking. Out scaling is also necessary.

I heard about JFreeChart in other SO discussions, but I see that Incanter uses this as a graphics engine, and it seemed a bit slow. It's really fast, but maybe the Incanter is doing something that slows it down?

I draw up to 2 million points (simple xy-plots, really), although, as a rule, they will be less displayed. Using Matlab, it is laid down in a few seconds, but the Incanter can hang for several minutes.

So is JFreeChart the way to go? Or something else, given my needs?

(In addition, it should be free, as well as for research).

+6
java clojure
source share
2 answers

Unfortunately, general-purpose graphics solutions probably won't scale to 2 million points — it's big enough that you need something specialized if you want interactive performance.

I see several reasonable options:

  • Write your own plotter function, which is optimized for drawing a large number of points. You will have to test it, but I think you can just get the performance you need by writing the points directly in BufferedImage using setRGB in a narrow loop. If it is not fast enough yet, you can write the points directly in an array of bytes and build a MemoryImageSource.

  • Exclude dots so that you only draw, for example. Maximum 10,000 points. This may be acceptable if you really care about the general shape of the scatterplot, rather than the individual points.

  • Preview all points, for example. Large BufferedImage allows users to zoom in and out / zoom in with this static image. You could hack JFreeChart to do this.

  • If OpenGL is an option (you need your own code + get up a steep learning curve!), Then drop all the points in the large array of vertices and get a graphics card to do it all for you. They will process 2 million points in real time without any difficulties.

+5
source share

MathGL is a fast and free (GPL) building library. But I have never tested my java interface (swig based), since I am not familiar with java :( So, if someone can help with testing, I will be grateful.

+1
source share

All Articles