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);
package org.wamblee.gpx;
+import java.awt.Color;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
_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) {