Changeset 33272 in osm for applications/editors/josm/plugins/imagery-xml-bounds/src/org/openstreetmap
- Timestamp:
- 2017-04-21T23:09:17+02:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/XmlBoundsConstants.java
r30735 r33272 7 7 8 8 import org.openstreetmap.josm.actions.ExtensionFileFilter; 9 import org.openstreetmap.josm.tools.ImageProvider;10 9 11 10 /** … … 15 14 */ 16 15 public interface XmlBoundsConstants { 17 18 /**19 * Plugin version.20 */21 public static final String PLUGIN_VERSION = "1.3";22 16 23 17 /** … … 42 36 /** XML url tag */ 43 37 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"; 44 42 /** XML default tag */ 45 43 public static final String XML_DEFAULT = "default"; … … 78 76 public static final String KEY_TYPE = PREFIX + XML_TYPE; 79 77 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; 80 80 public static final String KEY_DEFAULT = PREFIX + XML_DEFAULT; 81 81 public static final String KEY_EULA = PREFIX + XML_EULA; … … 106 106 public static final ExtensionFileFilter FILE_FILTER = new ExtensionFileFilter( 107 107 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");118 108 } -
applications/editors/josm/plugins/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/XmlBoundsLayer.java
r32489 r33272 22 22 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener; 23 23 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 24 import org.openstreetmap.josm.tools.ImageProvider; 24 25 import org.openstreetmap.josm.plugins.imageryxmlbounds.actions.BoundsLayerSaveAction; 25 26 import org.openstreetmap.josm.plugins.imageryxmlbounds.actions.BoundsLayerSaveAsAction; … … 95 96 @Override 96 97 public Icon getIcon() { 97 return XML_ICON_16;98 return ImageProvider.get("xml_24.png"); 98 99 } 99 100 -
applications/editors/josm/plugins/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/actions/ComputeBoundsAction.java
r30735 r33272 5 5 6 6 import java.awt.event.ActionEvent; 7 import java.io.InputStream; 8 import java.lang.Exception; 9 import java.math.RoundingMode; 7 10 import java.text.DecimalFormat; 8 11 import java.text.DecimalFormatSymbols; … … 15 18 import java.util.Locale; 16 19 import java.util.Map; 20 import java.util.Properties; 17 21 import java.util.Set; 18 22 … … 28 32 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 29 33 import org.openstreetmap.josm.plugins.imageryxmlbounds.XmlBoundsConstants; 34 import org.openstreetmap.josm.tools.ImageProvider; 30 35 31 36 /** … … 36 41 public class ComputeBoundsAction extends AbstractAction implements XmlBoundsConstants { 37 42 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)); 39 44 40 45 protected static final String ACTION_NAME = tr("XML Imagery Bounds"); … … 45 50 private final Set<Way> closedWays; 46 51 52 static { DF.setRoundingMode(RoundingMode.CEILING); } 47 53 /** 48 54 * Constructs a new {@code ComputeBoundsAction}. … … 62 68 putValue(SHORT_DESCRIPTION, tr("Generate Imagery XML bounds for the selection")); 63 69 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); 69 71 setEnabled(false); 70 72 … … 186 188 187 189 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 } 188 197 StringBuilder result = new StringBuilder(); 189 198 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"); 191 200 result.append("<imagery xmlns=\"").append(XML_NAMESPACE).append("\">\n"); 192 201 for (String entry : entries) { … … 200 209 return getEntry(p.get(KEY_NAME), p.get(KEY_TYPE), p.get(KEY_DEFAULT), p.get(KEY_URL), bounds, p.get(KEY_PROJECTIONS), 201 210 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)); 203 213 } 204 214 … … 209 219 protected static final String getEntry(String name, String type, String def, String url, String bounds, String projections, 210 220 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) { 212 222 StringBuilder result = new StringBuilder(); 213 223 result.append(" <entry>\n"+ … … 235 245 result.append(EIGHT_SP + simpleTag(XML_DEFAULT, def) + "\n"); 236 246 } 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 } 237 253 if (isSet(eula)) { 238 254 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 20 20 import org.openstreetmap.josm.plugins.imageryxmlbounds.XmlBoundsLayer; 21 21 import org.openstreetmap.josm.plugins.imageryxmlbounds.data.XmlBoundsConverter; 22 import org.openstreetmap.josm.tools.ImageProvider; 22 23 23 24 /** … … 41 42 putValue(SHORT_DESCRIPTION, tr("edit bounds for selected defaults")); 42 43 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); 48 45 this.defaultModel = defaultModel; 49 46 this.defaultTable = defaultTable; -
applications/editors/josm/plugins/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/data/XmlBoundsConverter.java
r30735 r33272 121 121 safePut(osmImagery, KEY_DEFAULT, imagery.isDefaultEntry()); 122 122 safePut(osmImagery, KEY_URL, imagery.getUrl()); 123 safePut(osmImagery, KEY_ID, imagery.getId()); 124 safePut(osmImagery, KEY_DATE, imagery.getDate()); 123 125 safePut(osmImagery, KEY_PROJECTIONS, imagery.getServerProjections()); 124 126 safePut(osmImagery, KEY_EULA, imagery.getEulaAcceptanceRequired());
Note:
See TracChangeset
for help on using the changeset viewer.