Changeset 9949 in josm for trunk/src


Ignore:
Timestamp:
2016-03-07T21:45:35+01:00 (8 years ago)
Author:
Don-vip
Message:

remove deprecated stuff, code cleanup, javadoc, unit tests

Location:
trunk/src/org/openstreetmap/josm
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxTrack.java

    r8510 r9949  
    99/**
    1010 * Read-only gpx track. Implementations doesn't have to be immutable, but should always be thread safe.
    11  *
     11 * @since 444
    1212 */
    1313public interface GpxTrack extends IWithAttributes {
    1414
     15    /**
     16     * Returns the track segments.
     17     * @return the track segments
     18     */
    1519    Collection<GpxTrackSegment> getSegments();
    1620
     21    /**
     22     * Returns the track attributes.
     23     * @return the track attributes
     24     */
    1725    Map<String, Object> getAttributes();
    1826
     27    /**
     28     * Returns the track bounds.
     29     * @return the track bounds
     30     */
    1931    Bounds getBounds();
    2032
     33    /**
     34     * Returns the track length.
     35     * @return the track length
     36     */
    2137    double length();
    2238
    2339    /**
    24      *
     40     * Returns the number of times this track has been changed.
    2541     * @return Number of times this track has been changed. Always 0 for read-only tracks
    2642     */
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxTrackSegment.java

    r8510 r9949  
    88/**
    99 * Read-only gpx track segments. Implementations doesn't have to be immutable, but should always be thread safe.
    10  *
     10 * @since 2907
    1111 */
    1212public interface GpxTrackSegment {
    1313
     14    /**
     15     * Returns the segment bounds.
     16     * @return the segment bounds
     17     */
    1418    Bounds getBounds();
    1519
     20    /**
     21     * Returns the segment waypoints.
     22     * @return the segment waypoints
     23     */
    1624    Collection<WayPoint> getWayPoints();
    1725
     26    /**
     27     * Returns the segment length.
     28     * @return the segment length
     29     */
    1830    double length();
    1931
    2032    /**
    21      *
     33     * Returns the number of times this track has been changed
    2234     * @return Number of times this track has been changed. Always 0 for read-only segments
    2335     */
  • trunk/src/org/openstreetmap/josm/data/gpx/ImmutableGpxTrack.java

    r8510 r9949  
    1111import org.openstreetmap.josm.data.Bounds;
    1212
     13/**
     14 * Immutable GPX track.
     15 * @since 2907
     16 */
    1317public class ImmutableGpxTrack extends WithAttributes implements GpxTrack {
    1418
     
    1721    private final Bounds bounds;
    1822
     23    /**
     24     * Constructs a new {@code ImmutableGpxTrack}.
     25     * @param trackSegs track segments
     26     * @param attributes track attributes
     27     */
    1928    public ImmutableGpxTrack(Collection<Collection<WayPoint>> trackSegs, Map<String, Object> attributes) {
    2029        List<GpxTrackSegment> newSegments = new ArrayList<>();
  • trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListPopup.java

    r8855 r9949  
    6767    }
    6868
     69    /**
     70     * Constructs a new {@code LayerListPopup}.
     71     * @param selectedLayers list of selected layers
     72     */
    6973    public LayerListPopup(List<Layer> selectedLayers) {
    7074
  • trunk/src/org/openstreetmap/josm/gui/layer/CustomizeColor.java

    r8513 r9949  
    2323
    2424public class CustomizeColor extends AbstractAction implements LayerAction, MultiLayerAction {
    25     private transient List<Layer> layers;
     25    private final transient List<Layer> layers;
    2626
     27    /**
     28     * Constructs a new {@code CustomizeColor} for a given list of layers.
     29     * @param l list of layers
     30     */
    2731    public CustomizeColor(List<Layer> l) {
    28         this();
     32        super(tr("Customize Color"), ImageProvider.get("colorchooser"));
     33        putValue("help", ht("/Action/LayerCustomizeColor"));
    2934        layers = l;
    3035    }
    3136
     37    /**
     38     * Constructs a new {@code CustomizeColor} for a single layer.
     39     * @param l layer
     40     */
    3241    public CustomizeColor(Layer l) {
    33         this();
    34         layers = new LinkedList<>();
     42        this(new LinkedList<Layer>());
    3543        layers.add(l);
    36     }
    37 
    38     private CustomizeColor() {
    39         super(tr("Customize Color"), ImageProvider.get("colorchooser"));
    40         putValue("help", ht("/Action/LayerCustomizeColor"));
    4144    }
    4245
     
    6366    public void actionPerformed(ActionEvent e) {
    6467        Color cl = layers.get(0).getColor(false);
    65         if (cl == null) cl = Color.gray;
     68        if (cl == null)
     69            cl = Color.gray;
    6670        JColorChooser c = new JColorChooser(cl);
    6771        Object[] options = new Object[]{tr("OK"), tr("Cancel"), tr("Default")};
  • trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java

    r9461 r9949  
    5252public class GpxLayer extends Layer {
    5353
     54    /** GPX data */
    5455    public GpxData data;
    55     private boolean isLocalFile;
     56    private final boolean isLocalFile;
    5657    // used by ChooseTrackVisibilityAction to determine which tracks to show/hide
    5758    public boolean[] trackVisibility = new boolean[0];
     
    6263    private final GpxDrawHelper drawHelper;
    6364
     65    /**
     66     * Constructs a new {@code GpxLayer} without name.
     67     * @param d GPX data
     68     */
    6469    public GpxLayer(GpxData d) {
     70        this(d, null, false);
     71    }
     72
     73    /**
     74     * Constructs a new {@code GpxLayer} with a given name.
     75     * @param d GPX data
     76     * @param name layer name
     77     */
     78    public GpxLayer(GpxData d, String name) {
     79        this(d, name, false);
     80    }
     81
     82    /**
     83     * Constructs a new {@code GpxLayer} with a given name, thah can be attached to a local file.
     84     * @param d GPX data
     85     * @param name layer name
     86     * @param isLocal whether data is attached to a local file
     87     */
     88    public GpxLayer(GpxData d, String name, boolean isLocal) {
    6589        super(d.getString(GpxConstants.META_NAME));
    6690        data = d;
    6791        drawHelper = new GpxDrawHelper(data);
    6892        ensureTrackVisibilityLength();
    69     }
    70 
    71     public GpxLayer(GpxData d, String name) {
    72         this(d);
    73         this.setName(name);
    74     }
    75 
    76     public GpxLayer(GpxData d, String name, boolean isLocal) {
    77         this(d);
    78         this.setName(name);
    79         this.isLocalFile = isLocal;
     93        setName(name);
     94        isLocalFile = isLocal;
    8095    }
    8196
     
    204219    }
    205220
     221    /**
     222     * Determines if data is attached to a local file.
     223     * @return {@code true} if data is attached to a local file, {@code false} otherwise
     224     */
    206225    public boolean isLocalFile() {
    207226        return isLocalFile;
  • trunk/src/org/openstreetmap/josm/gui/layer/ImageryLayer.java

    r9078 r9949  
    5252import org.openstreetmap.josm.tools.GBC;
    5353import org.openstreetmap.josm.tools.ImageProvider;
     54import org.openstreetmap.josm.tools.ImageProvider.ImageSizes;
    5455import org.openstreetmap.josm.tools.Utils;
    5556
     
    9192        if (info.getIcon() != null) {
    9293            icon = new ImageProvider(info.getIcon()).setOptional(true).
    93                     setMaxHeight(ICON_SIZE).setMaxWidth(ICON_SIZE).get();
     94                    setMaxSize(ImageSizes.LAYER).get();
    9495        }
    9596        if (icon == null) {
  • trunk/src/org/openstreetmap/josm/gui/layer/Layer.java

    r9848 r9949  
    5050public abstract class Layer implements Destroyable, MapViewPaintable, ProjectionChangeListener {
    5151
     52    /**
     53     * Action related to a single layer.
     54     */
    5255    public interface LayerAction {
     56
     57        /**
     58         * Determines if this action supports a given list of layers.
     59         * @param layers list of layers
     60         * @return {@code true} if this action supports the given list of layers, {@code false} otherwise
     61         */
    5362        boolean supportLayers(List<Layer> layers);
    5463
     64        /**
     65         * Creates and return the menu component.
     66         * @return the menu component
     67         */
    5568        Component createMenuComponent();
    5669    }
    5770
     71    /**
     72     * Action related to several layers.
     73     */
    5874    public interface MultiLayerAction {
     75
     76        /**
     77         * Returns the action for a given list of layers.
     78         * @param layers list of layers
     79         * @return the action for the given list of layers
     80         */
    5981        Action getMultiLayerAction(List<Layer> layers);
    6082    }
     
    6486     */
    6587    public static class SeparatorLayerAction extends AbstractAction implements LayerAction {
     88        /** Unique instance */
    6689        public static final SeparatorLayerAction INSTANCE = new SeparatorLayerAction();
    6790
     
    86109    public static final String NAME_PROP = Layer.class.getName() + ".name";
    87110    public static final String FILTER_STATE_PROP = Layer.class.getName() + ".filterstate";
    88 
    89     public static final int ICON_SIZE = 16;
    90111
    91112    /**
  • trunk/src/org/openstreetmap/josm/tools/HttpClient.java

    r9935 r9949  
    1111import java.net.CookieHandler;
    1212import java.net.CookieManager;
    13 import java.net.HttpRetryException;
    1413import java.net.HttpURLConnection;
    1514import java.net.URL;
     
    522521
    523522    /**
    524      * This method is used to enable streaming of a HTTP request body without internal buffering,
    525      * when the content length is known in advance.
    526      * <p>
    527      * An exception will be thrown if the application attempts to write more data than the indicated content-length,
    528      * or if the application closes the OutputStream before writing the indicated amount.
    529      * <p>
    530      * When output streaming is enabled, authentication and redirection cannot be handled automatically.
    531      * A {@linkplain HttpRetryException} will be thrown when reading the response if authentication or redirection
    532      * are required. This exception can be queried for the details of the error.
    533      *
    534      * @param contentLength The number of bytes which will be written to the OutputStream
    535      * @return {@code this}
    536      * @see HttpURLConnection#setFixedLengthStreamingMode(long)
    537      * @since 9178
    538      * @deprecated Submitting data via POST, PUT, DELETE automatically sets this property on the connection
    539      */
    540     @Deprecated
    541     public HttpClient setFixedLengthStreamingMode(long contentLength) {
    542         return this;
    543     }
    544 
    545     /**
    546523     * Sets the {@code Accept} header.
    547524     * @param accept header value
  • trunk/src/org/openstreetmap/josm/tools/ImageProvider.java

    r9827 r9949  
    132132     */
    133133    public enum ImageSizes {
    134         /** SMALL_ICON value of on Action */
     134        /** SMALL_ICON value of an Action */
    135135        SMALLICON(Main.pref.getInteger("iconsize.smallicon", 16)),
    136         /** LARGE_ICON_KEY value of on Action */
     136        /** LARGE_ICON_KEY value of an Action */
    137137        LARGEICON(Main.pref.getInteger("iconsize.largeicon", 24)),
    138138        /** map icon */
     
    375375        overlayInfo.add(overlay);
    376376        return this;
    377     }
    378 
    379     /**
    380      * Convert enumerated size values to real numbers
    381      * @param size the size enumeration
    382      * @return dimension of image in pixels
    383      * @since 7687
    384      * @deprecated Use {@link ImageSizes#getImageDimension()} instead
    385      */
    386     @Deprecated
    387     public static Dimension getImageSizes(ImageSizes size) {
    388         return (size == null ? ImageSizes.DEFAULT : size).getImageDimension();
    389377    }
    390378
Note: See TracChangeset for help on using the changeset viewer.