Changeset 12382 in josm


Ignore:
Timestamp:
2017-06-10T00:42:11+02:00 (2 years ago)
Author:
michael2402
Message:

More documentation for the tools package

Location:
trunk/src/org/openstreetmap/josm/tools
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java

    r11796 r12382  
    8181    }
    8282
     83    /**
     84     * Parses a precondition failure response from the server and attempts to get more information about it
     85     * @param msg The message from the server
     86     * @return The OSM primitive that caused the problem and a collection of primitives that e.g. refer to it
     87     */
    8388    public static Pair<OsmPrimitive, Collection<OsmPrimitive>> parsePreconditionFailed(String msg) {
    8489        if (msg == null)
  • trunk/src/org/openstreetmap/josm/tools/GeoPropertyIndex.java

    r11264 r12382  
    5050    }
    5151
     52    /**
     53     * Gets the index of the given coordinate. Only used internally
     54     * @param ll The lat/lon coordinate
     55     * @param level The scale level
     56     * @return The index for that position
     57     */
    5258    public static int index(LatLon ll, int level) {
    5359        long noParts = 1L << level;
  • trunk/src/org/openstreetmap/josm/tools/GeoUrlToBounds.java

    r11329 r12382  
    1717public final class GeoUrlToBounds {
    1818
     19    /**
     20     * The pattern of a geo: url, having named match groups.
     21     */
    1922    public static final Pattern PATTERN = Pattern.compile("geo:(?<lat>[+-]?[0-9.]+),(?<lon>[+-]?[0-9.]+)(\\?z=(?<zoom>[0-9]+))?");
    2023
  • trunk/src/org/openstreetmap/josm/tools/Geometry.java

    r12161 r12382  
    4848    }
    4949
     50    /**
     51     * The result types for a {@link Geometry#polygonIntersection(Area, Area)} test
     52     */
    5053    public enum PolygonIntersection {
     54        /**
     55         * The first polygon is inside the second one
     56         */
    5157        FIRST_INSIDE_SECOND,
     58        /**
     59         * The second one is inside the first
     60         */
    5261        SECOND_INSIDE_FIRST,
     62        /**
     63         * The polygons do not overlap
     64         */
    5365        OUTSIDE,
     66        /**
     67         * The polygon borders cross each other
     68         */
    5469        CROSSING
    5570    }
     
    373388    }
    374389
     390    /**
     391     * Check if the segment p1 - p2 is parallel to p3 - p4
     392     * @param p1 First point for first segment
     393     * @param p2 Second point for first segment
     394     * @param p3 First point for second segment
     395     * @param p4 Second point for second segment
     396     * @return <code>true</code> if they are parallel or close to parallel
     397     */
    375398    public static boolean segmentsParallel(EastNorth p1, EastNorth p2, EastNorth p3, EastNorth p4) {
    376399
     
    950973        private final double perimeter;
    951974
     975        /**
     976         * Create a new {@link AreaAndPerimeter}
     977         * @param area The area
     978         * @param perimeter The perimeter
     979         */
    952980        public AreaAndPerimeter(double area, double perimeter) {
    953981            this.area = area;
     
    955983        }
    956984
     985        /**
     986         * Gets the area
     987         * @return The area size
     988         */
    957989        public double getArea() {
    958990            return area;
    959991        }
    960992
     993        /**
     994         * Gets the perimeter
     995         * @return The perimeter length
     996         */
    961997        public double getPerimeter() {
    962998            return perimeter;
  • trunk/src/org/openstreetmap/josm/tools/LanguageInfo.java

    r9070 r12382  
    66import java.util.Locale;
    77
     8/**
     9 * This is a utility class that provides information about locales and allows to convert locale codes.
     10 */
    811public final class LanguageInfo {
    912
  • trunk/src/org/openstreetmap/josm/tools/OsmUrlToBounds.java

    r12090 r12382  
    213213    private static final int TILE_SIZE_IN_PIXELS = 256;
    214214
     215    /**
     216     * Compute the bounds for a given lat/lon position and the zoom level
     217     * @param lat The latitude
     218     * @param lon The longitude
     219     * @param zoom The current zoom level
     220     * @return The bounds the OSM server would display
     221     */
    215222    public static Bounds positionToBounds(final double lat, final double lon, final int zoom) {
    216223        final Dimension screenSize = getScreenSize();
  • trunk/src/org/openstreetmap/josm/tools/TextTagParser.java

    r12279 r12382  
    4040    }
    4141
     42    /**
     43     * A helper class that analyzes the text and attempts to parse tags from it
     44     */
    4245    public static class TextAnalyzer {
    4346        private boolean quotesStarted;
     
    4851        private final int n;
    4952
     53        /**
     54         * Create a new {@link TextAnalyzer}
     55         * @param text The text to parse
     56         */
    5057        public TextAnalyzer(String text) {
    5158            pos = 0;
     
    201208    }
    202209
     210    /**
     211     * Gets a list of tags that are in the given text
     212     * @param buf The text to parse
     213     * @return The tags or <code>null</code> if the tags are not valid
     214     */
    203215    public static Map<String, String> getValidatedTagsFromText(String buf) {
    204216        Map<String, String> tags = readTagsFromText(buf);
  • trunk/src/org/openstreetmap/josm/tools/WindowGeometry.java

    r11746 r12382  
    220220    }
    221221
     222    /**
     223     * Gets the geometry of the main window
     224     * @param preferenceKey The preference key to use
     225     * @param arg The command line geometry arguments
     226     * @param maximize If the user requested to maximize the window
     227     * @return The geometry for the main window
     228     */
    222229    public static WindowGeometry mainWindow(String preferenceKey, String arg, boolean maximize) {
    223230        Rectangle screenDimension = getScreenInfo("gui.geometry");
  • trunk/src/org/openstreetmap/josm/tools/XmlObjectParser.java

    r12279 r12382  
    4343 */
    4444public class XmlObjectParser implements Iterable<Object> {
     45    /**
     46     * The language prefix to use
     47     */
    4548    public static final String lang = LanguageInfo.getLanguageCodeXML();
    4649
     
    299302    }
    300303
     304    /**
     305     * Add a new tag name to class type mapping
     306     * @param tagName The tag name that should be converted to that class
     307     * @param klass The class the XML elements should be converted to.
     308     */
    301309    public void map(String tagName, Class<?> klass) {
    302310        mapping.put(tagName, new Entry(klass, false, false));
     
    311319    }
    312320
     321    /**
     322     * Get the next element that was parsed
     323     * @return The next object
     324     */
    313325    public Object next() {
    314326        return queueIterator.next();
    315327    }
    316328
     329    /**
     330     * Check if there is a next parsed object available
     331     * @return <code>true</code> if there is a next object
     332     */
    317333    public boolean hasNext() {
    318334        return queueIterator.hasNext();
Note: See TracChangeset for help on using the changeset viewer.