source: josm/trunk/src/org/openstreetmap/josm/gui/mappaint/LineTextElemStyle.java@ 8256

Last change on this file since 8256 was 7621, checked in by Don-vip, 10 years ago

fix #10615 - Inner ways of multipolygon not correctly displayed (regression from r7555)

  • 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 java.util.Objects;
5
6import org.openstreetmap.josm.data.osm.OsmPrimitive;
7import org.openstreetmap.josm.data.osm.Way;
8import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings;
9import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors;
10import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer;
11
12public class LineTextElemStyle extends ElemStyle {
13
14 private TextElement text;
15
16 protected LineTextElemStyle(Cascade c, TextElement text) {
17 super(c, 4.9f);
18 this.text = text;
19 }
20 public static LineTextElemStyle create(final Environment env) {
21 final Cascade c = env.mc.getCascade(env.layer);
22
23 Keyword textPos = c.get(TEXT_POSITION, null, Keyword.class);
24 if (textPos != null && !"line".equals(textPos.val))
25 return null;
26
27 TextElement text = TextElement.create(env, PaintColors.TEXT.get(), false);
28 if (text == null)
29 return null;
30 return new LineTextElemStyle(c, text);
31 }
32
33 @Override
34 public void paintPrimitive(OsmPrimitive primitive, MapPaintSettings paintSettings, StyledMapRenderer painter,
35 boolean selected, boolean outermember, boolean member) {
36 Way w = (Way)primitive;
37 painter.drawTextOnPath(w, text);
38 }
39
40 @Override
41 public boolean equals(Object obj) {
42 if (obj == null || getClass() != obj.getClass())
43 return false;
44 if (!super.equals(obj))
45 return false;
46 final LineTextElemStyle other = (LineTextElemStyle) obj;
47 return Objects.equals(text, other.text);
48 }
49
50 @Override
51 public int hashCode() {
52 return text.hashCode();
53 }
54
55 @Override
56 public String toString() {
57 return "LineTextElemStyle{" + super.toString() + "text=" + text + "}";
58 }
59}
Note: See TracBrowser for help on using the repository browser.