1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.mappaint.xml;
|
---|
3 |
|
---|
4 | import java.awt.Color;
|
---|
5 |
|
---|
6 | import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings;
|
---|
7 | import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors;
|
---|
8 | import org.openstreetmap.josm.gui.mappaint.Range;
|
---|
9 | import org.openstreetmap.josm.tools.I18n;
|
---|
10 |
|
---|
11 | public class LinePrototype extends Prototype {
|
---|
12 |
|
---|
13 | protected int width;
|
---|
14 | public Integer realWidth; // the real width of this line in meter
|
---|
15 | public Color color;
|
---|
16 | protected float[] dashed;
|
---|
17 | public Color dashedColor;
|
---|
18 |
|
---|
19 | public LinePrototype(LinePrototype s, Range range) {
|
---|
20 | super(range);
|
---|
21 | this.width = s.width;
|
---|
22 | this.realWidth = s.realWidth;
|
---|
23 | this.color = s.color;
|
---|
24 | this.dashed = s.dashed;
|
---|
25 | this.dashedColor = s.dashedColor;
|
---|
26 | this.priority = s.priority;
|
---|
27 | this.conditions = s.conditions;
|
---|
28 | }
|
---|
29 |
|
---|
30 | public LinePrototype() { init(); }
|
---|
31 |
|
---|
32 | public void init()
|
---|
33 | {
|
---|
34 | priority = 0;
|
---|
35 | range = new Range();
|
---|
36 | width = -1;
|
---|
37 | realWidth = null;
|
---|
38 | dashed = null;
|
---|
39 | dashedColor = null;
|
---|
40 | color = PaintColors.UNTAGGED.get();
|
---|
41 | }
|
---|
42 |
|
---|
43 | public float[] getDashed() {
|
---|
44 | return dashed;
|
---|
45 | }
|
---|
46 |
|
---|
47 | public void setDashed(float[] dashed) {
|
---|
48 | if (dashed == null || dashed.length == 0) {
|
---|
49 | this.dashed = dashed;
|
---|
50 | return;
|
---|
51 | }
|
---|
52 |
|
---|
53 | boolean found = false;
|
---|
54 | for (int i=0; i<dashed.length; i++) {
|
---|
55 | if (dashed[i] > 0) {
|
---|
56 | found = true;
|
---|
57 | }
|
---|
58 | if (dashed[i] < 0) {
|
---|
59 | System.out.println(I18n.tr("Illegal dash pattern, values must be positive"));
|
---|
60 | }
|
---|
61 | }
|
---|
62 | if (found) {
|
---|
63 | this.dashed = dashed;
|
---|
64 | } else {
|
---|
65 | System.out.println(I18n.tr("Illegal dash pattern, at least one value must be > 0"));
|
---|
66 | }
|
---|
67 | }
|
---|
68 |
|
---|
69 | public int getWidth() {
|
---|
70 | if (width == -1)
|
---|
71 | return MapPaintSettings.INSTANCE.getDefaultSegmentWidth();
|
---|
72 | return width;
|
---|
73 | }
|
---|
74 |
|
---|
75 | public void setWidth(int width) {
|
---|
76 | this.width = width;
|
---|
77 | }
|
---|
78 | }
|
---|