在 Java 中通过交互绘制点

发布于 2024-08-29 19:15:18 字数 201 浏览 5 评论 0原文

我有大量数据点,它们是具有非整数值(浮点数)的二维坐标。我正在寻找一个 Java 库,可以帮助我绘制这些点,允许自定义点大小、颜色和标签。此外,我希望用户能够通过平移和缩放与点进行交互,并且我希望能够捕获用户的 KeyEvent。

处理看起来很适合我想要的,但我不想从头开始做所有事情。有更好的解决方案吗?

提前致谢。

编辑:大约有2k点。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

べ繥欢鉨o。 2024-09-05 19:15:18

视情况而定。我最近制作了一个使用 JFreechart 显示大型二维数据集的应用程序,但我最终将数据集变小以提高性能。

我显示了点矩阵,这些点矩阵随时间变化(当新数据到达时),刷新时间为 1 秒(因此每隔一秒图表就会重新绘制一次)。

对于 256 x 256 的矩阵,在普通用户计算机上是可以的。如果矩阵是 ~350 点,它会变得粗糙(用户在 GUI 中看到滞后),但它是可用的,如果矩阵是 1024 x 1024 应用程序不可用。

我在 EDT 中绘制了图表,但即使我将其放入不同的线程中 — 渲染仍然会消耗处理器的电量。

因此,根据数据集大小 --- 您可能想要使用 JFreeChart。

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.

半山落雨半山空 2024-09-05 19:15:18

我还没有找到一个适合大型数据集的好库。

当你说大时,你的意思是什么? 1k、100k 还是 100 万点?

我刚刚推出了自己的数据集,因为我的数据集至少有 100k 点。我尝试了所有能找到的图表库,但没有一个比我自己构建的图表库快。

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.

攒眉千度 2024-09-05 19:15:18

示例可以轻松处理数千个节点。

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));
    }
}

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));
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文