Jfreechart学习笔记5-JFreeChart对象的一般基本方法

xiaoxiao2026-06-17  33

public class 总结 { public static void main(String[] args) { JFreeChart jfreechart = null; //获得标题title.getText() TextTitle title = jfreechart.getTitle(); //设置标题 jfreechart.setTitle("A Chart Title"); //设置标题的位置 jfreechart.getTitle().setPosition(RectangleEdge.BOTTOM); //当然了还可以设置副标题 TextTitle subtitle1 = new TextTitle("A Subtitle"); jfreechart.addSubtitle(subtitle1); //获得副标题,可以有很多副标题,这是获得第0个 Title subtitle = jfreechart.getSubtitle(0); //设置背景颜色 jfreechart.setBackgroundPaint(Color.blue); //当然还可以设置多种背影颜色 //表示在某个坐标之后是什么颜色 Paint p = new GradientPaint(0, 0, Color.white, 1000, 0, Color.green); jfreechart.setBackgroundPaint(p); //设置背景图片LOG jfreechart.setBackgroundImage(JFreeChart.INFO.getLogo()); //设置背景图片的位置,这个没有试过 jfreechart.setBackgroundImageAlignment(Align.TOP_LEFT); //Plot Attributes(共有的) //Plot(饼状图,) Plot plot1 = jfreechart.getPlot(); //Plot(柱状图,) CategoryPlot plot2 = jfreechart.getCategoryPlot(); //Plot(XY坐标图) XYPlot plot3 = jfreechart.getXYPlot(); //设置背影颜色(是图象的)(其它形状同理) plot1.setBackgroundPaint(Color.white); //设置背景颜色 plot1.setBackgroundImage(JFreeChart.INFO.getLogo()); //Axis Attributes(X和Y上面的,轴对象,分为X轴Y轴) // get an axis reference... CategoryPlot plot = jfreechart.getCategoryPlot(); //获得X轴对象 CategoryAxis domainAxis = plot.getDomainAxis(); //获得Y轴对象 ValueAxis rangeAxis = plot.getRangeAxis(); //change axis properties...改变属性 domainAxis.setLabel("Categories"); domainAxis.setLabelFont(new Font("宋体", Font.CENTER_BASELINE, 20)); //设置X轴字体,Y轴同样 domainAxis.setTickLabelFont(new Font("宋体", Font.CENTER_BASELINE, 20)); }} 相关资源:Jfreechart学习笔记3-简单Line图形创建
转载请注明原文地址: https://www.6miu.com/read-5050285.html

最新回复(0)