jfreechart 1.0.13中文乱码问题的解决
来源:互联网 发布:thumbdata4 软件 编辑:程序博客网 时间:2024/05/29 17:10
将坐标图和饼状图中的中文乱码问题解决了,只要做如下配置:
/**
* 配置字体 解决导出图中的中文乱码问题
*
* @param chart
* JFreeChart 对象
*/
public static void configFont(JFreeChart chart) {
// 配置字体
Font font = new Font("宋体", Font.BOLD, 25);
chart.getTitle().setFont(font);
if (chart.getLegend() != null) {
chart.getLegend().setItemFont(font);
}
if (chart.getPlot() instanceof CategoryPlot) {
chart.getCategoryPlot().getDomainAxis().setLabelFont(font);
chart.getCategoryPlot().getDomainAxis().setTickLabelFont(font);
chart.getCategoryPlot().getRangeAxis().setLabelFont(font);
chart.getCategoryPlot().getRangeAxis().setTickLabelFont(font);
} else if (chart.getPlot() instanceof XYPlot) {
if (chart.getXYPlot().getDomainAxis() != null) {
chart.getXYPlot().getDomainAxis().setLabelFont(font);
chart.getXYPlot().getDomainAxis().setTickLabelFont(font);
}
if (chart.getXYPlot().getRangeAxis() != null) {
chart.getXYPlot().getRangeAxis().setLabelFont(font);
chart.getXYPlot().getRangeAxis().setTickLabelFont(font);
}
} else if (chart.getPlot() instanceof PiePlot) {
((PiePlot3D) chart.getPlot()).setLabelFont(font);
}
// 设置背景色
chart.setBackgroundPaint(Color.WHITE);
}
/**
* 配置字体 解决导出图中的中文乱码问题
*
* @param chart
* JFreeChart 对象
*/
public static void configFont(JFreeChart chart) {
// 配置字体
Font font = new Font("宋体", Font.BOLD, 25);
chart.getTitle().setFont(font);
if (chart.getLegend() != null) {
chart.getLegend().setItemFont(font);
}
if (chart.getPlot() instanceof CategoryPlot) {
chart.getCategoryPlot().getDomainAxis().setLabelFont(font);
chart.getCategoryPlot().getDomainAxis().setTickLabelFont(font);
chart.getCategoryPlot().getRangeAxis().setLabelFont(font);
chart.getCategoryPlot().getRangeAxis().setTickLabelFont(font);
} else if (chart.getPlot() instanceof XYPlot) {
if (chart.getXYPlot().getDomainAxis() != null) {
chart.getXYPlot().getDomainAxis().setLabelFont(font);
chart.getXYPlot().getDomainAxis().setTickLabelFont(font);
}
if (chart.getXYPlot().getRangeAxis() != null) {
chart.getXYPlot().getRangeAxis().setLabelFont(font);
chart.getXYPlot().getRangeAxis().setTickLabelFont(font);
}
} else if (chart.getPlot() instanceof PiePlot) {
((PiePlot3D) chart.getPlot()).setLabelFont(font);
}
// 设置背景色
chart.setBackgroundPaint(Color.WHITE);
}
- jfreechart 1.0.13中文乱码问题的解决
- JfreeChart 解决中文乱码问题
- JFreeChart 解决中文乱码问题
- 解决JFreeChart中文乱码问题
- 解决JfreeChart中文乱码问题
- jfreechart的中文乱码问题
- JFreeChart中文乱码的问题
- Jfreechart 中文乱码问题的解决及zysong.ttf下载
- opensuse下解决jfreechart中文乱码的问题
- 解决linux 下jfreechart的中文乱码问题
- JfreeChart解决中文乱码
- JFreeChart中文乱码解决
- JfreeChart标题中文乱码的解决
- JFreeChart 中文乱码的解决 绝对管用!
- Linux下JFreechart 中文乱码的解决
- Linux下JFreechart 中文乱码的解决
- Linux下JFreechart 中文乱码的解决
- JFreeChart 中文乱码问题
- string 模拟之-big three
- Encoding 字符串的简单处理 我的开始
- [PHP]进阶教程:PHP中Cookies与Sessions的创建和使用
- Linux之V4L2基础编程
- Core Animation编程指南
- jfreechart 1.0.13中文乱码问题的解决
- JSP自定义标签
- java MD5
- python聊天服务器实现
- 局部加权回归
- 基于TMS320C62X DSP的混合编程研究
- 函数回调的理解
- flex与Java使用blazeds通信
- zoj Unique Ascending Array