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

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

checkstyle: enable relevant whitespace checks and fix them

  • 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
21 public static LineTextElemStyle create(final Environment env) {
22 final Cascade c = env.mc.getCascade(env.layer);
23
24 Keyword textPos = c.get(TEXT_POSITION, null, Keyword.class);
25 if (textPos != null && !"line".equals(textPos.val))
26 return null;
27
28 TextElement text = TextElement.create(env, PaintColors.TEXT.get(), false);
29 if (text == null)
30 return null;
31 return new LineTextElemStyle(c, text);
32 }
33
34 @Override
35 public void paintPrimitive(OsmPrimitive primitive, MapPaintSettings paintSettings, StyledMapRenderer painter,
36 boolean selected, boolean outermember, boolean member) {
37 Way w = (Way) primitive;
38 painter.drawTextOnPath(w, text);
39 }
40
41 @Override
42 public boolean equals(Object obj) {
43 if (obj == null || getClass() != obj.getClass())
44 return false;
45 if (!super.equals(obj))
46 return false;
47 final LineTextElemStyle other = (LineTextElemStyle) obj;
48 return Objects.equals(text, other.text);
49 }
50
51 @Override
52 public int hashCode() {
53 return text.hashCode();
54 }
55
56 @Override
57 public String toString() {
58 return "LineTextElemStyle{" + super.toString() + "text=" + text + "}";
59 }
60}
Note: See TracBrowser for help on using the repository browser.