-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCutDetectionLineChart.java
More file actions
55 lines (48 loc) · 1.88 KB
/
CutDetectionLineChart.java
File metadata and controls
55 lines (48 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.axis.NumberTickUnit;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
public class CutDetectionLineChart extends ApplicationFrame {
double[] data;
public CutDetectionLineChart(double[] data, String diffType, int range) {
super("Histogram Difference Between Frames ");
this.pack();
RefineryUtilities.centerFrameOnScreen(this);
this.setVisible(true);
this.data = data;
JFreeChart lineChart = ChartFactory.createXYLineChart(
diffType + " Difference Between Frames ",
"Frame", "Difference",
createDataset(),
PlotOrientation.VERTICAL,
true, true, false);
XYPlot plot = (XYPlot) lineChart.getPlot();
ValueAxis yAxis = plot.getRangeAxis();
yAxis.setRange(0, range);
ValueAxis xAxis = plot.getDomainAxis();
xAxis.setRange(0, 3000.0);
ChartPanel chartPanel = new ChartPanel(lineChart);
chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
setContentPane(chartPanel);
}
private XYDataset createDataset() {
XYSeriesCollection dataset = new XYSeriesCollection();
XYSeries series = new XYSeries("Object 1");
for(int i = 0; i < data.length; i++) {
series.add(i, data[i]);
}
dataset.addSeries(series);
return dataset;
}
}