Changeset 10216 in josm
- Timestamp:
- 2016-05-15T14:48:06+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java
r10181 r10216 234 234 switch (mode) { 235 235 case "problem": 236 TestError error = Main.map.validatorDialog.getSelectedError(); 237 if (error == null) 238 return null; 239 ((ValidatorBoundingXYVisitor) v).visit(error); 240 if (v.getBounds() == null) 241 return null; 242 v.enlargeBoundingBox(Main.pref.getDouble("validator.zoom-enlarge-bbox", 0.0002)); 243 break; 236 return modeProblem(v); 244 237 case "data": 245 for (Layer l : Main.map.mapView.getAllLayers()) { 246 l.visitBoundingBox(v); 247 } 248 break; 238 return modeData(v); 249 239 case "layer": 250 // try to zoom to the first selected layer 251 Layer l = getFirstSelectedLayer(); 252 if (l == null) 253 return null; 254 l.visitBoundingBox(v); 255 break; 240 return modeLayer(v); 256 241 case "selection": 257 242 case "conflict": 258 Collection<OsmPrimitive> sel = new HashSet<>(); 259 if ("selection".equals(mode)) { 260 sel = getCurrentDataSet().getSelected(); 243 return modeSelectionOrConflict(v); 244 case "download": 245 return modeDownload(v); 246 default: 247 return v; 248 } 249 } 250 251 private static BoundingXYVisitor modeProblem(BoundingXYVisitor v) { 252 TestError error = Main.map.validatorDialog.getSelectedError(); 253 if (error == null) 254 return null; 255 ((ValidatorBoundingXYVisitor) v).visit(error); 256 if (v.getBounds() == null) 257 return null; 258 v.enlargeBoundingBox(Main.pref.getDouble("validator.zoom-enlarge-bbox", 0.0002)); 259 return v; 260 } 261 262 private static BoundingXYVisitor modeData(BoundingXYVisitor v) { 263 for (Layer l : Main.map.mapView.getAllLayers()) { 264 l.visitBoundingBox(v); 265 } 266 return v; 267 } 268 269 private BoundingXYVisitor modeLayer(BoundingXYVisitor v) { 270 // try to zoom to the first selected layer 271 Layer l = getFirstSelectedLayer(); 272 if (l == null) 273 return null; 274 l.visitBoundingBox(v); 275 return v; 276 } 277 278 private BoundingXYVisitor modeSelectionOrConflict(BoundingXYVisitor v) { 279 Collection<OsmPrimitive> sel = new HashSet<>(); 280 if ("selection".equals(mode)) { 281 sel = getCurrentDataSet().getSelected(); 282 } else { 283 Conflict<? extends OsmPrimitive> c = Main.map.conflictDialog.getSelectedConflict(); 284 if (c != null) { 285 sel.add(c.getMy()); 286 } else if (Main.map.conflictDialog.getConflicts() != null) { 287 sel = Main.map.conflictDialog.getConflicts().getMyConflictParties(); 288 } 289 } 290 if (sel.isEmpty()) { 291 JOptionPane.showMessageDialog( 292 Main.parent, 293 "selection".equals(mode) ? tr("Nothing selected to zoom to.") : tr("No conflicts to zoom to"), 294 tr("Information"), 295 JOptionPane.INFORMATION_MESSAGE); 296 return null; 297 } 298 for (OsmPrimitive osm : sel) { 299 osm.accept(v); 300 } 301 302 // Increase the bounding box by up to 100% to give more context. 303 v.enlargeBoundingBoxLogarithmically(100); 304 // Make the bounding box at least 100 meter wide to 305 // ensure reasonable zoom level when zooming onto single nodes. 306 v.enlargeToMinSize(Main.pref.getDouble("zoom_to_selection_min_size_in_meter", 100)); 307 return v; 308 } 309 310 private BoundingXYVisitor modeDownload(BoundingXYVisitor v) { 311 if (lastZoomTime > 0 && System.currentTimeMillis() - lastZoomTime > Main.pref.getLong("zoom.bounds.reset.time", 10L*1000L)) { 312 lastZoomTime = -1; 313 } 314 final DataSet dataset = getCurrentDataSet(); 315 if (dataset != null) { 316 List<DataSource> dataSources = new ArrayList<>(dataset.getDataSources()); 317 int s = dataSources.size(); 318 if (s > 0) { 319 if (lastZoomTime == -1 || lastZoomArea == -1 || lastZoomArea > s) { 320 lastZoomArea = s-1; 321 v.visit(dataSources.get(lastZoomArea).bounds); 322 } else if (lastZoomArea > 0) { 323 lastZoomArea -= 1; 324 v.visit(dataSources.get(lastZoomArea).bounds); 325 } else { 326 lastZoomArea = -1; 327 Area sourceArea = Main.main.getCurrentDataSet().getDataSourceArea(); 328 if (sourceArea != null) { 329 v.visit(new Bounds(sourceArea.getBounds2D())); 330 } 331 } 332 lastZoomTime = System.currentTimeMillis(); 261 333 } else { 262 Conflict<? extends OsmPrimitive> c = Main.map.conflictDialog.getSelectedConflict(); 263 if (c != null) { 264 sel.add(c.getMy()); 265 } else if (Main.map.conflictDialog.getConflicts() != null) { 266 sel = Main.map.conflictDialog.getConflicts().getMyConflictParties(); 267 } 334 lastZoomTime = -1; 335 lastZoomArea = -1; 268 336 } 269 if (sel.isEmpty()) {270 JOptionPane.showMessageDialog(271 Main.parent,272 "selection".equals(mode) ? tr("Nothing selected to zoom to.") : tr("No conflicts to zoom to"),273 tr("Information"),274 JOptionPane.INFORMATION_MESSAGE);275 return null;276 }277 for (OsmPrimitive osm : sel) {278 osm.accept(v);279 }280 281 // Increase the bounding box by up to 100% to give more context.282 v.enlargeBoundingBoxLogarithmically(100);283 // Make the bounding box at least 100 meter wide to284 // ensure reasonable zoom level when zooming onto single nodes.285 v.enlargeToMinSize(Main.pref.getDouble("zoom_to_selection_min_size_in_meter", 100));286 break;287 case "download":288 289 if (lastZoomTime > 0 && System.currentTimeMillis() - lastZoomTime > Main.pref.getLong("zoom.bounds.reset.time", 10L*1000L)) {290 lastZoomTime = -1;291 }292 final DataSet dataset = getCurrentDataSet();293 if (dataset != null) {294 List<DataSource> dataSources = new ArrayList<>(dataset.getDataSources());295 int s = dataSources.size();296 if (s > 0) {297 if (lastZoomTime == -1 || lastZoomArea == -1 || lastZoomArea > s) {298 lastZoomArea = s-1;299 v.visit(dataSources.get(lastZoomArea).bounds);300 } else if (lastZoomArea > 0) {301 lastZoomArea -= 1;302 v.visit(dataSources.get(lastZoomArea).bounds);303 } else {304 lastZoomArea = -1;305 Area sourceArea = Main.main.getCurrentDataSet().getDataSourceArea();306 if (sourceArea != null) {307 v.visit(new Bounds(sourceArea.getBounds2D()));308 }309 }310 lastZoomTime = System.currentTimeMillis();311 } else {312 lastZoomTime = -1;313 lastZoomArea = -1;314 }315 }316 break;317 337 } 318 338 return v; -
trunk/src/org/openstreetmap/josm/actions/ImageryAdjustAction.java
r10152 r10216 118 118 } 119 119 KeyEvent kev = (KeyEvent) event; 120 int dx = 0, dy = 0; 120 int dx = 0; 121 int dy = 0; 121 122 switch (kev.getKeyCode()) { 122 123 case KeyEvent.VK_UP : dy = +1; break; … … 124 125 case KeyEvent.VK_LEFT : dx = -1; break; 125 126 case KeyEvent.VK_RIGHT : dx = +1; break; 127 default: // Do nothing 126 128 } 127 129 if (dx != 0 || dy != 0) { -
trunk/src/org/openstreetmap/josm/actions/PasteAction.java
r8513 r10216 64 64 public void pasteData(PrimitiveDeepCopy pasteBuffer, Layer source, ActionEvent e) { 65 65 /* Find the middle of the pasteBuffer area */ 66 double maxEast = -1E100, minEast = 1E100, maxNorth = -1E100, minNorth = 1E100; 66 double maxEast = -1E100; 67 double minEast = 1E100; 68 double maxNorth = -1E100; 69 double minNorth = 1E100; 67 70 boolean incomplete = false; 68 71 for (PrimitiveData data : pasteBuffer.getAll()) { … … 92 95 93 96 // Allow to cancel paste if there are incomplete primitives 94 if (incomplete) { 95 if (!confirmDeleteIncomplete())return;97 if (incomplete && !confirmDeleteIncomplete()) { 98 return; 96 99 } 97 100 … … 158 161 for (RelationMemberData member: ((RelationData) data).getMembers()) { 159 162 OsmPrimitiveType memberType = member.getMemberType(); 160 Long newId = null;163 Long newId; 161 164 switch (memberType) { 162 165 case NODE: … … 169 172 newId = newRelationIds.get(member.getMemberId()); 170 173 break; 174 default: throw new AssertionError(); 171 175 } 172 176 if (newId != null) { … … 183 187 } 184 188 185 pr otectedboolean confirmDeleteIncomplete() {189 private static boolean confirmDeleteIncomplete() { 186 190 ExtendedDialog ed = new ExtendedDialog(Main.parent, 187 191 tr("Delete incomplete members?"), -
trunk/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java
r10163 r10216 135 135 } 136 136 } catch (SecurityException e) { 137 // Ignore exception138 137 if (Main.isTraceEnabled()) { 139 138 Main.trace(e.getMessage()); … … 165 164 } 166 165 167 pr otectedstatic Collection<String> getCustomUrls(SourceEditor.SourcePrefHelper helper) {166 private static Collection<String> getCustomUrls(SourceEditor.SourcePrefHelper helper) { 168 167 Set<String> set = new TreeSet<>(); 169 168 for (SourceEntry entry : helper.get()) { … … 221 220 } 222 221 223 pr otectedstatic <T> void appendCollection(StringBuilder text, String label, Collection<T> col) {222 private static <T> void appendCollection(StringBuilder text, String label, Collection<T> col) { 224 223 if (!col.isEmpty()) { 225 224 text.append(label+":\n"); … … 267 266 case 1: ta.copyToClippboard(); break; 268 267 case 2: BugReportSender.reportBug(reportHeader); break; 268 default: // Do nothing 269 269 } 270 270 } -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadReferrersTask.java
r10212 r10216 184 184 if (canceled) 185 185 return; 186 String msg = "";186 String msg; 187 187 switch(entry.getValue()) { 188 188 case NODE: msg = tr("({0}/{1}) Loading parents of node {2}", i+1, children.size(), entry.getKey()); break; 189 189 case WAY: msg = tr("({0}/{1}) Loading parents of way {2}", i+1, children.size(), entry.getKey()); break; 190 190 case RELATION: msg = tr("({0}/{1}) Loading parents of relation {2}", i+1, children.size(), entry.getKey()); break; 191 default: throw new AssertionError(); 191 192 } 192 193 progressMonitor.subTask(msg); -
trunk/src/org/openstreetmap/josm/command/ChangeCommand.java
r9371 r10216 76 76 @Override 77 77 public String getDescriptionText() { 78 String msg = "";78 String msg; 79 79 switch(OsmPrimitiveType.from(osm)) { 80 80 case NODE: msg = marktr("Change node {0}"); break; 81 81 case WAY: msg = marktr("Change way {0}"); break; 82 82 case RELATION: msg = marktr("Change relation {0}"); break; 83 default: throw new AssertionError(); 83 84 } 84 85 return tr(msg, osm.getDisplayName(DefaultNameFormatter.getInstance())); -
trunk/src/org/openstreetmap/josm/command/ChangePropertyCommand.java
r9371 r10216 161 161 case WAY: msg = marktr("Remove \"{0}\" for way ''{1}''"); break; 162 162 case RELATION: msg = marktr("Remove \"{0}\" for relation ''{1}''"); break; 163 default: throw new AssertionError(); 163 164 } 164 165 text = tr(msg, entry.getKey(), primitive.getDisplayName(DefaultNameFormatter.getInstance())); … … 168 169 case WAY: msg = marktr("Set {0}={1} for way ''{2}''"); break; 169 170 case RELATION: msg = marktr("Set {0}={1} for relation ''{2}''"); break; 171 default: throw new AssertionError(); 170 172 } 171 173 text = tr(msg, entry.getKey(), entry.getValue(), primitive.getDisplayName(DefaultNameFormatter.getInstance())); -
trunk/src/org/openstreetmap/josm/command/DeleteCommand.java
r10174 r10216 160 160 } 161 161 162 private Set<OsmPrimitiveType> getTypesToDelete() { 163 Set<OsmPrimitiveType> typesToDelete = EnumSet.noneOf(OsmPrimitiveType.class); 162 private EnumSet<OsmPrimitiveType> getTypesToDelete() { 163 EnumSet<OsmPrimitiveType> typesToDelete = EnumSet.noneOf(OsmPrimitiveType.class); 164 164 for (OsmPrimitive osm : toDelete) { 165 165 typesToDelete.add(OsmPrimitiveType.from(osm)); … … 172 172 if (toDelete.size() == 1) { 173 173 OsmPrimitive primitive = toDelete.iterator().next(); 174 String msg = "";174 String msg; 175 175 switch(OsmPrimitiveType.from(primitive)) { 176 176 case NODE: msg = marktr("Delete node {0}"); break; 177 177 case WAY: msg = marktr("Delete way {0}"); break; 178 178 case RELATION:msg = marktr("Delete relation {0}"); break; 179 default: throw new AssertionError(); 179 180 } 180 181 … … 182 183 } else { 183 184 Set<OsmPrimitiveType> typesToDelete = getTypesToDelete(); 184 String msg = "";185 String msg; 185 186 if (typesToDelete.size() > 1) { 186 187 msg = trn("Delete {0} object", "Delete {0} objects", toDelete.size(), toDelete.size()); … … 191 192 case WAY: msg = trn("Delete {0} way", "Delete {0} ways", toDelete.size(), toDelete.size()); break; 192 193 case RELATION: msg = trn("Delete {0} relation", "Delete {0} relations", toDelete.size(), toDelete.size()); break; 194 default: throw new AssertionError(); 193 195 } 194 196 } -
trunk/src/org/openstreetmap/josm/command/conflict/ModifiedConflictResolveCommand.java
r9371 r10216 17 17 /** 18 18 * Represents the resolution of a conflict between the modified flag of two {@link OsmPrimitive}s. 19 * 20 * 19 * @since 2624 21 20 */ 22 21 public class ModifiedConflictResolveCommand extends ConflictResolveCommand { … … 35 34 @Override 36 35 public String getDescriptionText() { 37 String msg = "";36 String msg; 38 37 switch(OsmPrimitiveType.from(conflict.getMy())) { 39 38 case NODE: msg = marktr("Set the ''modified'' flag for node {0}"); break; 40 39 case WAY: msg = marktr("Set the ''modified'' flag for way {0}"); break; 41 40 case RELATION: msg = marktr("Set the ''modified'' flag for relation {0}"); break; 41 default: throw new AssertionError(); 42 42 } 43 43 return tr(msg, conflict.getMy().getId()); -
trunk/src/org/openstreetmap/josm/command/conflict/VersionConflictResolveCommand.java
r9371 r10216 17 17 /** 18 18 * Represents the resolution of a version conflict between two {@link OsmPrimitive}s. 19 * 20 * 19 * @since 1622 21 20 */ 22 21 public class VersionConflictResolveCommand extends ConflictResolveCommand { … … 35 34 @Override 36 35 public String getDescriptionText() { 37 String msg = "";36 String msg; 38 37 switch(OsmPrimitiveType.from(conflict.getMy())) { 39 38 case NODE: msg = marktr("Resolve version conflict for node {0}"); break; 40 39 case WAY: msg = marktr("Resolve version conflict for way {0}"); break; 41 40 case RELATION: msg = marktr("Resolve version conflict for relation {0}"); break; 41 default: throw new AssertionError(); 42 42 } 43 43 return tr(msg, conflict.getMy().getId()); -
trunk/src/org/openstreetmap/josm/data/CustomConfigurator.java
r10212 r10216 192 192 */ 193 193 public static void messageBox(String type, String text) { 194 if (type == null || type.isEmpty()) type = "plain"; 195 196 switch (type.charAt(0)) { 194 char c = (type == null || type.isEmpty() ? "plain" : type).charAt(0); 195 switch (c) { 197 196 case 'i': JOptionPane.showMessageDialog(Main.parent, text, tr("Information"), JOptionPane.INFORMATION_MESSAGE); break; 198 197 case 'w': JOptionPane.showMessageDialog(Main.parent, text, tr("Warning"), JOptionPane.WARNING_MESSAGE); break; … … 200 199 case 'q': JOptionPane.showMessageDialog(Main.parent, text, tr("Question"), JOptionPane.QUESTION_MESSAGE); break; 201 200 case 'p': JOptionPane.showMessageDialog(Main.parent, text, tr("Message"), JOptionPane.PLAIN_MESSAGE); break; 201 default: Main.warn("Unsupported messageBox type: " + c); 202 202 } 203 203 } -
trunk/src/org/openstreetmap/josm/data/osm/RelationMemberData.java
r9891 r10216 4 4 import java.io.Serializable; 5 5 import java.util.Objects; 6 7 import org.openstreetmap.josm.tools.CheckParameterUtil; 6 8 7 9 public class RelationMemberData implements PrimitiveId, Serializable { … … 12 14 private final OsmPrimitiveType memberType; 13 15 16 /** 17 * Constructs a new {@code RelationMemberData}. 18 * @param role member role - can be null 19 * @param type member type - cannot be null 20 * @param id member id - cannot be null 21 * @throws IllegalArgumentException is type or id is null 22 */ 14 23 public RelationMemberData(String role, OsmPrimitiveType type, long id) { 24 CheckParameterUtil.ensureParameterNotNull(type, "type"); 15 25 this.role = role == null ? "" : role; 16 26 this.memberType = type; … … 18 28 } 19 29 30 /** 31 * Constructs a new {@code RelationMemberData}. 32 * @param role member role - can be null 33 * @param primitive member type and id - cannot be null 34 * @throws NullPointerException if primitive is null 35 */ 20 36 public RelationMemberData(String role, PrimitiveId primitive) { 21 37 this(role, primitive.getType(), primitive.getUniqueId()); 22 38 } 23 39 40 /** 41 * Get member id. 42 * @return member id 43 */ 24 44 public long getMemberId() { 25 45 return memberId; 26 46 } 27 47 48 /** 49 * Get member role. 50 * @return member role 51 */ 28 52 public String getRole() { 29 53 return role; 30 54 } 31 55 56 /** 57 * Get member type. 58 * @return member type 59 */ 32 60 public OsmPrimitiveType getMemberType() { 33 61 return memberType; 34 62 } 35 63 64 /** 65 * Determines if this member has a role. 66 * @return {@code true} if this member has a role 67 */ 36 68 public boolean hasRole() { 37 69 return !"".equals(role); -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
r10181 r10216 1091 1091 via = w; 1092 1092 } 1093 break; 1094 default: // Do nothing 1093 1095 } 1094 1096 } else if (m.isNode()) { -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/relations/Multipolygon.java
r9952 r10216 264 264 } 265 265 total++; 266 break; 267 default: // Do nothing 266 268 } 267 269 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
r9997 r10216 211 211 case "K:": 212 212 ignoreDataTag.add(Tag.ofString(line)); 213 break; 214 default: 215 Main.warn("Unsupported TagChecker key: " + key); 213 216 } 214 217 } else if (tagcheckerfile) { -
trunk/src/org/openstreetmap/josm/gui/history/RelationMemberListTableCellRenderer.java
r10021 r10216 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.Color;7 6 import java.awt.Component; 8 7 import java.util.EnumMap; … … 48 47 49 48 protected void renderRole(Item diffItem) { 50 String text = "";51 Color bgColor = diffItem.state.getColor();52 49 RelationMemberData member = (RelationMemberData) diffItem.value; 53 text = member == null ? "" : member.getRole(); 50 String text = member == null ? "" : member.getRole(); 54 51 setText(text); 55 52 setToolTipText(text); 56 GuiHelper.setBackgroundReadable(this, bgColor);53 GuiHelper.setBackgroundReadable(this, diffItem.state.getColor()); 57 54 } 58 55 59 56 protected void renderPrimitive(Item diffItem) { 60 57 String text = ""; 61 Color bgColor = diffItem.state.getColor();62 58 RelationMemberData member = (RelationMemberData) diffItem.value; 63 text = "";64 59 if (member != null) { 65 60 switch(member.getMemberType()) { … … 67 62 case WAY: text = tr("Way {0}", member.getMemberId()); break; 68 63 case RELATION: text = tr("Relation {0}", member.getMemberId()); break; 64 default: throw new AssertionError(); 69 65 } 70 66 } 71 67 setText(text); 72 68 setToolTipText(text); 73 GuiHelper.setBackgroundReadable(this, bgColor);69 GuiHelper.setBackgroundReadable(this, diffItem.state.getColor()); 74 70 } 75 71 … … 89 85 renderPrimitive(member); 90 86 break; 87 default: // Do nothing 91 88 } 92 89 -
trunk/src/org/openstreetmap/josm/io/ChangesetQuery.java
r10194 r10216 400 400 else if (dates.length == 2) 401 401 return new Date[]{parseDate(dates[0], "time"), parseDate(dates[1], "time")}; 402 return n ull;402 return new Date[]{}; 403 403 } 404 404 … … 447 447 csQuery.closedAfterAndCreatedBefore(dates[0], dates[1]); 448 448 break; 449 default: 450 Main.warn("Unable to parse time: " + entry.getValue()); 449 451 } 450 452 break; -
trunk/src/org/openstreetmap/josm/io/GpxReader.java
r10212 r10216 45 45 46 46 private enum State { 47 init,48 gpx,49 metadata,50 wpt,51 rte,52 trk,53 ext,54 author,55 link,56 trkseg,57 copyright47 INIT, 48 GPX, 49 METADATA, 50 WPT, 51 RTE, 52 TRK, 53 EXT, 54 AUTHOR, 55 LINK, 56 TRKSEG, 57 COPYRIGHT 58 58 } 59 59 … … 72 72 private WayPoint currentWayPoint; 73 73 74 private State currentState = State. init;74 private State currentState = State.INIT; 75 75 76 76 private GpxLink currentLink; … … 108 108 elements.push(localName); 109 109 switch(currentState) { 110 case init:110 case INIT: 111 111 states.push(currentState); 112 currentState = State. gpx;112 currentState = State.GPX; 113 113 data.creator = atts.getValue("creator"); 114 114 version = atts.getValue("version"); … … 120 120 } 121 121 break; 122 case gpx:122 case GPX: 123 123 switch (localName) { 124 124 case "metadata": 125 125 states.push(currentState); 126 currentState = State. metadata;126 currentState = State.METADATA; 127 127 break; 128 128 case "wpt": 129 129 states.push(currentState); 130 currentState = State. wpt;130 currentState = State.WPT; 131 131 currentWayPoint = new WayPoint(parseLatLon(atts)); 132 132 break; 133 133 case "rte": 134 134 states.push(currentState); 135 currentState = State. rte;135 currentState = State.RTE; 136 136 currentRoute = new GpxRoute(); 137 137 break; 138 138 case "trk": 139 139 states.push(currentState); 140 currentState = State. trk;140 currentState = State.TRK; 141 141 currentTrack = new ArrayList<>(); 142 142 currentTrackAttr = new HashMap<>(); … … 144 144 case "extensions": 145 145 states.push(currentState); 146 currentState = State. ext;146 currentState = State.EXT; 147 147 currentExtensions = new Extensions(); 148 148 break; … … 151 151 nokiaSportsTrackerBug = true; 152 152 } 153 } 154 break; 155 case metadata: 153 break; 154 default: // Do nothing 155 } 156 break; 157 case METADATA: 156 158 switch (localName) { 157 159 case "author": 158 160 states.push(currentState); 159 currentState = State. author;161 currentState = State.AUTHOR; 160 162 break; 161 163 case "extensions": 162 164 states.push(currentState); 163 currentState = State. ext;165 currentState = State.EXT; 164 166 currentExtensions = new Extensions(); 165 167 break; 166 168 case "copyright": 167 169 states.push(currentState); 168 currentState = State. copyright;170 currentState = State.COPYRIGHT; 169 171 data.put(META_COPYRIGHT_AUTHOR, atts.getValue("author")); 170 172 break; 171 173 case "link": 172 174 states.push(currentState); 173 currentState = State. link;175 currentState = State.LINK; 174 176 currentLink = new GpxLink(atts.getValue("href")); 175 177 break; … … 180 182 parseCoord(atts.getValue("maxlat")), 181 183 parseCoord(atts.getValue("maxlon")))); 182 } 183 break; 184 case author: 185 switch (localName) { 186 case "link": 187 states.push(currentState); 188 currentState = State.link; 184 break; 185 default: // Do nothing 186 } 187 break; 188 case AUTHOR: 189 switch (localName) { 190 case "link": 191 states.push(currentState); 192 currentState = State.LINK; 189 193 currentLink = new GpxLink(atts.getValue("href")); 190 194 break; 191 195 case "email": 192 196 data.put(META_AUTHOR_EMAIL, atts.getValue("id") + '@' + atts.getValue("domain")); 193 } 194 break; 195 case trk: 197 break; 198 default: // Do nothing 199 } 200 break; 201 case TRK: 196 202 switch (localName) { 197 203 case "trkseg": 198 204 states.push(currentState); 199 currentState = State. trkseg;205 currentState = State.TRKSEG; 200 206 currentTrackSeg = new ArrayList<>(); 201 207 break; 202 208 case "link": 203 209 states.push(currentState); 204 currentState = State. link;210 currentState = State.LINK; 205 211 currentLink = new GpxLink(atts.getValue("href")); 206 212 break; 207 213 case "extensions": 208 214 states.push(currentState); 209 currentState = State. ext;215 currentState = State.EXT; 210 216 currentExtensions = new Extensions(); 211 } 212 break; 213 case trkseg: 217 break; 218 default: // Do nothing 219 } 220 break; 221 case TRKSEG: 214 222 if ("trkpt".equals(localName)) { 215 223 states.push(currentState); 216 currentState = State. wpt;224 currentState = State.WPT; 217 225 currentWayPoint = new WayPoint(parseLatLon(atts)); 218 226 } 219 227 break; 220 case wpt:221 switch (localName) { 222 case "link": 223 states.push(currentState); 224 currentState = State. link;228 case WPT: 229 switch (localName) { 230 case "link": 231 states.push(currentState); 232 currentState = State.LINK; 225 233 currentLink = new GpxLink(atts.getValue("href")); 226 234 break; 227 235 case "extensions": 228 236 states.push(currentState); 229 currentState = State. ext;237 currentState = State.EXT; 230 238 currentExtensions = new Extensions(); 231 239 break; 232 } 233 break; 234 case rte: 235 switch (localName) { 236 case "link": 237 states.push(currentState); 238 currentState = State.link; 240 default: // Do nothing 241 } 242 break; 243 case RTE: 244 switch (localName) { 245 case "link": 246 states.push(currentState); 247 currentState = State.LINK; 239 248 currentLink = new GpxLink(atts.getValue("href")); 240 249 break; 241 250 case "rtept": 242 251 states.push(currentState); 243 currentState = State. wpt;252 currentState = State.WPT; 244 253 currentWayPoint = new WayPoint(parseLatLon(atts)); 245 254 break; 246 255 case "extensions": 247 256 states.push(currentState); 248 currentState = State. ext;257 currentState = State.EXT; 249 258 currentExtensions = new Extensions(); 250 259 break; 251 } 252 break; 260 default: // Do nothing 261 } 262 break; 263 default: // Do nothing 253 264 } 254 265 accumulator.setLength(0); … … 276 287 private Map<String, Object> getAttr() { 277 288 switch (currentState) { 278 case rte: return currentRoute.attr;279 case metadata: return data.attr;280 case wpt: return currentWayPoint.attr;281 case trk: return currentTrackAttr;289 case RTE: return currentRoute.attr; 290 case METADATA: return data.attr; 291 case WPT: return currentWayPoint.attr; 292 case TRK: return currentTrackAttr; 282 293 default: return null; 283 294 } … … 289 300 elements.pop(); 290 301 switch (currentState) { 291 case gpx: // GPX 1.0292 case metadata: // GPX 1.1302 case GPX: // GPX 1.0 303 case METADATA: // GPX 1.1 293 304 switch (localName) { 294 305 case "name": … … 321 332 case "metadata": 322 333 case "gpx": 323 if ((currentState == State. metadata&& "metadata".equals(localName)) ||324 (currentState == State. gpx&& "gpx".equals(localName))) {334 if ((currentState == State.METADATA && "metadata".equals(localName)) || 335 (currentState == State.GPX && "gpx".equals(localName))) { 325 336 convertUrlToLink(data.attr); 326 337 if (currentExtensions != null && !currentExtensions.isEmpty()) { … … 337 348 } 338 349 break; 339 case author:350 case AUTHOR: 340 351 switch (localName) { 341 352 case "author": … … 351 362 data.put(META_AUTHOR_LINK, currentLink); 352 363 break; 353 } 354 break; 355 case copyright: 364 default: // Do nothing 365 } 366 break; 367 case COPYRIGHT: 356 368 switch (localName) { 357 369 case "copyright": … … 364 376 data.put(META_COPYRIGHT_LICENSE, accumulator.toString()); 365 377 break; 366 } 367 break; 368 case link: 378 default: // Do nothing 379 } 380 break; 381 case LINK: 369 382 switch (localName) { 370 383 case "text": … … 380 393 currentState = states.pop(); 381 394 break; 382 } 383 if (currentState == State.author) { 395 default: // Do nothing 396 } 397 if (currentState == State.AUTHOR) { 384 398 data.put(META_AUTHOR_LINK, currentLink); 385 } else if (currentState != State. link) {399 } else if (currentState != State.LINK) { 386 400 Map<String, Object> attr = getAttr(); 387 401 if (!attr.containsKey(META_LINKS)) { … … 391 405 } 392 406 break; 393 case wpt:407 case WPT: 394 408 switch (localName) { 395 409 case "ele": … … 437 451 data.waypoints.add(currentWayPoint); 438 452 break; 439 } 440 break; 441 case trkseg: 453 default: // Do nothing 454 } 455 break; 456 case TRKSEG: 442 457 if ("trkseg".equals(localName)) { 443 458 currentState = states.pop(); … … 445 460 } 446 461 break; 447 case trk:462 case TRK: 448 463 switch (localName) { 449 464 case "trk": … … 462 477 currentTrackAttr.put(localName, accumulator.toString()); 463 478 break; 464 } 465 break; 466 case ext: 479 default: // Do nothing 480 } 481 break; 482 case EXT: 467 483 if ("extensions".equals(localName)) { 468 484 currentState = states.pop(); … … 482 498 data.routes.add(currentRoute); 483 499 break; 500 default: // Do nothing 484 501 } 485 502 } … … 516 533 } 517 534 518 publicvoid tryToFinish() throws SAXException {535 void tryToFinish() throws SAXException { 519 536 List<String> remainingElements = new ArrayList<>(elements); 520 537 for (int i = remainingElements.size() - 1; i >= 0; i--) { -
trunk/src/org/openstreetmap/josm/io/MultiFetchServerObjectReader.java
r10212 r10216 125 125 case WAY: ways.add(id.getUniqueId()); break; 126 126 case RELATION: relations.add(id.getUniqueId()); break; 127 default: throw new AssertionError(); 127 128 } 128 129 } … … 580 581 for (long id : pkg) { 581 582 try { 582 String msg = "";583 String msg; 583 584 switch (type) { 584 585 case NODE: msg = tr("Fetching node with id {0} from ''{1}''", id, baseUrl); break; 585 586 case WAY: msg = tr("Fetching way with id {0} from ''{1}''", id, baseUrl); break; 586 587 case RELATION: msg = tr("Fetching relation with id {0} from ''{1}''", id, baseUrl); break; 588 default: throw new AssertionError(); 587 589 } 588 590 progressMonitor.setCustomText(msg); -
trunk/src/org/openstreetmap/josm/io/NoteReader.java
r10136 r10216 126 126 } 127 127 break; 128 default: // Do nothing 128 129 } 129 130 } -
trunk/src/org/openstreetmap/josm/io/OsmApiPrimitiveGoneException.java
r8510 r10216 11 11 * Represents an exception thrown by the OSM API if JOSM tries to update or delete a primitive 12 12 * which is already deleted on the server. 13 * 13 * @since 2198 14 14 */ 15 15 public class OsmApiPrimitiveGoneException extends OsmApiException { … … 19 19 public static final String ERROR_HEADER_PATTERN = "The (\\S+) with the id (\\d+) has already been deleted"; 20 20 /** the type of the primitive which is gone on the server */ 21 private OsmPrimitiveType type; 21 private final OsmPrimitiveType type; 22 22 /** the id of the primitive */ 23 private long id; 23 private final long id; 24 24 25 /** 26 * Constructs a new {@code OsmApiPrimitiveGoneException}. 27 * @param errorHeader error header 28 * @param errorBody error body 29 */ 25 30 public OsmApiPrimitiveGoneException(String errorHeader, String errorBody) { 26 31 super(HttpURLConnection.HTTP_GONE, errorHeader, errorBody); 27 if (errorHeader == null) return; 28 Pattern p = Pattern.compile(ERROR_HEADER_PATTERN); 29 Matcher m = p.matcher(errorHeader); 30 if (m.matches()) { 31 type = OsmPrimitiveType.from(m.group(1)); 32 id = Long.parseLong(m.group(2)); 32 if (errorHeader != null) { 33 Matcher m = Pattern.compile(ERROR_HEADER_PATTERN).matcher(errorHeader); 34 if (m.matches()) { 35 type = OsmPrimitiveType.from(m.group(1)); 36 id = Long.parseLong(m.group(2)); 37 } else { 38 type = null; 39 id = 0; 40 } 41 } else { 42 type = null; 43 id = 0; 33 44 } 34 45 } -
trunk/src/org/openstreetmap/josm/io/OsmServerWriter.java
r10181 r10216 219 219 break; 220 220 case CHUNKED_DATASET_STRATEGY: 221 default: 221 222 uploadChangesInChunks(primitives, monitor.createSubTaskMonitor(0, false), strategy.getChunkSize()); 222 223 break; -
trunk/src/org/openstreetmap/josm/io/imagery/ImageryReader.java
r9977 r10216 228 228 } 229 229 break; 230 default: // Do nothing 230 231 } 231 232 /** … … 433 434 entry.setEpsg4326To3857Supported(Boolean.valueOf(accumulator.toString())); 434 435 break; 436 default: // Do nothing 435 437 } 436 438 break; -
trunk/src/org/openstreetmap/josm/io/imagery/WMSImagery.java
r10212 r10216 55 55 private List<String> formats; 56 56 57 /** 58 * Returns the list of layers. 59 * @return the list of layers 60 */ 57 61 public List<LayerDetails> getLayers() { 58 62 return layers; 59 63 } 60 64 65 /** 66 * Returns the service URL. 67 * @return the service URL 68 */ 61 69 public URL getServiceUrl() { 62 70 return serviceUrl; 63 71 } 64 72 73 /** 74 * Returns the list of supported formats. 75 * @return the list of supported formats 76 */ 65 77 public List<String> getFormats() { 66 78 return Collections.unmodifiableList(formats); … … 311 323 content.append(node.getNodeValue()); 312 324 break; 325 default: // Do nothing 313 326 } 314 327 } … … 371 384 return this.name; 372 385 } 373 374 386 } 375 387 } -
trunk/src/org/openstreetmap/josm/io/session/GeoImageSessionImporter.java
r9455 r10216 49 49 Node attrNode = attrNodes.item(j); 50 50 if (attrNode.getNodeType() == Node.ELEMENT_NODE) { 51 Element attrElem = (Element) attrNode; 52 try { 53 switch(attrElem.getTagName()) { 54 case "file": 55 entry.setFile(new File(attrElem.getTextContent())); 56 break; 57 case "position": 58 double lat = Double.parseDouble(attrElem.getAttribute("lat")); 59 double lon = Double.parseDouble(attrElem.getAttribute("lon")); 60 entry.setPos(new LatLon(lat, lon)); 61 break; 62 case "speed": 63 entry.setSpeed(Double.valueOf(attrElem.getTextContent())); 64 break; 65 case "elevation": 66 entry.setElevation(Double.valueOf(attrElem.getTextContent())); 67 break; 68 case "gps-time": 69 entry.setGpsTime(new Date(Long.parseLong(attrElem.getTextContent()))); 70 break; 71 case "exif-orientation": 72 entry.setExifOrientation(Integer.valueOf(attrElem.getTextContent())); 73 break; 74 case "exif-time": 75 entry.setExifTime(new Date(Long.parseLong(attrElem.getTextContent()))); 76 break; 77 case "exif-gps-time": 78 entry.setExifGpsTime(new Date(Long.parseLong(attrElem.getTextContent()))); 79 break; 80 case "exif-coordinates": 81 entry.setExifCoor(new LatLon( 82 Double.parseDouble(attrElem.getAttribute("lat")), 83 Double.parseDouble(attrElem.getAttribute("lon")))); 84 break; 85 case "exif-image-direction": 86 entry.setExifImgDir(Double.parseDouble(attrElem.getTextContent())); 87 break; 88 case "is-new-gps-data": 89 if (Boolean.parseBoolean(attrElem.getTextContent())) { 90 entry.flagNewGpsData(); 91 } 92 } 93 // TODO: handle thumbnail loading 94 } catch (NumberFormatException e) { 95 // do nothing 96 if (Main.isTraceEnabled()) { 97 Main.trace(e.getMessage()); 98 } 99 } 51 handleElement(entry, (Element) attrNode); 100 52 } 101 53 } … … 118 70 return new GeoImageLayer(entries, gpxLayer, useThumbs); 119 71 } 72 73 private static void handleElement(ImageEntry entry, Element attrElem) { 74 try { 75 switch(attrElem.getTagName()) { 76 case "file": 77 entry.setFile(new File(attrElem.getTextContent())); 78 break; 79 case "position": 80 double lat = Double.parseDouble(attrElem.getAttribute("lat")); 81 double lon = Double.parseDouble(attrElem.getAttribute("lon")); 82 entry.setPos(new LatLon(lat, lon)); 83 break; 84 case "speed": 85 entry.setSpeed(Double.valueOf(attrElem.getTextContent())); 86 break; 87 case "elevation": 88 entry.setElevation(Double.valueOf(attrElem.getTextContent())); 89 break; 90 case "gps-time": 91 entry.setGpsTime(new Date(Long.parseLong(attrElem.getTextContent()))); 92 break; 93 case "exif-orientation": 94 entry.setExifOrientation(Integer.valueOf(attrElem.getTextContent())); 95 break; 96 case "exif-time": 97 entry.setExifTime(new Date(Long.parseLong(attrElem.getTextContent()))); 98 break; 99 case "exif-gps-time": 100 entry.setExifGpsTime(new Date(Long.parseLong(attrElem.getTextContent()))); 101 break; 102 case "exif-coordinates": 103 entry.setExifCoor(new LatLon( 104 Double.parseDouble(attrElem.getAttribute("lat")), 105 Double.parseDouble(attrElem.getAttribute("lon")))); 106 break; 107 case "exif-image-direction": 108 entry.setExifImgDir(Double.parseDouble(attrElem.getTextContent())); 109 break; 110 case "is-new-gps-data": 111 if (Boolean.parseBoolean(attrElem.getTextContent())) { 112 entry.flagNewGpsData(); 113 } 114 break; 115 default: // Do nothing 116 } 117 // TODO: handle thumbnail loading 118 } catch (NumberFormatException e) { 119 if (Main.isTraceEnabled()) { 120 Main.trace(e.getMessage()); 121 } 122 } 123 } 120 124 } -
trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java
r10212 r10216 451 451 Main.pref.put(togglePreferenceKey, "never"); 452 452 break; 453 default: // Do nothing 453 454 } 454 455 } else { -
trunk/src/org/openstreetmap/josm/tools/AudioPlayer.java
r10212 r10216 286 286 command.possiblyInterrupt(); 287 287 break; 288 default: // Do nothing 288 289 } 289 290 } catch (InterruptedException e) { … … 355 356 stateChange = State.PAUSED; 356 357 break; 358 default: // Do nothing 357 359 } 358 360 command.ok(stateChange);
Note:
See TracChangeset
for help on using the changeset viewer.