简体   繁体   中英

Plotting Points in Java with Interaction

I have a large number of data points which are two dimensional coordinates with non-integer values (floats). I am looking for a Java library that can help me plot these points, allowing for custom point size, color, and labels. Further, I would like the user to be able to interact with the points with panning and zooming, and I want to be able to capture KeyEvents from the user.

Processing looks great for what I want, but I don't want to do everything from scratch. Is there a better solution?

Thanks in advance.

Edit: There are about 2k points.

I haven't found a good library that works well for large data sets.

When you say large what do you mean? 1k, 100k, or 1 million points?

I just rolled my own since my data sets were at least 100k points. I've tried all the charting libraries I could find but none of them were as fast the one I rolled on my own.

Depends. I recently did app that displays large 2d datasets with JFreechart, but I ended making datasets smaller to have performance.

I displayed matrices of points, that changed in time (when new data arrives) with 1 second refresh time (so every one second chart is repainted).

For matries 256 x 256 it is OK on normal user computer. If the matrix is ~350 pts it gets rough (user sees lags in the GUI), but it is usable, if the matrix is 1024 x 1024 app is unusable.

I did chart drawing ind EDT, but still even if I took it into different thread --- rendering would still eat processor power.

So depending on data set size --- you might want to use JFreeChart.

This example easily handles thousands of nodes.

GraphPanel() {
    ...
    Random rnd = new Random();
    for (int i = 0; i < 2000; i++) {
        Point p = new Point(rnd.nextInt(WIDE), rnd.nextInt(HIGH));
        nodes.add(new Node(p, 4, Color.blue, kind));
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM