package edu.agh.tunev.statistics;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;

public final class LifeStatistics implements Statistics {

	private JFreeChart chart;
	private XYSeries killed, alive, rescued;

	public LifeStatistics() {
		killed = new XYSeries("killed");
		alive = new XYSeries("alive");
		rescued = new XYSeries("rescued");

		XYSeriesCollection dataset = new XYSeriesCollection();
		dataset.addSeries(killed);
		dataset.addSeries(alive);
		dataset.addSeries(rescued);

		chart = ChartFactory.createXYLineChart(getTitle(), "Time [t]",
				"Num. people", dataset, PlotOrientation.VERTICAL, true, true,
				false);
	}

	@Override
	public String getTitle() {
		return "Life statistics";
	}

	@Override
	public JFreeChart getChart() {
		return chart;
	}

	public void add(double time, int numAlive, int numRescued, int numDead) {
		killed.add(time, numDead);
	}

}

@@ -1018,14 +1018,76 @@
 mDead);%0A
+%09%09alive.add(time, numAlive);%0A%09%09rescued.add(time, numRescued);%0A
 %09%7D%0A%0A%7D%0A

Fix saving of series