[PATCH 1 of 2] Tkh theme should only be pressed to bottom if other themes are present

Wald Commits scm-commit at wald.intevation.org
Tue Mar 6 17:14:43 CET 2018


# HG changeset patch
# User gernotbelger
# Date 1520352531 -3600
# Node ID 8596f95673b13b3f2ffcaa21ba2801e50d7e44ee
# Parent  93ea282c33e8bd4137535d51ba42ba8042bdff09
Tkh theme should only be pressed to bottom if other themes are present

diff -r 93ea282c33e8 -r 8596f95673b1 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthChartExtender.java
--- 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 */
 


More information about the Dive4Elements-commits mailing list