Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/themes/ThemeFactory.java @ 9555:ef5754ba5573
Implemented legend aggregation based on type of themes.
Added theme-editor style configuration for aggregated legend entries.
Only configured themes get aggregated.
author | gernotbelger |
---|---|
date | Tue, 23 Oct 2018 16:26:48 +0200 |
parents | f0ea2063b58e |
children |
rev | line source |
---|---|
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5867
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5867
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3785
diff
changeset
|
9 package org.dive4elements.river.themes; |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
3464
0b9b2a0c4e64
Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
3155
diff
changeset
|
11 import java.util.ArrayList; |
0b9b2a0c4e64
Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
3155
diff
changeset
|
12 import java.util.HashMap; |
1747
d2a17e990c70
Improved the Themes: we now support special themes for facets which need to match a given pattern string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
345
diff
changeset
|
13 import java.util.List; |
345
88a669785863
Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
342
diff
changeset
|
14 import java.util.Map; |
88a669785863
Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
342
diff
changeset
|
15 |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 import javax.xml.xpath.XPathConstants; |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 import org.apache.log4j.Logger; |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
19 import org.dive4elements.artifacts.common.utils.XMLUtils; |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
20 import org.dive4elements.river.artifacts.D4EArtifact; |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
21 import org.dive4elements.river.artifacts.context.RiverContext; |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 import org.w3c.dom.Document; |
3464
0b9b2a0c4e64
Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
3155
diff
changeset
|
23 import org.w3c.dom.Element; |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 import org.w3c.dom.NamedNodeMap; |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 import org.w3c.dom.Node; |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 import org.w3c.dom.NodeList; |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 /** |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
1822
6ed439ff61bf
Changed theme-mapping mechanism to include further condition (on master-artifacts attributes), added point themes for longitudinal.ws for calculations at locations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1747
diff
changeset
|
30 * |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
31 * Mapping-matching rules: |
1822
6ed439ff61bf
Changed theme-mapping mechanism to include further condition (on master-artifacts attributes), added point themes for longitudinal.ws for calculations at locations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1747
diff
changeset
|
32 * |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 */ |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 public class ThemeFactory { |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
36 private static Logger log = Logger.getLogger(ThemeFactory.class); |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 |
1822
6ed439ff61bf
Changed theme-mapping mechanism to include further condition (on master-artifacts attributes), added point themes for longitudinal.ws for calculations at locations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1747
diff
changeset
|
38 /** Trivial, hidden constructor. */ |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 private ThemeFactory() { |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 /** |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 * Creates a new theme from <i>config</i>. |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 * |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
45 * @param themeCfg |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
46 * The theme config document that is used to fetch parent |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
47 * themes. |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
48 * @param config |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
49 * The theme config node. |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 * |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 * @return a new theme. |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 */ |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
53 public static Theme createTheme(final Document themeCfg, final Node config) { |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
54 final String name = getName(config); |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
55 final String desc = getDescription(config); |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 |
8707
f0ea2063b58e
Change some debugs to trace in theme factory
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8202
diff
changeset
|
57 log.trace("Create new theme: " + name); |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
59 final DefaultTheme theme = new DefaultTheme(name, desc); |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 parseInherits(themeCfg, config, theme); |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 parseFields(config, theme); |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 parseAttrs(config, theme); |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 return theme; |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 |
345
88a669785863
Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
342
diff
changeset
|
68 /** |
1822
6ed439ff61bf
Changed theme-mapping mechanism to include further condition (on master-artifacts attributes), added point themes for longitudinal.ws for calculations at locations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1747
diff
changeset
|
69 * Get first matching theme for facet. |
6ed439ff61bf
Changed theme-mapping mechanism to include further condition (on master-artifacts attributes), added point themes for longitudinal.ws for calculations at locations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1747
diff
changeset
|
70 * |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
71 * @param name |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
72 * Name to match "from" of theme mapping. |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
73 * @param pattern |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
74 * String to 'compare' to pattern in mapping. |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
75 * @param output |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
76 * Name of the current output |
1822
6ed439ff61bf
Changed theme-mapping mechanism to include further condition (on master-artifacts attributes), added point themes for longitudinal.ws for calculations at locations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1747
diff
changeset
|
77 * |
6ed439ff61bf
Changed theme-mapping mechanism to include further condition (on master-artifacts attributes), added point themes for longitudinal.ws for calculations at locations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1747
diff
changeset
|
78 * @return First matching theme. |
6ed439ff61bf
Changed theme-mapping mechanism to include further condition (on master-artifacts attributes), added point themes for longitudinal.ws for calculations at locations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1747
diff
changeset
|
79 */ |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
80 public static Theme getTheme(final RiverContext c, final String name, final String pattern, final String output, final String groupName) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
81 if (log.isDebugEnabled()) { |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
82 log.debug("Search theme for: " + name + " - pattern: " + pattern); |
3555
b1912514e0f5
s/container.size() == 0/container.isEmpty()/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3464
diff
changeset
|
83 } |
1822
6ed439ff61bf
Changed theme-mapping mechanism to include further condition (on master-artifacts attributes), added point themes for longitudinal.ws for calculations at locations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1747
diff
changeset
|
84 |
345
88a669785863
Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
342
diff
changeset
|
85 if (c == null || name == null) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
86 log.warn("Cannot search for theme."); |
345
88a669785863
Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
342
diff
changeset
|
87 return null; |
88a669785863
Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
342
diff
changeset
|
88 } |
88a669785863
Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
342
diff
changeset
|
89 |
1822
6ed439ff61bf
Changed theme-mapping mechanism to include further condition (on master-artifacts attributes), added point themes for longitudinal.ws for calculations at locations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1747
diff
changeset
|
90 // Fetch mapping and themes. |
3464
0b9b2a0c4e64
Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
3155
diff
changeset
|
91 @SuppressWarnings("unchecked") |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
92 final |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
93 Map<String, List<ThemeMapping>> map = (Map<String, List<ThemeMapping>>) c.get(RiverContext.THEME_MAPPING); |
345
88a669785863
Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
342
diff
changeset
|
94 |
3464
0b9b2a0c4e64
Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
3155
diff
changeset
|
95 @SuppressWarnings("unchecked") |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
96 final |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
97 List<ThemeGroup> tgs = (List<ThemeGroup>) c.get(RiverContext.THEMES); |
345
88a669785863
Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
342
diff
changeset
|
98 |
2737
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
99 ThemeGroup group = null; |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
100 for (final ThemeGroup tg : tgs) { |
3555
b1912514e0f5
s/container.size() == 0/container.isEmpty()/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3464
diff
changeset
|
101 if (tg.getName().equals(groupName)) { |
2737
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
102 group = tg; |
3555
b1912514e0f5
s/container.size() == 0/container.isEmpty()/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3464
diff
changeset
|
103 break; |
2737
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
104 } |
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
105 } |
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
106 |
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
107 if (group == null) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
108 log.warn("No theme group found: '" + groupName + "'"); |
2737
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
109 return null; |
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
110 } |
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
111 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
112 final Map<String, Theme> t = group.getThemes(); |
2737
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
113 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
114 final D4EArtifact artifact = (D4EArtifact) c.get(RiverContext.ARTIFACT_KEY); |
1822
6ed439ff61bf
Changed theme-mapping mechanism to include further condition (on master-artifacts attributes), added point themes for longitudinal.ws for calculations at locations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1747
diff
changeset
|
115 |
3555
b1912514e0f5
s/container.size() == 0/container.isEmpty()/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3464
diff
changeset
|
116 if (map == null || map.isEmpty() || t == null || t.isEmpty()) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
117 log.warn("No mappings or themes found. Cannot retrieve theme!"); |
345
88a669785863
Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
342
diff
changeset
|
118 return null; |
88a669785863
Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
342
diff
changeset
|
119 } |
88a669785863
Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
342
diff
changeset
|
120 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
121 final List<ThemeMapping> mapping = map.get(name); |
345
88a669785863
Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
342
diff
changeset
|
122 |
1747
d2a17e990c70
Improved the Themes: we now support special themes for facets which need to match a given pattern string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
345
diff
changeset
|
123 if (mapping == null) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
124 log.warn("No theme found for mapping: " + name); |
1747
d2a17e990c70
Improved the Themes: we now support special themes for facets which need to match a given pattern string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
345
diff
changeset
|
125 return null; |
345
88a669785863
Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
342
diff
changeset
|
126 } |
88a669785863
Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
342
diff
changeset
|
127 |
1822
6ed439ff61bf
Changed theme-mapping mechanism to include further condition (on master-artifacts attributes), added point themes for longitudinal.ws for calculations at locations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1747
diff
changeset
|
128 // Take first mapping of which all conditions are satisfied. |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
129 for (final ThemeMapping tm : mapping) { |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
130 if (name.equals(tm.getFrom()) && tm.applyPattern(pattern) && tm.masterAttrMatches(artifact) && tm.outputMatches(output)) { |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
131 final String target = tm.getTo(); |
3785
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3781
diff
changeset
|
132 |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
133 log.debug("Found theme '" + target + "'"); |
3781
8e713e9bb4d7
Defined colors for bed quality themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3555
diff
changeset
|
134 return t.get(target); |
1747
d2a17e990c70
Improved the Themes: we now support special themes for facets which need to match a given pattern string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
345
diff
changeset
|
135 } |
d2a17e990c70
Improved the Themes: we now support special themes for facets which need to match a given pattern string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
345
diff
changeset
|
136 } |
d2a17e990c70
Improved the Themes: we now support special themes for facets which need to match a given pattern string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
345
diff
changeset
|
137 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
138 final String msg = "No theme found for '" + name + "' with pattern '" + pattern + "' and output " + output + "."; |
1747
d2a17e990c70
Improved the Themes: we now support special themes for facets which need to match a given pattern string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
345
diff
changeset
|
139 |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
140 log.warn(msg); |
1747
d2a17e990c70
Improved the Themes: we now support special themes for facets which need to match a given pattern string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
345
diff
changeset
|
141 |
d2a17e990c70
Improved the Themes: we now support special themes for facets which need to match a given pattern string.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
345
diff
changeset
|
142 return null; |
345
88a669785863
Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
342
diff
changeset
|
143 } |
88a669785863
Initialized the facet2theme mappings configured in themes.xml and added a function to the ThemeFactory that retrieves a theme from FLYSContext based on its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
342
diff
changeset
|
144 |
3464
0b9b2a0c4e64
Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
3155
diff
changeset
|
145 @SuppressWarnings("unchecked") |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
146 public static List<ThemeGroup> getThemeGroups(final RiverContext c) { |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
147 final List<ThemeGroup> tgs = (List<ThemeGroup>) c.get(RiverContext.THEMES); |
2737
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
148 return tgs; |
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
149 } |
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
150 |
3464
0b9b2a0c4e64
Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
3155
diff
changeset
|
151 @SuppressWarnings("unchecked") |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
152 public static List<Theme> getThemes(final RiverContext c, final String name) { |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
153 final List<ThemeGroup> tgs = (List<ThemeGroup>) c.get(RiverContext.THEMES); |
2737
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
154 if (tgs == null) { |
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
155 return null; |
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
156 } |
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
157 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
158 final List<Theme> themes = new ArrayList<>(); |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
159 for (final ThemeGroup tg : tgs) { |
2737
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
160 themes.add(tg.getThemeByName(name)); |
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
161 } |
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
162 return themes; |
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
163 } |
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
164 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
165 private static String getName(final Node config) { |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
166 return ((Element) config).getAttribute("name"); |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
167 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
168 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
169 private static String getDescription(final Node config) { |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
170 return ((Element) config).getAttribute("desc"); |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
171 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
172 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
173 private static void parseInherits(final Document themeCfg, final Node cfg, final DefaultTheme t) { |
2737
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
174 parseInherits(themeCfg, cfg, t, null); |
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
175 } |
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
176 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
177 private static void parseInherits(final Document themeCfg, final Node cfg, final DefaultTheme t, Map<String, Node> themes) { |
8707
f0ea2063b58e
Change some debugs to trace in theme factory
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8202
diff
changeset
|
178 log.trace("ThemeFactory.parseInherits"); |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
179 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
180 final NodeList inherits = ((Element) cfg).getElementsByTagName("inherit"); |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
181 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
182 final int num = inherits.getLength(); |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
183 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
184 if (num == 0) { |
8707
f0ea2063b58e
Change some debugs to trace in theme factory
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8202
diff
changeset
|
185 log.trace("Theme does not inherit from other themes."); |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
186 return; |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
187 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
188 |
8707
f0ea2063b58e
Change some debugs to trace in theme factory
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8202
diff
changeset
|
189 log.trace("Theme inherits from " + num + " other themes."); |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
190 |
2737
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
191 if (themes == null) { |
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
192 themes = buildThemeMap(themeCfg); |
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
193 } |
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
194 |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
195 for (int i = 0; i < num; i++) { |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
196 final Node inherit = inherits.item(i); |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
197 final String from = ((Element) inherit).getAttribute("from"); |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
198 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
199 final Node tmp = themes.get(from); |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
200 |
2737
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
201 parseInherits(themeCfg, tmp, t, themes); |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
202 parseFields(tmp, t); |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
203 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
204 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
205 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
206 private static Map<String, Node> buildThemeMap(final Document themeCfg) { |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
207 final Map<String, Node> map = new HashMap<>(); |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
208 final String xpath = "/themes/themegroup/theme"; |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
209 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
210 final NodeList nodes = (NodeList) XMLUtils.xpath(themeCfg, xpath, XPathConstants.NODESET); |
2737
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
211 |
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
212 if (nodes != null) { |
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
213 for (int i = 0, N = nodes.getLength(); i < N; ++i) { |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
214 final Node node = nodes.item(i); |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
215 final String name = ((Element) node).getAttribute("name"); |
2737
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
216 map.put(name, node); |
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
217 } |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
218 } |
2737
83b22ccf48da
Introduced theme groups and added new service to get themes filtered by name.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1886
diff
changeset
|
219 return map; |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
220 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
221 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
222 private static void parseFields(final Node config, final DefaultTheme theme) { |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
223 if (config == null || theme == null) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
224 log.warn("Parsing fields without node or theme is senseless!"); |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
225 return; |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
226 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
227 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
228 final NodeList fields = ((Element) config).getElementsByTagName("field"); |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
229 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
230 final int num = fields.getLength(); |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
231 |
8707
f0ea2063b58e
Change some debugs to trace in theme factory
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8202
diff
changeset
|
232 log.trace("Found " + num + " own fields in this theme."); |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
233 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
234 if (num == 0) { |
8707
f0ea2063b58e
Change some debugs to trace in theme factory
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8202
diff
changeset
|
235 log.trace("Theme has no own fields."); |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
236 return; |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
237 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
238 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
239 for (int i = 0; i < num; i++) { |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
240 final Node field = fields.item(i); |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
241 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
242 addField(theme, field); |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
243 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
244 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
245 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
246 private static void addField(final DefaultTheme theme, final Node field) { |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
247 final String name = ((Element) field).getAttribute("name"); |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
248 |
8707
f0ea2063b58e
Change some debugs to trace in theme factory
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8202
diff
changeset
|
249 log.trace("Add field " + name + " to theme " + theme.getName()); |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
250 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
251 final NamedNodeMap attrs = field.getAttributes(); |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
252 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
253 final int num = attrs != null ? attrs.getLength() : 0; |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
254 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
255 if (num == 0) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
256 log.warn("This field has no attributes."); |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
257 return; |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
258 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
259 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
260 final ThemeField theField = new DefaultThemeField(name); |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
261 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
262 for (int i = 0; i < num; i++) { |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
263 final Node attr = attrs.item(i); |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
264 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
265 final String key = attr.getNodeName(); |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
266 final String value = attr.getNodeValue(); |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
267 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
268 theField.setAttribute(key, value); |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
269 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
270 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
271 theme.addField(name, theField); |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
272 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
273 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
274 private static void parseAttrs(final Node config, final DefaultTheme theme) { |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
275 final NamedNodeMap attrs = config.getAttributes(); |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
276 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
277 final int num = attrs != null ? attrs.getLength() : 0; |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
278 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
279 if (num == 0) { |
8707
f0ea2063b58e
Change some debugs to trace in theme factory
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8202
diff
changeset
|
280 log.trace("Theme has no attributes set."); |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
281 return; |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
282 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
283 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
284 for (int i = 0; i < num; i++) { |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
285 final Node attr = attrs.item(i); |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
286 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
287 final String name = attr.getNodeName(); |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
288 final String value = attr.getNodeValue(); |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
289 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
290 theme.addAttribute(name, value); |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
291 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
292 } |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
293 |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
294 public static Theme getLegendTheme(final RiverContext flysContext, final String themeType) { |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
295 |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
296 @SuppressWarnings("unchecked") |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
297 final |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
298 Map<String, Theme> themes = (Map<String, Theme>) flysContext.get(RiverContext.LEGEND); |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
299 return themes.get(themeType); |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
300 } |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
8707
diff
changeset
|
301 } |