Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/exports/DiagramAttributes.java @ 8892:87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
author | gernotbelger |
---|---|
date | Thu, 15 Feb 2018 13:46:35 +0100 |
parents | f87f435df856 |
children | 55e2155ab52d |
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; |
8892
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
12 import java.util.Collection; |
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
13 import java.util.Collections; |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
14 import java.util.List; |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
15 |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
16 import org.w3c.dom.Element; |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
17 import org.w3c.dom.NodeList; |
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.dive4elements.river.exports.process.Processor; |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
20 |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
21 import org.apache.log4j.Logger; |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
22 |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
23 import org.dive4elements.artifacts.CallContext; |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
24 |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
25 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
|
26 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
|
27 |
7099
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
28 import org.dive4elements.artifacts.common.utils.ElementConverter; |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
29 |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
30 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
|
31 implements ElementConverter, D4EArtifact.FacetFilter |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
32 { |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
33 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
|
34 |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
35 public interface Evaluator { |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
36 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
|
37 } // interface Evaluator |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
38 |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
39 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
|
40 @Override |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
41 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
|
42 return Boolean.TRUE; |
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 }; |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
45 |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
46 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
|
47 @Override |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
48 public Object evaluate(D4EArtifact artifact, CallContext context) { |
7166 | 49 return Boolean.FALSE; |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
50 } |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
51 }; |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
52 |
7099
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
53 public class Instance { |
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 private List<Processor> processors; |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
56 |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
57 public Instance() { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
58 processors = createProcessors(); |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
59 } |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
60 |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
61 private List<Processor> createProcessors() { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
62 List<Processor> processors = |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
63 new ArrayList<Processor>(axesProcessors.size()); |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
64 for (AxisProcessor ap: axesProcessors) { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
65 Processor pr = ap.createProcessor(); |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
66 if (pr != null) { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
67 processors.add(pr); |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
68 } |
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 return processors; |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
71 } |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
72 |
7122
038a04e001d7
Handle multiple processors for axis labeling.
Andre Heinecke <aheinecke@intevation.de>
parents:
7099
diff
changeset
|
73 public List<Processor> getProcessorsForAxisName(String axisName) { |
038a04e001d7
Handle multiple processors for axis labeling.
Andre Heinecke <aheinecke@intevation.de>
parents:
7099
diff
changeset
|
74 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
|
75 for (Processor pr: processors) { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
76 String aName = pr.getAxisName(); |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
77 if (aName != null && axisName.equals(aName)) { |
7122
038a04e001d7
Handle multiple processors for axis labeling.
Andre Heinecke <aheinecke@intevation.de>
parents:
7099
diff
changeset
|
78 retval.add(pr); |
7099
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
79 } |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
80 } |
7122
038a04e001d7
Handle multiple processors for axis labeling.
Andre Heinecke <aheinecke@intevation.de>
parents:
7099
diff
changeset
|
81 return retval; |
7099
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
82 } |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
83 |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
84 public List<Processor> getProcessors() { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
85 return processors; |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
86 } |
8892
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
87 |
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
88 public Collection<ChartExtender> getExtenders() { |
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
89 return DiagramAttributes.this.getExtenders(); |
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
90 } |
7099
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
91 |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
92 public Title getTitle() { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
93 return DiagramAttributes.this.getTitle(); |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
94 } |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
95 |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
96 public Title getSubtitle() { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
97 return DiagramAttributes.this.getSubtitle(); |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
98 } |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
99 |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
100 public DomainAxisAttributes getDomainAxis() { |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
101 return DiagramAttributes.this.getDomainAxis(); |
7099
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
102 } |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
103 |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
104 public int getAxisIndex(String axisName) { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
105 return DiagramAttributes.this.getAxisIndex(axisName); |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
106 } |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
107 |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
108 public String getAxisName(int index) { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
109 return DiagramAttributes.this.getAxisName(index); |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
110 } |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
111 |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
112 public List<AxisAttributes> getAxesAttributes() { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
113 return DiagramAttributes.this.getAxesAttributes(); |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
114 } |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
115 } // class Instance |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
116 |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
117 public static class AxisAttributes { |
8889
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
118 private final String name; |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
119 private final boolean isLeftAlign; // TODO: Remove! |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
120 private final boolean forceAlign; // TODO: Remove! |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
121 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
|
122 |
8889
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
123 private final Evaluator isInverted; |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
124 private final Evaluator isLog; |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
125 private final double lowerMargin; |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
126 private final double upperMargin; |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
127 |
7049
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
128 public AxisAttributes( |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
129 String name, |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
130 boolean isLeftAlign, |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
131 boolean forceAlign, |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
132 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
|
133 Evaluator isInverted, |
8889
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
134 Evaluator isLog, |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
135 double lowerMargin, |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
136 double upperMargin |
7049
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
137 ) { |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
138 this.name = name; |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
139 this.isLeftAlign = isLeftAlign; |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
140 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
|
141 this.includeZero = includeZero; |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
142 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
|
143 this.isLog = isLog; |
8889
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
144 this.lowerMargin = lowerMargin; |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
145 this.upperMargin = upperMargin; |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
146 } |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
147 |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
148 public String getName() { |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
149 return name; |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
150 } |
7049
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
151 |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
152 public boolean isLeftAlign() { |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
153 return isLeftAlign; |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
154 } |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
155 |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
156 public boolean forceAlign() { |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
157 return forceAlign; |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
158 } |
7062
4310c612a986
Added 'include-zero' attribute to <axis> tag in diagram configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7061
diff
changeset
|
159 |
4310c612a986
Added 'include-zero' attribute to <axis> tag in diagram configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7061
diff
changeset
|
160 public boolean includeZero() { |
4310c612a986
Added 'include-zero' attribute to <axis> tag in diagram configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7061
diff
changeset
|
161 return includeZero; |
4310c612a986
Added 'include-zero' attribute to <axis> tag in diagram configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7061
diff
changeset
|
162 } |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
163 |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
164 public Evaluator isInverted() { |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
165 return isInverted; |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
166 } |
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
|
167 |
32db4f89b65f
Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents:
7227
diff
changeset
|
168 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
|
169 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
|
170 } |
8889
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
171 |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
172 public double getLowerMargin() { |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
173 return this.lowerMargin; |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
174 } |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
175 |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
176 public double getUpperMargin() { |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
177 return this.upperMargin; |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
178 } |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
179 } // class AxisAttributes |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
180 |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
181 public class DomainAxisAttributes extends AxisAttributes { |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
182 |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
183 private Title title; |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
184 |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
185 public DomainAxisAttributes( |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
186 String name, |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
187 boolean isLeftAlign, |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
188 boolean forceAlign, |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
189 boolean includeZero, |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
190 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
|
191 Evaluator isLog, |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
192 Title title |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
193 ) { |
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
|
194 super(name, isLeftAlign, forceAlign, includeZero, isInverted, |
8889
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
195 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
|
196 this.title = title; |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
197 } |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
198 |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
199 public Title getTitle() { |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
200 return title; |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
201 } |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
202 } // class DomainAxisAttributes |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
203 |
7099
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
204 public static class AxisProcessor { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
205 |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
206 private Class<Processor> processorClass; |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
207 private String axisName; |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
208 |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
209 public AxisProcessor(Class<Processor> processorClass, String axisName) { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
210 this.processorClass = processorClass; |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
211 this.axisName = axisName; |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
212 } |
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 public Processor createProcessor() { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
215 try { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
216 Processor pr = processorClass.newInstance(); |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
217 pr.setAxisName(axisName); |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
218 return pr; |
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 catch (InstantiationException ie) { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
221 log.error(ie, ie); |
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 catch (IllegalAccessException iae) { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
224 log.error(iae, iae); |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
225 } |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
226 return null; |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
227 } |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
228 |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
229 } // class AxisProcessor |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
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 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
|
232 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
|
233 { |
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 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
|
235 protected String type; |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
236 |
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
|
237 public ConvertEvaluator() { |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
238 } |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
239 |
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
|
240 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
|
241 this.key = key; |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
242 this.type = type; |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
243 } |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
244 |
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
|
245 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
|
246 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
|
247 return value; |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
248 } |
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
|
249 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
|
250 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
|
251 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
|
252 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
|
253 } |
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
|
254 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
|
255 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
|
256 } |
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 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
|
258 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
|
259 } |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
260 } |
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
|
261 // 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
|
262 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
|
263 } |
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
|
264 } // 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
|
265 |
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 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
|
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 public ContextEvaluator() { |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
269 } |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
270 |
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
|
271 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
|
272 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
|
273 } |
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 @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
|
276 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
|
277 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
|
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 } // 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
|
280 |
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 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
|
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 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
|
284 } |
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 |
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 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
|
287 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
|
288 } |
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 @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
|
291 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
|
292 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
|
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 } // 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
|
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 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
|
297 |
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 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
|
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 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
|
301 } |
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
|
302 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
|
303 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
|
304 } |
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
|
305 |
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
|
306 @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
|
307 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
|
308 return value; |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
309 } |
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 } // class StringEvaluator |
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 static class Title { |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
313 |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
314 private String key; |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
315 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
|
316 private List<Evaluator> arguments; |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
317 |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
318 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
|
319 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
|
320 } |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
321 |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
322 public Title(String key) { |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
323 this(key, key); |
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 Title(String key, String def) { |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
327 this(); |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
328 this.key = key; |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
329 this.def = def; |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
330 } |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
331 |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
332 public String getKey() { |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
333 return key; |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
334 } |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
335 |
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
|
336 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
|
337 arguments.add(argument); |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
338 } |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
339 |
7060
78ded33f5f5b
Some more accessors and typo fix
Andre Heinecke <aheinecke@intevation.de>
parents:
7059
diff
changeset
|
340 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
|
341 if (key == null || key.isEmpty()) { |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
342 return def; |
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 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
|
345 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
|
346 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
|
347 } |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
348 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
|
349 } |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
350 } // class Title |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
351 |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
352 private List<AxisAttributes> axesAttrs; |
7099
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
353 private List<AxisProcessor> axesProcessors; |
8892
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
354 private List<ChartExtender> extenders = new ArrayList<>(); |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
355 |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
356 private Title title; |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
357 private Title subtitle; |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
358 |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
359 private DomainAxisAttributes domainAxis; |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
360 |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
361 public DiagramAttributes() { |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
362 axesAttrs = new ArrayList<AxisAttributes>(5); |
7099
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
363 axesProcessors = new ArrayList<AxisProcessor>(5); |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
364 } |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
365 |
7099
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
366 @Override |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
367 public Object convert(Element config) { |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
368 parseAxis(config); |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
369 parseProcessors(config); |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
370 parseTitle(config); |
7049
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
371 parseSubtitle(config); |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
372 parseDomainAxis(config); |
8892
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
373 parseExtenders(config); |
7099
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
374 return this; |
7040
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 |
7060
78ded33f5f5b
Some more accessors and typo fix
Andre Heinecke <aheinecke@intevation.de>
parents:
7059
diff
changeset
|
377 public List<AxisAttributes> getAxesAttributes() { |
78ded33f5f5b
Some more accessors and typo fix
Andre Heinecke <aheinecke@intevation.de>
parents:
7059
diff
changeset
|
378 return axesAttrs; |
78ded33f5f5b
Some more accessors and typo fix
Andre Heinecke <aheinecke@intevation.de>
parents:
7059
diff
changeset
|
379 } |
78ded33f5f5b
Some more accessors and typo fix
Andre Heinecke <aheinecke@intevation.de>
parents:
7059
diff
changeset
|
380 |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
381 private void parseAxis(Element config) { |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
382 NodeList axisNodes = config.getElementsByTagName("axis"); |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
383 |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
384 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
|
385 Element axisElement = (Element)axisNodes.item(i); |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
386 String name = axisElement.getAttribute("name").trim(); |
7049
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
387 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
|
388 String includeZero = |
4310c612a986
Added 'include-zero' attribute to <axis> tag in diagram configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7061
diff
changeset
|
389 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
|
390 |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
391 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
|
392 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
|
393 |
8889
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
394 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
|
395 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
|
396 |
7049
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
397 if (name.isEmpty()) { |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
398 continue; |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
399 } |
7049
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
400 boolean isleftAlign = false; |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
401 boolean forceAlign = false; |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
402 for (String part: align.split("[\\s,]")) { |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
403 part = part.trim(); |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
404 if ("left" .equals(part)) isleftAlign = true; |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
405 else if ("right".equals(part)) isleftAlign = false; |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
406 else if ("force".equals(part)) forceAlign = true; |
165ea04b1545
Added alignment rules for diagrams.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7048
diff
changeset
|
407 } |
7062
4310c612a986
Added 'include-zero' attribute to <axis> tag in diagram configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7061
diff
changeset
|
408 |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
409 Evaluator isInvertedE = parseEvaluator(isInverted, FALSE); |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
410 |
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
|
411 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
|
412 |
7062
4310c612a986
Added 'include-zero' attribute to <axis> tag in diagram configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7061
diff
changeset
|
413 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
|
414 name, isleftAlign, forceAlign, |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
415 includeZero.equals("true"), |
8889
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
416 isInvertedE, isLogE, |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
417 lowerMargin,upperMargin)); |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
418 } |
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 |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
421 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
|
422 if( text == null || text.isEmpty() ) |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
423 return defaultValue; |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
424 |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
425 try { |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
426 return Double.parseDouble(text); |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
427 } |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
428 catch (final NumberFormatException e) { |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
429 e.printStackTrace(); |
f87f435df856
Allow to configure lower and upper margin of a chart axis
gernotbelger
parents:
7241
diff
changeset
|
430 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
|
431 return defaultValue; |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
432 } |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
433 } |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
434 |
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
|
435 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
|
436 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
|
437 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
|
438 ) { |
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 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
|
440 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
|
441 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
|
442 } |
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 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
|
444 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
|
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 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
|
447 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
|
448 } |
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
|
449 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
|
450 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
|
451 } |
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 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
|
453 } |
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 |
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
|
455 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
|
456 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
|
457 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
|
458 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
|
459 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
|
460 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
|
461 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
|
462 def); |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
463 } |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
464 return def; |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
465 } |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
466 |
7099
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
467 public List<AxisProcessor> getAxesProcessors() { |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
468 return axesProcessors; |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
469 } |
8892
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
470 |
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
471 public Collection<ChartExtender> getExtenders() { |
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
472 return Collections.unmodifiableCollection(extenders); |
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
473 } |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
474 |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
475 public Title getTitle() { |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
476 return title; |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
477 } |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
478 |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
479 public Title getSubtitle() { |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
480 return subtitle; |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
481 } |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
482 |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
483 public DomainAxisAttributes getDomainAxis() { |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
484 return domainAxis; |
7061
4f6b3ba542de
Added domain axis title to diagram attributes.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7060
diff
changeset
|
485 } |
4f6b3ba542de
Added domain axis title to diagram attributes.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7060
diff
changeset
|
486 |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
487 private void parseProcessors(Element config) { |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
488 NodeList processorNodes = config.getElementsByTagName("processor"); |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
489 |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
490 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
|
491 Element processorElement = (Element)processorNodes.item(i); |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
492 String className = processorElement.getAttribute("class").trim(); |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
493 String axisName = processorElement.getAttribute("axis").trim(); |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
494 if (className.isEmpty() || axisName.isEmpty()) { |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
495 continue; |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
496 } |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
497 |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
498 try { |
7099
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
499 Class<Processor> processorClass = |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
500 (Class<Processor>)Class.forName(className); |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
501 axesProcessors.add(new AxisProcessor(processorClass, axisName)); |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
502 } |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
503 catch (ClassNotFoundException cnfe) { |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
504 log.error(cnfe, cnfe); |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
505 } |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
506 } |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
507 } |
8892
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
508 |
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
509 private void parseExtenders(final Element config) { |
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
510 final NodeList processorNodes = config.getElementsByTagName("chartextender"); |
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
511 |
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
512 for (int i = 0, N = processorNodes.getLength(); i < N; ++i) { |
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
513 final Element extenderElement = (Element)processorNodes.item(i); |
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
514 final String className = extenderElement.getAttribute("class").trim(); |
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
515 if (className.isEmpty() ) { |
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
516 log.error("chartextender missing 'class' attribute"); |
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
517 continue; |
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
518 } |
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
519 |
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
520 try { |
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
521 final Class<?> protoclass = Class.forName(className); |
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
522 if( !ChartExtender.class.isAssignableFrom(protoclass) ) { |
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
523 log.error(String.format( "Chart extender must implement interface ChartExtender: %s", className) ); |
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
524 continue; |
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
525 } |
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
526 |
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
527 final ChartExtender extender = (ChartExtender) protoclass.newInstance(); |
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
528 extenders.add(extender); |
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
529 } |
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
530 catch (ClassNotFoundException | InstantiationException | IllegalAccessException cnfe) { |
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
531 log.error(String.format( "Failed to load or create chartextender class: %s", className ), cnfe); |
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
532 } |
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
533 } |
87a242425467
Introduced ChartExtender that allows to tweak the charts for very specific use cases.
gernotbelger
parents:
8889
diff
changeset
|
534 } |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
535 |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
536 private void parseTitle(Element config) { |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
537 title = extractTitle(config, "title"); |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
538 } |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
539 |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
540 private void parseSubtitle(Element config) { |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
541 subtitle = extractTitle(config, "subtitle"); |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
542 } |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
543 |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
544 private void parseDomainAxis(Element config) { |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
545 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
|
546 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
|
547 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
|
548 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
|
549 |
32db4f89b65f
Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents:
7227
diff
changeset
|
550 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
|
551 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
|
552 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
|
553 |
32db4f89b65f
Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents:
7227
diff
changeset
|
554 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
|
555 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
|
556 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
|
557 } |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
558 |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
559 domainAxis = new DomainAxisAttributes( |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
560 "X", |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
561 false, |
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
562 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
|
563 includeZero.equals("true"), |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
564 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
|
565 parseEvaluator(isLog, FALSE), |
7143
053e39436ba3
Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7122
diff
changeset
|
566 title); |
7061
4f6b3ba542de
Added domain axis title to diagram attributes.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7060
diff
changeset
|
567 } |
4f6b3ba542de
Added domain axis title to diagram attributes.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7060
diff
changeset
|
568 |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
569 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
|
570 NodeList titleNodes = config.getElementsByTagName(tagName); |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
571 if (titleNodes.getLength() < 1) { |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
572 return null; |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
573 } |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
574 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
|
575 String key = titleElement.getAttribute("key"); |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
576 String def = titleElement.getAttribute("default"); |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
577 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
|
578 NodeList argumentNodes = titleElement.getElementsByTagName("arg"); |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
579 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
|
580 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
|
581 String expression = argumentElement.getAttribute("expr"); |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
582 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
|
583 |
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
|
584 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
|
585 |
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
|
586 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
|
587 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
|
588 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
|
589 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
|
590 } |
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
|
591 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
|
592 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
|
593 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
|
594 } |
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
|
595 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
|
596 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
|
597 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
|
598 } |
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
|
599 |
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
|
600 title.addArgument(ev); |
7048
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
601 } |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
602 return title; |
a43137dfdcac
Simple interpolation logic for diagram titles and subtitles.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7042
diff
changeset
|
603 } |
7060
78ded33f5f5b
Some more accessors and typo fix
Andre Heinecke <aheinecke@intevation.de>
parents:
7059
diff
changeset
|
604 |
78ded33f5f5b
Some more accessors and typo fix
Andre Heinecke <aheinecke@intevation.de>
parents:
7059
diff
changeset
|
605 public int getAxisIndex(String axisName) { |
7061
4f6b3ba542de
Added domain axis title to diagram attributes.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7060
diff
changeset
|
606 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
|
607 if (axesAttrs.get(i).getName().equals(axisName)) { |
78ded33f5f5b
Some more accessors and typo fix
Andre Heinecke <aheinecke@intevation.de>
parents:
7059
diff
changeset
|
608 return i; |
78ded33f5f5b
Some more accessors and typo fix
Andre Heinecke <aheinecke@intevation.de>
parents:
7059
diff
changeset
|
609 } |
78ded33f5f5b
Some more accessors and typo fix
Andre Heinecke <aheinecke@intevation.de>
parents:
7059
diff
changeset
|
610 } |
78ded33f5f5b
Some more accessors and typo fix
Andre Heinecke <aheinecke@intevation.de>
parents:
7059
diff
changeset
|
611 return -1; |
78ded33f5f5b
Some more accessors and typo fix
Andre Heinecke <aheinecke@intevation.de>
parents:
7059
diff
changeset
|
612 } |
7068
726d998dce29
Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents:
7062
diff
changeset
|
613 |
726d998dce29
Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents:
7062
diff
changeset
|
614 public String getAxisName(int index) { |
7099
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
615 return index < 0 || index >= axesAttrs.size() |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
616 ? "" // null? |
24f153ad1f40
Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7084
diff
changeset
|
617 : axesAttrs.get(index).getName(); |
7068
726d998dce29
Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents:
7062
diff
changeset
|
618 } |
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
|
619 |
744df5a03337
Use diagram configuration and there processors to define compatible facets in loaded data.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7166
diff
changeset
|
620 @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
|
621 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
|
622 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
|
623 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
|
624 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
|
625 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
|
626 } |
744df5a03337
Use diagram configuration and there processors to define compatible facets in loaded data.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7166
diff
changeset
|
627 } |
744df5a03337
Use diagram configuration and there processors to define compatible facets in loaded data.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7166
diff
changeset
|
628 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
|
629 } |
7040
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
630 } |
f3cdc620b666
Added first version of diagram attribute parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
631 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |