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

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

see #8465 - replace Utils.equal by Objects.equals, new in Java 7

  • Property svn:eol-style set to native
File size: 1.8 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(Environment env) {
21 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(c, 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, boolean selected, boolean member) {
35 Way w = (Way)primitive;
36 painter.drawTextOnPath(w, text);
37 }
38
39 @Override
40 public boolean equals(Object obj) {
41 if (obj == null || getClass() != obj.getClass())
42 return false;
43 if (!super.equals(obj))
44 return false;
45 final LineTextElemStyle other = (LineTextElemStyle) obj;
46 return Objects.equals(text, other.text);
47 }
48
49 @Override
50 public int hashCode() {
51 return text.hashCode();
52 }
53
54 @Override
55 public String toString() {
56 return "LineTextElemStyle{" + super.toString() + "text=" + text + "}";
57 }
58}
Note: See TracBrowser for help on using the repository browser.