package org.wamblee.gpx;
+import java.awt.Color;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.wamblee.general.Pair;
import org.wamblee.gps.geometry.Point;
import org.wamblee.gps.geometry.ReferenceCoordinateSystem;
-import org.wamblee.gps.track.Track;
+import org.wamblee.gps.track.TrackSegment;
-public class TrackStatistics {
+public class TrackStatistics implements Serializable {
- private Track _track;
+ private TrackSegment _track;
- public TrackStatistics(Track aTrack) {
+ public TrackStatistics(TrackSegment aTrack) {
_track = aTrack;
}
- public void writeHeightProfileJpg(OutputStream aStream, int aWidth, int aHeight) throws IOException {
+ public void writeHeightProfilePng(OutputStream aStream, int aWidth, int aHeight) throws IOException {
List<Pair<Double,Double>> data = computeElevationProfile();
XYSeriesCollection dataset = createDataset(data, "height");
JFreeChart chart = ChartFactory.createXYLineChart(
true,
true,
false);
- ChartUtilities.writeChartAsJPEG(aStream, chart, aWidth, aHeight);
+ chart.setBackgroundPaint(Color.WHITE);
+ ChartUtilities.writeChartAsPNG(aStream, chart, aWidth, aHeight);
}
private static XYSeriesCollection createDataset(List<Pair<Double, Double>> aHeightProfile, String aName) {