1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.mappaint.styleelement;
|
---|
3 |
|
---|
4 | import java.util.Objects;
|
---|
5 |
|
---|
6 | import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
---|
7 | import org.openstreetmap.josm.data.osm.Way;
|
---|
8 | import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings;
|
---|
9 | import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors;
|
---|
10 | import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer;
|
---|
11 | import org.openstreetmap.josm.gui.mappaint.Cascade;
|
---|
12 | import org.openstreetmap.josm.gui.mappaint.Environment;
|
---|
13 | import org.openstreetmap.josm.gui.mappaint.Keyword;
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * A text that is only on the line
|
---|
17 | * @deprecated since 11722. To be removed summer 2017
|
---|
18 | */
|
---|
19 | @Deprecated
|
---|
20 | public class LineTextElement extends StyleElement {
|
---|
21 |
|
---|
22 | private final TextLabel text;
|
---|
23 |
|
---|
24 | protected LineTextElement(Cascade c, TextLabel text) {
|
---|
25 | super(c, 4.9f);
|
---|
26 | this.text = text;
|
---|
27 | }
|
---|
28 |
|
---|
29 | public static LineTextElement create(final Environment env) {
|
---|
30 | final Cascade c = env.mc.getCascade(env.layer);
|
---|
31 |
|
---|
32 | Keyword textPos = c.get(TEXT_POSITION, null, Keyword.class);
|
---|
33 | if (textPos != null && !"line".equals(textPos.val))
|
---|
34 | return null;
|
---|
35 |
|
---|
36 | TextLabel text = TextLabel.create(env, PaintColors.TEXT.get(), false);
|
---|
37 | if (text == null)
|
---|
38 | return null;
|
---|
39 | return new LineTextElement(c, text);
|
---|
40 | }
|
---|
41 |
|
---|
42 | @Override
|
---|
43 | public void paintPrimitive(OsmPrimitive primitive, MapPaintSettings paintSettings, StyledMapRenderer painter,
|
---|
44 | boolean selected, boolean outermember, boolean member) {
|
---|
45 | Way w = (Way) primitive;
|
---|
46 | painter.drawTextOnPath(w, text);
|
---|
47 | }
|
---|
48 |
|
---|
49 | @Override
|
---|
50 | public boolean equals(Object obj) {
|
---|
51 | if (this == obj) return true;
|
---|
52 | if (obj == null || getClass() != obj.getClass()) return false;
|
---|
53 | if (!super.equals(obj)) return false;
|
---|
54 | LineTextElement that = (LineTextElement) obj;
|
---|
55 | return Objects.equals(text, that.text);
|
---|
56 | }
|
---|
57 |
|
---|
58 | @Override
|
---|
59 | public int hashCode() {
|
---|
60 | return Objects.hash(super.hashCode(), text);
|
---|
61 | }
|
---|
62 |
|
---|
63 | @Override
|
---|
64 | public String toString() {
|
---|
65 | return "LineTextElemStyle{" + super.toString() + "text=" + text + '}';
|
---|
66 | }
|
---|
67 | }
|
---|