1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.mappaint.xml;
|
---|
3 |
|
---|
4 | import java.awt.Color;
|
---|
5 | import java.util.List;
|
---|
6 |
|
---|
7 | import org.openstreetmap.josm.Main;
|
---|
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.gui.mappaint.Range;
|
---|
11 | import org.openstreetmap.josm.tools.I18n;
|
---|
12 |
|
---|
13 | public class LinePrototype extends Prototype {
|
---|
14 |
|
---|
15 | protected int width;
|
---|
16 | public Integer realWidth; // the real width of this line in meter
|
---|
17 | public Color color;
|
---|
18 | protected List<Float> dashed;
|
---|
19 | public Color dashedColor;
|
---|
20 |
|
---|
21 | public LinePrototype(LinePrototype s, Range range) {
|
---|
22 | super(range);
|
---|
23 | this.width = s.width;
|
---|
24 | this.realWidth = s.realWidth;
|
---|
25 | this.color = s.color;
|
---|
26 | this.dashed = s.dashed;
|
---|
27 | this.dashedColor = s.dashedColor;
|
---|
28 | this.priority = s.priority;
|
---|
29 | this.conditions = s.conditions;
|
---|
30 | }
|
---|
31 |
|
---|
32 | /**
|
---|
33 | * Constructs a new {@code LinePrototype}.
|
---|
34 | */
|
---|
35 | public LinePrototype() {
|
---|
36 | init();
|
---|
37 | }
|
---|
38 |
|
---|
39 | public void init() {
|
---|
40 | priority = 0;
|
---|
41 | range = Range.ZERO_TO_INFINITY;
|
---|
42 | width = -1;
|
---|
43 | realWidth = null;
|
---|
44 | dashed = null;
|
---|
45 | dashedColor = null;
|
---|
46 | color = PaintColors.UNTAGGED.get();
|
---|
47 | }
|
---|
48 |
|
---|
49 | public List<Float> getDashed() {
|
---|
50 | return dashed;
|
---|
51 | }
|
---|
52 |
|
---|
53 | public void setDashed(List<Float> dashed) {
|
---|
54 | if (dashed == null || dashed.isEmpty()) {
|
---|
55 | this.dashed = null;
|
---|
56 | return;
|
---|
57 | }
|
---|
58 |
|
---|
59 | boolean found = false;
|
---|
60 | for (Float f : dashed) {
|
---|
61 | if (f == null) {
|
---|
62 | this.dashed = null;
|
---|
63 | return;
|
---|
64 | }
|
---|
65 | if (f > 0) {
|
---|
66 | found = true;
|
---|
67 | }
|
---|
68 | if (f < 0) {
|
---|
69 | Main.error(I18n.tr("Illegal dash pattern, values must be positive"));
|
---|
70 | this.dashed = null;
|
---|
71 | return;
|
---|
72 | }
|
---|
73 | }
|
---|
74 | if (found) {
|
---|
75 | this.dashed = dashed;
|
---|
76 | } else {
|
---|
77 | Main.error(I18n.tr("Illegal dash pattern, at least one value must be > 0"));
|
---|
78 | }
|
---|
79 | }
|
---|
80 |
|
---|
81 | public int getWidth() {
|
---|
82 | if (width == -1)
|
---|
83 | return MapPaintSettings.INSTANCE.getDefaultSegmentWidth();
|
---|
84 | return width;
|
---|
85 | }
|
---|
86 |
|
---|
87 | public void setWidth(int width) {
|
---|
88 | this.width = width;
|
---|
89 | }
|
---|
90 | }
|
---|