source: josm/trunk/src/org/openstreetmap/josm/gui/mappaint/xml/LinePrototype.java@ 8513

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

checkstyle: blocks

  • Property svn:eol-style set to native
File size: 2.3 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.mappaint.xml;
3
4import java.awt.Color;
5import java.util.List;
6
7import org.openstreetmap.josm.Main;
8import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings;
9import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors;
10import org.openstreetmap.josm.gui.mappaint.Range;
11import org.openstreetmap.josm.tools.I18n;
12
13public 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}
Note: See TracBrowser for help on using the repository browser.