diff flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java @ 422:3b83341e0cf4

ISSUE-52 The longitudinal section charts will now always have the head of the river at the left side. flys-artifacts/trunk@1904 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 11 May 2011 16:31:38 +0000
parents a0afdda4d4b9
children 88d9e1d75d64
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Wed May 11 09:51:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Wed May 11 16:31:38 2011 +0000
@@ -6,6 +6,7 @@
 
 import org.jfree.chart.JFreeChart;
 import org.jfree.chart.axis.NumberAxis;
+import org.jfree.chart.axis.ValueAxis;
 import org.jfree.chart.plot.XYPlot;
 import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
 import org.jfree.chart.title.TextTitle;
@@ -16,6 +17,9 @@
 
 import de.intevation.artifacts.Artifact;
 
+import de.intevation.flys.model.River;
+
+import de.intevation.flys.artifacts.FLYSArtifact;
 import de.intevation.flys.artifacts.WINFOArtifact;
 import de.intevation.flys.artifacts.model.WQKms;
 
@@ -150,6 +154,28 @@
 
         plot.setRangeAxis(2, qAxis);
         plot.mapDatasetToRangeAxis(1, 2);
+
+        invertXAxis(plot.getDomainAxis());
+    }
+
+
+    /**
+     * This method inverts the x-axis based on the kilometer information of the
+     * selected river. If the head of the river is at kilometer 0, the axis is
+     * not inverted, otherwise it is.
+     *
+     * @param xaxis The domain axis.
+     */
+    protected void invertXAxis(ValueAxis xaxis) {
+        FLYSArtifact artifact = (FLYSArtifact) master;
+        River        river    = artifact.getRiver();
+
+        boolean up = river.getKmUp();
+
+        if (up) {
+            logger.info("Invert X-Axis.");
+            xaxis.setInverted(true);
+        }
     }
 
 

http://dive4elements.wald.intevation.org