jfreechart之中文处理处理类
import java.awt.Color; import java.awt.Font; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.CategoryLabelPositions; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PiePlot; import org.jfree.chart.title.TextTitle; /** * @author 刘毅 * @date 2010-2-25 * @ClassName JfreeChinese.java * @Email liu_yi126@163.com * @param 字体 * @param */ public class JfreeChinese { //柱.标题 public static Font FONT_TILE_CHINESE= new Font("宋体",Font.BOLD,16); //X轴 public static Font FONT_X_CHINESE= new Font("宋体",Font.BOLD,12); //Y轴 public static Font FONT_Y_CHINESE= new Font("宋体",Font.BOLD,13); //底部 public static Font FONT_L_CHINESE= new Font("宋体",Font.BOLD,18); //饼标题 public static Font FONT_PIE_TILE_CHINESE= new Font("宋体",Font.BOLD,16); //Y轴 public static Font FONT_PIE_IMG_CHINESE= new Font("宋体",Font.BOLD,13); //底部 public static Font FONT_PIE_D_CHINESE= new Font("宋体",Font.BOLD,18); /** * 柱形图字体 * @param chart */ public static void setChineseForXY(JFreeChart chart){ CategoryPlot plot = chart.getCategoryPlot();// 图形的绘制结构对象 //标题字体 TextTitle title; title = chart.getTitle(); title.setFont(FONT_TILE_CHINESE); // 底部 chart.getLegend().setItemFont(FONT_L_CHINESE); // X 轴 CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setLabelFont(FONT_X_CHINESE);// 轴标题 domainAxis.setTickLabelFont(FONT_X_CHINESE);// 轴数值 domainAxis.setTickLabelPaint(Color.BLUE) ; // 字体颜色 domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); // 横轴上的label斜显示 // Y 轴 ValueAxis rangeAxis = plot.getRangeAxis(); rangeAxis.setLabelFont(FONT_Y_CHINESE); rangeAxis.setLabelPaint(Color.BLUE) ; // 字体颜色 rangeAxis.setTickLabelFont(FONT_Y_CHINESE); } /** * 饼图字体 * @param chart */ public static void setChineseForPie(JFreeChart chart){ //标题 TextTitle title; title = chart.getTitle(); title.setFont(FONT_PIE_TILE_CHINESE); //图 PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelFont(FONT_PIE_IMG_CHINESE); //底部说明 chart.getLegend().setItemFont(FONT_PIE_D_CHINESE); } }