Last change
on this file since 3824 was 3824, checked in by bastiK, 13 years ago |
Separate styles from style generation. This may seem a little over the top, but its just an intermediate state of development, should make sense later. Regarding performance: execution time is the same, memory use is similar, or a little less (due to intern pool for StyleCache). Tested, but can have still some bugs.
|
-
Property svn:eol-style
set to
native
|
File size:
1.6 KB
|
Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.mappaint.xml;
|
---|
3 |
|
---|
4 | import java.util.Collection;
|
---|
5 |
|
---|
6 | import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
---|
7 | import org.openstreetmap.josm.data.osm.OsmUtils;
|
---|
8 |
|
---|
9 | abstract public class Prototype {
|
---|
10 | // zoom range to display the feature
|
---|
11 | public long minScale;
|
---|
12 | public long maxScale;
|
---|
13 |
|
---|
14 | public int priority;
|
---|
15 | public String code;
|
---|
16 | public Collection<XmlCondition> conditions = null;
|
---|
17 |
|
---|
18 | public Prototype(long maxScale, long minScale) {
|
---|
19 | this.maxScale = maxScale;
|
---|
20 | this.minScale = minScale;
|
---|
21 | }
|
---|
22 |
|
---|
23 | public Prototype() {
|
---|
24 | }
|
---|
25 |
|
---|
26 | @Override
|
---|
27 | public boolean equals(Object o) {
|
---|
28 | return (o instanceof Prototype) && (((Prototype) o).getCode().equals(getCode()));
|
---|
29 | }
|
---|
30 |
|
---|
31 | @Override
|
---|
32 | public int hashCode() {
|
---|
33 | return getClass().hashCode();
|
---|
34 | }
|
---|
35 |
|
---|
36 | public String getCode() {
|
---|
37 | if(code == null) {
|
---|
38 | code = "";
|
---|
39 | if (conditions != null) {
|
---|
40 | for(XmlCondition r: conditions) {
|
---|
41 | code += r.toCode();
|
---|
42 | }
|
---|
43 | }
|
---|
44 | }
|
---|
45 | return code;
|
---|
46 | }
|
---|
47 |
|
---|
48 | public boolean check(OsmPrimitive primitive)
|
---|
49 | {
|
---|
50 | if(conditions == null)
|
---|
51 | return true;
|
---|
52 | for(XmlCondition r : conditions)
|
---|
53 | {
|
---|
54 | String k = primitive.get(r.key);
|
---|
55 | String bv = OsmUtils.getNamedOsmBoolean(r.boolValue);
|
---|
56 | if(k == null || (r.value != null && !k.equals(r.value))
|
---|
57 | || (bv != null && !bv.equals(OsmUtils.getNamedOsmBoolean(k))))
|
---|
58 | return false;
|
---|
59 | }
|
---|
60 | return true;
|
---|
61 | }
|
---|
62 |
|
---|
63 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.