diff artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java @ 7241:32db4f89b65f

Add new option to diagram axes "logarithmic" that can be set to an evaluator
author Andre Heinecke <aheinecke@intevation.de>
date Fri, 04 Oct 2013 17:02:01 +0200
parents 2fd238b681a9
children 7ea428c4aca0
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java	Fri Oct 04 17:00:05 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java	Fri Oct 04 17:02:01 2013 +0200
@@ -356,7 +356,14 @@
 
 
     protected NumberAxis createXAxis(String label) {
-        return new NumberAxis(label);
+        boolean logarithmic = (Boolean)diagramAttributes.getDomainAxis().
+            isLog().evaluate((D4EArtifact)getMaster(), context);
+
+        if (logarithmic) {
+            return new LogarithmicAxis(label);
+        } else {
+            return new NumberAxis(label);
+        }
     }
 
 
@@ -1090,6 +1097,10 @@
         return axisSections;
     }
 
+    protected String getYAxisLabel(int index) {
+        return getYAxisLabel(diagramAttributes.getAxisName(index));
+    }
+
     /**
      * Returns the Y-Axis label of a chart at position <i>pos</i>.
      *
@@ -1157,7 +1168,15 @@
 
     @Override
     protected NumberAxis createYAxis(int index) {
-        NumberAxis axis = super.createYAxis(index);
+        NumberAxis axis;
+        boolean logarithmic = (Boolean)diagramAttributes.getAxesAttributes().
+            get(index).isLog().evaluate((D4EArtifact)getMaster(), context);
+
+        if (logarithmic) {
+            axis = new LogarithmicAxis(getYAxisLabel(index));
+        } else {
+            axis = super.createYAxis(index);
+        }
 
         if (diagramAttributes.getAxesAttributes().get(index).includeZero()) {
             axis.setAutoRangeIncludesZero(true);

http://dive4elements.wald.intevation.org