Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package views.analysis; import models.DataList; import models.Point; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; /** * * @author hourdinf */ public final class ResidualPlotDisplay extends AnalysisDisplay { DataList dataList; DataList linearDatalist; public ResidualPlotDisplay(String applicationTitle, String chartTitle, DataList dataList) { super(applicationTitle, chartTitle); this.dataList = dataList; initialize(); } public XYDataset createDataset() { XYSeriesCollection dataset = new XYSeriesCollection(); XYSeries serie = new XYSeries("Rsidu"); for (Point p : this.dataList) { double value = p.getValue(); serie.add(p.getX(), value); } dataset.addSeries(serie); return dataset; } @Override public void initialize() { JFreeChart lineChart = ChartFactory.createScatterPlot(this.getTitle(), "Temps", "Rsidus", createDataset()); ChartPanel chartPanel = new ChartPanel(lineChart); chartPanel.setPreferredSize(new java.awt.Dimension(560, 367)); setContentPane(chartPanel); } }