Changeset 885 in josm for trunk/src/org/openstreetmap/josm/gui/mappaint/LineElemStyle.java
- Timestamp:
- 2008-08-28T22:07:04+02:00 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/LineElemStyle.java
r627 r885 1 1 package org.openstreetmap.josm.gui.mappaint; 2 2 3 import java.awt.Color; 4 import java.util.LinkedList; 5 import java.util.List; 3 6 4 public class LineElemStyle extends ElemStyle 7 public class LineElemStyle extends ElemStyle implements Comparable<LineElemStyle> 5 8 { 6 9 public int width; 7 public int realWidth = 0; //the real width of this line in meter8 public Color colo ur;9 public boolean dashed = false;10 public int realWidth; //the real width of this line in meter 11 public Color color; 12 public boolean dashed; 10 13 11 public LineElemStyle (int width, int realWidth, Color colour, boolean dashed, long maxScale, long minScale) { 12 this.width = width; 13 this.realWidth = realWidth; 14 this.colour = colour; 15 this.dashed = dashed; 14 public boolean over; 15 public enum WidthMode { ABSOLUTE, PERCENT, OFFSET }; 16 public WidthMode widthMode; 17 18 public List<LineElemStyle> overlays; 19 20 public LineElemStyle(LineElemStyle s, long maxScale, long minScale) { 21 this.width = s.width; 22 this.realWidth = s.realWidth; 23 this.color = s.color; 24 this.dashed = s.dashed; 25 this.over = s.over; 26 this.widthMode = s.widthMode; 27 28 this.priority = s.priority; 16 29 this.maxScale = maxScale; 17 30 this.minScale = minScale; 18 31 } 19 32 20 @Override public String toString() { 21 return "LineElemStyle: width= " + width + "realWidth= " + realWidth + " colour=" + colour + " dashed=" + dashed; 33 public LineElemStyle(LineElemStyle s, List<LineElemStyle> overlays) { 34 this.width = s.width; 35 this.realWidth = s.realWidth; 36 this.color = s.color; 37 this.dashed = s.dashed; 38 this.over = s.over; 39 this.widthMode = s.widthMode; 40 41 this.priority = s.priority; 42 this.maxScale = s.maxScale; 43 this.minScale = s.minScale; 44 45 this.overlays = overlays; 46 } 47 48 public LineElemStyle() { init(); } 49 50 public void init() 51 { 52 width = 1; 53 realWidth = 0; 54 dashed = false; 55 priority = 0; 56 color = null; 57 over = true; // only used for line modifications 58 widthMode = WidthMode.ABSOLUTE; 59 overlays = null; 60 }; 61 62 // get width for overlays 63 public int getWidth(int ref) 64 { 65 int res; 66 if(widthMode == WidthMode.ABSOLUTE) 67 res = width; 68 else if(widthMode == WidthMode.OFFSET) 69 res = ref + width; 70 else 71 { 72 if(width < 0) 73 res = 0; 74 else 75 res = ref*width/100; 76 } 77 return res <= 0 ? 1 : res; 78 } 79 80 public int compareTo(LineElemStyle s) 81 { 82 if(s.priority != priority) 83 return s.priority > priority ? 1 : -1; 84 if(!over && s.over) 85 return -1; 86 // we have no idea how to order other objects :-) 87 return 0; 22 88 } 23 89 }
Note:
See TracChangeset
for help on using the changeset viewer.
