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

Last change on this file since 3836 was 3836, checked in by bastiK, 13 years ago

mappaint restructuring aimed at mapcss support:

  • area- and line style of multipolygon outer & inner ways are no longer determined by MapPaintVisitor, but the information is calculated in advance and cached
  • cache is aware of zoom level
  • z_index property to allow more fancy styles in future

Performance: when the style cache is filled, painting is the same or ~5% faster. The first painting, which includes style generation, takes ~30% longer than before. (There is potential for optimization, though.) Memory usage unchanged.

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