JFreeChar-----图像(散点分布)

package com.test;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.ui.ApplicationFrame;


import java.awt.RenderingHints;


import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.FastScatterPlot;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
public class CreateChartServiceImpl extends ApplicationFrame {


    /**

*/
private static final long serialVersionUID = 1L;


/** A constant for the number of items in the sample dataset. */
    private static final int COUNT = 100;


    /** The data. */
    private float[][] data = new float[2][COUNT];


    /**
     * Creates a new fast scatter plot demo.
     *
     * @param title  the frame title.
     */
    public CreateChartServiceImpl(final String title) {


        super(title);
        populateData();
        final NumberAxis domainAxis = new NumberAxis("X");
        domainAxis.setAutoRangeIncludesZero(false);
        final NumberAxis rangeAxis = new NumberAxis("Y");
        rangeAxis.setAutoRangeIncludesZero(false);
        final FastScatterPlot plot = new FastScatterPlot(this.data, domainAxis, rangeAxis);
        final JFreeChart chart = new JFreeChart("123", plot);
//        chart.setLegend(null);


        // force aliasing of the rendered content..
        chart.getRenderingHints().put
            (RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);


        final ChartPanel panel = new ChartPanel(chart, true);
        panel.setPreferredSize(new java.awt.Dimension(500, 500));
  //      panel.setHorizontalZoom(true);
    //    panel.setVerticalZoom(true);
        panel.setMinimumDrawHeight(0);
        panel.setMaximumDrawHeight(1000);
        panel.setMinimumDrawWidth(0);
        panel.setMaximumDrawWidth(1000);
        
        setContentPane(panel);


    }


  
    private void populateData() {
   
    int [] di=new int[50];
   
    int c=0;//表示di求和
    for(int i=0;i<di.length;i++ ){
   
    di[i]=(int) (Math.random()*100);//随机生成0--100的数
    c+=di[i];
     
     
    }


    int [] di2=new int[50];
   
    int c2=0;//表示di求和
    for(int i=0;i<di2.length;i++ ){
   
    di2[i]=(int) (Math.random()*100);//随机生成0--100的数
    c2+=di[i];
     
     
    }
   
   
   


        for (int i = 0; i < 50; i++) {
           data[0][i]=di[i];//-----------------------------------------赋值坐标
           data[1][i]=di2[i];
        }


    }


    /**
     * Starting point for the demonstration application.
     *
     * @param args  ignored.
     */
    public static void main(final String[] args) {


        final CreateChartServiceImpl demo = new CreateChartServiceImpl("Fast Scatter Plot Demo");
        demo.pack();
        RefineryUtilities.centerFrameOnScreen(demo);
        demo.setVisible(true);


    }


}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值