Changeset 4874 in josm for trunk/src/org/openstreetmap/josm/io
- Timestamp:
- 2012-01-26T21:52:34+01:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/io
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/GpxImporter.java
r4759 r4874 6 6 import java.io.File; 7 7 import java.io.FileInputStream; 8 import java.io.FileNotFoundException;9 8 import java.io.IOException; 10 9 import java.io.InputStream; … … 12 11 13 12 import javax.swing.JOptionPane; 14 import javax.swing.SwingUtilities;15 13 16 14 import org.openstreetmap.josm.Main; … … 24 22 public class GpxImporter extends FileImporter { 25 23 26 protected class GpxImporterData { 24 protected static class GpxImporterData { 27 25 public GpxLayer gpxLayer; 28 26 public MarkerLayer markerLayer; … … 59 57 60 58 public GpxImporterData loadLayers(InputStream is, final File associatedFile, 61 59 final String gpxLayerName, String markerLayerName, ProgressMonitor progressMonitor) throws IOException { 62 60 final GpxImporterData data = new GpxImporterData(); 63 61 try { -
trunk/src/org/openstreetmap/josm/io/imagery/ImageryReader.java
r4713 r4874 30 30 private String source; 31 31 32 private enum State { 32 private enum State { 33 33 INIT, // initial state, should always be at the bottom of the stack 34 34 IMAGERY, // inside the imagery element … … 63 63 } 64 64 65 private class Parser extends DefaultHandler { 65 private static class Parser extends DefaultHandler { 66 66 private StringBuffer accumulator = new StringBuffer(); 67 67 … … 97 97 State newState = null; 98 98 switch (states.peek()) { 99 100 101 102 103 104 105 106 107 108 109 110 111 112 99 case INIT: 100 if (qName.equals("imagery")) { 101 newState = State.IMAGERY; 102 } 103 break; 104 case IMAGERY: 105 if (qName.equals("entry")) { 106 entry = new ImageryInfo(); 107 skipEntry = false; 108 newState = State.ENTRY; 109 } 110 break; 111 case ENTRY: 112 if (Arrays.asList(new String[] { 113 113 "name", 114 114 "type", … … 126 126 "country-code", 127 127 "icon", 128 129 130 131 132 133 134 atts.getValue("min-lon") + "," + 135 atts.getValue("max-lat") + "," + 136 atts.getValue("max-lon"), ","); 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 128 }).contains(qName)) { 129 newState = State.ENTRY_ATTRIBUTE; 130 } else if (qName.equals("bounds")) { 131 try { 132 bounds = new ImageryBounds( 133 atts.getValue("min-lat") + "," + 134 atts.getValue("min-lon") + "," + 135 atts.getValue("max-lat") + "," + 136 atts.getValue("max-lon"), ","); 137 } catch (IllegalArgumentException e) { 138 break; 139 } 140 newState = State.BOUNDS; 141 } else if (qName.equals("projections")) { 142 projections = new ArrayList<String>(); 143 newState = State.PROJECTIONS; 144 } 145 break; 146 case BOUNDS: 147 if (qName.equals("shape")) { 148 shape = new Shape(); 149 newState = State.SHAPE; 150 } 151 break; 152 case SHAPE: 153 if (qName.equals("point")) { 154 try { 155 shape.addPoint(atts.getValue("lat"), atts.getValue("lon")); 156 } catch (IllegalArgumentException e) { 157 break; 158 } 159 } 160 break; 161 case PROJECTIONS: 162 if (qName.equals("code")) { 163 newState = State.CODE; 164 } 165 break; 166 166 } 167 167 /** … … 189 189 public void endElement(String namespaceURI, String qName, String rqName) { 190 190 switch (states.pop()) { 191 case INIT: 192 throw new RuntimeException("parsing error: more closing than opening elements"); 193 case ENTRY: 194 if (qName.equals("entry")) { 195 if (!skipEntry) { 196 entries.add(entry); 191 case INIT: 192 throw new RuntimeException("parsing error: more closing than opening elements"); 193 case ENTRY: 194 if (qName.equals("entry")) { 195 if (!skipEntry) { 196 entries.add(entry); 197 } 198 entry = null; 199 } 200 break; 201 case ENTRY_ATTRIBUTE: 202 if (qName.equals("name")) { 203 entry.setName(tr(accumulator.toString())); 204 } else if (qName.equals("type")) { 205 boolean found = false; 206 for (ImageryType type : ImageryType.values()) { 207 if (equal(accumulator.toString(), type.getUrlString())) { 208 entry.setImageryType(type); 209 found = true; 210 break; 197 211 } 198 entry = null; 199 } 200 break; 201 case ENTRY_ATTRIBUTE: 202 if (qName.equals("name")) { 203 entry.setName(tr(accumulator.toString())); 204 } else if (qName.equals("type")) { 205 boolean found = false; 206 for (ImageryType type : ImageryType.values()) { 207 if (equal(accumulator.toString(), type.getUrlString())) { 208 entry.setImageryType(type); 209 found = true; 210 break; 211 } 212 } 213 if (!found) { 214 skipEntry = true; 215 } 216 } else if (qName.equals("default")) { 217 if (accumulator.toString().equals("true")) { 218 entry.setDefaultEntry(true); 219 } else if (accumulator.toString().equals("false")) { 220 entry.setDefaultEntry(false); 221 } else { 222 skipEntry = true; 223 } 224 } else if (qName.equals("url")) { 225 entry.setUrl(accumulator.toString()); 226 } else if (qName.equals("eula")) { 227 entry.setEulaAcceptanceRequired(accumulator.toString()); 228 } else if (qName.equals("min-zoom") || qName.equals("max-zoom")) { 229 Integer val = null; 230 try { 231 val = Integer.parseInt(accumulator.toString()); 232 } catch(NumberFormatException e) { 233 val = null; 234 } 235 if (val == null) { 236 skipEntry = true; 237 } else { 238 if (qName.equals("min-zoom")) { 239 entry.setDefaultMinZoom(val); 240 } else { 241 entry.setDefaultMaxZoom(val); 212 242 } 213 if (!found) { 214 skipEntry = true; 215 } 216 } else if (qName.equals("default")) { 217 if (accumulator.toString().equals("true")) { 218 entry.setDefaultEntry(true); 219 } else if (accumulator.toString().equals("false")) { 220 entry.setDefaultEntry(false); 221 } else { 222 skipEntry = true; 223 } 224 } else if (qName.equals("url")) { 225 entry.setUrl(accumulator.toString()); 226 } else if (qName.equals("eula")) { 227 entry.setEulaAcceptanceRequired(accumulator.toString()); 228 } else if (qName.equals("min-zoom") || qName.equals("max-zoom")) { 229 Integer val = null; 230 try { 231 val = Integer.parseInt(accumulator.toString()); 232 } catch(NumberFormatException e) { 233 val = null; 234 } 235 if (val == null) { 236 skipEntry = true; 237 } else { 238 if (qName.equals("min-zoom")) { 239 entry.setDefaultMinZoom(val); 240 } else { 241 entry.setDefaultMaxZoom(val); 242 } 243 } 244 } else if (qName.equals("attribution-text")) { 245 entry.setAttributionText(accumulator.toString()); 246 } else if (qName.equals("attribution-url")) { 247 entry.setAttributionLinkURL(accumulator.toString()); 248 } else if (qName.equals("logo-image")) { 249 entry.setAttributionImage(accumulator.toString()); 250 } else if (qName.equals("logo-url")) { 251 entry.setAttributionImageURL(accumulator.toString()); 252 } else if (qName.equals("terms-of-use-text")) { 253 entry.setTermsOfUseText(accumulator.toString()); 254 } else if (qName.equals("terms-of-use-url")) { 255 entry.setTermsOfUseURL(accumulator.toString()); 256 } else if (qName.equals("country-code")) { 257 entry.setCountryCode(accumulator.toString()); 258 } else if (qName.equals("icon")) { 259 entry.setIcon(accumulator.toString()); 260 } else { 261 } 262 break; 263 case BOUNDS: 264 entry.setBounds(bounds); 265 bounds = null; 266 break; 267 case SHAPE: 268 bounds.addShape(shape); 269 shape = null; 270 break; 271 case CODE: 272 projections.add(accumulator.toString()); 273 break; 274 case PROJECTIONS: 275 entry.setServerProjections(projections); 276 projections = null; 277 break; 243 } 244 } else if (qName.equals("attribution-text")) { 245 entry.setAttributionText(accumulator.toString()); 246 } else if (qName.equals("attribution-url")) { 247 entry.setAttributionLinkURL(accumulator.toString()); 248 } else if (qName.equals("logo-image")) { 249 entry.setAttributionImage(accumulator.toString()); 250 } else if (qName.equals("logo-url")) { 251 entry.setAttributionImageURL(accumulator.toString()); 252 } else if (qName.equals("terms-of-use-text")) { 253 entry.setTermsOfUseText(accumulator.toString()); 254 } else if (qName.equals("terms-of-use-url")) { 255 entry.setTermsOfUseURL(accumulator.toString()); 256 } else if (qName.equals("country-code")) { 257 entry.setCountryCode(accumulator.toString()); 258 } else if (qName.equals("icon")) { 259 entry.setIcon(accumulator.toString()); 260 } else { 261 } 262 break; 263 case BOUNDS: 264 entry.setBounds(bounds); 265 bounds = null; 266 break; 267 case SHAPE: 268 bounds.addShape(shape); 269 shape = null; 270 break; 271 case CODE: 272 projections.add(accumulator.toString()); 273 break; 274 case PROJECTIONS: 275 entry.setServerProjections(projections); 276 projections = null; 277 break; 278 278 } 279 279 } -
trunk/src/org/openstreetmap/josm/io/session/SessionReader.java
r4868 r4874 407 407 * needed to block the current thread and wait for the result of the modal dialog from EDT. 408 408 */ 409 private class CancelOrContinueDialog { 409 private static class CancelOrContinueDialog { 410 410 411 411 private boolean cancel;
Note:
See TracChangeset
for help on using the changeset viewer.