简体   繁体   English

用交互式绘制Java中的点

[英]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. 我正在寻找一个可以帮助我绘制这些点的Java库,允许自定义点大小,颜色和标签。 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. 此外,我希望用户能够通过平移和缩放与点进行交互,并且我希望能够从用户捕获KeyEvents。

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. 编辑:大约有2k点。

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? 1k,100k或100万点?

I just rolled my own since my data sets were at least 100k points. 因为我的数据集至少是100k点,所以我只是自己动手了。 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. 我最近做了一个用JFreechart显示大型2d数据集的应用程序,但我最终使数据集变小以获得性能。

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). 我显示了点的矩阵,这些点在时间上变化(当新数据到达时),刷新时间为1秒(因此重新绘制每一秒图表)。

For matries 256 x 256 it is OK on normal user computer. 对于256 x 256,可以在普通用户计算机上使用。 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. 如果矩阵是~350 pts它变得粗糙(用户在GUI中看到滞后),但是如果矩阵是1024 x 1024应用程序不可用,则它是可用的。

I did chart drawing ind EDT, but still even if I took it into different thread --- rendering would still eat processor power. 我做了EDT图表绘图,但即使我把它带入不同的线程---渲染仍然会占用处理器能力。

So depending on data set size --- you might want to use JFreeChart. 因此,根据数据集大小---您可能希望使用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));
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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