changeset 7122:038a04e001d7

Handle multiple processors for axis labeling. It now looks for the first processor that provides a label != null
author Andre Heinecke <aheinecke@intevation.de>
date Tue, 24 Sep 2013 18:35:21 +0200
parents 30cec9369608
children 1a20738e9a21
files artifacts/src/main/java/org/dive4elements/river/exports/DiagramAttributes.java artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java artifacts/src/main/java/org/dive4elements/river/exports/process/DefaultProcessor.java
diffstat 3 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/DiagramAttributes.java	Tue Sep 24 18:33:30 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/DiagramAttributes.java	Tue Sep 24 18:35:21 2013 +0200
@@ -50,14 +50,15 @@
             return processors;
         }
 
-        public Processor getProcessorForAxisName(String axisName) {
+        public List<Processor> getProcessorsForAxisName(String axisName) {
+            List<Processor> retval = new ArrayList<Processor>(5);
             for (Processor pr: processors) {
                 String aName = pr.getAxisName();
                 if (aName != null && axisName.equals(aName)) {
-                    return pr;
+                    retval.add(pr);
                 }
             }
-            return null;
+            return retval;
         }
 
         public List<Processor> getProcessors() {
--- a/artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java	Tue Sep 24 18:33:30 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java	Tue Sep 24 18:35:21 2013 +0200
@@ -985,7 +985,8 @@
     public String getDefaultChartSubtitle() {
         DiagramAttributes.Title dTitle = diagramAttributes.getSubtitle();
         if (dTitle == null) {
-            return "Subtitle not configured in conf.xml";
+            /* Subtitle is optional */
+            return null;
         }
 
         return dTitle.evaluate((D4EArtifact)getMaster(), context);
@@ -1006,8 +1007,14 @@
 
     @Override
     protected String getDefaultYAxisLabel(String axisName) {
-        Processor pr = diagramAttributes.getProcessorForAxisName(axisName);
-        return pr == null ? "" : pr.getAxisLabel(this);
+        String label;
+        for (Processor pr: diagramAttributes.getProcessorsForAxisName(axisName)) {
+            label = pr.getAxisLabel(this);
+            if (label != null) {
+                return label;
+            }
+        }
+        return "No configured axis label";
     }
 
 
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/DefaultProcessor.java	Tue Sep 24 18:33:30 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/DefaultProcessor.java	Tue Sep 24 18:35:21 2013 +0200
@@ -57,7 +57,7 @@
 
     @Override
     public String getAxisLabel(DiagramGenerator generator) {
-        return "Please overwrite me in the implementation";
+        return null;
     }
 
 

http://dive4elements.wald.intevation.org