解决jfreechart中文乱码,以及字体模糊,设置主题问题
来源:互联网 发布:最新网络流行词2016 编辑:程序博客网 时间:2024/05/21 13:58
发现一篇博客解决了我的乱码问题,复制过来分享下。
package cn.com.gwypx.util;import java.awt.Color;import java.awt.Font;import java.awt.Paint;import org.jfree.chart.ChartFactory;import org.jfree.chart.JFreeChart;import org.jfree.chart.StandardChartTheme;import org.jfree.chart.plot.DefaultDrawingSupplier;import org.jfree.chart.plot.PieLabelLinkStyle;import org.jfree.chart.renderer.category.StandardBarPainter;import org.jfree.chart.renderer.xy.StandardXYBarPainter;import org.jfree.ui.RectangleInsets;public class ChartUtils{ private static Font FONT = new Font("宋体", Font.PLAIN, 12); public static Color[] CHART_COLORS = {new Color(31, 129, 188), new Color(241, 92, 128), new Color(124, 181, 236), new Color(102, 172, 204), new Color(102, 102, 0), new Color(204, 153, 102), new Color(0, 153, 255), new Color(204, 255, 255), new Color(51, 153, 153), new Color(255, 204, 102), new Color(102, 102, 0), new Color(204, 204, 204), new Color(204, 255, 255), new Color(255, 204, 204), new Color(255, 255, 204), new Color(255, 153, 204), new Color(51, 0, 0), new Color(0, 51, 102), new Color(0, 153, 102), new Color(153, 102, 153), new Color(102, 153, 204), new Color(153, 204, 153), new Color(204, 204, 153), new Color(255, 255, 153), new Color(255, 204, 153), new Color(255, 153, 204), new Color(204, 153, 153), new Color(204, 204, 255), new Color(204, 255, 204), new Color(153, 204, 153), new Color(255, 204, 102)};// 颜色 /** * 中文主题样式 解决乱码 */ public static void setChartTheme() { // 设置中文主题样式 解决乱码 StandardChartTheme chartTheme = new StandardChartTheme("CN"); // 设置标题字体 chartTheme.setExtraLargeFont(FONT); // 设置图例的字体 chartTheme.setRegularFont(FONT); // 设置轴向的字体 chartTheme.setLargeFont(FONT); chartTheme.setSmallFont(FONT); chartTheme.setTitlePaint(new Color(51, 51, 51)); chartTheme.setSubtitlePaint(new Color(85, 85, 85)); chartTheme.setLegendBackgroundPaint(Color.WHITE);// 设置标注 chartTheme.setLegendItemPaint(Color.BLACK);// chartTheme.setChartBackgroundPaint(Color.WHITE); // 绘制颜色绘制颜色.轮廓供应商 // paintSequence,outlinePaintSequence,strokeSequence,outlineStrokeSequence,shapeSequence Paint[] OUTLINE_PAINT_SEQUENCE = new Paint[]{Color.WHITE}; // 绘制器颜色源 DefaultDrawingSupplier drawingSupplier = new DefaultDrawingSupplier( CHART_COLORS, CHART_COLORS, OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE); chartTheme.setDrawingSupplier(drawingSupplier); chartTheme.setPlotBackgroundPaint(Color.WHITE);// 绘制区域 chartTheme.setPlotOutlinePaint(Color.WHITE);// 绘制区域外边框 chartTheme.setLabelLinkPaint(new Color(8, 55, 114));// 链接标签颜色 chartTheme.setLabelLinkStyle(PieLabelLinkStyle.CUBIC_CURVE); chartTheme.setAxisOffset(new RectangleInsets(5, 12, 5, 12)); chartTheme.setDomainGridlinePaint(new Color(192, 208, 224));// X坐标轴垂直网格颜色 chartTheme.setRangeGridlinePaint(new Color(192, 192, 192));// Y坐标轴水平网格颜色 chartTheme.setBaselinePaint(Color.WHITE); chartTheme.setCrosshairPaint(Color.BLUE);// 不确定含义 chartTheme.setAxisLabelPaint(new Color(51, 51, 51));// 坐标轴标题文字颜色 chartTheme.setTickLabelPaint(new Color(67, 67, 72));// 刻度数字 chartTheme.setBarPainter(new StandardBarPainter());// 设置柱状图渲染 chartTheme.setXYBarPainter(new StandardXYBarPainter());// XYBar 渲染 chartTheme.setItemLabelPaint(Color.black); chartTheme.setThermometerPaint(Color.white);// 温度计 ChartFactory.setChartTheme(chartTheme); } /** * 解决中文字体模糊 */ public static void setAntiAlias(JFreeChart chart) { chart.setTextAntiAlias(false); }}创建报表对象之前调用setChartTheme(),创建报表对象之后调用setAntiAlias(JFreeChart chart)
0 0
- 解决jfreechart中文乱码,以及字体模糊,设置主题问题
- JfreeChart 解决中文乱码问题
- JFreeChart 解决中文乱码问题
- 解决JFreeChart中文乱码问题
- 解决JfreeChart中文乱码问题
- jfreechart一&二维报表导出为word&pdf&html-中文乱码和字体模糊问题(一)
- Netbeans8.0设置Consola字体并解决中文乱码问题
- JFreeChart中文乱码和文字模糊问题的通用解决方案
- JFreeChart中文乱码和文字模糊问题的通用解决方案
- JfreeChart解决中文乱码
- JFreeChart中文乱码解决
- JFreeChart 中文乱码问题
- jfreechart中文乱码问题
- jfreechart中文乱码问题
- Qt之解决中文乱码,字体设置
- xampp下mysql设置密码以及解决中文乱码问题
- jfreechart解决乱码问题。
- JFreeChart中文乱码、文字模糊通用解决方案
- IOS开发 根据某个日期计算是星期几
- 使用NSURLProtocol实现UIWebView的离线缓存
- 选择排序
- 【日常学习】【线性DP】codevs1044 拦截导弹题解
- Android WebView H5开发问题
- 解决jfreechart中文乱码,以及字体模糊,设置主题问题
- CAS和Shiro在spring中集成
- 我的bashrc,留而利值(不定期更新)
- solr 4.7.2 环境搭建
- 模式识别入门与贝叶斯决策理论
- 【LeetCode #179】Largest Number 解题报告
- 浅谈Autolayout之Masonry
- Android一分钟环境搭建,包含Mac、Linux、Windows
- UVa 11292 The Dragon of Loowater 勇者斗恶龙