Changeset 9062 in josm for trunk/src/org
- Timestamp:
- 2015-11-25T01:21:14+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/CreateCircleAction.java
r8870 r9062 162 162 } 163 163 164 // now we can start doing things to OSM data 165 Collection<Command> cmds = new LinkedList<>(); 166 EastNorth center = null; 164 EastNorth center; 167 165 168 166 if (nodes.size() == 2) { … … 201 199 int[] count = distributeNodes(angles, 202 200 numberOfNodesInCircle >= nodes.size() ? numberOfNodesInCircle - nodes.size() : 0); 201 202 // now we can start doing things to OSM data 203 Collection<Command> cmds = new LinkedList<>(); 203 204 204 205 // build a way for the circle -
trunk/src/org/openstreetmap/josm/actions/CreateMultipolygonAction.java
r8870 r9062 141 141 142 142 final Collection<Way> selectedWays = Main.main.getCurrentDataSet().getSelectedWays(); 143 final Collection<Relation> selectedRelations = Main.main.getCurrentDataSet().getSelectedRelations();144 143 145 144 if (selectedWays.isEmpty()) { … … 154 153 } 155 154 155 final Collection<Relation> selectedRelations = Main.main.getCurrentDataSet().getSelectedRelations(); 156 156 final Relation multipolygonRelation = update 157 157 ? getSelectedMultipolygonRelation(selectedWays, selectedRelations) -
trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java
r8955 r9062 768 768 private List<WayInPolygon> markWayInsideSide(List<Way> parts, boolean isInner) { 769 769 770 List<WayInPolygon> result = new ArrayList<>();771 772 770 //prepare next map 773 771 Map<Way, Way> nextWayMap = new HashMap<>(); … … 854 852 Way curWay = topWay; 855 853 boolean curWayInsideToTheRight = wayClockwise ^ isInner; 854 List<WayInPolygon> result = new ArrayList<>(); 856 855 857 856 //iterate till full circle is reached -
trunk/src/org/openstreetmap/josm/actions/JumpToAction.java
r8670 r9062 97 97 98 98 double dist = mv.getDist100Pixel(); 99 double zoomFactor = 1/dist;100 101 99 zm.setText(Long.toString(Math.round(dist*100)/100)); 102 100 updateUrl(true); … … 161 159 } 162 160 161 double zoomFactor = 1/dist; 163 162 mv.zoomToFactor(mv.getProjection().latlon2eastNorth(ll), zoomFactor * zoomLvl); 164 163 } -
trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java
r8919 r9062 314 314 try { 315 315 TagCollection nodeTags = TagCollection.unionOfAllPrimitives(nodes); 316 List<Command> resultion = CombinePrimitiveResolverDialog.launchIfNecessary(nodeTags, nodes, Collections.singleton(targetNode));317 List<Command> cmds = new LinkedList<>();318 316 319 317 // the nodes we will have to delete … … 324 322 // fix the ways referring to at least one of the merged nodes 325 323 // 326 Collection<Way> waysToDelete = new HashSet<>(); 327 List<Command> wayFixCommands = fixParentWays( 328 nodesToDelete, 329 targetNode); 324 List<Command> wayFixCommands = fixParentWays(nodesToDelete, targetNode); 330 325 if (wayFixCommands == null) { 331 326 return null; 332 327 } 333 cmds.addAll(wayFixCommands);328 List<Command> cmds = new LinkedList<>(wayFixCommands); 334 329 335 330 // build the commands … … 343 338 } 344 339 } 345 cmds.addAll( resultion);340 cmds.addAll(CombinePrimitiveResolverDialog.launchIfNecessary(nodeTags, nodes, Collections.singleton(targetNode))); 346 341 if (!nodesToDelete.isEmpty()) { 347 342 cmds.add(new DeleteCommand(nodesToDelete)); 348 }349 if (!waysToDelete.isEmpty()) {350 cmds.add(new DeleteCommand(waysToDelete));351 343 } 352 344 return new SequenceCommand(/* for correct i18n of plural forms - see #9110 */ -
trunk/src/org/openstreetmap/josm/actions/OpenLocationAction.java
r8510 r9062 189 189 */ 190 190 public void openUrl(boolean newLayer, final String url) { 191 PleaseWaitProgressMonitor monitor = new PleaseWaitProgressMonitor(tr("Download Data"));192 191 Collection<DownloadTask> tasks = findDownloadTasks(url, false); 193 192 … … 198 197 return; 199 198 } 199 200 PleaseWaitProgressMonitor monitor = new PleaseWaitProgressMonitor(tr("Download Data")); 200 201 201 202 for (final DownloadTask task : tasks) { … … 207 208 } 208 209 } 209 210 210 } 211 211 -
trunk/src/org/openstreetmap/josm/actions/SelectNonBranchingWaySequences.java
r8780 r9062 136 136 */ 137 137 public void extend(DataSet data) { 138 Collection<OsmPrimitive> currentSelection;139 Collection<OsmPrimitive> selection;140 boolean selectionChanged = false;141 Way way;142 143 138 if (!canExtend()) 144 139 return; 145 140 146 currentSelection = data.getSelected();141 Collection<OsmPrimitive> currentSelection = data.getSelected(); 147 142 148 way = findWay(currentSelection);143 Way way = findWay(currentSelection); 149 144 150 145 if (way == null) 151 146 return; 152 147 153 selection = new LinkedList<>(); 148 boolean selectionChanged = false; 149 Collection<OsmPrimitive> selection = new LinkedList<>(); 154 150 for (OsmPrimitive primitive : currentSelection) { 155 151 selection.add(primitive); -
trunk/src/org/openstreetmap/josm/actions/SessionSaveAsAction.java
r8919 r9062 230 230 231 231 protected final Component build() { 232 JPanel p = new JPanel(new GridBagLayout());233 232 JPanel ip = new JPanel(new GridBagLayout()); 234 233 for (Layer layer : layers) { … … 249 248 JScrollPane sp = new JScrollPane(ip); 250 249 sp.setBorder(BorderFactory.createEmptyBorder()); 250 JPanel p = new JPanel(new GridBagLayout()); 251 251 p.add(sp, GBC.eol().fill()); 252 252 final JTabbedPane tabs = new JTabbedPane(); -
trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java
r8990 r9062 137 137 List<Node> selectedNodes = OsmPrimitive.getFilteredList(selection, Node.class); 138 138 List<Way> selectedWays = OsmPrimitive.getFilteredList(selection, Way.class); 139 List<Relation> selectedRelations =140 OsmPrimitive.getFilteredList(selection, Relation.class);141 139 List<Way> applicableWays = getApplicableWays(selectedWays, selectedNodes); 142 140 … … 191 189 final List<List<Node>> wayChunks = buildSplitChunks(selectedWay, selectedNodes); 192 190 if (wayChunks != null) { 191 List<Relation> selectedRelations = 192 OsmPrimitive.getFilteredList(selection, Relation.class); 193 193 final List<OsmPrimitive> sel = new ArrayList<>(selectedWays.size() + selectedRelations.size()); 194 194 sel.addAll(selectedWays); -
trunk/src/org/openstreetmap/josm/actions/UploadSelectionAction.java
r8856 r9062 101 101 } 102 102 } 103 UploadHullBuilder builder = new UploadHullBuilder();104 UploadSelectionDialog dialog = new UploadSelectionDialog();105 103 Collection<OsmPrimitive> modifiedCandidates = getModifiedPrimitives(getEditLayer().data.getAllSelected()); 106 104 Collection<OsmPrimitive> deletedCandidates = getDeletedPrimitives(getEditLayer().data); … … 114 112 return; 115 113 } 114 UploadSelectionDialog dialog = new UploadSelectionDialog(); 116 115 dialog.populate( 117 116 modifiedCandidates, … … 121 120 if (dialog.isCanceled()) 122 121 return; 123 Collection<OsmPrimitive> toUpload = builder.build(dialog.getSelectedPrimitives());122 Collection<OsmPrimitive> toUpload = new UploadHullBuilder().build(dialog.getSelectedPrimitives()); 124 123 if (toUpload.isEmpty()) { 125 124 JOptionPane.showMessageDialog( -
trunk/src/org/openstreetmap/josm/actions/mapmode/AddNoteAction.java
r8308 r9062 68 68 } 69 69 Main.map.selectMapMode(Main.map.mapModeSelect); 70 LatLon latlon = Main.map.mapView.getLatLon(e.getPoint().x, e.getPoint().y);71 70 72 71 NoteInputDialog dialog = new NoteInputDialog(Main.parent, tr("Create new note"), tr("Create note")); … … 79 78 String input = dialog.getInputText(); 80 79 if (input != null && !input.isEmpty()) { 80 LatLon latlon = Main.map.mapView.getLatLon(e.getPoint().x, e.getPoint().y); 81 81 noteData.createNote(latlon, input); 82 82 } else { -
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r9059 r9062 394 394 DataSet ds = getCurrentDataSet(); 395 395 Collection<OsmPrimitive> selection = new ArrayList<>(ds.getSelected()); 396 Collection<Command> cmds = new LinkedList<>(); 397 Collection<OsmPrimitive> newSelection = new LinkedList<>(ds.getSelected()); 398 399 List<Way> reuseWays = new ArrayList<>(), 400 replacedWays = new ArrayList<>(); 396 401 397 boolean newNode = false; 402 398 Node n = null; … … 451 447 snapHelper.unsetFixedMode(); 452 448 } 449 450 Collection<Command> cmds = new LinkedList<>(); 451 Collection<OsmPrimitive> newSelection = new LinkedList<>(ds.getSelected()); 452 List<Way> reuseWays = new ArrayList<>(); 453 List<Way> replacedWays = new ArrayList<>(); 453 454 454 455 if (newNode) { … … 769 770 */ 770 771 private void computeHelperLine() { 771 MapView mv = Main.map.mapView;772 772 if (mousePos == null) { 773 773 // Don't draw the line. … … 779 779 Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected(); 780 780 781 MapView mv = Main.map.mapView; 781 782 Node currentMouseNode = null; 782 783 mouseOnExistingNode = null; … … 1271 1272 public void actionPerformed(ActionEvent e) { 1272 1273 Main.main.undoRedo.undo(); 1273 Node n = null;1274 1274 Command lastCmd = Main.main.undoRedo.commands.peekLast(); 1275 1275 if (lastCmd == null) return; 1276 Node n = null; 1276 1277 for (OsmPrimitive p: lastCmd.getParticipatingPrimitives()) { 1277 1278 if (p instanceof Node) { -
trunk/src/org/openstreetmap/josm/actions/mapmode/ParallelWayAction.java
r8870 r9062 393 393 mouseHasBeenDragged = true; 394 394 395 Point p = e.getPoint();396 395 if (mode == Mode.normal) { 397 396 // Should we ensure that the copyTags modifiers are still valid? … … 407 406 408 407 // Calculate distance to the reference line 408 Point p = e.getPoint(); 409 409 EastNorth enp = mv.getEastNorth((int) p.getX(), (int) p.getY()); 410 410 EastNorth nearestPointOnRefLine = Geometry.closestPointToLine(referenceSegment.getFirstNode().getEastNorth(), -
trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
r8985 r9062 1102 1102 */ 1103 1103 private Collection<OsmPrimitive> cyclePrims() { 1104 OsmPrimitive nxt = null;1105 1106 1104 if (cycleList.size() <= 1) { 1107 1105 // no real cycling, just return one-element collection with nearest primitive in it … … 1112 1110 DataSet ds = getCurrentDataSet(); 1113 1111 OsmPrimitive first = cycleList.iterator().next(), foundInDS = null; 1114 nxt = first;1112 OsmPrimitive nxt = first; 1115 1113 1116 1114 if (cyclePrims && shift) { -
trunk/src/org/openstreetmap/josm/command/DeleteCommand.java
r8855 r9062 374 374 return null; 375 375 376 Collection<Way> waysToBeChanged = new HashSet<>();377 378 376 if (alsoDeleteNodesInWay) { 379 377 // delete untagged nodes only referenced by primitives in primitivesToDelete, too … … 386 384 return null; 387 385 388 waysToBeChanged.addAll(OsmPrimitive.getFilteredSet(OsmPrimitive.getReferrer(primitivesToDelete), Way.class));386 Collection<Way> waysToBeChanged = new HashSet<>(OsmPrimitive.getFilteredSet(OsmPrimitive.getReferrer(primitivesToDelete), Way.class)); 389 387 390 388 Collection<Command> cmds = new LinkedList<>(); -
trunk/src/org/openstreetmap/josm/command/PurgeCommand.java
r8931 r9062 200 200 @SuppressWarnings({ "unchecked", "rawtypes" }) 201 201 Set<Relation> inR = (Set) in; 202 Set<Relation> childlessR = new HashSet<>();203 List<Relation> outR = new ArrayList<>(inR.size());204 202 205 203 Map<Relation, Integer> numChilds = new HashMap<>(); … … 219 217 } 220 218 } 219 Set<Relation> childlessR = new HashSet<>(); 221 220 for (Relation r : inR) { 222 221 if (numChilds.get(r).equals(0)) { … … 225 224 } 226 225 226 List<Relation> outR = new ArrayList<>(inR.size()); 227 227 while (!childlessR.isEmpty()) { 228 228 // Identify one childless Relation and -
trunk/src/org/openstreetmap/josm/corrector/TagCorrector.java
r8919 r9062 139 139 if (answer == JOptionPane.YES_OPTION) { 140 140 for (Entry<OsmPrimitive, List<TagCorrection>> entry : tagCorrectionsMap.entrySet()) { 141 List<TagCorrection> tagCorrections = entry.getValue();142 141 OsmPrimitive primitive = entry.getKey(); 143 142 … … 158 157 159 158 // apply all changes to this clone 159 List<TagCorrection> tagCorrections = entry.getValue(); 160 160 for (int i = 0; i < tagCorrections.size(); i++) { 161 161 if (tagTableMap.get(primitive).getCorrectionTableModel().getApply(i)) { -
trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java
r9059 r9062 380 380 if (message == null) return false; 381 381 382 UpdatePluginsMessagePanel pnlMessage = new UpdatePluginsMessagePanel(); 383 pnlMessage.setMessage(message); 384 pnlMessage.initDontShowAgain(togglePreferenceKey); 385 386 // check whether automatic update at startup was disabled 387 // 388 String policy = Main.pref.get(togglePreferenceKey, "ask").trim().toLowerCase(Locale.ENGLISH); 389 switch(policy) { 390 case "never": 391 if ("pluginmanager.version-based-update.policy".equals(togglePreferenceKey)) { 392 Main.info(tr("Skipping plugin update after JOSM upgrade. Automatic update at startup is disabled.")); 393 } else if ("pluginmanager.time-based-update.policy".equals(togglePreferenceKey)) { 394 Main.info(tr("Skipping plugin update after elapsed update interval. Automatic update at startup is disabled.")); 395 } 396 return false; 397 398 case "always": 399 if ("pluginmanager.version-based-update.policy".equals(togglePreferenceKey)) { 400 Main.info(tr("Running plugin update after JOSM upgrade. Automatic update at startup is enabled.")); 401 } else if ("pluginmanager.time-based-update.policy".equals(togglePreferenceKey)) { 402 Main.info(tr("Running plugin update after elapsed update interval. Automatic update at startup is disabled.")); 403 } 404 return true; 405 406 case "ask": 407 break; 408 409 default: 410 Main.warn(tr("Unexpected value ''{0}'' for preference ''{1}''. Assuming value ''ask''.", policy, togglePreferenceKey)); 411 } 412 382 413 ButtonSpec[] options = new ButtonSpec[] { 383 414 new ButtonSpec( … … 394 425 ) 395 426 }; 396 397 UpdatePluginsMessagePanel pnlMessage = new UpdatePluginsMessagePanel();398 pnlMessage.setMessage(message);399 pnlMessage.initDontShowAgain(togglePreferenceKey);400 401 // check whether automatic update at startup was disabled402 //403 String policy = Main.pref.get(togglePreferenceKey, "ask").trim().toLowerCase(Locale.ENGLISH);404 switch(policy) {405 case "never":406 if ("pluginmanager.version-based-update.policy".equals(togglePreferenceKey)) {407 Main.info(tr("Skipping plugin update after JOSM upgrade. Automatic update at startup is disabled."));408 } else if ("pluginmanager.time-based-update.policy".equals(togglePreferenceKey)) {409 Main.info(tr("Skipping plugin update after elapsed update interval. Automatic update at startup is disabled."));410 }411 return false;412 413 case "always":414 if ("pluginmanager.version-based-update.policy".equals(togglePreferenceKey)) {415 Main.info(tr("Running plugin update after JOSM upgrade. Automatic update at startup is enabled."));416 } else if ("pluginmanager.time-based-update.policy".equals(togglePreferenceKey)) {417 Main.info(tr("Running plugin update after elapsed update interval. Automatic update at startup is disabled."));418 }419 return true;420 421 case "ask":422 break;423 424 default:425 Main.warn(tr("Unexpected value ''{0}'' for preference ''{1}''. Assuming value ''ask''.", policy, togglePreferenceKey));426 }427 427 428 428 int ret = HelpAwareOptionPane.showOptionDialog( -
trunk/src/org/openstreetmap/josm/plugins/ReadRemotePluginInformationTask.java
r8540 r9062 315 315 if (sites == null) return; 316 316 getProgressMonitor().setTicksCount(sites.size() * 3); 317 File pluginDir = Main.pref.getPluginsDirectory();318 317 319 318 // collect old cache files and remove if no longer in use … … 334 333 } 335 334 335 File pluginDir = Main.pref.getPluginsDirectory(); 336 336 for (String site: sites) { 337 337 String printsite = site.replaceAll("%<(.*)>", ""); -
trunk/src/org/openstreetmap/josm/tools/Geometry.java
r9059 r9062 352 352 double a2 = p4.getY() - p3.getY(); 353 353 double b2 = p3.getX() - p4.getX(); 354 double c2 = (p4.getX() - p1.getX()) * (p3.getY() - p1.getY()) - (p3.getX() - p1.getX()) * (p4.getY() - p1.getY());355 354 356 355 // Solve the equations … … 358 357 if (det == 0) 359 358 return null; // Lines are parallel 359 360 double c2 = (p4.getX() - p1.getX()) * (p3.getY() - p1.getY()) - (p3.getX() - p1.getX()) * (p4.getY() - p1.getY()); 360 361 361 362 return new EastNorth(b1 * c2 / det + p1.getX(), -a1 * c2 / det + p1.getY()); … … 573 574 return false; 574 575 576 //iterate each side of the polygon, start with the last segment 577 Node oldPoint = polygonNodes.get(polygonNodes.size() - 1); 578 579 if (!oldPoint.isLatLonKnown()) { 580 return false; 581 } 582 575 583 boolean inside = false; 576 584 Node p1, p2; 577 578 //iterate each side of the polygon, start with the last segment579 Node oldPoint = polygonNodes.get(polygonNodes.size() - 1);580 581 if (!oldPoint.isLatLonKnown()) {582 return false;583 }584 585 585 586 for (Node newPoint : polygonNodes) { … … 708 709 */ 709 710 public static boolean isClockwise(List<Node> nodes) { 710 double area2 = 0.;711 711 int nodesCount = nodes.size(); 712 712 if (nodesCount < 3 || nodes.get(0) != nodes.get(nodesCount - 1)) { 713 713 throw new IllegalArgumentException("Way must be closed to check orientation."); 714 714 } 715 double area2 = 0.; 715 716 716 717 for (int node = 1; node <= /*sic! consider last-first as well*/ nodesCount; node++) { -
trunk/src/org/openstreetmap/josm/tools/I18n.java
r8989 r9062 583 583 } 584 584 String[] enstrings = new String[ennum]; 585 String[] trstrings = new String[trnum];586 585 for (int i = 0; i < ennum; ++i) { 587 586 int val = ens.read(enlen); … … 597 596 enstrings[i] = new String(str, 0, val, StandardCharsets.UTF_8); 598 597 } 598 String[] trstrings = new String[trnum]; 599 599 for (int i = 0; i < trnum; ++i) { 600 600 int val = trs.read(trlen); -
trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
r8992 r9062 836 836 Matcher m = dataUrlPattern.matcher(url); 837 837 if (m.matches()) { 838 String mediatype = m.group(1);839 838 String base64 = m.group(2); 840 839 String data = m.group(3); … … 850 849 } 851 850 } 851 String mediatype = m.group(1); 852 852 if ("image/svg+xml".equals(mediatype)) { 853 853 String s = new String(bytes, StandardCharsets.UTF_8); -
trunk/src/org/openstreetmap/josm/tools/OsmUrlToBounds.java
r8846 r9062 93 93 } 94 94 int zoom; 95 double lat, lon;96 95 try { 97 96 zoom = Integer.parseInt(parts[0]); … … 100 99 return null; 101 100 } 101 double lat, lon; 102 102 try { 103 103 lat = Double.parseDouble(parts[1]); -
trunk/src/org/openstreetmap/josm/tools/WindowGeometry.java
r8924 r9062 67 67 */ 68 68 public static WindowGeometry centerInWindow(Component reference, Dimension extent) { 69 Window parentWindow = null;70 69 while (reference != null && !(reference instanceof Window)) { 71 70 reference = reference.getParent(); … … 73 72 if (reference == null) 74 73 return new WindowGeometry(new Point(0, 0), extent); 75 parentWindow = (Window) reference;74 Window parentWindow = (Window) reference; 76 75 Point topLeft = new Point( 77 76 Math.max(0, (parentWindow.getSize().width - extent.width) /2), -
trunk/src/org/openstreetmap/josm/tools/date/PrimaryDateParser.java
r8870 r9062 41 41 42 42 private static boolean isDateInShortStandardFormat(String date) { 43 char[] dateChars;44 43 // We can only parse the date if it is in a very specific format. 45 44 // eg. 2007-09-23T08:25:43Z … … 49 48 } 50 49 51 dateChars = date.toCharArray();50 char[] dateChars = date.toCharArray(); 52 51 53 52 // Make sure any fixed characters are in the correct place. … … 108 107 109 108 private static boolean isDateInLongStandardFormat(String date) { 110 char[] dateChars;111 109 // We can only parse the date if it is in a very specific format. 112 110 // eg. 2007-09-23T08:25:43.000Z … … 116 114 } 117 115 118 dateChars = date.toCharArray();116 char[] dateChars = date.toCharArray(); 119 117 120 118 // Make sure any fixed characters are in the correct place.
Note:
See TracChangeset
for help on using the changeset viewer.