JavaFX中使用JFreeChart方法总结
来源:互联网 发布:vvic搜款网络批发广州 编辑:程序博客网 时间:2024/06/06 07:35
首先介绍一下,JavaFX2自带包括折线图等统计图表,样式可以用css设置,教程http://docs.oracle.com/javafx/2/charts/jfxpub-charts.htm。JFreeChart是Java平台的一个开放的图表绘制类库,使用广泛。JavaFX虽然在不断发展,取得一定成绩,但是图表比久未更新的JFreeChart在专业性上还是差不少。另外JFreeChart通过适当设置也可以很美观。
在JavaFX中使用JFreeChart,有如下两种方法,欢迎补充:
1、生成图片加载,可设置大小,输出格式,关联EXCEL
public static void saveAsFile(JFreeChart chart, String outputPath, int weight, int height) {
FileOutputStream out = null;
try {
File outFile = new File(outputPath);
if (!outFile.getParentFile().exists()) {
outFile.getParentFile().mkdirs();
}
out = new FileOutputStream(outputPath);
// 保存为PNG
ChartUtilities.writeChartAsPNG(out, chart, weight, height);
// 保存为JPEG
// ChartUtilities.writeChartAsJPEG(out, chart, weight, height);
out.flush();
}
catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
// do nothing
}
}
}
}
2、包装成SwingNode,默认大小,可设置node的横纵向拉伸调整
public SwingNode toNode(JFreeChart chart){
SwingNode node=new SwingNode();
ChartPanel c=new ChartPanel(chart);
node.setContent(c);
return node;
}
如有错误,欢迎纠正!
参考资料
http://premier9527.iteye.com/blog/1575018
http://stackoverflow.com/questions/16691320/how-i-can-use-jfreechart-with-javafx2
- JavaFX中使用JFreeChart方法总结
- javafx中radiobutton使用
- 转:jfreechart使用总结
- jfreechart使用总结
- jfreechart使用总结
- JFreeChart使用总结(四)
- jfreechart中使用URL
- java中JFreeChart使用
- JSP中使用JFreeChart
- struts2中 JFreeChart使用
- 在JavaFX中使用布局
- JavaFX中javafx.concurrent.Task类的使用
- jsp中JFreeChart的使用
- 在SWT中使用jfreechart
- 在struts2中使用jfreechart
- JFreechart的Axis的方法总结
- 在NetBeans IDE中使用JAVAFX
- 在Swing和Swt中使用JavaFX
- VScode常用快捷键
- Nginx+Keepalived
- linux下安装php扩展
- spring 学习 错误记录
- Invade the Mars HDU
- JavaFX中使用JFreeChart方法总结
- 性能测试心得之一
- java 空心等腰三角形
- PCA降维
- 二分
- Intellij IDEA快捷键
- BZOJ 1050 [HAOI2006]旅行comf
- CodeForces 604 A.Uncowed Forces(水~)
- 链表应用--多项式加法、乘法