changeset 8937:8596f95673b1

Tkh theme should only be pressed to bottom if other themes are present
author gernotbelger
date Tue, 06 Mar 2018 17:08:51 +0100
parents 93ea282c33e8
children 9c02733a1b3c
files artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthChartExtender.java
diffstat 1 files changed, 19 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthChartExtender.java	Tue Mar 06 17:07:27 2018 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthChartExtender.java	Tue Mar 06 17:08:51 2018 +0100
@@ -21,14 +21,30 @@
  * @author Gernot Belger
  */
 public class FlowDepthChartExtender implements ChartExtender {
+
+    private static final String TKH_AXIS = "tkhAxis";
+
+    private static final String FLOWDEPTH_AXIS = "flowdepthAxis";
+
+    @Override
+    public void beforeAutoZoom(final DiagramGenerator generator) {
+        final ValueAxis tkhAxis = generator.getAxis(TKH_AXIS);
+        if (tkhAxis != null) {
+            /* If tkh is not the only dataset, we push it to the bottom */
+            final int numYAxes = generator.getNumYAxes();
+            if (numYAxes > 1)
+                tkhAxis.setUpperMargin(4.0);
+        }
+    }
+
     /**
      * Synchronizes the location of '0' on the flow-depth-axis with the tkh-axis, by extending the lower bound of the
      * flow-depth-axis.
      */
     @Override
     public void afterAutoZoom(final DiagramGenerator generator) {
-        final ValueAxis axis1 = generator.getAxis("flowdepthAxis");
-        final ValueAxis axis2 = generator.getAxis("tkhAxis");
+        final ValueAxis axis1 = generator.getAxis(FLOWDEPTH_AXIS);
+        final ValueAxis axis2 = generator.getAxis(TKH_AXIS);
         if (axis1 == null || axis2 == null)
             return;
 
@@ -44,8 +60,7 @@
 
     @Override
     public void afterGenerateChart(final DiagramGenerator generator, final XYPlot plot) {
-
-        final ValueAxis tkhAxis = generator.getAxis("tkhAxis");
+        final ValueAxis tkhAxis = generator.getAxis(TKH_AXIS);
         if (tkhAxis != null) {
             /* show baseline if tkhAxis is present */
 

http://dive4elements.wald.intevation.org