Ignore:
Timestamp:
2017-04-21T23:09:17+02:00 (7 years ago)
Author:
stoecker
Message:

some cleanups, add date and id

Location:
applications/editors/josm/plugins/imagery-xml-bounds
Files:
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/imagery-xml-bounds/build.xml

    r32680 r33272  
    44    <property name="commit.message" value="Commit message"/>
    55    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    6     <property name="plugin.main.version" value="10580"/>
     6    <property name="plugin.main.version" value="11570"/>
    77   
    88    <!-- Configure these properties (replace "..." accordingly).
  • applications/editors/josm/plugins/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/XmlBoundsConstants.java

    r30735 r33272  
    77
    88import org.openstreetmap.josm.actions.ExtensionFileFilter;
    9 import org.openstreetmap.josm.tools.ImageProvider;
    109
    1110/**
     
    1514 */
    1615public interface XmlBoundsConstants {
    17 
    18     /**
    19      * Plugin version.
    20      */
    21     public static final String PLUGIN_VERSION = "1.3";
    2216
    2317    /**
     
    4236    /** XML url tag */
    4337    public static final String XML_URL = "url";
     38    /** XML id tag */
     39    public static final String XML_ID = "id";
     40    /** XML date tag */
     41    public static final String XML_DATE = "date";
    4442    /** XML default tag */
    4543    public static final String XML_DEFAULT = "default";
     
    7876    public static final String KEY_TYPE = PREFIX + XML_TYPE;
    7977    public static final String KEY_URL = PREFIX + XML_URL;
     78    public static final String KEY_ID = PREFIX + XML_ID;
     79    public static final String KEY_DATE = PREFIX + XML_DATE;
    8080    public static final String KEY_DEFAULT = PREFIX + XML_DEFAULT;
    8181    public static final String KEY_EULA = PREFIX + XML_EULA;
     
    106106    public static final ExtensionFileFilter FILE_FILTER = new ExtensionFileFilter(
    107107            EXTENSION, EXTENSION, tr("Imagery XML Files") + " (*."+EXTENSION+")");
    108 
    109     /**
    110      * Plugin 16x16 icon.
    111      */
    112     public static ImageIcon XML_ICON_16 = ImageProvider.get("xml_16.png");
    113 
    114     /**
    115      * Plugin 24x24 icon.
    116      */
    117     public static ImageIcon XML_ICON_24 = ImageProvider.get("xml_24.png");
    118108}
  • applications/editors/josm/plugins/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/XmlBoundsLayer.java

    r32489 r33272  
    2222import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener;
    2323import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     24import org.openstreetmap.josm.tools.ImageProvider;
    2425import org.openstreetmap.josm.plugins.imageryxmlbounds.actions.BoundsLayerSaveAction;
    2526import org.openstreetmap.josm.plugins.imageryxmlbounds.actions.BoundsLayerSaveAsAction;
     
    9596    @Override
    9697    public Icon getIcon() {
    97         return XML_ICON_16;
     98        return ImageProvider.get("xml_24.png");
    9899    }
    99100
  • applications/editors/josm/plugins/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/actions/ComputeBoundsAction.java

    r30735 r33272  
    55
    66import java.awt.event.ActionEvent;
     7import java.io.InputStream;
     8import java.lang.Exception;
     9import java.math.RoundingMode;
    710import java.text.DecimalFormat;
    811import java.text.DecimalFormatSymbols;
     
    1518import java.util.Locale;
    1619import java.util.Map;
     20import java.util.Properties;
    1721import java.util.Set;
    1822
     
    2832import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    2933import org.openstreetmap.josm.plugins.imageryxmlbounds.XmlBoundsConstants;
     34import org.openstreetmap.josm.tools.ImageProvider;
    3035
    3136/**
     
    3641public class ComputeBoundsAction extends AbstractAction implements XmlBoundsConstants {
    3742
    38     protected static final DecimalFormat DF = new DecimalFormat("#0.0000000", new DecimalFormatSymbols(Locale.UK));
     43    protected static final DecimalFormat DF = new DecimalFormat("#0.#######", new DecimalFormatSymbols(Locale.UK));
    3944
    4045    protected static final String ACTION_NAME = tr("XML Imagery Bounds");
     
    4550    private final Set<Way> closedWays;
    4651
     52    static { DF.setRoundingMode(RoundingMode.CEILING); }
    4753    /**
    4854     * Constructs a new {@code ComputeBoundsAction}.
     
    6268        putValue(SHORT_DESCRIPTION, tr("Generate Imagery XML bounds for the selection"));
    6369        putValue(NAME, ACTION_NAME);
    64         try {
    65             putValue(SMALL_ICON, XML_ICON_24);
    66         } catch (Exception e) {
    67             Main.error(e);
    68         }
     70        new ImageProvider("xml_24.png").getResource().attachImageIcon(this, true);
    6971        setEnabled(false);
    7072
     
    186188
    187189    protected static final String getImagery(String ... entries) {
     190        String version = "UNKNOWN";
     191        try {
     192            Properties p = new Properties();
     193            p.load(ComputeBoundsAction.class.getResourceAsStream("/REVISION"));
     194            version = p.getProperty("Revision");
     195        } catch(Exception e) {
     196        }
    188197        StringBuilder result = new StringBuilder();
    189198        result.append("<?xml version=\"1.0\" encoding=\"").append(ENCODING).append("\" ?>\n");
    190         result.append("<!-- Generated with JOSM Imagery XML Plugin version ").append(PLUGIN_VERSION).append(" -->\n");
     199        result.append("<!-- Generated with JOSM Imagery XML Plugin version ").append(version).append(" -->\n");
    191200        result.append("<imagery xmlns=\"").append(XML_NAMESPACE).append("\">\n");
    192201        for (String entry : entries) {
     
    200209        return getEntry(p.get(KEY_NAME), p.get(KEY_TYPE), p.get(KEY_DEFAULT), p.get(KEY_URL), bounds, p.get(KEY_PROJECTIONS),
    201210                p.get(KEY_LOGO_URL), p.get(KEY_EULA), p.get(KEY_ATTR_TEXT), p.get(KEY_ATTR_URL),  p.get(KEY_TERMS_TEXT),
    202                 p.get(KEY_TERMS_URL), p.get(KEY_COUNTRY_CODE), p.get(KEY_MAX_ZOOM), p.get(KEY_MIN_ZOOM));
     211                p.get(KEY_TERMS_URL), p.get(KEY_COUNTRY_CODE), p.get(KEY_MAX_ZOOM), p.get(KEY_MIN_ZOOM), p.get(KEY_ID),
     212                p.get(KEY_DATE));
    203213    }
    204214
     
    209219    protected static final String getEntry(String name, String type, String def, String url, String bounds, String projections,
    210220            String logoURL, String eula, String attributionText, String attributionUrl, String termsText, String termsUrl,
    211             String countryCode, String maxZoom, String minZoom) {
     221            String countryCode, String maxZoom, String minZoom, String id, String date) {
    212222        StringBuilder result = new StringBuilder();
    213223        result.append("    <entry>\n"+
     
    235245            result.append(EIGHT_SP + simpleTag(XML_DEFAULT, def) + "\n");
    236246        }
     247        if (isSet(id)) {
     248            result.append(EIGHT_SP + simpleTag(XML_ID, id, false) + "\n");
     249        }
     250        if (isSet(date)) {
     251            result.append(EIGHT_SP + simpleTag(XML_DATE, date, false) + "\n");
     252        }
    237253        if (isSet(eula)) {
    238254            result.append(EIGHT_SP + mandatoryTag(XML_EULA, encodeUrl(eula), false) + "\n");
  • applications/editors/josm/plugins/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/actions/EditEntriesAction.java

    r32489 r33272  
    2020import org.openstreetmap.josm.plugins.imageryxmlbounds.XmlBoundsLayer;
    2121import org.openstreetmap.josm.plugins.imageryxmlbounds.data.XmlBoundsConverter;
     22import org.openstreetmap.josm.tools.ImageProvider;
    2223
    2324/**
     
    4142        putValue(SHORT_DESCRIPTION, tr("edit bounds for selected defaults"));
    4243        putValue(NAME, ACTION_NAME);
    43         try {
    44             putValue(SMALL_ICON, XML_ICON_24);
    45         } catch (Exception ex) {
    46             Main.error(ex);
    47         }
     44        new ImageProvider("xml_24.png").getResource().attachImageIcon(this, true);
    4845        this.defaultModel = defaultModel;
    4946        this.defaultTable = defaultTable;
  • applications/editors/josm/plugins/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/data/XmlBoundsConverter.java

    r30735 r33272  
    121121        safePut(osmImagery, KEY_DEFAULT, imagery.isDefaultEntry());
    122122        safePut(osmImagery, KEY_URL, imagery.getUrl());
     123        safePut(osmImagery, KEY_ID, imagery.getId());
     124        safePut(osmImagery, KEY_DATE, imagery.getDate());
    123125        safePut(osmImagery, KEY_PROJECTIONS, imagery.getServerProjections());
    124126        safePut(osmImagery, KEY_EULA, imagery.getEulaAcceptanceRequired());
Note: See TracChangeset for help on using the changeset viewer.