使用 Java Applet 绘制图形 [英] Plotting a graph using Java Applet

查看:41
本文介绍了使用 Java Applet 绘制图形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个问题,我必须使用 Excel 文件中的一些数据在小程序上绘制图形.我需要设计一个小程序,我可以在同一个小程序上显示图形和数据.

I have a problem where I have to draw a graph on an applet using some data in an excel file. I would need to design an applet where I can display the graph and the data on the same applet.

我很难用 Java 编写一些代码来编写一些 CSVreader 和 ExcelReader 文件.现在,我真的被困在如何获取这些数据并将其绘制在小程序上.

I had a hard time writing some code in Java to code some CSVreader and ExcelReader files. Now, I am really stuck in how to take this data and graph it on an applet.

我不知道使用哪个类/库来绘制图形以及如何缩放它并绘制实际点或设计小程序本身.如果有人可以帮助我,我将不胜感激.

I don't know which class/libraries to use for drawing the graph and how to scale it and draw the actual points or designing the applet itself. I would appreciate if someone can help me out.

编辑

样本输入:

mis(t)  nt       Vt       N(t)      h(t)      H(t)
1      141    200,000   200,000   0.00071   0.00071
2      103    200,000   199,859   0.00052   0.00122

这里,要绘制 mis(t)h(t) 的图表.

Here, the graph is to be plotted for mis(t) vs. h(t).

推荐答案

也许,您正在寻找一个易于使用的 Java 图表应用程序.答案是 jFreeChart.他们还有很多示例,可以让您立即开始使用.

Perhaps, what you are looking for is an easy to use Chart application in Java. The answer is jFreeChart. They have a lots of samples as well to get you started immediately.

关于读取 CSV 文件以将数据传递给 jFreeChart,请使用 OpenCSV

And regarding reading CSV files to pass the data to jFreeChart, use OpenCSV

读取 CSV 文件就像 -

Reading a CSV file is as simple as -

CSVReader rec = new CSVReader(new FileReader(filePath));
String[] recLine;
while ((recLine = rec.readNext()) != null) {
 //Get the data from recLine
}

如果您需要更多详细信息,请告诉我.

Let me know if you need more details.

这篇关于使用 Java Applet 绘制图形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆