More track data.
[utils] / trunk / gps / src / main / java / org / wamblee / gpx / TrackStatistics.java
index ce43a79d28741dd01636d0a13f508101a04634ca..455ca985c0b5c245fe6a9bd40d5986a99a3eaf6e 100644 (file)
@@ -1,8 +1,10 @@
 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;
 
@@ -15,17 +17,17 @@ import org.jfree.data.xy.XYSeriesCollection;
 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(
@@ -37,7 +39,8 @@ public class TrackStatistics {
                 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) {