(no commit message)
authorErik Brakkee <erik@brakkee.org>
Sun, 20 Sep 2009 18:39:05 +0000 (18:39 +0000)
committerErik Brakkee <erik@brakkee.org>
Sun, 20 Sep 2009 18:39:05 +0000 (18:39 +0000)
gps/src/main/java/org/wamblee/gpx/GpxPlotter.java
gps/src/main/java/org/wamblee/gpx/TrackStatistics.java

index 232c70139c7ffb594d5c902121281e15a4567dfd..3056eff507eb79f8be10acf944a3af1d0622a145 100644 (file)
@@ -57,7 +57,7 @@ public class GpxPlotter {
         Track track = parser.parse(new FileInputStream(file));
         
         TrackStatistics profile = new TrackStatistics(track);
-        profile.writeHeightProfileJpg(new FileOutputStream("x.jpg"), 600, 300);
+        profile.writeHeightProfilePng(new FileOutputStream("x.png"), 600, 300);
     
         List<Pair<Double,Double>> elevationProfile = computeElevationProfile(track);
         printTrack(elevationProfile); 
index 42c2039e3fad8411b95db686f0ef07c2234131eb..0d054a411b4630cc0d06ac192cd44463fd3d1dca 100644 (file)
@@ -1,5 +1,6 @@
 package org.wamblee.gpx;
 
+import java.awt.Color;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
@@ -26,7 +27,7 @@ public class TrackStatistics implements Serializable {
         _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(
@@ -38,7 +39,8 @@ public class TrackStatistics implements Serializable {
                 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) {