|
Last change
on this file since 2889 was 2679, checked in by jttt, 16 years ago |
|
Fixed #4230 NPE when searching for name$:[a-z] in Iceland.osm
|
-
Property svn:eol-style
set to
native
|
|
File size:
1.6 KB
|
| Line | |
|---|
| 1 | package org.openstreetmap.josm.gui.mappaint;
|
|---|
| 2 |
|
|---|
| 3 | import java.util.Collection;
|
|---|
| 4 |
|
|---|
| 5 | import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
|---|
| 6 | import org.openstreetmap.josm.data.osm.OsmUtils;
|
|---|
| 7 | import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings;
|
|---|
| 8 | import org.openstreetmap.josm.data.osm.visitor.paint.MapPainter;
|
|---|
| 9 |
|
|---|
| 10 | abstract public class ElemStyle {
|
|---|
| 11 | // zoom range to display the feature
|
|---|
| 12 | public long minScale;
|
|---|
| 13 | public long maxScale;
|
|---|
| 14 |
|
|---|
| 15 | public int priority;
|
|---|
| 16 | public String code;
|
|---|
| 17 | Collection<Rule> rules = null;
|
|---|
| 18 |
|
|---|
| 19 | @Override
|
|---|
| 20 | public boolean equals(Object o) {
|
|---|
| 21 | return (o instanceof ElemStyle) && (((ElemStyle) o).getCode().equals(getCode()));
|
|---|
| 22 | }
|
|---|
| 23 |
|
|---|
| 24 | @Override
|
|---|
| 25 | public int hashCode() {
|
|---|
| 26 | return getClass().hashCode();
|
|---|
| 27 | }
|
|---|
| 28 |
|
|---|
| 29 | public String getCode() {
|
|---|
| 30 | if(code == null) {
|
|---|
| 31 | code = "";
|
|---|
| 32 | if (rules != null) {
|
|---|
| 33 | for(Rule r: rules) {
|
|---|
| 34 | code += r.toCode();
|
|---|
| 35 | }
|
|---|
| 36 | }
|
|---|
| 37 | }
|
|---|
| 38 | return code;
|
|---|
| 39 | }
|
|---|
| 40 | public boolean check(OsmPrimitive primitive)
|
|---|
| 41 | {
|
|---|
| 42 | if(rules == null)
|
|---|
| 43 | return true;
|
|---|
| 44 | for(Rule r : rules)
|
|---|
| 45 | {
|
|---|
| 46 | String k = primitive.get(r.key);
|
|---|
| 47 | String bv = OsmUtils.getNamedOsmBoolean(r.boolValue);
|
|---|
| 48 | if(k == null || (r.value != null && !k.equals(r.value))
|
|---|
| 49 | || (bv != null && !bv.equals(OsmUtils.getNamedOsmBoolean(k))))
|
|---|
| 50 | return false;
|
|---|
| 51 | }
|
|---|
| 52 | return true;
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|
| 55 | public abstract void paintPrimitive(OsmPrimitive primitive, MapPaintSettings paintSettings, MapPainter painter, boolean selected);
|
|---|
| 56 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.