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

Last change on this file since 6419 was 5801, checked in by bastiK, 11 years ago

mapcss: new map element 'repeat-image' similar to 'pattern-image', but more flexible

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