[PATCH 4 of 6] Handle multiple processors for axis labeling

Wald Commits scm-commit at wald.intevation.org
Tue Sep 24 18:37:48 CEST 2013


# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1380040521 -7200
# Node ID 038a04e001d7de54ad79ee230c371264f0229377
# Parent  30cec9369608b6508ab66376c75908c99fa5ac68
Handle multiple processors for axis labeling.

    It now looks for the first processor that provides a label != null

diff -r 30cec9369608 -r 038a04e001d7 artifacts/src/main/java/org/dive4elements/river/exports/DiagramAttributes.java
--- 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() {
diff -r 30cec9369608 -r 038a04e001d7 artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java
--- 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";
     }
 
 
diff -r 30cec9369608 -r 038a04e001d7 artifacts/src/main/java/org/dive4elements/river/exports/process/DefaultProcessor.java
--- 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;
     }
 
 


More information about the Dive4elements-commits mailing list