Changeset 4847 in osm
- Timestamp:
- 2007-10-07T13:57:09+02:00 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mappaint/src/mappaint/MapPaintVisitor.java
r4423 r4847 17 17 import org.openstreetmap.josm.Main; 18 18 import org.openstreetmap.josm.data.osm.Node; 19 import org.openstreetmap.josm.data.osm.Segment;20 19 import org.openstreetmap.josm.data.osm.Way; 21 20 import org.openstreetmap.josm.data.osm.DataSet; … … 56 55 } 57 56 58 // formula rto calculate a map scale: natural size / map size = scale57 // formula to calculate a map scale: natural size / map size = scale 59 58 // example: 876000mm (876m as displayed) / 22mm (roughly estimated screen size of legend bar) = 39818 60 59 // … … 95 94 96 95 /** 97 * Draw just a line between the points.98 * White if selected (as always) or grey otherwise.99 * Want to make un-wayed segments stand out less than ways.100 */101 @Override public void visit(Segment ls) {102 ElemStyle segmentStyle = MapPaintPlugin.elemStyles.getStyle(ls);103 if(isZoomOk(segmentStyle)) {104 drawSegment(ls, untaggedColor, showDirectionArrow);105 }106 }107 108 /**109 96 * Draw a line for all segments, according to tags. 110 97 * @param w The way to draw. … … 145 132 drawWayAsArea(w, colour); 146 133 int orderNumber = 0; 147 for (Segment ls : w.segments) 148 { 134 135 Node lastN = null; 136 for (Node n : w.nodes) { 137 if (lastN == null) { 138 lastN = n; 139 continue; 140 } 149 141 orderNumber++; 150 if (area && fillAreas) 151 //Draw segments in a different colour so direction arrows show against the fill 152 drawSegment(ls, w.selected ? selectedColor : untaggedColor, showDirection, width,true); 142 // drawSegment(lastN, n, w.selected && !inactive ? selectedColor : wayColor, showDirectionArrow); 143 144 if (area && fillAreas) 145 //Draw segments in a different colour so direction arrows show against the fill 146 drawSeg(lastN, n, w.selected ? selectedColor : untaggedColor, showDirection, width, true); 147 else 148 if (area) 149 drawSeg(lastN, n, w.selected ? selectedColor : colour, showDirection, width, true); 153 150 else 154 if (area) 155 drawSegment(ls, w.selected ? selectedColor : colour, showDirection, width,true); 156 else 157 if (realWidth > 0 && useRealWidth && !showDirection){ 158 int tmpWidth = (int) (100 / (float) (circum / realWidth)); 159 if (tmpWidth > width) width = tmpWidth; 160 } 161 162 drawSegment(ls, w.selected ? selectedColor : colour,showDirection, width,dashed); 163 if (!ls.incomplete && showOrderNumber) 164 { 165 try 166 { 167 g.setColor(w.selected ? selectedColor : colour); 168 drawOrderNumber(ls, orderNumber); 151 if (realWidth > 0 && useRealWidth && !showDirection){ 152 int tmpWidth = (int) (100 / (float) (circum / realWidth)); 153 if (tmpWidth > width) width = tmpWidth; 169 154 } 170 catch (IllegalAccessError e) {} //SimplePaintVisitor::drawOrderNumber was private prior to rev #211 171 } 155 156 drawSeg(lastN, n, w.selected ? selectedColor : colour, showDirection, width, dashed); 157 158 if (showOrderNumber) 159 drawOrderNumber(lastN, n, orderNumber); 160 161 lastN = n; 172 162 } 173 163 } … … 178 168 Polygon polygon = new Polygon(); 179 169 Point p; 180 boolean first=true; 181 for (Segment ls : w.segments) 170 for (Node n : w.nodes) 182 171 { 183 if (ls.incomplete) continue; 184 if(first) 185 { 186 p = nc.getPoint(ls.from.eastNorth); 187 polygon.addPoint(p.x,p.y); 188 first=false; 189 } 190 p = nc.getPoint(ls.to.eastNorth); 172 p = nc.getPoint(n.eastNorth); 191 173 polygon.addPoint(p.x,p.y); 192 174 } … … 224 206 */ 225 207 // Altered - now specify width 226 @Override protected void drawSegment(Segment ls, Color col,boolean showDirection) { 227 if (useRealWidth && showDirection && !ls.selected) showDirection = false; 228 drawSegment(ls,col,showDirection,1,false); 229 } 230 231 232 // Altered - now specify width 233 private void drawSegment (Segment ls, Color col,boolean showDirection, int width,boolean dashed) { 234 //do not draw already visible segments 235 if (ls.shown) return; 236 ls.shown=true; 237 if (ls.incomplete) 238 return; 239 if (ls.selected) { 240 col = selectedColor; 241 } 242 drawSeg(ls, col, showDirection, width, dashed); 243 } 244 245 private void drawSeg(Segment ls, Color col,boolean showDirection, int width,boolean dashed) { 208 @Override protected void drawSegment(Node n1, Node n2, Color col, boolean showDirection) { 209 if (useRealWidth && showDirection) showDirection = false; 210 drawSeg(n1, n2, col, showDirection, 1, false); 211 } 212 213 private void drawSeg(Node n1, Node n2, Color col, boolean showDirection, int width, boolean dashed) { 246 214 if (col != currentColor || width != currentWidth || dashed != currentDashed) { 247 215 displaySegments(col, width, dashed); 248 216 } 249 Point p1 = nc.getPoint( ls.from.eastNorth);250 Point p2 = nc.getPoint( ls.to.eastNorth);217 Point p1 = nc.getPoint(n1.eastNorth); 218 Point p2 = nc.getPoint(n2.eastNorth); 251 219 252 220 // checking if this segment is visible … … 265 233 266 234 //g.drawLine(p1.x, p1.y, p2.x, p2.y); 267 curr rentPath.moveTo(p1.x, p1.y);268 curr rentPath.lineTo(p2.x, p2.y);235 currentPath.moveTo(p1.x, p1.y); 236 currentPath.lineTo(p2.x, p2.y); 269 237 270 238 if (showDirection) { … … 272 240 //g.drawLine(p2.x,p2.y, (int)(p2.x + 10*Math.cos(t-PHI)), (int)(p2.y + 10*Math.sin(t-PHI))); 273 241 //g.drawLine(p2.x,p2.y, (int)(p2.x + 10*Math.cos(t+PHI)), (int)(p2.y + 10*Math.sin(t+PHI))); 274 curr rentPath.lineTo((int)(p2.x + 10*Math.cos(t-PHI)), (int)(p2.y + 10*Math.sin(t-PHI)));275 curr rentPath.moveTo((int)(p2.x + 10*Math.cos(t+PHI)), (int)(p2.y + 10*Math.sin(t+PHI)));276 curr rentPath.lineTo(p2.x, p2.y);242 currentPath.lineTo((int)(p2.x + 10*Math.cos(t-PHI)), (int)(p2.y + 10*Math.sin(t-PHI))); 243 currentPath.moveTo((int)(p2.x + 10*Math.cos(t+PHI)), (int)(p2.y + 10*Math.sin(t+PHI))); 244 currentPath.lineTo(p2.x, p2.y); 277 245 } 278 246 //g2d.setStroke(new BasicStroke(1)); … … 286 254 protected void displaySegments(Color newColor, int newWidth, boolean newDash) { 287 255 288 if (curr rentPath != null) {256 if (currentPath != null) { 289 257 Graphics2D g2d = (Graphics2D)g; 290 258 g2d.setColor(currentColor); … … 295 263 g2d.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND)); 296 264 } 297 g2d.draw(curr rentPath);265 g2d.draw(currentPath); 298 266 g2d.setStroke(new BasicStroke(1)); 299 267 300 curr rentPath = new GeneralPath();268 currentPath = new GeneralPath(); 301 269 currentColor = newColor; 302 270 currentWidth = newWidth; … … 327 295 selectedColor = getPreferencesColor("selected", Color.YELLOW); 328 296 nodeColor = getPreferencesColor("node", Color.RED); 329 segmentColor = getPreferencesColor("segment", darkgreen);330 297 dfltWayColor = getPreferencesColor("way", darkblue); 331 298 incompleteColor = getPreferencesColor("incomplete way", darkerblue); … … 341 308 Collection<Way> noAreaWays = new LinkedList<Way>(); 342 309 343 for (final OsmPrimitive osm : data.segments)344 if (!osm.deleted)345 osm.shown=false;346 347 310 for (final OsmPrimitive osm : data.ways) 348 311 if (!osm.deleted && MapPaintPlugin.elemStyles.isArea(osm)) … … 354 317 osm.visit(this); 355 318 356 for (final OsmPrimitive osm : data.segments)357 if (!osm.deleted)358 osm.visit(this);359 319 360 320 for (final OsmPrimitive osm : data.nodes)
Note:
See TracChangeset
for help on using the changeset viewer.