Changeset 885 in josm for trunk/src/org/openstreetmap/josm/data
- Timestamp:
- 2008-08-28T22:07:04+02:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java
r880 r885 48 48 49 49 protected boolean isZoomOk(ElemStyle e) { 50 if (!zoomLevelDisplay) /* show everything if the user wishes so */ 51 return true; 52 50 53 double circum = Main.map.mapView.getScale()*100*Main.proj.scaleFactor()*40041455; // circumference of the earth in meter 51 54 52 /* show everything if the user wishes so */ 53 if (!zoomLevelDisplay) { 54 return true; 55 } 56 57 if (e == null) { 58 /* the default for things that don't have a rule (show, if scale is smaller than 1500m) */ 59 if (circum < 1500) 60 return true; 61 return false; 62 } 55 if(e == null) /* the default for things that don't have a rule (show, if scale is smaller than 1500m) */ 56 return (circum < 1500); 63 57 64 58 // formula to calculate a map scale: natural size / map size = scale … … 67 61 // so the exact "correcting value" below depends only on the screen size and resolution 68 62 // XXX - do we need a Preference setting for this (if things vary widely)? 69 /*System.out.println( 70 "Circum: " + circum + 71 " max: " + e.getMaxScale() + "(" + e.getMaxScale()/22 + ")" + 72 " min:" + e.getMinScale() + "(" + e.getMinScale()/22 + ")");*/ 73 if(circum>=e.getMaxScale() / 22 || circum<e.getMinScale() / 22) 74 return false; 75 return true; 63 return !(circum >= e.maxScale / 22 || circum < e.minScale / 22); 76 64 } 77 65 … … 83 71 */ 84 72 public void visit(Node n) { 85 ElemStyle nodeStyle = MapPaintStyles.getStyle(n); 86 if (nodeStyle!=null) { 87 if (nodeStyle instanceof IconElemStyle) { 88 if (isZoomOk(nodeStyle)) { 89 drawNode(n, ((IconElemStyle)nodeStyle).getIcon(), ((IconElemStyle)nodeStyle).doAnnotate()); 90 } 91 } else { 92 // throw some sort of exception 93 } 94 } else { 73 IconElemStyle nodeStyle = MapPaintStyles.getStyles().get(n); 74 if (nodeStyle != null && isZoomOk(nodeStyle)) 75 drawNode(n, nodeStyle.icon, nodeStyle.annotate); 76 else { 95 77 if (n.selected) 96 78 drawNode(n, selectedColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode); … … 113 95 && (!showRelevantDirectionsOnly || w.hasDirectionKeys))); 114 96 115 Color colo ur = untaggedColor;116 Color areacolo ur = untaggedColor;97 Color color = untaggedColor; 98 Color areacolor = untaggedColor; 117 99 int width = defaultSegmentWidth; 118 100 int realWidth = 0; //the real width of the element in meters 119 101 boolean dashed = false; 120 102 boolean area = false; 121 ElemStyle wayStyle = MapPaintStyles.getStyle (w);122 123 if(!isZoomOk(wayStyle)) {103 ElemStyle wayStyle = MapPaintStyles.getStyles().get(w); 104 105 if(!isZoomOk(wayStyle)) 124 106 return; 125 } 126 107 108 LineElemStyle l = null; 127 109 if(wayStyle!=null) 128 110 { 129 LineElemStyle l = null;130 111 if(wayStyle instanceof LineElemStyle) 131 {132 112 l = (LineElemStyle)wayStyle; 133 }134 113 else if (wayStyle instanceof AreaElemStyle) 135 114 { 136 areacolo ur = ((AreaElemStyle)wayStyle).colour;137 colo ur = areacolour;115 areacolor = ((AreaElemStyle)wayStyle).color; 116 color = areacolor; 138 117 l = ((AreaElemStyle)wayStyle).line; 139 118 area = true; … … 141 120 if(l != null) 142 121 { 143 colo ur = l.colour;122 color = l.color; 144 123 width = l.width; 145 124 realWidth = l.realWidth; … … 149 128 150 129 if (area && fillAreas) 151 drawWayAsArea(w, areacolour); 152 int orderNumber = 0; 153 154 Node lastN = null; 155 for (Node n : w.nodes) { 156 if (lastN == null) { 130 drawWayAsArea(w, areacolor); 131 if (realWidth > 0 && useRealWidth && !showDirection) 132 { 133 int tmpWidth = (int) (100 / (float) (circum / realWidth)); 134 if (tmpWidth > width) width = tmpWidth; 135 } 136 137 Node lastN; 138 if(l != null && l.overlays != null) 139 { 140 for(LineElemStyle s : l.overlays) 141 { 142 if(!s.over) 143 { 144 lastN = null; 145 for(Node n : w.nodes) 146 { 147 if(lastN != null) 148 drawSeg(lastN, n, s.color != null ? s.color : color, false, s.getWidth(width), s.dashed); 149 lastN = n; 150 } 151 } 152 } 153 } 154 155 lastN = null; 156 for(Node n : w.nodes) 157 { 158 if(lastN != null) 159 drawSeg(lastN, n, w.selected ? selectedColor : color, showDirection, width, dashed); 160 lastN = n; 161 } 162 163 if(l != null && l.overlays != null) 164 { 165 for(LineElemStyle s : l.overlays) 166 { 167 if(s.over) 168 { 169 lastN = null; 170 for(Node n : w.nodes) 171 { 172 if(lastN != null) 173 drawSeg(lastN, n, s.color != null ? s.color : color, false, s.getWidth(width), s.dashed); 174 lastN = n; 175 } 176 } 177 } 178 } 179 180 if(showOrderNumber) 181 { 182 int orderNumber = 0; 183 lastN = null; 184 for(Node n : w.nodes) 185 { 186 if(lastN != null) 187 { 188 orderNumber++; 189 drawOrderNumber(lastN, n, orderNumber); 190 } 157 191 lastN = n; 158 continue; 159 } 160 orderNumber++; 161 162 if (realWidth > 0 && useRealWidth && !showDirection) 163 { 164 int tmpWidth = (int) (100 / (float) (circum / realWidth)); 165 if (tmpWidth > width) width = tmpWidth; 166 } 167 drawSeg(lastN, n, w.selected ? selectedColor : colour, showDirection, width, dashed); 168 169 if (showOrderNumber) 170 drawOrderNumber(lastN, n, orderNumber); 171 172 lastN = n; 192 } 173 193 } 174 194 } … … 179 199 180 200 // This assumes that all segments are aligned in the same direction! 181 protected void drawWayAsArea(Way w, Color colo ur)201 protected void drawWayAsArea(Way w, Color color) 182 202 { 183 203 Polygon polygon = new Polygon(); … … 189 209 } 190 210 191 Color mycolor = w.selected ? selectedColor : colo ur;211 Color mycolor = w.selected ? selectedColor : color; 192 212 // set the opacity (alpha) level of the filled polygon 193 213 g.setColor(new Color( mycolor.getRed(), mycolor.getGreen(), mycolor.getBlue(), fillAlpha)); … … 299 319 300 320 for (final OsmPrimitive osm : data.ways) 301 if (!osm.incomplete && !osm.deleted && MapPaintStyles. isArea(osm))321 if (!osm.incomplete && !osm.deleted && MapPaintStyles.getStyles().isArea((Way)osm)) 302 322 osm.visit(this); 303 323 else if (!osm.deleted && !osm.incomplete)
Note:
See TracChangeset
for help on using the changeset viewer.