Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
[fw/altos] / altosui / AltosGraph.java
1
2 // Copyright (c) 2010 Anthony Towns
3 // GPL v2 or later
4
5 package AltosUI;
6
7 import java.io.*;
8
9 import org.jfree.chart.JFreeChart;
10 import org.jfree.chart.ChartUtilities;
11 import org.altusmetrum.AltosLib.*;
12
13 abstract class AltosGraph {
14     public String filename;
15     public abstract void addData(AltosDataPoint d);
16     public abstract JFreeChart createChart();
17     public String title;
18     public void toPNG() throws java.io.IOException { toPNG(300, 500); }
19     public void toPNG(int width, int height)
20         throws java.io.IOException
21     {
22         File pngout = new File(filename);
23         JFreeChart chart = createChart();
24         ChartUtilities.saveChartAsPNG(pngout, chart, width, height);
25         System.out.println("Created " + filename);
26     }
27 }