Ticket #13176: patch-doc-imagery.patch

File patch-doc-imagery.patch, 7.7 KB (added by michael2402, 8 years ago)
  • src/org/openstreetmap/josm/data/imagery/ImageryInfo.java

    diff --git a/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java b/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java
    index 764e7dc..6b2671a 100644
    a b public class ImageryInfo extends TileSourceInfo implements Comparable<ImageryInf  
    167167    /** display bounds of imagery, displayed in prefs and used for automatic imagery selection */
    168168    private ImageryBounds bounds;
    169169    /** projections supported by WMS servers */
    170     private List<String> serverProjections;
     170    private List<String> serverProjections = Collections.emptyList();
    171171    /** description of the imagery entry, should contain notes what type of data it is */
    172172    private String description;
    173173    /** language of the description entry */
    public class ImageryInfo extends TileSourceInfo implements Comparable<ImageryInf  
    270270                    shapes = shapesString.toString();
    271271                }
    272272            }
    273             if (i.serverProjections != null && !i.serverProjections.isEmpty()) {
     273            if (!i.serverProjections.isEmpty()) {
    274274                StringBuilder val = new StringBuilder();
    275275                for (String p : i.serverProjections) {
    276276                    if (val.length() > 0) {
    public class ImageryInfo extends TileSourceInfo implements Comparable<ImageryInf  
    536536        return url.equals(in.url);
    537537    }
    538538
     539    /**
     540     * Sets the pixel per degree value.
     541     * @param ppd The ppd value
     542     * @see #getPixelPerDegree()
     543     */
    539544    public void setPixelPerDegree(double ppd) {
    540545        this.pixelPerDegree = ppd;
    541546    }
    public class ImageryInfo extends TileSourceInfo implements Comparable<ImageryInf  
    611616        return termsOfUseURL;
    612617    }
    613618
     619    /**
     620     * Set the attribution text
     621     * @param text The text
     622     * @see #getAttributionText(int, ICoordinate, ICoordinate)
     623     */
    614624    public void setAttributionText(String text) {
    615625        attributionText = text;
    616626    }
    617627
    618     public void setAttributionImageURL(String text) {
    619         attributionImageURL = text;
     628    /**
     629     * Set the attribution image
     630     * @param url The url of the image.
     631     * @see #getAttributionImageURL()
     632     */
     633    public void setAttributionImageURL(String url) {
     634        attributionImageURL = url;
    620635    }
    621636
    622     public void setAttributionImage(String text) {
    623         attributionImage = text;
     637    /**
     638     * Set the image for the attribution
     639     * @param res The image resource
     640     * @see #getAttributionImage()
     641     */
     642    public void setAttributionImage(String res) {
     643        attributionImage = res;
    624644    }
    625645
    626     public void setAttributionLinkURL(String text) {
    627         attributionLinkURL = text;
     646    /**
     647     * Sets the URL the attribution should link to.
     648     * @param url The url.
     649     * @see #getAttributionLinkURL()
     650     */
     651    public void setAttributionLinkURL(String url) {
     652        attributionLinkURL = url;
    628653    }
    629654
     655    /**
     656     * Sets the text to display to the user as terms of use.
     657     * @param text The text
     658     * @see #getTermsOfUseText()
     659     */
    630660    public void setTermsOfUseText(String text) {
    631661        termsOfUseText = text;
    632662    }
    633663
     664    /**
     665     * Sets a url that links to the terms of use text.
     666     * @param text The url.
     667     * @see #getTermsOfUseURL()
     668     */
    634669    public void setTermsOfUseURL(String text) {
    635670        termsOfUseURL = text;
    636671    }
    public class ImageryInfo extends TileSourceInfo implements Comparable<ImageryInf  
    663698            }
    664699        }
    665700
    666         if (serverProjections == null || serverProjections.isEmpty()) {
     701        if (serverProjections.isEmpty()) {
    667702            serverProjections = new ArrayList<>();
    668703            Matcher m = Pattern.compile(".*\\{PROJ\\(([^)}]+)\\)\\}.*").matcher(url.toUpperCase(Locale.ENGLISH));
    669704            if (m.matches()) {
    public class ImageryInfo extends TileSourceInfo implements Comparable<ImageryInf  
    700735        }
    701736    }
    702737
     738    /**
     739     * Store the id of this info to the preferences and clear it afterwards.
     740     */
    703741    public void clearId() {
    704742        if (this.id != null) {
    705743            Collection<String> newAddedIds = new TreeSet<>(Main.pref.getCollection("imagery.layers.addedIds"));
    public class ImageryInfo extends TileSourceInfo implements Comparable<ImageryInf  
    734772        return this.cookies;
    735773    }
    736774
     775    /**
     776     * Gets the pixel per degree value
     777     * @return The ppd value.
     778     */
    737779    public double getPixelPerDegree() {
    738780        return this.pixelPerDegree;
    739781    }
    public class ImageryInfo extends TileSourceInfo implements Comparable<ImageryInf  
    847889     * of supported projections otherwise.
    848890     */
    849891    public List<String> getServerProjections() {
    850         if (serverProjections == null)
    851             return Collections.emptyList();
    852892        return Collections.unmodifiableList(serverProjections);
    853893    }
    854894
     895    /**
     896     * Sets the list of collections the server supports
     897     * @param serverProjections The list of supported projections
     898     */
    855899    public void setServerProjections(Collection<String> serverProjections) {
     900        CheckParameterUtil.ensureParameterNotNull(serverProjections, "serverProjections");
    856901        this.serverProjections = new ArrayList<>(serverProjections);
    857902    }
    858903
    public class ImageryInfo extends TileSourceInfo implements Comparable<ImageryInf  
    865910            ? ('['+(defaultMinZoom != 0 ? (Integer.toString(defaultMinZoom) + ',') : "")+defaultMaxZoom+']') : "") + ':' + url;
    866911    }
    867912
     913    /**
     914     * Gets a unique toolbar key to store this layer as toolbar item
     915     * @return The kay.
     916     */
    868917    public String getToolbarName() {
    869918        String res = name;
    870919        if (pixelPerDegree != 0) {
    public class ImageryInfo extends TileSourceInfo implements Comparable<ImageryInf  
    873922        return res;
    874923    }
    875924
     925    /**
     926     * Gets the name that should be displayed in the menu to add this imagery layer.
     927     * @return The text.
     928     */
    876929    public String getMenuName() {
    877930        String res = name;
    878931        if (pixelPerDegree != 0) {
    public class ImageryInfo extends TileSourceInfo implements Comparable<ImageryInf  
    10191072        this.metadataHeaders = metadataHeaders;
    10201073    }
    10211074
     1075    /**
     1076     * Gets the flag if epsg 4326 to 3857 is supported
     1077     * @return The flag.
     1078     */
    10221079    public boolean isEpsg4326To3857Supported() {
    10231080        return isEpsg4326To3857Supported;
    10241081    }
    10251082
     1083    /**
     1084     * Sets the flag that epsg 4326 to 3857 is supported
     1085     * @param isEpsg4326To3857Supported The flag.
     1086     */
    10261087    public void setEpsg4326To3857Supported(boolean isEpsg4326To3857Supported) {
    10271088        this.isEpsg4326To3857Supported = isEpsg4326To3857Supported;
    10281089    }
    10291090
     1091    /**
     1092     * Gets the flag if the georeference is valid.
     1093     * @return <code>true</code> if it is valid.
     1094     */
    10301095    public boolean isGeoreferenceValid() {
    10311096        return isGeoreferenceValid;
    10321097    }
    10331098
     1099    /**
     1100     * Sets an indicator that the georeference is valid
     1101     * @param isGeoreferenceValid <code>true</code> if it is marked as valid.
     1102     */
    10341103    public void setGeoreferenceValid(boolean isGeoreferenceValid) {
    10351104        this.isGeoreferenceValid = isGeoreferenceValid;
    10361105    }
    public class ImageryInfo extends TileSourceInfo implements Comparable<ImageryInf  
    10661135               if (i.defaultMinZoom != 0) {
    10671136                   n.defaultMinZoom = i.defaultMinZoom;
    10681137               }
    1069                if (i.serverProjections != null) {
    1070                    n.serverProjections = i.serverProjections;
    1071                }
     1138               n.setServerProjections(i.getServerProjections());
    10721139               n.url = i.url;
    10731140               n.imageryType = i.imageryType;
    10741141               if (i.getTileSize() != 0) {