source: josm/trunk/src/org/openstreetmap/josm/gui/mappaint/LinePatternElemStyle.java@ 5399

Last change on this file since 5399 was 5217, checked in by bastiK, 12 years ago

mapcss: change z-index handling

In contrast to previous default z-index of 1000 for nodes and -1000 for areas, the default z-index is
now always 0. An additional "major-z-index" is used to sort elemstyles by category, this property
can be adjusted in the style, so icons can be rendered below lines, if you want to.

  • Property svn:eol-style set to native
File size: 1.9 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.mappaint;
3
4import org.openstreetmap.josm.data.osm.OsmPrimitive;
5import org.openstreetmap.josm.data.osm.Way;
6import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings;
7import org.openstreetmap.josm.data.osm.visitor.paint.MapPainter;
8import org.openstreetmap.josm.gui.mappaint.MapPaintStyles.IconReference;
9
10/**
11 * similar to mapnik's LinePatternSymbolizer
12 */
13public class LinePatternElemStyle extends ElemStyle {
14
15 public MapImage pattern;
16
17 public LinePatternElemStyle(Cascade c, MapImage pattern) {
18 super(c, 2.9f);
19 this.pattern = pattern;
20 }
21
22 public static LinePatternElemStyle create(Environment env) {
23 Cascade c = env.mc.getCascade(env.layer);
24
25 IconReference iconRef = c.get("pattern-image", null, IconReference.class);
26 if (iconRef == null)
27 return null;
28 MapImage pattern = new MapImage(iconRef.iconName, iconRef.source);
29 return new LinePatternElemStyle(c, pattern);
30 }
31
32 @Override
33 public void paintPrimitive(OsmPrimitive primitive, MapPaintSettings paintSettings, MapPainter painter, boolean selected, boolean member) {
34 Way w = (Way)primitive;
35 painter.drawLinePattern(w, pattern.getImage());
36 }
37
38 @Override
39 public boolean isProperLineStyle() {
40 return true;
41 }
42
43 @Override
44 public boolean equals(Object obj) {
45 if (obj == null || getClass() != obj.getClass())
46 return false;
47 if (!super.equals(obj))
48 return false;
49 final LinePatternElemStyle other = (LinePatternElemStyle) obj;
50 return pattern.equals(other.pattern);
51 }
52
53 @Override
54 public int hashCode() {
55 return pattern.hashCode();
56 }
57
58 @Override
59 public String toString() {
60 return "LinePatternElemStyle{" + super.toString() + "pattern=[" + pattern + "]}";
61 }
62}
Note: See TracBrowser for help on using the repository browser.