+ /**
+ * @param dataset
+ * @return
+ */
+ private static JFreeChart createLineChart(XYSeriesCollection dataset) {
+ NumberAxis xAxis = new NumberAxis("S->N");
+ xAxis.setAutoRangeIncludesZero(false);
+
+ NumberAxis yAxis = new NumberAxis("W->E");
+ yAxis.setAutoRangeIncludesZero(false);
+
+ XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false);
+ XYPlot plot = new ZoomableBackgroundXYPlot(dataset, xAxis, yAxis, renderer);
+ plot.setOrientation(PlotOrientation.HORIZONTAL);
+
+ JFreeChart chart = new JFreeChart(
+ "Track", JFreeChart.DEFAULT_TITLE_FONT, plot, true
+ );
+
+ return chart;
+ /*
+ JFreeChart chart = ChartFactory.createXYLineChart(
+ "Track",
+ "S->N",
+ "W->E",
+ dataset,
+ PlotOrientation.HORIZONTAL,
+ true,
+ true,
+ false);
+ return chart;
+ */
+ }
+
+ /**
+ * @param aHeightProfile
+ * @return
+ */
+ private static XYSeriesCollection createDataset(List<Pair<Double, Double>> aHeightProfile, String aName) {
+ XYSeries series = new XYSeries(aName, false);
+ for (Pair<Double,Double> point: aHeightProfile) {
+ series.add(point.getFirst(), point.getSecond());
+ }
+ XYSeriesCollection dataset = new XYSeriesCollection(series);
+ return dataset;
+ }
+
+ private static Pair<Pair<Double,Double>,Pair<Double,Double>> getBounds(List<Pair<Double,Double>> aList) {
+ Pair<Double,Double> first = aList.get(0);
+ double minx= first.getFirst();
+ double maxx = minx;
+ double miny = first.getSecond();
+ double maxy = miny;
+
+ for (int i = 0; i < aList.size(); i++) {
+ Pair<Double,Double> value = aList.get(i);
+ minx = Math.min(minx, value.getFirst());
+ maxx = Math.max(maxx, value.getFirst());
+ miny = Math.min(miny, value.getSecond());
+ maxy = Math.max(maxy, value.getSecond());
+ }
+ if ( maxx == minx ) {
+ maxx += 1.0; // to avoid problems.
+ }
+ if ( maxy == miny ) {
+ maxy += 1.0; // to avoid problems.
+ }
+ final double paddingFactor = 0.3; // allow some space around min and max
+ return new Pair<Pair<Double,Double>,Pair<Double,Double>>(
+ new Pair<Double,Double>( minx - paddingFactor*(maxx-minx),
+ maxx + paddingFactor*(maxx-minx)),
+ new Pair<Double,Double>( miny - paddingFactor*(maxy-miny),
+ maxy + paddingFactor*(maxy-miny))
+ );
+ }