JFreeChart对象的一般基本方法

public class test {
 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));

 }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值