Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/exports/DiagramAttributes.java @ 8889:f87f435df856
Allow to configure lower and upper margin of a chart axis
author | gernotbelger |
---|---|
date | Wed, 14 Feb 2018 18:45:01 +0100 |
parents | 32db4f89b65f |
children | 87a242425467 |
rev | line source |
---|---|
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
2 * Software engineering by Intevation GmbH |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
3 * |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
7 */ |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
8 |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
9 package org.dive4elements.river.exports; |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
10 |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
11 import java.util.ArrayList; |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
12 import java.util.List; |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
13 |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
14 import org.w3c.dom.Element; |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
15 import org.w3c.dom.NodeList; |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
16 |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
17 import org.dive4elements.river.exports.process.Processor; |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
18 |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
19 import org.apache.log4j.Logger; |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
20 |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
21 import org.dive4elements.artifacts.CallContext; |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
22 |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
23 import org.dive4elements.river.artifacts.resources.Resources; |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
24 import org.dive4elements.river.artifacts.D4EArtifact; |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
25 |
7099
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
26 import org.dive4elements.artifacts.common.utils.ElementConverter; |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
27 |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
28 public class DiagramAttributes |
7227
744df5a03337
Use diagram configuration and there processors to define compatible facets in loaded data.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7166
diff
changeset
|
29 implements ElementConverter, D4EArtifact.FacetFilter |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
30 { |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
31 private static Logger log = Logger.getLogger(DiagramAttributes.class); |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
32 |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
33 public interface Evaluator { |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
34 Object evaluate(D4EArtifact artifact, CallContext context); |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
35 } // interface Evaluator |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
36 |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
37 public static final Evaluator TRUE = new Evaluator() { |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
38 @Override |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
39 public Object evaluate(D4EArtifact artifact, CallContext context) { |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
40 return Boolean.TRUE; |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
41 } |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
42 }; |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
43 |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
44 public static final Evaluator FALSE = new Evaluator() { |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
45 @Override |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
46 public Object evaluate(D4EArtifact artifact, CallContext context) { |
7166 | 47 return Boolean.FALSE; |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
48 } |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
49 }; |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
50 |
7099
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
51 public class Instance { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
52 |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
53 private List<Processor> processors; |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
54 |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
55 public Instance() { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
56 processors = createProcessors(); |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
57 } |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
58 |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
59 private List<Processor> createProcessors() { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
60 List<Processor> processors = |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
61 new ArrayList<Processor>(axesProcessors.size()); |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
62 for (AxisProcessor ap: axesProcessors) { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
63 Processor pr = ap.createProcessor(); |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
64 if (pr != null) { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
65 processors.add(pr); |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
66 } |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
67 } |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
68 return processors; |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
69 } |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
70 |
7122
038a04e001d7
Handle multiple processors for axis labeling.
Andre Heinecke <aheinecke@intevation.de>
parents:
7099
diff
changeset
|
71 public List<Processor> getProcessorsForAxisName(String axisName) { |
038a04e001d7
Handle multiple processors for axis labeling.
Andre Heinecke <aheinecke@intevation.de>
parents:
7099
diff
changeset
|
72 List<Processor> retval = new ArrayList<Processor>(5); |
7099
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
73 for (Processor pr: processors) { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
74 String aName = pr.getAxisName(); |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
75 if (aName != null && axisName.equals(aName)) { |
7122
038a04e001d7
Handle multiple processors for axis labeling.
Andre Heinecke <aheinecke@intevation.de>
parents:
7099
diff
changeset
|
76 retval.add(pr); |
7099
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
77 } |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
78 } |
7122
038a04e001d7
Handle multiple processors for axis labeling.
Andre Heinecke <aheinecke@intevation.de>
parents:
7099
diff
changeset
|
79 return retval; |
7099
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
80 } |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
81 |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
82 public List<Processor> getProcessors() { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
83 return processors; |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
84 } |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
85 |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
86 public Title getTitle() { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
87 return DiagramAttributes.this.getTitle(); |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
88 } |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
89 |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
90 public Title getSubtitle() { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
91 return DiagramAttributes.this.getSubtitle(); |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
92 } |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
93 |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
94 public DomainAxisAttributes getDomainAxis() { |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
95 return DiagramAttributes.this.getDomainAxis(); |
7099
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
96 } |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
97 |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
98 public int getAxisIndex(String axisName) { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
99 return DiagramAttributes.this.getAxisIndex(axisName); |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
100 } |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
101 |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
102 public String getAxisName(int index) { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
103 return DiagramAttributes.this.getAxisName(index); |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
104 } |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
105 |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
106 public List<AxisAttributes> getAxesAttributes() { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
107 return DiagramAttributes.this.getAxesAttributes(); |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
108 } |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
109 } // class Instance |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
110 |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
111 public static class AxisAttributes { |
8889
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
112 private final String name; |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
113 private final boolean isLeftAlign; // TODO: Remove! |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
114 private final boolean forceAlign; // TODO: Remove! |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
115 private final boolean includeZero; // TODO: Use Evaluator |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
116 |
8889
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
117 private final Evaluator isInverted; |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
118 private final Evaluator isLog; |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
119 private final double lowerMargin; |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
120 private final double upperMargin; |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
121 |
7049
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
122 public AxisAttributes( |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
123 String name, |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
124 boolean isLeftAlign, |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
125 boolean forceAlign, |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
126 boolean includeZero, |
7241
32db4f89b65f
Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents:
7227
diff
changeset
|
127 Evaluator isInverted, |
8889
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
128 Evaluator isLog, |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
129 double lowerMargin, |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
130 double upperMargin |
7049
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
131 ) { |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
132 this.name = name; |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
133 this.isLeftAlign = isLeftAlign; |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
134 this.forceAlign = forceAlign; |
7062
4310c612a986
Added 'include-zero' attribute to <axis> tag in diagram configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7061
diff
changeset
|
135 this.includeZero = includeZero; |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
136 this.isInverted = isInverted; |
7241
32db4f89b65f
Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents:
7227
diff
changeset
|
137 this.isLog = isLog; |
8889
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
138 this.lowerMargin = lowerMargin; |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
139 this.upperMargin = upperMargin; |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
140 } |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
141 |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
142 public String getName() { |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
143 return name; |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
144 } |
7049
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
145 |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
146 public boolean isLeftAlign() { |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
147 return isLeftAlign; |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
148 } |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
149 |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
150 public boolean forceAlign() { |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
151 return forceAlign; |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
152 } |
7062
4310c612a986
Added 'include-zero' attribute to <axis> tag in diagram configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7061
diff
changeset
|
153 |
4310c612a986
Added 'include-zero' attribute to <axis> tag in diagram configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7061
diff
changeset
|
154 public boolean includeZero() { |
4310c612a986
Added 'include-zero' attribute to <axis> tag in diagram configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7061
diff
changeset
|
155 return includeZero; |
4310c612a986
Added 'include-zero' attribute to <axis> tag in diagram configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7061
diff
changeset
|
156 } |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
157 |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
158 public Evaluator isInverted() { |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
159 return isInverted; |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
160 } |
7241
32db4f89b65f
Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents:
7227
diff
changeset
|
161 |
32db4f89b65f
Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents:
7227
diff
changeset
|
162 public Evaluator isLog() { |
32db4f89b65f
Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents:
7227
diff
changeset
|
163 return isLog; |
32db4f89b65f
Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents:
7227
diff
changeset
|
164 } |
8889
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
165 |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
166 public double getLowerMargin() { |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
167 return this.lowerMargin; |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
168 } |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
169 |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
170 public double getUpperMargin() { |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
171 return this.upperMargin; |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
172 } |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
173 } // class AxisAttributes |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
174 |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
175 public class DomainAxisAttributes extends AxisAttributes { |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
176 |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
177 private Title title; |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
178 |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
179 public DomainAxisAttributes( |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
180 String name, |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
181 boolean isLeftAlign, |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
182 boolean forceAlign, |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
183 boolean includeZero, |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
184 Evaluator isInverted, |
7241
32db4f89b65f
Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents:
7227
diff
changeset
|
185 Evaluator isLog, |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
186 Title title |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
187 ) { |
7241
32db4f89b65f
Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents:
7227
diff
changeset
|
188 super(name, isLeftAlign, forceAlign, includeZero, isInverted, |
8889
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
189 isLog, 0.0, 0.0); |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
190 this.title = title; |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
191 } |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
192 |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
193 public Title getTitle() { |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
194 return title; |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
195 } |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
196 } // class DomainAxisAttributes |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
197 |
7099
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
198 public static class AxisProcessor { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
199 |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
200 private Class<Processor> processorClass; |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
201 private String axisName; |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
202 |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
203 public AxisProcessor(Class<Processor> processorClass, String axisName) { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
204 this.processorClass = processorClass; |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
205 this.axisName = axisName; |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
206 } |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
207 |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
208 public Processor createProcessor() { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
209 try { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
210 Processor pr = processorClass.newInstance(); |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
211 pr.setAxisName(axisName); |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
212 return pr; |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
213 } |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
214 catch (InstantiationException ie) { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
215 log.error(ie, ie); |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
216 } |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
217 catch (IllegalAccessException iae) { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
218 log.error(iae, iae); |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
219 } |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
220 return null; |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
221 } |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
222 |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
223 } // class AxisProcessor |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
224 |
7160
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
225 public abstract static class ConvertEvaluator |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
226 implements Evaluator |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
227 { |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
228 protected String key; |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
229 protected String type; |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
230 |
7160
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
231 public ConvertEvaluator() { |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
232 } |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
233 |
7160
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
234 public ConvertEvaluator(String key, String type) { |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
235 this.key = key; |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
236 this.type = type; |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
237 } |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
238 |
7160
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
239 protected Object convert(Object value) { |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
240 if (value == null || type == null || type.isEmpty()) { |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
241 return value; |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
242 } |
7160
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
243 if (value instanceof String) { |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
244 String v = (String)value; |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
245 if ("double".equals(type)) { |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
246 return Double.valueOf(v); |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
247 } |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
248 if ("int".equals(type)) { |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
249 return Integer.valueOf(v); |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
250 } |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
251 if ("string".equals(type)) { |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
252 return v; |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
253 } |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
254 } |
7160
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
255 // TODO: Support more types |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
256 return value; |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
257 } |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
258 } // class ConvertEvaluator |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
259 |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
260 public static class ContextEvaluator extends ConvertEvaluator { |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
261 |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
262 public ContextEvaluator() { |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
263 } |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
264 |
7160
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
265 public ContextEvaluator(String key, String type) { |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
266 super(key, type); |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
267 } |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
268 |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
269 @Override |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
270 public Object evaluate(D4EArtifact artifact, CallContext context) { |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
271 return convert(context.getContextValue(key)); |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
272 } |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
273 } // class ContextEvaluator |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
274 |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
275 public static class ArtifactEvaluator extends ConvertEvaluator { |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
276 |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
277 public ArtifactEvaluator() { |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
278 } |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
279 |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
280 public ArtifactEvaluator(String key, String type) { |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
281 super(key, type); |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
282 } |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
283 |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
284 @Override |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
285 public Object evaluate(D4EArtifact artifact, CallContext context) { |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
286 return convert(artifact.getDataAsString(key)); |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
287 } |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
288 } // class ContextEvaluator |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
289 |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
290 public static class StringEvaluator implements Evaluator { |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
291 |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
292 private String value; |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
293 |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
294 public StringEvaluator() { |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
295 } |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
296 public StringEvaluator(String value) { |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
297 this.value = value; |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
298 } |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
299 |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
300 @Override |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
301 public Object evaluate(D4EArtifact artifact, CallContext context) { |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
302 return value; |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
303 } |
7160
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
304 } // class StringEvaluator |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
305 |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
306 public static class Title { |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
307 |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
308 private String key; |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
309 private String def; |
7160
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
310 private List<Evaluator> arguments; |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
311 |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
312 public Title() { |
7160
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
313 arguments = new ArrayList<Evaluator>(5); |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
314 } |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
315 |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
316 public Title(String key) { |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
317 this(key, key); |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
318 } |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
319 |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
320 public Title(String key, String def) { |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
321 this(); |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
322 this.key = key; |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
323 this.def = def; |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
324 } |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
325 |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
326 public String getKey() { |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
327 return key; |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
328 } |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
329 |
7160
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
330 public void addArgument(Evaluator argument) { |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
331 arguments.add(argument); |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
332 } |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
333 |
7060
78ded33f5f5b
Some more accessors and typo fix
Andre Heinecke <aheinecke@intevation.de>
parents:
7059
diff
changeset
|
334 public String evaluate(D4EArtifact artifact, CallContext context) { |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
335 if (key == null || key.isEmpty()) { |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
336 return def; |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
337 } |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
338 Object [] args = new Object[arguments.size()]; |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
339 for (int i = 0; i < args.length; ++i) { |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
340 args[i] = arguments.get(i).evaluate(artifact, context); |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
341 } |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
342 return Resources.getMsg(context.getMeta(), key, def, args); |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
343 } |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
344 } // class Title |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
345 |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
346 private List<AxisAttributes> axesAttrs; |
7099
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
347 private List<AxisProcessor> axesProcessors; |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
348 |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
349 private Title title; |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
350 private Title subtitle; |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
351 |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
352 private DomainAxisAttributes domainAxis; |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
353 |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
354 public DiagramAttributes() { |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
355 axesAttrs = new ArrayList<AxisAttributes>(5); |
7099
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
356 axesProcessors = new ArrayList<AxisProcessor>(5); |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
357 } |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
358 |
7099
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
359 @Override |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
360 public Object convert(Element config) { |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
361 parseAxis(config); |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
362 parseProcessors(config); |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
363 parseTitle(config); |
7049
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
364 parseSubtitle(config); |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
365 parseDomainAxis(config); |
7099
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
366 return this; |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
367 } |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
368 |
7060
78ded33f5f5b
Some more accessors and typo fix
Andre Heinecke <aheinecke@intevation.de>
parents:
7059
diff
changeset
|
369 public List<AxisAttributes> getAxesAttributes() { |
78ded33f5f5b
Some more accessors and typo fix
Andre Heinecke <aheinecke@intevation.de>
parents:
7059
diff
changeset
|
370 return axesAttrs; |
78ded33f5f5b
Some more accessors and typo fix
Andre Heinecke <aheinecke@intevation.de>
parents:
7059
diff
changeset
|
371 } |
78ded33f5f5b
Some more accessors and typo fix
Andre Heinecke <aheinecke@intevation.de>
parents:
7059
diff
changeset
|
372 |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
373 private void parseAxis(Element config) { |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
374 NodeList axisNodes = config.getElementsByTagName("axis"); |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
375 |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
376 for (int i = 0, N = axisNodes.getLength(); i < N; ++i) { |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
377 Element axisElement = (Element)axisNodes.item(i); |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
378 String name = axisElement.getAttribute("name").trim(); |
7049
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
379 String align = axisElement.getAttribute("align").trim(); |
7062
4310c612a986
Added 'include-zero' attribute to <axis> tag in diagram configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7061
diff
changeset
|
380 String includeZero = |
4310c612a986
Added 'include-zero' attribute to <axis> tag in diagram configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7061
diff
changeset
|
381 axisElement.getAttribute("include-zero").trim(); |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
382 |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
383 String isInverted = axisElement.getAttribute("inverted"); |
7241
32db4f89b65f
Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents:
7227
diff
changeset
|
384 String isLog = axisElement.getAttribute("logarithmic"); |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
385 |
8889
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
386 final double lowerMargin = parseDouble( axisElement.getAttribute("lowerMargin"), 0.0 ); |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
387 final double upperMargin = parseDouble( axisElement.getAttribute("upperMargin"), 0.0 ); |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
388 |
7049
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
389 if (name.isEmpty()) { |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
390 continue; |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
391 } |
7049
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
392 boolean isleftAlign = false; |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
393 boolean forceAlign = false; |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
394 for (String part: align.split("[\\s,]")) { |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
395 part = part.trim(); |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
396 if ("left" .equals(part)) isleftAlign = true; |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
397 else if ("right".equals(part)) isleftAlign = false; |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
398 else if ("force".equals(part)) forceAlign = true; |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
399 } |
7062
4310c612a986
Added 'include-zero' attribute to <axis> tag in diagram configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7061
diff
changeset
|
400 |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
401 Evaluator isInvertedE = parseEvaluator(isInverted, FALSE); |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
402 |
7241
32db4f89b65f
Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents:
7227
diff
changeset
|
403 Evaluator isLogE = parseEvaluator(isLog, FALSE); |
32db4f89b65f
Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents:
7227
diff
changeset
|
404 |
7062
4310c612a986
Added 'include-zero' attribute to <axis> tag in diagram configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7061
diff
changeset
|
405 axesAttrs.add(new AxisAttributes( |
4310c612a986
Added 'include-zero' attribute to <axis> tag in diagram configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7061
diff
changeset
|
406 name, isleftAlign, forceAlign, |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
407 includeZero.equals("true"), |
8889
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
408 isInvertedE, isLogE, |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
409 lowerMargin,upperMargin)); |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
410 } |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
411 } |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
412 |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
413 private static double parseDouble( final String text, final double defaultValue ) { |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
414 if( text == null || text.isEmpty() ) |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
415 return defaultValue; |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
416 |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
417 try { |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
418 return Double.parseDouble(text); |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
419 } |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
420 catch (final NumberFormatException e) { |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
421 e.printStackTrace(); |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
422 log.error(String.format("Invalid double attribute: ", text), e); |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
423 return defaultValue; |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
424 } |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
425 } |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
426 |
7160
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
427 private static Evaluator createDynamicEvaluator( |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
428 String className, |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
429 Evaluator def |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
430 ) { |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
431 try { |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
432 Class<Evaluator> clazz = (Class<Evaluator>)Class.forName(className); |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
433 return clazz.newInstance(); |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
434 } |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
435 catch (ClassNotFoundException cnfe) { |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
436 log.error(cnfe, cnfe); |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
437 } |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
438 catch (InstantiationException ie) { |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
439 log.error(ie, ie); |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
440 } |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
441 catch (IllegalAccessException iae) { |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
442 log.error(iae, iae); |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
443 } |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
444 return def; |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
445 } |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
446 |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
447 private static Evaluator parseEvaluator(String s, Evaluator def) { |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
448 if ((s = s.trim()).isEmpty()) return def; |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
449 if ("true".equals(s)) return TRUE; |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
450 if ("false".equals(s)) return FALSE; |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
451 if (s.endsWith("()")) { |
7160
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
452 return createDynamicEvaluator( |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
453 s.substring(0, s.length()-2).trim(), |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
454 def); |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
455 } |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
456 return def; |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
457 } |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
458 |
7099
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
459 public List<AxisProcessor> getAxesProcessors() { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
460 return axesProcessors; |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
461 } |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
462 |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
463 public Title getTitle() { |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
464 return title; |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
465 } |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
466 |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
467 public Title getSubtitle() { |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
468 return subtitle; |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
469 } |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
470 |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
471 public DomainAxisAttributes getDomainAxis() { |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
472 return domainAxis; |
7061
4f6b3ba542de
Added domain axis title to diagram attributes.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7060
diff
changeset
|
473 } |
4f6b3ba542de
Added domain axis title to diagram attributes.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7060
diff
changeset
|
474 |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
475 private void parseProcessors(Element config) { |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
476 NodeList processorNodes = config.getElementsByTagName("processor"); |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
477 |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
478 for (int i = 0, N = processorNodes.getLength(); i < N; ++i) { |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
479 Element processorElement = (Element)processorNodes.item(i); |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
480 String className = processorElement.getAttribute("class").trim(); |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
481 String axisName = processorElement.getAttribute("axis").trim(); |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
482 if (className.isEmpty() || axisName.isEmpty()) { |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
483 continue; |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
484 } |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
485 |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
486 try { |
7099
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
487 Class<Processor> processorClass = |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
488 (Class<Processor>)Class.forName(className); |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
489 axesProcessors.add(new AxisProcessor(processorClass, axisName)); |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
490 } |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
491 catch (ClassNotFoundException cnfe) { |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
492 log.error(cnfe, cnfe); |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
493 } |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
494 } |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
495 } |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
496 |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
497 private void parseTitle(Element config) { |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
498 title = extractTitle(config, "title"); |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
499 } |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
500 |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
501 private void parseSubtitle(Element config) { |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
502 subtitle = extractTitle(config, "subtitle"); |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
503 } |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
504 |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
505 private void parseDomainAxis(Element config) { |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
506 Title title = extractTitle(config, "domain-axis"); |
7241
32db4f89b65f
Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents:
7227
diff
changeset
|
507 String includeZero = ""; |
32db4f89b65f
Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents:
7227
diff
changeset
|
508 String isInverted = ""; |
32db4f89b65f
Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents:
7227
diff
changeset
|
509 String isLog = ""; |
32db4f89b65f
Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents:
7227
diff
changeset
|
510 |
32db4f89b65f
Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents:
7227
diff
changeset
|
511 NodeList dAlist = config.getElementsByTagName("domain-axis"); |
32db4f89b65f
Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents:
7227
diff
changeset
|
512 if (dAlist.getLength() > 0) { |
32db4f89b65f
Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents:
7227
diff
changeset
|
513 Element dAelement = (Element)dAlist.item(0); |
32db4f89b65f
Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents:
7227
diff
changeset
|
514 |
32db4f89b65f
Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents:
7227
diff
changeset
|
515 includeZero = dAelement.getAttribute("include-zero"); |
32db4f89b65f
Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents:
7227
diff
changeset
|
516 isInverted = dAelement.getAttribute("inverted"); |
32db4f89b65f
Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents:
7227
diff
changeset
|
517 isLog = dAelement.getAttribute("logarithmic"); |
32db4f89b65f
Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents:
7227
diff
changeset
|
518 } |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
519 |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
520 domainAxis = new DomainAxisAttributes( |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
521 "X", |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
522 false, |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
523 false, |
7160
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
524 includeZero.equals("true"), |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
525 parseEvaluator(isInverted, FALSE), |
7241
32db4f89b65f
Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents:
7227
diff
changeset
|
526 parseEvaluator(isLog, FALSE), |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
527 title); |
7061
4f6b3ba542de
Added domain axis title to diagram attributes.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7060
diff
changeset
|
528 } |
4f6b3ba542de
Added domain axis title to diagram attributes.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7060
diff
changeset
|
529 |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
530 private static Title extractTitle(Element config, String tagName) { |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
531 NodeList titleNodes = config.getElementsByTagName(tagName); |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
532 if (titleNodes.getLength() < 1) { |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
533 return null; |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
534 } |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
535 Element titleElement = (Element)titleNodes.item(0); |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
536 String key = titleElement.getAttribute("key"); |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
537 String def = titleElement.getAttribute("default"); |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
538 Title title = new Title(key, def); |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
539 NodeList argumentNodes = titleElement.getElementsByTagName("arg"); |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
540 for (int i = 0, N = argumentNodes.getLength(); i < N; ++i) { |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
541 Element argumentElement = (Element)argumentNodes.item(i); |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
542 String expression = argumentElement.getAttribute("expr"); |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
543 String type = argumentElement.getAttribute("type"); |
7160
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
544 |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
545 Evaluator ev = new StringEvaluator(expression); |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
546 |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
547 if (expression.endsWith("()")) { |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
548 ev = createDynamicEvaluator( |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
549 expression.substring(0, expression.length()-2).trim(), |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
550 ev); |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
551 } |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
552 else if (expression.startsWith("artifact.")) { |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
553 ev = new ArtifactEvaluator( |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
554 expression.substring("artifact.".length()), type); |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
555 } |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
556 else if (expression.startsWith("context.")) { |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
557 ev = new ContextEvaluator( |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
558 expression.substring("context.".length()), type); |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
559 } |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
560 |
f2ffa631c2ed
Diagram attributes: Use evaluators for title arguments, too. This makes it more consistent, powerful and a little bit faster.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7143
diff
changeset
|
561 title.addArgument(ev); |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
562 } |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
563 return title; |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
564 } |
7060
78ded33f5f5b
Some more accessors and typo fix
Andre Heinecke <aheinecke@intevation.de>
parents:
7059
diff
changeset
|
565 |
78ded33f5f5b
Some more accessors and typo fix
Andre Heinecke <aheinecke@intevation.de>
parents:
7059
diff
changeset
|
566 public int getAxisIndex(String axisName) { |
7061
4f6b3ba542de
Added domain axis title to diagram attributes.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7060
diff
changeset
|
567 for (int i = axesAttrs.size()-1; i >= 0; --i) { |
7060
78ded33f5f5b
Some more accessors and typo fix
Andre Heinecke <aheinecke@intevation.de>
parents:
7059
diff
changeset
|
568 if (axesAttrs.get(i).getName().equals(axisName)) { |
78ded33f5f5b
Some more accessors and typo fix
Andre Heinecke <aheinecke@intevation.de>
parents:
7059
diff
changeset
|
569 return i; |
78ded33f5f5b
Some more accessors and typo fix
Andre Heinecke <aheinecke@intevation.de>
parents:
7059
diff
changeset
|
570 } |
78ded33f5f5b
Some more accessors and typo fix
Andre Heinecke <aheinecke@intevation.de>
parents:
7059
diff
changeset
|
571 } |
78ded33f5f5b
Some more accessors and typo fix
Andre Heinecke <aheinecke@intevation.de>
parents:
7059
diff
changeset
|
572 return -1; |
78ded33f5f5b
Some more accessors and typo fix
Andre Heinecke <aheinecke@intevation.de>
parents:
7059
diff
changeset
|
573 } |
7068
726d998dce29
Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents:
7062
diff
changeset
|
574 |
726d998dce29
Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents:
7062
diff
changeset
|
575 public String getAxisName(int index) { |
7099
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
576 return index < 0 || index >= axesAttrs.size() |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
577 ? "" // null? |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
578 : axesAttrs.get(index).getName(); |
7068
726d998dce29
Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents:
7062
diff
changeset
|
579 } |
7227
744df5a03337
Use diagram configuration and there processors to define compatible facets in loaded data.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7166
diff
changeset
|
580 |
744df5a03337
Use diagram configuration and there processors to define compatible facets in loaded data.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7166
diff
changeset
|
581 @Override |
744df5a03337
Use diagram configuration and there processors to define compatible facets in loaded data.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7166
diff
changeset
|
582 public boolean accept(String outName, String facetName) { |
744df5a03337
Use diagram configuration and there processors to define compatible facets in loaded data.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7166
diff
changeset
|
583 Instance instance = new Instance(); |
744df5a03337
Use diagram configuration and there processors to define compatible facets in loaded data.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7166
diff
changeset
|
584 for (Processor pr: instance.getProcessors()) { |
744df5a03337
Use diagram configuration and there processors to define compatible facets in loaded data.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7166
diff
changeset
|
585 if (pr.canHandle(facetName)) { |
744df5a03337
Use diagram configuration and there processors to define compatible facets in loaded data.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7166
diff
changeset
|
586 return true; |
744df5a03337
Use diagram configuration and there processors to define compatible facets in loaded data.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7166
diff
changeset
|
587 } |
744df5a03337
Use diagram configuration and there processors to define compatible facets in loaded data.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7166
diff
changeset
|
588 } |
744df5a03337
Use diagram configuration and there processors to define compatible facets in loaded data.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7166
diff
changeset
|
589 return false; |
744df5a03337
Use diagram configuration and there processors to define compatible facets in loaded data.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7166
diff
changeset
|
590 } |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
591 } |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
592 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |