- Timestamp:
- 2012-08-11T17:09:12+02:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/osm/visitor
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/Visitor.java
r2017 r5421 8 8 9 9 /** 10 * Implementation of the visitor scheme. Every OsmPrimitive can be visited by 11 * several different visitors. 12 * 13 * @author imi 10 * Implementation of the visitor scheme. Every @{link org.openstreetmap.josm.data.OsmPrimitive} 11 * can be visited by several different visitors. 14 12 */ 15 13 public interface Visitor { 14 /** 15 * Visiting call for points. 16 * @param n The node to inspect. 17 */ 16 18 void visit(Node n); 19 /** 20 * Visiting call for lines. 21 * @param w The way to inspect. 22 */ 17 23 void visit(Way w); 24 /** 25 * Visiting call for relations. 26 * @param e The relation to inspect. 27 */ 18 28 void visit(Relation e); 29 /** 30 * Visiting call for changesets. 31 * @param cs The changeset to inspect. 32 */ 19 33 void visit(Changeset cs); 20 34 } -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/MapPaintSettings.java
r4627 r5421 13 13 14 14 private boolean useRealWidth; 15 /** Preference: should directional arrows be displayed */ 15 16 private boolean showDirectionArrow; 17 /** Preference: should arrows for oneways be displayed */ 16 18 private boolean showOnewayArrow; 17 private int defaultSegmentWidth;19 /** Preference: should the segement numbers of ways be displayed */ 18 20 private boolean showOrderNumber; 21 /** Preference: should only the last arrow of a way be displayed */ 19 22 private boolean showHeadArrowOnly; 20 23 private int showNamesDistance; 21 24 private int useStrokesDistance; 22 25 private int showIconsDistance; 26 /** Preference: size of selected nodes */ 23 27 private int selectedNodeSize; 28 /** Preference: size of multiply connected nodes */ 24 29 private int connectionNodeSize; 30 /** Preference: size of unselected nodes */ 25 31 private int unselectedNodeSize; 32 /** Preference: size of tagged nodes */ 26 33 private int taggedNodeSize; 34 /** Preference: should selected nodes be filled */ 27 35 private boolean fillSelectedNode; 36 /** Preference: should unselected nodes be filled */ 28 37 private boolean fillUnselectedNode; 38 /** Preference: should tagged nodes be filled */ 29 39 private boolean fillTaggedNode; 40 /** Preference: should multiply connected nodes be filled */ 30 41 private boolean fillConnectionNode; 31 42 private boolean outlineOnly; 43 /** Color Preference for selected objects */ 32 44 private Color selectedColor; 33 45 private Color relationSelectedColor; 46 /** Color Preference for hightlighted objects */ 34 47 private Color highlightColor; 48 /** Color Preference for inactive objects */ 35 49 private Color inactiveColor; 50 /** Color Preference for nodes */ 36 51 private Color nodeColor; 52 /** Color Preference for tagged nodes */ 37 53 private Color taggedColor; 54 /** Color Preference for multiply connected nodes */ 38 55 private Color connectionColor; 56 /** Color Preference for tagged and multiply connected nodes */ 39 57 private Color taggedConnectionColor; 40 58 … … 48 66 showOnewayArrow = Main.pref.getBoolean("draw.oneway", true); 49 67 useRealWidth = Main.pref.getBoolean("mappaint.useRealWidth", false); 50 defaultSegmentWidth = Main.pref.getInteger("mappaint.segment.default-width", 2);51 68 52 69 selectedColor = PaintColors.SELECTED.get(); … … 100 117 } 101 118 102 public int getDefaultSegmentWidth() {103 return defaultSegmentWidth;104 }105 106 119 public Color getSelectedColor() { 107 120 return selectedColor; -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/PaintColors.java
r4952 r5421 24 24 RELATION(marktr("relation"), new Color(0,128,128)), // teal 25 25 UNTAGGED_WAY(marktr("untagged way"), new Color(0,128,0)), // dark green 26 INCOMPLETE_WAY(marktr("incomplete way"), new Color(0,0,96)), // darker blue27 26 BACKGROUND(marktr("background"), Color.BLACK), 28 27 HIGHLIGHT(marktr("highlight"), SELECTED.get()), -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/WireframeMapRenderer.java
r5351 r5421 32 32 * A map renderer that paints a simple scheme of every primitive it visits to a 33 33 * previous set graphic environment. 34 *35 * @author imi36 34 */ 37 35 public class WireframeMapRenderer extends AbstractMapRenderer implements Visitor { 38 36 39 /** 40 * Preferences 41 */ 37 /** Color Preference for inactive objects */ 42 38 protected Color inactiveColor; 39 /** Color Preference for selected objects */ 43 40 protected Color selectedColor; 41 /** Color Preference for nodes */ 44 42 protected Color nodeColor; 43 /** Color Preference for ways not matching any other group */ 45 44 protected Color dfltWayColor; 45 /** Color Preference for relations */ 46 46 protected Color relationColor; 47 /** Color Preference for untagged ways */ 47 48 protected Color untaggedWayColor; 48 protected Color incompleteColor;49 /** Color Preference for background */ 49 50 protected Color backgroundColor; 51 /** Color Preference for hightlighted objects */ 50 52 protected Color highlightColor; 53 /** Color Preference for tagged nodes */ 51 54 protected Color taggedColor; 55 /** Color Preference for multiply connected nodes */ 52 56 protected Color connectionColor; 57 /** Color Preference for tagged and multiply connected nodes */ 53 58 protected Color taggedConnectionColor; 59 /** Preference: should directional arrows be displayed */ 54 60 protected boolean showDirectionArrow; 61 /** Preference: should arrows for oneways be displayed */ 55 62 protected boolean showOnewayArrow; 63 /** Preference: should only the last arrow of a way be displayed */ 56 64 protected boolean showHeadArrowOnly; 65 /** Preference: should the segement numbers of ways be displayed */ 57 66 protected boolean showOrderNumber; 67 /** Preference: should selected nodes be filled */ 58 68 protected boolean fillSelectedNode; 69 /** Preference: should unselected nodes be filled */ 59 70 protected boolean fillUnselectedNode; 71 /** Preference: should tagged nodes be filled */ 60 72 protected boolean fillTaggedNode; 73 /** Preference: should multiply connected nodes be filled */ 61 74 protected boolean fillConnectionNode; 75 /** Preference: size of selected nodes */ 62 76 protected int selectedNodeSize; 77 /** Preference: size of unselected nodes */ 63 78 protected int unselectedNodeSize; 79 /** Preference: size of multiply connected nodes */ 64 80 protected int connectionNodeSize; 81 /** Preference: size of tagged nodes */ 65 82 protected int taggedNodeSize; 66 protected int defaultSegmentWidth;83 /** Preference: size of virtual nodes (0 displayes display) */ 67 84 protected int virtualNodeSize; 85 /** Preference: minimum space (displayed way length) to display virtual nodes */ 68 86 protected int virtualNodeSpace; 87 /** Preference: minimum space (displayed way length) to display segment numbers */ 69 88 protected int segmentNumberSpace; 70 89 71 /** 72 * Draw subsequent segments of same color as one Path 73 */ 90 /** Color cache to draw subsequent segments of same color as one <code>Path</code>. */ 74 91 protected Color currentColor = null; 92 /** Path store to draw subsequent segments of same color as one <code>Path</code>. */ 75 93 protected GeneralPath currentPath = new GeneralPath(); 76 77 /** 78 * {@inheritDoc} 94 /** 95 * <code>DataSet</code> passed to the @{link render} function to overcome the argument 96 * limitations of @{link Visitor} interface. Only valid until end of rendering call. 97 */ 98 private DataSet ds; 99 100 /** Helper variable for {@link #drawSgement} */ 101 private static final double PHI = Math.toRadians(20); 102 /** Helper variable for {@link #drawSgement} */ 103 private static final double cosPHI = Math.cos(PHI); 104 /** Helper variable for {@link #drawSgement} */ 105 private static final double sinPHI = Math.sin(PHI); 106 107 /** Helper variable for {@link #visit(Relation) */ 108 private Stroke relatedWayStroke = new BasicStroke( 109 4, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL); 110 111 /** 112 * Creates an wireframe render 113 * 114 * @param g the graphics context. Must not be null. 115 * @param nc the map viewport. Must not be null. 116 * @param isInactiveMode if true, the paint visitor shall render OSM objects such that they 117 * look inactive. Example: rendering of data in an inactive layer using light gray as color only. 118 * @throws IllegalArgumentException thrown if {@code g} is null 119 * @throws IllegalArgumentException thrown if {@code nc} is null 79 120 */ 80 121 public WireframeMapRenderer(Graphics2D g, NavigatableComponent nc, boolean isInactiveMode) { … … 82 123 } 83 124 125 /** 126 * Reads the color definitions from preferences. This function is <code>public</code>, so that 127 * color names in preferences can be displayed even without calling the wireframe display before. 128 */ 84 129 public void getColors() 85 130 { … … 90 135 relationColor = PaintColors.RELATION.get(); 91 136 untaggedWayColor = PaintColors.UNTAGGED_WAY.get(); 92 incompleteColor = PaintColors.INCOMPLETE_WAY.get();93 137 backgroundColor = PaintColors.BACKGROUND.get(); 94 138 highlightColor = PaintColors.HIGHLIGHT_WIREFRAME.get(); … … 103 147 } 104 148 149 /** 150 * Reads all the settings from preferences. Calls the @{link #getColors} 151 * function. 152 * 153 * @param virtual <code>true</code> if virtual nodes are used 154 */ 105 155 protected void getSettings(boolean virtual) { 106 156 MapPaintSettings settings = MapPaintSettings.INSTANCE; … … 113 163 connectionNodeSize = settings.getConnectionNodeSize(); 114 164 taggedNodeSize = settings.getTaggedNodeSize(); 115 defaultSegmentWidth = settings.getDefaultSegmentWidth();116 165 fillSelectedNode = settings.isFillSelectedNode(); 117 166 fillUnselectedNode = settings.isFillUnselectedNode(); … … 128 177 } 129 178 130 DataSet ds; 179 /** 180 * Renders the dataset for display. 181 * 182 * @param data <code>DataSet</code> to display 183 * @param virtual <code>true</code> if virtual nodes are used 184 * @param bounds display boundaries 185 */ 131 186 public void render(DataSet data, boolean virtual, Bounds bounds) { 132 187 BBox bbox = new BBox(bounds); … … 181 236 } 182 237 238 /** 239 * Helper function to calculate maximum of 4 values. 240 * 241 * @param a First value 242 * @param b Second value 243 * @param c Third value 244 * @param d Fourth value 245 */ 183 246 private static final int max(int a, int b, int c, int d) { 184 247 return Math.max(Math.max(a, b), Math.max(c, d)); … … 191 254 * @param n The node to draw. 192 255 */ 256 @Override 193 257 public void visit(Node n) { 194 258 if (n.isIncomplete()) return; … … 231 295 } 232 296 297 /** 298 * Checks if a way segemnt is large enough for additional information display. 299 * 300 * @param p1 First point of the way segment. 301 * @param p2 Second point of the way segment. 302 * @param space The free space to check against. 303 * @return <code>true</code> if segment is larger than required space 304 */ 233 305 public static boolean isLargeSegment(Point2D p1, Point2D p2, int space) 234 306 { … … 238 310 } 239 311 312 /** 313 * Draws virtual nodes. 314 * 315 * @param ways The ways to draw nodes for. 316 * @param highlightVirtualNodes Way segements, where nodesshould be highlighted. 317 */ 240 318 public void drawVirtualNodes(Collection<Way> ways, Collection<WaySegment> highlightVirtualNodes) { 241 319 if (virtualNodeSize == 0) … … 263 341 } 264 342 343 /** 344 * Creates path for drawing virtual nodes for one way. 345 * 346 * @param path The path to append drawing to. 347 * @param w The ways to draw node for. 348 */ 265 349 public void visitVirtual(GeneralPath path, Way w) { 266 350 Iterator<Node> it = w.getNodes().iterator(); … … 285 369 286 370 /** 287 * Draw a darkblue line for allsegments.371 * Draw a line for all way segments. 288 372 * @param w The way to draw. 289 373 */ 374 @Override 290 375 public void visit(Way w) { 291 376 if (w.isIncomplete() || w.getNodesCount() < 2) … … 328 413 } 329 414 330 private Stroke relatedWayStroke = new BasicStroke( 331 4, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL); 415 /** 416 * Draw objects used in relations. 417 * @param r The relation to draw. 418 */ 419 @Override 332 420 public void visit(Relation r) { 333 421 if (r.isIncomplete()) return; … … 378 466 } 379 467 468 /** 469 * Visitor for changesets not used in this class 470 * @param cs The changeset for inspection. 471 */ 380 472 @Override 381 473 public void visit(Changeset cs) {/* ignore */} … … 384 476 * Draw an number of the order of the two consecutive nodes within the 385 477 * parents way 478 * 479 * @param p1 First point of the way segment. 480 * @param p2 Second point of the way segment. 481 * @param orderNumber The number of the segment in the way. 386 482 */ 387 483 protected void drawOrderNumber(Point p1, Point p2, int orderNumber) { … … 429 525 } 430 526 431 private static final double PHI = Math.toRadians(20); 432 private static final double cosPHI = Math.cos(PHI); 433 private static final double sinPHI = Math.sin(PHI); 434 527 /** 528 * Draw a line with the given color. 529 * 530 * @param path The path to append this segment. 531 * @param p1 First point of the way segment. 532 * @param p2 Second point of the way segment. 533 * @param showDirection <code>true</code> if segment direction should be indicated 534 */ 435 535 protected void drawSegment(GeneralPath path, Point p1, Point p2, boolean showDirection) { 436 536 Rectangle bounds = g.getClipBounds(); … … 458 558 /** 459 559 * Draw a line with the given color. 560 * 561 * @param p1 First point of the way segment. 562 * @param p2 Second point of the way segment. 563 * @param col The color to use for drawing line. 564 * @param showDirection <code>true</code> if segment direction should be indicated. 460 565 */ 461 566 protected void drawSegment(Point p1, Point p2, Color col, boolean showDirection) { … … 466 571 } 467 572 573 /** 574 * Checks if segment is visible in display. 575 * 576 * @param p1 First point of the way segment. 577 * @param p2 Second point of the way segment. 578 * @return <code>true</code> if segment is visible. 579 */ 468 580 protected boolean isSegmentVisible(Point p1, Point p2) { 469 581 if ((p1.x < 0) && (p2.x < 0)) return false; … … 474 586 } 475 587 588 /** 589 * Checks if a polygon is visible in display. 590 * 591 * @param polygon The polygon to check. 592 * @return <code>true</code> if polygon is visible. 593 */ 476 594 protected boolean isPolygonVisible(Polygon polygon) { 477 595 Rectangle bounds = polygon.getBounds(); … … 484 602 } 485 603 604 /** 605 * Finally display all segments in currect path. 606 */ 486 607 protected void displaySegments() { 487 608 displaySegments(null); 488 609 } 610 611 /** 612 * Finally display all segments in currect path. 613 * 614 * @param newColor This color is set after the path is drawn. 615 */ 489 616 protected void displaySegments(Color newColor) { 490 617 if (currentPath != null) {
Note:
See TracChangeset
for help on using the changeset viewer.