日期:2014-05-16 浏览次数:20692 次
System.out.println(jfreechart.getTitle().getFont().getFamily());
SansSerif
jfreechart.getTitle().setFont(new Font("宋体", Font.BOLD, 22));
jfreechart.getTitle().setFont(new Font("宋体", Font.BOLD, 22)); Font font = new Font("宋体", Font.BOLD, 22); jfreechart.getTitle().setFont(font); // 标题 font = new Font("宋体", Font.PLAIN, 14); jfreechart.getLegend().setItemFont(font); // 列类型的文字字体 font = new Font("宋体", Font.PLAIN, 16); categoryaxis.setLabelFont(font); // x轴名称的字体 categoryplot.getRangeAxis().setLabelFont(font); // y轴名称的字体 CategoryPlot categoryplot = jfreechart.getCategoryPlot(); CategoryAxis categoryaxis = categoryplot.getDomainAxis(); font = new Font("宋体", Font.PLAIN, 12); categoryaxis.setTickLabelFont(font); // x轴上的刻度名称字体 categoryplot.getRangeAxis().setTickLabelFont(font); // y轴上的刻度名称字体 font = new Font("宋体", Font.PLAIN, 18); categoryplot.setNoDataMessage(emptyMsg); categoryplot.setNoDataMessageFont(font); // 没有数据时的提示
package test; public class ImageTester { public static void generate(String fileName) throws Exception { BufferedImage image = new BufferedImage(300, 200, BufferedImage.TYPE_INT_RGB); Graphics g = image.getGraphics(); String fontType = "宋体"; g.setFont(new Font(fontType , Font.BOLD, 22)); g.drawString("你好我好", 30, 30); g.drawString("\u5b8b\u4f53", 30, 80); ImageIO.write(image, "JPEG", new FileOutputStream(new File(fileName))); } /** * @param args */ public static void main(String[] args) throws Exception { generate(args[0]); } } linux下运行时这样运行: java test.ImageTetser /home/test.png