Ignore:
Timestamp:
2012-08-11T17:09:12+02:00 (12 years ago)
Author:
stoecker
Message:

fix javadoc, remove unused code

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  
    88
    99/**
    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.
    1412 */
    1513public interface Visitor {
     14    /**
     15     * Visiting call for points.
     16     * @param n The node to inspect.
     17     */
    1618    void visit(Node n);
     19    /**
     20     * Visiting call for lines.
     21     * @param w The way to inspect.
     22     */
    1723    void visit(Way w);
     24    /**
     25     * Visiting call for relations.
     26     * @param e The relation to inspect.
     27     */
    1828    void visit(Relation e);
     29    /**
     30     * Visiting call for changesets.
     31     * @param cs The changeset to inspect.
     32     */
    1933    void visit(Changeset cs);
    2034}
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/MapPaintSettings.java

    r4627 r5421  
    1313
    1414    private boolean useRealWidth;
     15    /** Preference: should directional arrows be displayed */
    1516    private boolean showDirectionArrow;
     17    /** Preference: should arrows for oneways be displayed */
    1618    private boolean showOnewayArrow;
    17     private int defaultSegmentWidth;
     19    /** Preference: should the segement numbers of ways be displayed */
    1820    private boolean showOrderNumber;
     21    /** Preference: should only the last arrow of a way be displayed */
    1922    private boolean showHeadArrowOnly;
    2023    private int showNamesDistance;
    2124    private int useStrokesDistance;
    2225    private int showIconsDistance;
     26    /** Preference: size of selected nodes */
    2327    private int selectedNodeSize;
     28    /** Preference: size of multiply connected nodes */
    2429    private int connectionNodeSize;
     30    /** Preference: size of unselected nodes */
    2531    private int unselectedNodeSize;
     32    /** Preference: size of tagged nodes */
    2633    private int taggedNodeSize;
     34    /** Preference: should selected nodes be filled */
    2735    private boolean fillSelectedNode;
     36    /** Preference: should unselected nodes be filled */
    2837    private boolean fillUnselectedNode;
     38    /** Preference: should tagged nodes be filled */
    2939    private boolean fillTaggedNode;
     40    /** Preference: should multiply connected nodes be filled */
    3041    private boolean fillConnectionNode;
    3142    private boolean outlineOnly;
     43    /** Color Preference for selected objects */
    3244    private Color selectedColor;
    3345    private Color relationSelectedColor;
     46    /** Color Preference for hightlighted objects */
    3447    private Color highlightColor;
     48    /** Color Preference for inactive objects */
    3549    private Color inactiveColor;
     50    /** Color Preference for nodes */
    3651    private Color nodeColor;
     52    /** Color Preference for tagged nodes */
    3753    private Color taggedColor;
     54    /** Color Preference for multiply connected nodes */
    3855    private Color connectionColor;
     56    /** Color Preference for tagged and multiply connected nodes */
    3957    private Color taggedConnectionColor;
    4058
     
    4866        showOnewayArrow = Main.pref.getBoolean("draw.oneway", true);
    4967        useRealWidth = Main.pref.getBoolean("mappaint.useRealWidth", false);
    50         defaultSegmentWidth = Main.pref.getInteger("mappaint.segment.default-width", 2);
    5168
    5269        selectedColor = PaintColors.SELECTED.get();
     
    100117    }
    101118
    102     public int getDefaultSegmentWidth() {
    103         return defaultSegmentWidth;
    104     }
    105 
    106119    public Color getSelectedColor() {
    107120        return selectedColor;
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/PaintColors.java

    r4952 r5421  
    2424    RELATION(marktr("relation"), new Color(0,128,128)), // teal
    2525    UNTAGGED_WAY(marktr("untagged way"), new Color(0,128,0)), // dark green
    26     INCOMPLETE_WAY(marktr("incomplete way"), new Color(0,0,96)), // darker blue
    2726    BACKGROUND(marktr("background"), Color.BLACK),
    2827    HIGHLIGHT(marktr("highlight"), SELECTED.get()),
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/WireframeMapRenderer.java

    r5351 r5421  
    3232 * A map renderer that paints a simple scheme of every primitive it visits to a
    3333 * previous set graphic environment.
    34  *
    35  * @author imi
    3634 */
    3735public class WireframeMapRenderer extends AbstractMapRenderer implements Visitor {
    3836
    39     /**
    40      * Preferences
    41      */
     37    /** Color Preference for inactive objects */
    4238    protected Color inactiveColor;
     39    /** Color Preference for selected objects */
    4340    protected Color selectedColor;
     41    /** Color Preference for nodes */
    4442    protected Color nodeColor;
     43    /** Color Preference for ways not matching any other group */
    4544    protected Color dfltWayColor;
     45    /** Color Preference for relations */
    4646    protected Color relationColor;
     47    /** Color Preference for untagged ways */
    4748    protected Color untaggedWayColor;
    48     protected Color incompleteColor;
     49    /** Color Preference for background */
    4950    protected Color backgroundColor;
     51    /** Color Preference for hightlighted objects */
    5052    protected Color highlightColor;
     53    /** Color Preference for tagged nodes */
    5154    protected Color taggedColor;
     55    /** Color Preference for multiply connected nodes */
    5256    protected Color connectionColor;
     57    /** Color Preference for tagged and multiply connected nodes */
    5358    protected Color taggedConnectionColor;
     59    /** Preference: should directional arrows be displayed */
    5460    protected boolean showDirectionArrow;
     61    /** Preference: should arrows for oneways be displayed */
    5562    protected boolean showOnewayArrow;
     63    /** Preference: should only the last arrow of a way be displayed */
    5664    protected boolean showHeadArrowOnly;
     65    /** Preference: should the segement numbers of ways be displayed */
    5766    protected boolean showOrderNumber;
     67    /** Preference: should selected nodes be filled */
    5868    protected boolean fillSelectedNode;
     69    /** Preference: should unselected nodes be filled */
    5970    protected boolean fillUnselectedNode;
     71    /** Preference: should tagged nodes be filled */
    6072    protected boolean fillTaggedNode;
     73    /** Preference: should multiply connected nodes be filled */
    6174    protected boolean fillConnectionNode;
     75    /** Preference: size of selected nodes */
    6276    protected int selectedNodeSize;
     77    /** Preference: size of unselected nodes */
    6378    protected int unselectedNodeSize;
     79    /** Preference: size of multiply connected nodes */
    6480    protected int connectionNodeSize;
     81    /** Preference: size of tagged nodes */
    6582    protected int taggedNodeSize;
    66     protected int defaultSegmentWidth;
     83    /** Preference: size of virtual nodes (0 displayes display) */
    6784    protected int virtualNodeSize;
     85    /** Preference: minimum space (displayed way length) to display virtual nodes */
    6886    protected int virtualNodeSpace;
     87    /** Preference: minimum space (displayed way length) to display segment numbers */
    6988    protected int segmentNumberSpace;
    7089
    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>. */
    7491    protected Color currentColor = null;
     92    /** Path store to draw subsequent segments of same color as one <code>Path</code>. */
    7593    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
    79120     */
    80121    public WireframeMapRenderer(Graphics2D g, NavigatableComponent nc, boolean isInactiveMode) {
     
    82123    }
    83124
     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     */
    84129    public void getColors()
    85130    {
     
    90135        relationColor = PaintColors.RELATION.get();
    91136        untaggedWayColor = PaintColors.UNTAGGED_WAY.get();
    92         incompleteColor = PaintColors.INCOMPLETE_WAY.get();
    93137        backgroundColor = PaintColors.BACKGROUND.get();
    94138        highlightColor = PaintColors.HIGHLIGHT_WIREFRAME.get();
     
    103147    }
    104148
     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     */
    105155    protected void getSettings(boolean virtual) {
    106156        MapPaintSettings settings = MapPaintSettings.INSTANCE;
     
    113163        connectionNodeSize = settings.getConnectionNodeSize();
    114164        taggedNodeSize = settings.getTaggedNodeSize();
    115         defaultSegmentWidth = settings.getDefaultSegmentWidth();
    116165        fillSelectedNode = settings.isFillSelectedNode();
    117166        fillUnselectedNode = settings.isFillUnselectedNode();
     
    128177    }
    129178
    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     */
    131186    public void render(DataSet data, boolean virtual, Bounds bounds) {
    132187        BBox bbox = new BBox(bounds);
     
    181236    }
    182237
     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     */
    183246    private static final int max(int a, int b, int c, int d) {
    184247        return Math.max(Math.max(a, b), Math.max(c, d));
     
    191254     * @param n The node to draw.
    192255     */
     256    @Override
    193257    public void visit(Node n) {
    194258        if (n.isIncomplete()) return;
     
    231295    }
    232296
     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     */
    233305    public static boolean isLargeSegment(Point2D p1, Point2D p2, int space)
    234306    {
     
    238310    }
    239311
     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     */
    240318    public void drawVirtualNodes(Collection<Way> ways, Collection<WaySegment> highlightVirtualNodes) {
    241319        if (virtualNodeSize == 0)
     
    263341    }
    264342
     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     */
    265349    public void visitVirtual(GeneralPath path, Way w) {
    266350        Iterator<Node> it = w.getNodes().iterator();
     
    285369
    286370    /**
    287      * Draw a darkblue line for all segments.
     371     * Draw a line for all way segments.
    288372     * @param w The way to draw.
    289373     */
     374    @Override
    290375    public void visit(Way w) {
    291376        if (w.isIncomplete() || w.getNodesCount() < 2)
     
    328413    }
    329414
    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
    332420    public void visit(Relation r) {
    333421        if (r.isIncomplete()) return;
     
    378466    }
    379467
     468    /**
     469     * Visitor for changesets not used in this class
     470     * @param cs The changeset for inspection.
     471     */
    380472    @Override
    381473    public void visit(Changeset cs) {/* ignore */}
     
    384476     * Draw an number of the order of the two consecutive nodes within the
    385477     * 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.
    386482     */
    387483    protected void drawOrderNumber(Point p1, Point p2, int orderNumber) {
     
    429525    }
    430526
    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     */
    435535    protected void drawSegment(GeneralPath path, Point p1, Point p2, boolean showDirection) {
    436536        Rectangle bounds = g.getClipBounds();
     
    458558    /**
    459559     * 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.
    460565     */
    461566    protected void drawSegment(Point p1, Point p2, Color col, boolean showDirection) {
     
    466571    }
    467572
     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     */
    468580    protected boolean isSegmentVisible(Point p1, Point p2) {
    469581        if ((p1.x < 0) && (p2.x < 0)) return false;
     
    474586    }
    475587
     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     */
    476594    protected boolean isPolygonVisible(Polygon polygon) {
    477595        Rectangle bounds = polygon.getBounds();
     
    484602    }
    485603
     604    /**
     605     * Finally display all segments in currect path.
     606     */
    486607    protected void displaySegments() {
    487608        displaySegments(null);
    488609    }
     610
     611    /**
     612     * Finally display all segments in currect path.
     613     *
     614     * @param newColor This color is set after the path is drawn.
     615     */
    489616    protected void displaySegments(Color newColor) {
    490617        if (currentPath != null) {
Note: See TracChangeset for help on using the changeset viewer.