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

Last change on this file since 6340 was 6248, checked in by Don-vip, 11 years ago

Rework console output:

  • new log level "error"
  • Replace nearly all calls to system.out and system.err to Main.(error|warn|info|debug)
  • Remove some unnecessary debug output
  • Some messages are modified (removal of "Info", "Warning", "Error" from the message itself -> notable i18n impact but limited to console error messages not seen by the majority of users, so that's ok)
  • 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 public LinePrototype() { init(); }
33
34 public void init()
35 {
36 priority = 0;
37 range = new Range();
38 width = -1;
39 realWidth = null;
40 dashed = null;
41 dashedColor = null;
42 color = PaintColors.UNTAGGED.get();
43 }
44
45 public List<Float> getDashed() {
46 return dashed;
47 }
48
49 public void setDashed(List<Float> dashed) {
50 if (dashed == null || dashed.isEmpty()) {
51 this.dashed = null;
52 return;
53 }
54
55 boolean found = false;
56 for (Float f : dashed) {
57 if (f == null) {
58 this.dashed = null;
59 return;
60 }
61 if (f > 0) {
62 found = true;
63 }
64 if (f < 0) {
65 Main.error(I18n.tr("Illegal dash pattern, values must be positive"));
66 this.dashed = null;
67 return;
68 }
69 }
70 if (found) {
71 this.dashed = dashed;
72 } else {
73 Main.error(I18n.tr("Illegal dash pattern, at least one value must be > 0"));
74 }
75 }
76
77 public int getWidth() {
78 if (width == -1)
79 return MapPaintSettings.INSTANCE.getDefaultSegmentWidth();
80 return width;
81 }
82
83 public void setWidth(int width) {
84 this.width = width;
85 }
86}
Note: See TracBrowser for help on using the repository browser.