Changeset 14120 in josm for trunk/src/org
- Timestamp:
- 2018-08-11T17:29:48+02:00 (6 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 added
- 45 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r14119 r14120 7 7 import java.awt.GraphicsEnvironment; 8 8 import java.io.IOException; 9 import java.lang.ref.WeakReference;10 9 import java.net.URL; 11 10 import java.nio.file.InvalidPathException; … … 16 15 import java.util.List; 17 16 import java.util.Map; 18 import java.util.Objects;19 17 import java.util.Set; 20 18 import java.util.concurrent.Callable; 21 import java.util.concurrent.CopyOnWriteArrayList;22 19 import java.util.concurrent.ExecutionException; 23 20 import java.util.concurrent.ExecutorService; … … 25 22 import java.util.concurrent.Future; 26 23 27 import org.openstreetmap.josm.data.Bounds;28 24 import org.openstreetmap.josm.data.Preferences; 29 25 import org.openstreetmap.josm.data.UndoRedoHandler; … … 38 34 import org.openstreetmap.josm.data.projection.Projection; 39 35 import org.openstreetmap.josm.data.projection.ProjectionChangeListener; 36 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 40 37 import org.openstreetmap.josm.io.FileWatcher; 41 38 import org.openstreetmap.josm.io.OnlineResource; … … 364 361 } 365 362 366 /* ----------------------------------------------------------------------------------------- */367 /* projection handling - Main is a registry for a single, global projection instance */368 /* */369 /* TODO: For historical reasons the registry is implemented by Main. An alternative approach */370 /* would be a singleton org.openstreetmap.josm.data.projection.ProjectionRegistry class. */371 /* ----------------------------------------------------------------------------------------- */372 /**373 * The projection method used.374 * Use {@link #getProjection()} and {@link #setProjection(Projection)} for access.375 * Use {@link #setProjection(Projection)} in order to trigger a projection change event.376 */377 private static volatile Projection proj;378 379 363 /** 380 364 * Replies the current projection. 381 365 * 382 366 * @return the currently active projection 383 */ 367 * @deprecated Use {@link ProjectionRegistry#getProjection} 368 */ 369 @Deprecated 384 370 public static Projection getProjection() { 385 return proj;371 return ProjectionRegistry.getProjection(); 386 372 } 387 373 … … 390 376 * 391 377 * @param p the projection 392 */ 378 * @deprecated Use {@link ProjectionRegistry#setProjection} 379 */ 380 @Deprecated 393 381 public static void setProjection(Projection p) { 394 CheckParameterUtil.ensureParameterNotNull(p); 395 Projection oldValue = proj; 396 Bounds b = main != null ? main.getRealBounds() : null; 397 proj = p; 398 fireProjectionChanged(oldValue, proj, b); 399 } 400 401 /** 402 * Returns the bounds for the current projection. Used for projection events. 403 * @return the bounds for the current projection 404 * @see #restoreOldBounds 405 */ 406 protected Bounds getRealBounds() { 407 // To be overriden 408 return null; 409 } 410 411 /** 412 * Restore clean state corresponding to old bounds after a projection change event. 413 * @param oldBounds bounds previously returned by {@link #getRealBounds}, before the change of projection 414 * @see #getRealBounds 415 */ 416 protected void restoreOldBounds(Bounds oldBounds) { 417 // To be overriden 418 } 419 420 /* 421 * Keep WeakReferences to the listeners. This relieves clients from the burden of 422 * explicitly removing the listeners and allows us to transparently register every 423 * created dataset as projection change listener. 424 */ 425 private static final List<WeakReference<ProjectionChangeListener>> listeners = new CopyOnWriteArrayList<>(); 426 427 private static void fireProjectionChanged(Projection oldValue, Projection newValue, Bounds oldBounds) { 428 if ((newValue == null ^ oldValue == null) 429 || (newValue != null && oldValue != null && !Objects.equals(newValue.toCode(), oldValue.toCode()))) { 430 listeners.removeIf(x -> x.get() == null); 431 listeners.stream().map(WeakReference::get).filter(Objects::nonNull).forEach(x -> x.projectionChanged(oldValue, newValue)); 432 if (newValue != null && oldBounds != null && main != null) { 433 main.restoreOldBounds(oldBounds); 434 } 435 /* TODO - remove layers with fixed projection */ 436 } 382 ProjectionRegistry.setProjection(p); 437 383 } 438 384 … … 442 388 * 443 389 * @param listener the listener. Ignored if <code>null</code>. 444 */ 390 * @deprecated Use {@link ProjectionRegistry#addProjectionChangeListener} 391 */ 392 @Deprecated 445 393 public static void addProjectionChangeListener(ProjectionChangeListener listener) { 446 if (listener == null) return; 447 for (WeakReference<ProjectionChangeListener> wr : listeners) { 448 // already registered ? => abort 449 if (wr.get() == listener) return; 450 } 451 listeners.add(new WeakReference<>(listener)); 394 ProjectionRegistry.addProjectionChangeListener(listener); 452 395 } 453 396 … … 456 399 * 457 400 * @param listener the listener. Ignored if <code>null</code>. 458 */ 401 * @deprecated Use {@link ProjectionRegistry#removeProjectionChangeListener} 402 */ 403 @Deprecated 459 404 public static void removeProjectionChangeListener(ProjectionChangeListener listener) { 460 if (listener == null) return; 461 // remove the listener - and any other listener which got garbage collected in the meantime 462 listeners.removeIf(wr -> wr.get() == null || wr.get() == listener); 405 ProjectionRegistry.removeProjectionChangeListener(listener); 463 406 } 464 407 … … 466 409 * Remove all projection change listeners. For testing purposes only. 467 410 * @since 13322 468 */ 411 * @deprecated Use {@link ProjectionRegistry#clearProjectionChangeListeners} 412 */ 413 @Deprecated 469 414 public static void clearProjectionChangeListeners() { 470 listeners.clear();415 ProjectionRegistry.clearProjectionChangeListeners(); 471 416 } 472 417 -
trunk/src/org/openstreetmap/josm/actions/CreateCircleAction.java
r13434 r14120 18 18 import javax.swing.JOptionPane; 19 19 20 import org.openstreetmap.josm.Main;21 20 import org.openstreetmap.josm.command.AddCommand; 22 21 import org.openstreetmap.josm.command.ChangeCommand; … … 30 29 import org.openstreetmap.josm.data.osm.OsmPrimitive; 31 30 import org.openstreetmap.josm.data.osm.Way; 31 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 32 32 import org.openstreetmap.josm.gui.MainApplication; 33 33 import org.openstreetmap.josm.gui.Notification; … … 180 180 181 181 // see #10777 182 LatLon ll1 = Main.getProjection().eastNorth2latlon(n1);183 LatLon ll2 = Main.getProjection().eastNorth2latlon(center);182 LatLon ll1 = ProjectionRegistry.getProjection().eastNorth2latlon(n1); 183 LatLon ll2 = ProjectionRegistry.getProjection().eastNorth2latlon(center); 184 184 185 185 double radiusInMeters = ll1.greatCircleDistance(ll2); … … 218 218 double x = center.east() + r*Math.cos(alpha); 219 219 double y = center.north() + r*Math.sin(alpha); 220 LatLon ll = Main.getProjection().eastNorth2latlon(new EastNorth(x, y));220 LatLon ll = ProjectionRegistry.getProjection().eastNorth2latlon(new EastNorth(x, y)); 221 221 if (ll.isOutSideWorld()) { 222 222 notifyNodesNotOnCircle(); -
trunk/src/org/openstreetmap/josm/actions/ImageryAdjustAction.java
r13867 r14120 26 26 import org.openstreetmap.josm.data.coor.LatLon; 27 27 import org.openstreetmap.josm.data.imagery.OffsetBookmark; 28 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 28 29 import org.openstreetmap.josm.gui.ExtendedDialog; 29 30 import org.openstreetmap.josm.gui.MainApplication; … … 74 75 } 75 76 old = layer.getDisplaySettings().getOffsetBookmark(); 76 EastNorth curOff = old == null ? EastNorth.ZERO : old.getDisplacement( Main.getProjection());77 EastNorth curOff = old == null ? EastNorth.ZERO : old.getDisplacement(ProjectionRegistry.getProjection()); 77 78 LatLon center; 78 79 if (MainApplication.isDisplayingMapView()) { 79 center = Main.getProjection().eastNorth2latlon(MainApplication.getMap().mapView.getCenter());80 center = ProjectionRegistry.getProjection().eastNorth2latlon(MainApplication.getMap().mapView.getCenter()); 80 81 } else { 81 82 center = LatLon.ZERO; 82 83 } 83 84 tempOffset = new OffsetBookmark( 84 Main.getProjection().toCode(),85 ProjectionRegistry.getProjection().toCode(), 85 86 layer.getInfo().getId(), 86 87 layer.getInfo().getName(), … … 258 259 "You can also enter east and north offset in the {0} coordinates.\n" + 259 260 "If you want to save the offset as bookmark, enter the bookmark name below", 260 Main.getProjection().toString())), GBC.eop());261 ProjectionRegistry.getProjection().toString())), GBC.eop()); 261 262 pnl.add(new JLabel(tr("Offset:")), GBC.std()); 262 263 pnl.add(tOffset, GBC.eol().fill(GBC.HORIZONTAL).insets(0, 0, 0, 5)); … … 313 314 if (layer != null) { 314 315 // Support projections with very small numbers (e.g. 4326) 315 int precision = Main.getProjection().getDefaultZoomInPPD() >= 1.0 ? 2 : 7;316 int precision = ProjectionRegistry.getProjection().getDefaultZoomInPPD() >= 1.0 ? 2 : 7; 316 317 // US locale to force decimal separator to be '.' 317 318 try (Formatter us = new Formatter(Locale.US)) { -
trunk/src/org/openstreetmap/josm/actions/JoinNodeWayAction.java
r13434 r14120 19 19 import java.util.TreeSet; 20 20 21 import org.openstreetmap.josm.Main;22 21 import org.openstreetmap.josm.command.ChangeCommand; 23 22 import org.openstreetmap.josm.command.Command; … … 30 29 import org.openstreetmap.josm.data.osm.Way; 31 30 import org.openstreetmap.josm.data.osm.WaySegment; 31 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 32 32 import org.openstreetmap.josm.gui.MainApplication; 33 33 import org.openstreetmap.josm.gui.MapView; … … 143 143 node.getEastNorth()); 144 144 MoveCommand c = new MoveCommand( 145 node, Main.getProjection().eastNorth2latlon(newPosition));145 node, ProjectionRegistry.getProjection().eastNorth2latlon(newPosition)); 146 146 // Avoid moving a given node several times at the same position in case of overlapping ways 147 147 if (!cmds.contains(c)) { -
trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java
r13712 r14120 30 30 import org.openstreetmap.josm.data.osm.OsmPrimitive; 31 31 import org.openstreetmap.josm.data.osm.Way; 32 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 32 33 import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil; 33 34 import org.openstreetmap.josm.gui.MainApplication; … … 148 149 if (!isEnabled()) 149 150 return; 150 if ("EPSG:4326".equals( Main.getProjection().toString())) {151 if ("EPSG:4326".equals(ProjectionRegistry.getProjection().toString())) { 151 152 String msg = tr("<html>You are using the EPSG:4326 projection which might lead<br>" + 152 153 "to undesirable results when doing rectangular alignments.<br>" + … … 307 308 throw new InvalidUserInputException("Unable to orthogonalize " + singleNode); 308 309 } 309 return new MoveCommand(singleNode, Main.getProjection().eastNorth2latlon(Geometry.getCentroidEN(rightAnglePositions)));310 return new MoveCommand(singleNode, ProjectionRegistry.getProjection().eastNorth2latlon(Geometry.getCentroidEN(rightAnglePositions))); 310 311 } 311 312 -
trunk/src/org/openstreetmap/josm/actions/SessionLoadAction.java
r13437 r14120 20 20 21 21 import org.openstreetmap.josm.Main; 22 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 22 23 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 23 24 import org.openstreetmap.josm.gui.MainApplication; … … 147 148 } 148 149 if (noMap && viewport != null) { 149 MainApplication.getMap().mapView.scheduleZoomTo(viewport.getEastNorthViewport( Main.getProjection()));150 MainApplication.getMap().mapView.scheduleZoomTo(viewport.getEastNorthViewport(ProjectionRegistry.getProjection())); 150 151 } 151 152 } -
trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java
r13434 r14120 29 29 import javax.swing.JMenuItem; 30 30 31 import org.openstreetmap.josm.Main;32 31 import org.openstreetmap.josm.actions.JosmAction; 33 32 import org.openstreetmap.josm.actions.MergeNodesAction; … … 46 45 import org.openstreetmap.josm.data.osm.WaySegment; 47 46 import org.openstreetmap.josm.data.preferences.NamedColorProperty; 47 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 48 48 import org.openstreetmap.josm.gui.MainApplication; 49 49 import org.openstreetmap.josm.gui.MainMenu; … … 655 655 //move existing node 656 656 Node n1Old = selectedSegment.getFirstNode(); 657 cmds.add(new MoveCommand(n1Old, Main.getProjection().eastNorth2latlon(newN1en)));657 cmds.add(new MoveCommand(n1Old, ProjectionRegistry.getProjection().eastNorth2latlon(newN1en))); 658 658 changedNodes.add(n1Old); 659 659 } else if (ignoreSharedNodes && segmentAngleZero && !alwaysCreateNodes && hasOtherWays) { 660 660 // replace shared node with new one 661 661 Node n1Old = selectedSegment.getFirstNode(); 662 Node n1New = new Node( Main.getProjection().eastNorth2latlon(newN1en));662 Node n1New = new Node(ProjectionRegistry.getProjection().eastNorth2latlon(newN1en)); 663 663 wnew.addNode(insertionPoint, n1New); 664 664 wnew.removeNode(n1Old); … … 668 668 } else { 669 669 //introduce new node 670 Node n1New = new Node( Main.getProjection().eastNorth2latlon(newN1en));670 Node n1New = new Node(ProjectionRegistry.getProjection().eastNorth2latlon(newN1en)); 671 671 wnew.addNode(insertionPoint, n1New); 672 672 wayWasModified = true; … … 685 685 //move existing node 686 686 Node n2Old = selectedSegment.getSecondNode(); 687 cmds.add(new MoveCommand(n2Old, Main.getProjection().eastNorth2latlon(newN2en)));687 cmds.add(new MoveCommand(n2Old, ProjectionRegistry.getProjection().eastNorth2latlon(newN2en))); 688 688 changedNodes.add(n2Old); 689 689 } else if (ignoreSharedNodes && segmentAngleZero && !alwaysCreateNodes && hasOtherWays) { 690 690 // replace shared node with new one 691 691 Node n2Old = selectedSegment.getSecondNode(); 692 Node n2New = new Node( Main.getProjection().eastNorth2latlon(newN2en));692 Node n2New = new Node(ProjectionRegistry.getProjection().eastNorth2latlon(newN2en)); 693 693 wnew.addNode(insertionPoint, n2New); 694 694 wnew.removeNode(n2Old); … … 698 698 } else { 699 699 //introduce new node 700 Node n2New = new Node( Main.getProjection().eastNorth2latlon(newN2en));700 Node n2New = new Node(ProjectionRegistry.getProjection().eastNorth2latlon(newN2en)); 701 701 wnew.addNode(insertionPoint, n2New); 702 702 wayWasModified = true; … … 937 937 938 938 // find out the movement distance, in metres 939 double distance = Main.getProjection().eastNorth2latlon(initialN1en).greatCircleDistance(940 Main.getProjection().eastNorth2latlon(n1movedEn));939 double distance = ProjectionRegistry.getProjection().eastNorth2latlon(initialN1en).greatCircleDistance( 940 ProjectionRegistry.getProjection().eastNorth2latlon(n1movedEn)); 941 941 MainApplication.getMap().statusLine.setDist(distance); 942 942 updateStatusLine(); -
trunk/src/org/openstreetmap/josm/command/MoveCommand.java
r12778 r14120 14 14 import javax.swing.Icon; 15 15 16 import org.openstreetmap.josm.Main;17 16 import org.openstreetmap.josm.data.coor.EastNorth; 18 17 import org.openstreetmap.josm.data.coor.LatLon; … … 21 20 import org.openstreetmap.josm.data.osm.OsmPrimitive; 22 21 import org.openstreetmap.josm.data.osm.visitor.AllNodesVisitor; 22 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 23 23 import org.openstreetmap.josm.tools.ImageProvider; 24 24 … … 73 73 public MoveCommand(Node node, LatLon position) { 74 74 this(Collections.singleton((OsmPrimitive) node), 75 Main.getProjection().latlon2eastNorth(position).subtract(node.getEastNorth()));75 ProjectionRegistry.getProjection().latlon2eastNorth(position).subtract(node.getEastNorth())); 76 76 } 77 77 -
trunk/src/org/openstreetmap/josm/data/coor/CachedLatLon.java
r12161 r14120 4 4 import java.util.Objects; 5 5 6 import org.openstreetmap.josm.Main;7 6 import org.openstreetmap.josm.data.projection.Projecting; 8 7 import org.openstreetmap.josm.data.projection.Projection; 8 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 9 9 10 10 /** … … 46 46 */ 47 47 public CachedLatLon(EastNorth eastNorth) { 48 this(eastNorth, Main.getProjection());48 this(eastNorth, ProjectionRegistry.getProjection()); 49 49 } 50 50 -
trunk/src/org/openstreetmap/josm/data/coor/LatLon.java
r14091 r14120 17 17 import java.util.Objects; 18 18 19 import org.openstreetmap.josm.Main;20 19 import org.openstreetmap.josm.data.Bounds; 20 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 21 21 import org.openstreetmap.josm.tools.Logging; 22 22 import org.openstreetmap.josm.tools.Utils; … … 195 195 */ 196 196 public boolean isOutSideWorld() { 197 Bounds b = Main.getProjection().getWorldBoundsLatLon();197 Bounds b = ProjectionRegistry.getProjection().getWorldBoundsLatLon(); 198 198 return lat() < b.getMinLat() || lat() > b.getMaxLat() || 199 199 lon() < b.getMinLon() || lon() > b.getMaxLon(); -
trunk/src/org/openstreetmap/josm/data/coor/conversion/ProjectedCoordinateFormat.java
r12741 r14120 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import org.openstreetmap.josm.Main;7 6 import org.openstreetmap.josm.data.coor.ILatLon; 7 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 8 8 9 9 /** … … 25 25 @Override 26 26 public String latToString(ILatLon ll) { 27 return cDdFormatter.format(ll.getEastNorth( Main.getProjection()).north());27 return cDdFormatter.format(ll.getEastNorth(ProjectionRegistry.getProjection()).north()); 28 28 } 29 29 30 30 @Override 31 31 public String lonToString(ILatLon ll) { 32 return cDdFormatter.format(ll.getEastNorth( Main.getProjection()).east());32 return cDdFormatter.format(ll.getEastNorth(ProjectionRegistry.getProjection()).east()); 33 33 } 34 34 } -
trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java
r13257 r14120 20 20 import java.util.stream.Stream; 21 21 22 import org.openstreetmap.josm.Main;23 22 import org.openstreetmap.josm.data.Bounds; 24 23 import org.openstreetmap.josm.data.Data; … … 26 25 import org.openstreetmap.josm.data.coor.EastNorth; 27 26 import org.openstreetmap.josm.data.gpx.GpxTrack.GpxTrackChangeListener; 27 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 28 28 import org.openstreetmap.josm.gui.MainApplication; 29 29 import org.openstreetmap.josm.gui.layer.GpxLayer; … … 539 539 WayPoint r = null; 540 540 for (WayPoint wpSeg : seg.getWayPoints()) { 541 EastNorth en = wpSeg.getEastNorth( Main.getProjection());541 EastNorth en = wpSeg.getEastNorth(ProjectionRegistry.getProjection()); 542 542 if (r == null) { 543 543 r = wpSeg; … … 586 586 } 587 587 if (r != null) { 588 EastNorth c = r.getEastNorth( Main.getProjection());588 EastNorth c = r.getEastNorth(ProjectionRegistry.getProjection()); 589 589 /* if there is only one point in the seg, it will do this twice, but no matter */ 590 590 rx = c.east(); … … 603 603 if (bestEN == null) 604 604 return null; 605 WayPoint best = new WayPoint( Main.getProjection().eastNorth2latlon(bestEN));605 WayPoint best = new WayPoint(ProjectionRegistry.getProjection().eastNorth2latlon(bestEN)); 606 606 best.time = bestTime; 607 607 return best; -
trunk/src/org/openstreetmap/josm/data/imagery/OffsetBookmark.java
r13798 r14120 10 10 import java.util.stream.Collectors; 11 11 12 import org.openstreetmap.josm.Main;13 12 import org.openstreetmap.josm.data.StructUtils; 14 13 import org.openstreetmap.josm.data.StructUtils.StructEntry; … … 18 17 import org.openstreetmap.josm.data.coor.LatLon; 19 18 import org.openstreetmap.josm.data.projection.Projection; 19 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 20 20 import org.openstreetmap.josm.data.projection.Projections; 21 21 import org.openstreetmap.josm.gui.MainApplication; … … 49 49 public boolean isUsable(ImageryLayer layer) { 50 50 if (projection_code == null) return false; 51 if (! Main.getProjection().toCode().equals(projection_code) && !hasCenter()) return false;51 if (!ProjectionRegistry.getProjection().toCode().equals(projection_code) && !hasCenter()) return false; 52 52 ImageryInfo info = layer.getInfo(); 53 53 return imagery_id != null ? Objects.equals(info.getId(), imagery_id) : Objects.equals(info.getName(), imagery_name); … … 363 363 LatLon center; 364 364 if (MainApplication.isDisplayingMapView()) { 365 center = Main.getProjection().eastNorth2latlon(MainApplication.getMap().mapView.getCenter());365 center = ProjectionRegistry.getProjection().eastNorth2latlon(MainApplication.getMap().mapView.getCenter()); 366 366 } else { 367 367 center = LatLon.ZERO; 368 368 } 369 369 OffsetBookmark nb = new OffsetBookmark( 370 Main.getProjection().toCode(), layer.getInfo().getId(), layer.getInfo().getName(),370 ProjectionRegistry.getProjection().toCode(), layer.getInfo().getId(), layer.getInfo().getName(), 371 371 name, layer.getDisplaySettings().getDisplacement(), center); 372 372 for (ListIterator<OffsetBookmark> it = allBookmarks.listIterator(); it.hasNext();) { -
trunk/src/org/openstreetmap/josm/data/imagery/TemplatedWMSTileSource.java
r13733 r14120 16 16 17 17 import org.openstreetmap.gui.jmapviewer.interfaces.TemplatedTileSource; 18 import org.openstreetmap.josm.Main;19 18 import org.openstreetmap.josm.data.coor.EastNorth; 20 19 import org.openstreetmap.josm.data.projection.Projection; 20 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 21 21 import org.openstreetmap.josm.gui.layer.WMSLayer; 22 22 import org.openstreetmap.josm.tools.CheckParameterUtil; … … 108 108 } else if (baseUrl.toLowerCase(Locale.US).contains("crs=")) { 109 109 // assume WMS 1.3.0 110 switchLatLon = Main.getProjection().switchXY();110 switchLatLon = ProjectionRegistry.getProjection().switchXY(); 111 111 } 112 112 String bbox = getBbox(zoom, tilex, tiley, switchLatLon); -
trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java
r13879 r14120 50 50 import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType; 51 51 import org.openstreetmap.josm.data.projection.Projection; 52 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 52 53 import org.openstreetmap.josm.data.projection.Projections; 53 54 import org.openstreetmap.josm.gui.ExtendedDialog; … … 346 347 List<Layer> ls = layerById.entrySet().iterator().next().getValue() 347 348 .stream().filter( 348 u -> u.tileMatrixSet.crs.equals( Main.getProjection().toCode()))349 u -> u.tileMatrixSet.crs.equals(ProjectionRegistry.getProjection().toCode())) 349 350 .collect(Collectors.toList()); 350 351 if (ls.size() == 1) { … … 631 632 private static TileMatrix parseTileMatrix(XMLStreamReader reader, String matrixCrs) throws XMLStreamException { 632 633 Projection matrixProj = Optional.ofNullable(Projections.getProjectionByCode(matrixCrs)) 633 .orElseGet( Main::getProjection); // use current projection if none found. Maybe user is using custom string634 .orElseGet(ProjectionRegistry::getProjection); // use current projection if none found. Maybe user is using custom string 634 635 TileMatrix ret = new TileMatrix(); 635 636 for (int event = reader.getEventType(); -
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r14119 r14120 25 25 import java.util.stream.Stream; 26 26 27 import org.openstreetmap.josm.Main;28 27 import org.openstreetmap.josm.data.APIDataSet.APIOperation; 29 28 import org.openstreetmap.josm.data.Bounds; … … 54 53 import org.openstreetmap.josm.data.projection.Projection; 55 54 import org.openstreetmap.josm.data.projection.ProjectionChangeListener; 55 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 56 56 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 57 57 import org.openstreetmap.josm.spi.preferences.Config; … … 175 175 // Transparently register as projection change listener. No need to explicitly remove 176 176 // the listener, projection change listeners are managed as WeakReferences. 177 Main.addProjectionChangeListener(this);177 ProjectionRegistry.addProjectionChangeListener(this); 178 178 addSelectionListener((DataSelectionListener) e -> fireSelectionChange(e.getSelection())); 179 179 } … … 1045 1045 */ 1046 1046 public void invalidateEastNorthCache() { 1047 if ( Main.getProjection() == null)1047 if (ProjectionRegistry.getProjection() == null) 1048 1048 return; // sanity check 1049 1049 beginUpdate(); -
trunk/src/org/openstreetmap/josm/data/osm/INode.java
r13669 r14120 6 6 import org.openstreetmap.josm.data.coor.ILatLon; 7 7 import org.openstreetmap.josm.data.coor.LatLon; 8 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 8 9 9 10 /** … … 34 35 */ 35 36 default EastNorth getEastNorth() { 36 return getEastNorth( Main.getProjection());37 return getEastNorth(ProjectionRegistry.getProjection()); 37 38 } 38 39 -
trunk/src/org/openstreetmap/josm/data/osm/Node.java
r13669 r14120 10 10 import java.util.function.Predicate; 11 11 12 import org.openstreetmap.josm.Main;13 12 import org.openstreetmap.josm.data.coor.EastNorth; 14 13 import org.openstreetmap.josm.data.coor.LatLon; … … 16 15 import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor; 17 16 import org.openstreetmap.josm.data.projection.Projecting; 17 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 18 18 import org.openstreetmap.josm.tools.CheckParameterUtil; 19 19 import org.openstreetmap.josm.tools.Utils; … … 114 114 invalidateEastNorthCache(); 115 115 } else if (eastNorth != null) { 116 LatLon ll = Main.getProjection().eastNorth2latlon(eastNorth);116 LatLon ll = ProjectionRegistry.getProjection().eastNorth2latlon(eastNorth); 117 117 this.lat = ll.lat(); 118 118 this.lon = ll.lon(); 119 119 this.east = eastNorth.east(); 120 120 this.north = eastNorth.north(); 121 this.eastNorthCacheKey = Main.getProjection().getCacheKey();121 this.eastNorthCacheKey = ProjectionRegistry.getProjection().getCacheKey(); 122 122 } else { 123 123 this.lat = Double.NaN; -
trunk/src/org/openstreetmap/josm/data/osm/NodeData.java
r13764 r14120 2 2 package org.openstreetmap.josm.data.osm; 3 3 4 import org.openstreetmap.josm.Main;5 4 import org.openstreetmap.josm.data.coor.EastNorth; 6 5 import org.openstreetmap.josm.data.coor.LatLon; 7 6 import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor; 7 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 8 8 9 9 /** … … 77 77 @Override 78 78 public void setEastNorth(EastNorth eastNorth) { 79 setCoor( Main.getProjection().eastNorth2latlon(eastNorth));79 setCoor(ProjectionRegistry.getProjection().eastNorth2latlon(eastNorth)); 80 80 } 81 81 -
trunk/src/org/openstreetmap/josm/data/osm/search/SearchCompiler.java
r14098 r14120 23 23 import java.util.stream.Collectors; 24 24 25 import org.openstreetmap.josm.Main;26 25 import org.openstreetmap.josm.data.Bounds; 27 26 import org.openstreetmap.josm.data.coor.LatLon; … … 36 35 import org.openstreetmap.josm.data.osm.search.PushbackTokenizer.Range; 37 36 import org.openstreetmap.josm.data.osm.search.PushbackTokenizer.Token; 37 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 38 38 import org.openstreetmap.josm.gui.mappaint.Environment; 39 39 import org.openstreetmap.josm.gui.mappaint.mapcss.Selector; … … 1895 1895 protected Collection<Bounds> getBounds(OsmPrimitive primitive) { 1896 1896 final Collection<Bounds> bounds = super.getBounds(primitive); 1897 return bounds == null || bounds.isEmpty() ? Collections.singleton(Main.getProjection().getWorldBoundsLatLon()) : bounds; 1897 return bounds == null || bounds.isEmpty() ? 1898 Collections.singleton(ProjectionRegistry.getProjection().getWorldBoundsLatLon()) : bounds; 1898 1899 } 1899 1900 -
trunk/src/org/openstreetmap/josm/data/osm/visitor/BoundingXYVisitor.java
r13906 r14120 4 4 import java.util.Collection; 5 5 6 import org.openstreetmap.josm.Main;7 6 import org.openstreetmap.josm.data.Bounds; 8 7 import org.openstreetmap.josm.data.ProjectionBounds; … … 19 18 import org.openstreetmap.josm.data.osm.Relation; 20 19 import org.openstreetmap.josm.data.osm.Way; 20 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 21 21 import org.openstreetmap.josm.gui.MainApplication; 22 22 import org.openstreetmap.josm.gui.MapFrame; … … 76 76 public void visit(Bounds b) { 77 77 if (b != null) { 78 Main.getProjection().visitOutline(b, this::visit);78 ProjectionRegistry.getProjection().visitOutline(b, this::visit); 79 79 } 80 80 } … … 98 98 public void visit(ILatLon latlon) { 99 99 if (latlon != null) { 100 visit(latlon.getEastNorth( Main.getProjection()));100 visit(latlon.getEastNorth(ProjectionRegistry.getProjection())); 101 101 } 102 102 } … … 159 159 if (bounds == null) 160 160 return; 161 LatLon minLatlon = Main.getProjection().eastNorth2latlon(bounds.getMin());162 LatLon maxLatlon = Main.getProjection().eastNorth2latlon(bounds.getMax());161 LatLon minLatlon = ProjectionRegistry.getProjection().eastNorth2latlon(bounds.getMin()); 162 LatLon maxLatlon = ProjectionRegistry.getProjection().eastNorth2latlon(bounds.getMax()); 163 163 bounds = new ProjectionBounds(new LatLon( 164 164 Math.max(-90, minLatlon.lat() - enlargeDegree), 165 Math.max(-180, minLatlon.lon() - enlargeDegree)).getEastNorth( Main.getProjection()),165 Math.max(-180, minLatlon.lon() - enlargeDegree)).getEastNorth(ProjectionRegistry.getProjection()), 166 166 new LatLon( 167 167 Math.min(90, maxLatlon.lat() + enlargeDegree), 168 Math.min(180, maxLatlon.lon() + enlargeDegree)).getEastNorth( Main.getProjection()));168 Math.min(180, maxLatlon.lon() + enlargeDegree)).getEastNorth(ProjectionRegistry.getProjection())); 169 169 } 170 170 -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/relations/MultipolygonCache.java
r14000 r14120 9 9 import java.util.concurrent.ConcurrentHashMap; 10 10 11 import org.openstreetmap.josm.Main;12 11 import org.openstreetmap.josm.data.osm.DataSelectionListener; 13 12 import org.openstreetmap.josm.data.osm.DataSet; … … 29 28 import org.openstreetmap.josm.data.projection.Projection; 30 29 import org.openstreetmap.josm.data.projection.ProjectionChangeListener; 30 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 31 31 import org.openstreetmap.josm.gui.MainApplication; 32 32 import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent; … … 49 49 50 50 private MultipolygonCache() { 51 Main.addProjectionChangeListener(this);51 ProjectionRegistry.addProjectionChangeListener(this); 52 52 SelectionEventManager.getInstance().addSelectionListener(this); 53 53 MainApplication.getLayerManager().addLayerChangeListener(this); -
trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java
r13672 r14120 31 31 import org.openstreetmap.josm.Main; 32 32 import org.openstreetmap.josm.data.preferences.sources.ValidatorPrefHelper; 33 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 33 34 import org.openstreetmap.josm.data.validation.tests.Addresses; 34 35 import org.openstreetmap.josm.data.validation.tests.ApiCapabilitiesTest; … … 352 353 */ 353 354 public static void initializeGridDetail() { 354 String code = Main.getProjection().toCode();355 String code = ProjectionRegistry.getProjection().toCode(); 355 356 if (Arrays.asList(ProjectionPreference.wgs84.allCodes()).contains(code)) { 356 357 OsmValidator.griddetail = 10_000; -
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r14119 r14120 102 102 import org.openstreetmap.josm.data.preferences.JosmUrls; 103 103 import org.openstreetmap.josm.data.preferences.sources.SourceType; 104 import org.openstreetmap.josm.data.projection.ProjectionBoundsProvider; 104 105 import org.openstreetmap.josm.data.projection.ProjectionCLI; 106 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 105 107 import org.openstreetmap.josm.data.projection.datum.NTV2GridShiftFileSource; 106 108 import org.openstreetmap.josm.data.projection.datum.NTV2GridShiftFileWrapper; … … 258 260 }; 259 261 262 private static final ProjectionBoundsProvider mainBoundsProvider = new ProjectionBoundsProvider() { 263 @Override 264 public Bounds getRealBounds() { 265 return isDisplayingMapView() ? map.mapView.getRealBounds() : null; 266 } 267 268 @Override 269 public void restoreOldBounds(Bounds oldBounds) { 270 if (isDisplayingMapView()) { 271 map.mapView.zoomTo(oldBounds); 272 } 273 } 274 }; 275 260 276 private static final List<CLIModule> cliModules = new ArrayList<>(); 261 277 … … 341 357 undoRedo = super.undoRedo; 342 358 getLayerManager().addLayerChangeListener(undoRedoCleaner); 359 ProjectionRegistry.setboundsProvider(mainBoundsProvider); 343 360 } 344 361 … … 511 528 } catch (SecurityException e) { 512 529 Logging.log(Logging.LEVEL_ERROR, "Unable to shutdown worker", e); 513 }514 }515 516 @Override517 protected Bounds getRealBounds() {518 return isDisplayingMapView() ? map.mapView.getRealBounds() : null;519 }520 521 @Override522 protected void restoreOldBounds(Bounds oldBounds) {523 if (isDisplayingMapView()) {524 map.mapView.zoomTo(oldBounds);525 530 } 526 531 } -
trunk/src/org/openstreetmap/josm/gui/MapView.java
r13890 r14120 37 37 import javax.swing.SwingUtilities; 38 38 39 import org.openstreetmap.josm.Main;40 39 import org.openstreetmap.josm.actions.mapmode.MapMode; 41 40 import org.openstreetmap.josm.data.Bounds; … … 48 47 import org.openstreetmap.josm.data.osm.visitor.paint.Rendering; 49 48 import org.openstreetmap.josm.data.osm.visitor.paint.relations.MultipolygonCache; 49 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 50 50 import org.openstreetmap.josm.gui.MapViewState.MapViewRectangle; 51 51 import org.openstreetmap.josm.gui.autofilter.AutoFilterManager; … … 358 358 359 359 layer.addPropertyChangeListener(this); 360 Main.addProjectionChangeListener(layer);360 ProjectionRegistry.addProjectionChangeListener(layer); 361 361 invalidatedListener.addTo(layer); 362 362 AudioPlayer.reset(); … … 398 398 } 399 399 painter.detachFromMapView(new MapViewEvent(this, false)); 400 Main.removeProjectionChangeListener(layer);400 ProjectionRegistry.removeProjectionChangeListener(layer); 401 401 layer.removePropertyChangeListener(this); 402 402 invalidatedListener.removeFrom(layer); -
trunk/src/org/openstreetmap/josm/gui/MapViewState.java
r14052 r14120 16 16 import javax.swing.JComponent; 17 17 18 import org.openstreetmap.josm.Main;19 18 import org.openstreetmap.josm.data.Bounds; 20 19 import org.openstreetmap.josm.data.ProjectionBounds; … … 25 24 import org.openstreetmap.josm.data.projection.Projecting; 26 25 import org.openstreetmap.josm.data.projection.Projection; 26 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 27 27 import org.openstreetmap.josm.gui.download.DownloadDialog; 28 28 import org.openstreetmap.josm.tools.CheckParameterUtil; … … 394 394 */ 395 395 public static MapViewState createDefaultState(int width, int height) { 396 Projection projection = Main.getProjection();396 Projection projection = ProjectionRegistry.getProjection(); 397 397 double scale = projection.getDefaultZoomInPPD(); 398 398 MapViewState state = new MapViewState(projection, width, height, scale, new EastNorth(0, 0)); … … 403 403 private static EastNorth calculateDefaultCenter() { 404 404 Bounds b = Optional.ofNullable(DownloadDialog.getSavedDownloadBounds()).orElseGet( 405 () -> Main.getProjection().getWorldBoundsLatLon());406 return b.getCenter().getEastNorth( Main.getProjection());405 () -> ProjectionRegistry.getProjection().getWorldBoundsLatLon()); 406 return b.getCenter().getEastNorth(ProjectionRegistry.getProjection()); 407 407 } 408 408 -
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r14052 r14120 32 32 import javax.swing.SwingUtilities; 33 33 34 import org.openstreetmap.josm.Main;35 34 import org.openstreetmap.josm.data.Bounds; 36 35 import org.openstreetmap.josm.data.ProjectionBounds; … … 53 52 import org.openstreetmap.josm.data.projection.Projection; 54 53 import org.openstreetmap.josm.data.projection.ProjectionChangeListener; 54 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 55 55 import org.openstreetmap.josm.gui.help.Helpful; 56 56 import org.openstreetmap.josm.gui.layer.NativeScaleLayer; … … 188 188 setLayout(null); 189 189 state = MapViewState.createDefaultState(getWidth(), getHeight()); 190 Main.addProjectionChangeListener(projectionChangeListener);190 ProjectionRegistry.addProjectionChangeListener(projectionChangeListener); 191 191 } 192 192 … … 334 334 */ 335 335 public void fixProjection() { 336 state = state.usingProjection( Main.getProjection());336 state = state.usingProjection(ProjectionRegistry.getProjection()); 337 337 repaint(); 338 338 } … … 492 492 */ 493 493 public Bounds getLatLonBounds(Rectangle r) { 494 return Main.getProjection().getLatLonBoundsBox(getProjectionBounds(r));494 return ProjectionRegistry.getProjection().getLatLonBoundsBox(getProjectionBounds(r)); 495 495 } 496 496 … … 525 525 return new Point(); 526 526 } else { 527 return getPoint2D(latlon.getEastNorth( Main.getProjection()));527 return getPoint2D(latlon.getEastNorth(ProjectionRegistry.getProjection())); 528 528 } 529 529 } -
trunk/src/org/openstreetmap/josm/gui/datatransfer/importers/PrimitiveDataPaster.java
r13907 r14120 23 23 import org.openstreetmap.josm.data.osm.RelationMemberData; 24 24 import org.openstreetmap.josm.data.osm.WayData; 25 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 25 26 import org.openstreetmap.josm.gui.ExtendedDialog; 26 27 import org.openstreetmap.josm.gui.MainApplication; … … 73 74 if (data instanceof NodeData) { 74 75 NodeData nodeData = (NodeData) data; 75 nodeData.setEastNorth(nodeData.getEastNorth( Main.getProjection()).add(offset));76 nodeData.setEastNorth(nodeData.getEastNorth(ProjectionRegistry.getProjection()).add(offset)); 76 77 } else if (data instanceof WayData) { 77 78 updateNodes(newIds.get(OsmPrimitiveType.NODE), data); -
trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDataText.java
r13953 r14120 8 8 import java.util.List; 9 9 10 import org.openstreetmap.josm.Main;11 10 import org.openstreetmap.josm.data.conflict.Conflict; 12 11 import org.openstreetmap.josm.data.coor.EastNorth; … … 22 21 import org.openstreetmap.josm.data.osm.OsmData; 23 22 import org.openstreetmap.josm.data.osm.OsmPrimitive; 23 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 24 24 import org.openstreetmap.josm.data.projection.proj.TransverseMercator; 25 25 import org.openstreetmap.josm.data.projection.proj.TransverseMercator.Hemisphere; … … 171 171 addBbox(o); 172 172 add(tr("Centroid: "), 173 toStringCSV(", ", Main.getProjection().eastNorth2latlon(173 toStringCSV(", ", ProjectionRegistry.getProjection().eastNorth2latlon( 174 174 Geometry.getCentroid(((IWay<?>) o).getNodes())))); 175 175 addWayNodes((IWay<?>) o); … … 203 203 if (bbox != null) { 204 204 add(tr("Bounding box: "), bbox.toStringCSV(", ")); 205 EastNorth bottomRigth = bbox.getBottomRight().getEastNorth( Main.getProjection());206 EastNorth topLeft = bbox.getTopLeft().getEastNorth( Main.getProjection());205 EastNorth bottomRigth = bbox.getBottomRight().getEastNorth(ProjectionRegistry.getProjection()); 206 EastNorth topLeft = bbox.getTopLeft().getEastNorth(ProjectionRegistry.getProjection()); 207 207 add(tr("Bounding box (projected): "), 208 208 Double.toString(topLeft.east()), ", ", -
trunk/src/org/openstreetmap/josm/gui/dialogs/LatLonDialog.java
r13050 r14120 23 23 import javax.swing.event.DocumentListener; 24 24 25 import org.openstreetmap.josm.Main;26 25 import org.openstreetmap.josm.data.coor.EastNorth; 27 26 import org.openstreetmap.josm.data.coor.LatLon; 28 27 import org.openstreetmap.josm.data.coor.conversion.CoordinateFormatManager; 29 28 import org.openstreetmap.josm.data.coor.conversion.LatLonParser; 29 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 30 30 import org.openstreetmap.josm.gui.ExtendedDialog; 31 31 import org.openstreetmap.josm.gui.util.WindowGeometry; … … 196 196 tfLatLon.setText(CoordinateFormatManager.getDefaultFormat().latToString(llc) + ' ' + 197 197 CoordinateFormatManager.getDefaultFormat().lonToString(llc)); 198 EastNorth en = Main.getProjection().latlon2eastNorth(llc);198 EastNorth en = ProjectionRegistry.getProjection().latlon2eastNorth(llc); 199 199 tfEastNorth.setText(Double.toString(en.east()) + ' ' + Double.toString(en.north())); 200 200 // Both latLonCoordinates and eastNorthCoordinates may have been reset to null if ll is out of the world … … 213 213 } else { 214 214 if (eastNorthCoordinates == null) return null; 215 return Main.getProjection().eastNorth2latlon(eastNorthCoordinates);215 return ProjectionRegistry.getProjection().eastNorth2latlon(eastNorthCoordinates); 216 216 } 217 217 } -
trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
r13967 r14120 91 91 import org.openstreetmap.josm.data.preferences.IntegerProperty; 92 92 import org.openstreetmap.josm.data.projection.Projection; 93 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 93 94 import org.openstreetmap.josm.data.projection.Projections; 94 95 import org.openstreetmap.josm.gui.ExtendedDialog; … … 328 329 if (coordinateConverter.requiresReprojection()) { 329 330 content.add(Arrays.asList(tr("Tile download projection"), tileSource.getServerCRS())); 330 content.add(Arrays.asList(tr("Tile display projection"), Main.getProjection().toCode()));331 content.add(Arrays.asList(tr("Tile display projection"), ProjectionRegistry.getProjection().toCode())); 331 332 } 332 333 content.add(Arrays.asList(tr("Current zoom"), Integer.toString(currentZoomLevel))); … … 449 450 content.add(Arrays.asList(tr("Reprojection"), 450 451 tile.getTileSource().getServerCRS() + 451 " -> " + Main.getProjection().toCode()));452 " -> " + ProjectionRegistry.getProjection().toCode())); 452 453 BufferedImage img = tile.getImage(); 453 454 if (img != null) { … … 566 567 } 567 568 // check if projection is supported 568 projectionChanged(null, Main.getProjection());569 projectionChanged(null, ProjectionRegistry.getProjection()); 569 570 initTileSource(this.tileSource); 570 571 } … … 1412 1413 CoordinateConversion.projToEn(topLeftUnshifted), 1413 1414 CoordinateConversion.projToEn(botRightUnshifted)); 1414 ProjectionBounds bbox = projServer.getEastNorthBoundsBox(projBounds, Main.getProjection());1415 ProjectionBounds bbox = projServer.getEastNorthBoundsBox(projBounds, ProjectionRegistry.getProjection()); 1415 1416 t1 = tileSource.projectedToTileXY(CoordinateConversion.enToProj(bbox.getMin()), zoom); 1416 1417 t2 = tileSource.projectedToTileXY(CoordinateConversion.enToProj(bbox.getMax()), zoom); … … 1962 1963 @Override 1963 1964 public boolean isActive() { 1964 EastNorth offset = bookmark.getDisplacement( Main.getProjection());1965 EastNorth offset = bookmark.getDisplacement(ProjectionRegistry.getProjection()); 1965 1966 EastNorth active = getDisplaySettings().getDisplacement(); 1966 1967 return Utils.equalsEpsilon(offset.east(), active.east()) && Utils.equalsEpsilon(offset.north(), active.north()); -
trunk/src/org/openstreetmap/josm/gui/layer/ImageryLayer.java
r13967 r14120 29 29 import javax.swing.JTextField; 30 30 31 import org.openstreetmap.josm.Main;32 31 import org.openstreetmap.josm.data.ProjectionBounds; 33 32 import org.openstreetmap.josm.data.imagery.ImageryInfo; 34 33 import org.openstreetmap.josm.data.preferences.IntegerProperty; 34 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 35 35 import org.openstreetmap.josm.gui.MainApplication; 36 36 import org.openstreetmap.josm.gui.MapView; … … 85 85 public double getPPD() { 86 86 if (!MainApplication.isDisplayingMapView()) 87 return Main.getProjection().getDefaultZoomInPPD();87 return ProjectionRegistry.getProjection().getDefaultZoomInPPD(); 88 88 MapView mapView = MainApplication.getMap().mapView; 89 89 ProjectionBounds bounds = mapView.getProjectionBounds(); -
trunk/src/org/openstreetmap/josm/gui/layer/WMSLayer.java
r13742 r14120 16 16 import org.apache.commons.jcs.access.CacheAccess; 17 17 import org.openstreetmap.gui.jmapviewer.interfaces.TileLoader; 18 import org.openstreetmap.josm.Main;19 18 import org.openstreetmap.josm.data.cache.BufferedImageCacheEntry; 20 19 import org.openstreetmap.josm.data.coor.LatLon; … … 29 28 import org.openstreetmap.josm.data.preferences.IntegerProperty; 30 29 import org.openstreetmap.josm.data.projection.Projection; 30 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 31 31 import org.openstreetmap.josm.data.projection.Projections; 32 32 import org.openstreetmap.josm.gui.MainApplication; … … 96 96 AbstractWMSTileSource tileSource; 97 97 if (info.getImageryType() == ImageryType.WMS) { 98 tileSource = new TemplatedWMSTileSource(info, chooseProjection( Main.getProjection()));98 tileSource = new TemplatedWMSTileSource(info, chooseProjection(ProjectionRegistry.getProjection())); 99 99 } else { 100 100 /* … … 107 107 * * we always use current definitions returned by server 108 108 */ 109 WMSEndpointTileSource endpointTileSource = new WMSEndpointTileSource(info, Main.getProjection());109 WMSEndpointTileSource endpointTileSource = new WMSEndpointTileSource(info, ProjectionRegistry.getProjection()); 110 110 this.serverProjections = endpointTileSource.getServerProjections(); 111 endpointTileSource.setTileProjection(chooseProjection( Main.getProjection()));111 endpointTileSource.setTileProjection(chooseProjection(ProjectionRegistry.getProjection())); 112 112 tileSource = endpointTileSource; 113 113 } … … 182 182 Logging.info(tr("Reprojecting layer {0} from {1} to {2}. For best image quality and performance," 183 183 + " switch to one of the supported projections: {3}", 184 getName(), proj.toCode(), Main.getProjection().toCode(), Utils.join(", ", getNativeProjections())));184 getName(), proj.toCode(), ProjectionRegistry.getProjection().toCode(), Utils.join(", ", getNativeProjections()))); 185 185 return proj; 186 186 } -
trunk/src/org/openstreetmap/josm/gui/layer/WMTSLayer.java
r13733 r14120 7 7 import org.apache.commons.jcs.access.CacheAccess; 8 8 import org.openstreetmap.gui.jmapviewer.interfaces.TileLoader; 9 import org.openstreetmap.josm.Main;10 9 import org.openstreetmap.josm.data.cache.BufferedImageCacheEntry; 11 10 import org.openstreetmap.josm.data.imagery.ImageryInfo; … … 15 14 import org.openstreetmap.josm.data.imagery.WMTSTileSource.WMTSGetCapabilitiesException; 16 15 import org.openstreetmap.josm.data.projection.Projection; 16 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 17 17 import org.openstreetmap.josm.gui.MainApplication; 18 18 import org.openstreetmap.josm.gui.layer.imagery.TileSourceDisplaySettings; … … 81 81 double displayScale = MainApplication.getMap().mapView.getScale(); 82 82 if (coordinateConverter.requiresReprojection()) { 83 displayScale *= Main.getProjection().getMetersPerUnit();83 displayScale *= ProjectionRegistry.getProjection().getMetersPerUnit(); 84 84 } 85 85 Scale snap = scaleList.getSnapScale(displayScale, false); -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/ImportAudioAction.java
r13130 r14120 25 25 import org.openstreetmap.josm.data.gpx.GpxTrackSegment; 26 26 import org.openstreetmap.josm.data.gpx.WayPoint; 27 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 27 28 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 28 29 import org.openstreetmap.josm.gui.MainApplication; … … 189 190 continue; 190 191 } 191 WayPoint wNear = layer.data.nearestPointOnTrack(w.getEastNorth( Main.getProjection()), snapDistance);192 WayPoint wNear = layer.data.nearestPointOnTrack(w.getEastNorth(ProjectionRegistry.getProjection()), snapDistance); 192 193 if (wNear != null) { 193 194 WayPoint wc = new WayPoint(w.getCoor()); -
trunk/src/org/openstreetmap/josm/gui/layer/imagery/ReprojectionTile.java
r12846 r14120 8 8 import org.openstreetmap.gui.jmapviewer.Tile; 9 9 import org.openstreetmap.gui.jmapviewer.interfaces.TileSource; 10 import org.openstreetmap.josm.Main;11 10 import org.openstreetmap.josm.data.ProjectionBounds; 12 11 import org.openstreetmap.josm.data.coor.EastNorth; 13 12 import org.openstreetmap.josm.data.imagery.CoordinateConversion; 14 13 import org.openstreetmap.josm.data.projection.Projection; 14 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 15 15 import org.openstreetmap.josm.data.projection.Projections; 16 16 import org.openstreetmap.josm.gui.MainApplication; … … 122 122 } 123 123 124 Projection projCurrent = Main.getProjection();124 Projection projCurrent = ProjectionRegistry.getProjection(); 125 125 Projection projServer = Projections.getProjectionByCode(source.getServerCRS()); 126 126 EastNorth en00Server = tileToEastNorth(xtile, ytile, zoom); -
trunk/src/org/openstreetmap/josm/gui/layer/imagery/TileCoordinateConverter.java
r13387 r14120 14 14 import org.openstreetmap.gui.jmapviewer.interfaces.IProjected; 15 15 import org.openstreetmap.gui.jmapviewer.interfaces.TileSource; 16 import org.openstreetmap.josm.Main;17 16 import org.openstreetmap.josm.data.coor.EastNorth; 18 17 import org.openstreetmap.josm.data.coor.LatLon; 19 18 import org.openstreetmap.josm.data.imagery.CoordinateConversion; 20 19 import org.openstreetmap.josm.data.projection.Projecting; 20 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 21 21 import org.openstreetmap.josm.data.projection.ShiftedProjecting; 22 22 import org.openstreetmap.josm.gui.MapView; … … 202 202 */ 203 203 public boolean requiresReprojection() { 204 return !Objects.equals(tileSource.getServerCRS(), Main.getProjection().toCode());204 return !Objects.equals(tileSource.getServerCRS(), ProjectionRegistry.getProjection().toCode()); 205 205 } 206 206 } -
trunk/src/org/openstreetmap/josm/gui/layer/imagery/TileSourceDisplaySettings.java
r13244 r14120 7 7 8 8 import org.openstreetmap.gui.jmapviewer.interfaces.TileSource; 9 import org.openstreetmap.josm.Main;10 9 import org.openstreetmap.josm.data.coor.EastNorth; 11 10 import org.openstreetmap.josm.data.imagery.OffsetBookmark; 12 11 import org.openstreetmap.josm.data.preferences.BooleanProperty; 12 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 13 13 import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer; 14 14 import org.openstreetmap.josm.io.session.SessionAwareReadApply; … … 206 206 setDisplacement(EastNorth.ZERO); 207 207 } else { 208 setDisplacement(offsetBookmark.getDisplacement( Main.getProjection()));208 setDisplacement(offsetBookmark.getDisplacement(ProjectionRegistry.getProjection())); 209 209 } 210 210 } -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/PlayHeadMarker.java
r13281 r14120 22 22 import org.openstreetmap.josm.data.gpx.GpxTrackSegment; 23 23 import org.openstreetmap.josm.data.gpx.WayPoint; 24 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 24 25 import org.openstreetmap.josm.gui.MainApplication; 25 26 import org.openstreetmap.josm.gui.MapFrame; … … 215 216 for (Marker m : recent.parentLayer.data) { 216 217 if (m instanceof AudioMarker) { 217 double distanceSquared = m.getEastNorth( Main.getProjection()).distanceSq(en);218 double distanceSquared = m.getEastNorth(ProjectionRegistry.getProjection()).distanceSq(en); 218 219 if (distanceSquared < closestAudioMarkerDistanceSquared) { 219 220 ca = (AudioMarker) m; … … 348 349 return; 349 350 setEastNorth(w2 == null ? 350 w1.getEastNorth( Main.getProjection()) :351 w1.getEastNorth( Main.getProjection()).interpolate(w2.getEastNorth(Main.getProjection()),351 w1.getEastNorth(ProjectionRegistry.getProjection()) : 352 w1.getEastNorth(ProjectionRegistry.getProjection()).interpolate(w2.getEastNorth(ProjectionRegistry.getProjection()), 352 353 (audioTime - w1.time)/(w2.time - w1.time))); 353 354 time = audioTime; -
trunk/src/org/openstreetmap/josm/gui/mappaint/RenderingCLI.java
r14119 r14120 21 21 22 22 import org.openstreetmap.gui.jmapviewer.OsmMercator; 23 import org.openstreetmap.josm.Main;24 23 import org.openstreetmap.josm.cli.CLIModule; 25 24 import org.openstreetmap.josm.data.Bounds; … … 32 31 import org.openstreetmap.josm.data.preferences.JosmUrls; 33 32 import org.openstreetmap.josm.data.projection.Projection; 33 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 34 34 import org.openstreetmap.josm.data.projection.Projections; 35 35 import org.openstreetmap.josm.gui.mappaint.RenderingHelper.StyleData; … … 427 427 Config.getPref().putBoolean("mappaint.auto_reload_local_styles", false); // unnecessary to listen for external changes 428 428 String projCode = Optional.ofNullable(argProjection).orElse("epsg:3857"); 429 Main.setProjection(Projections.getProjectionByCode(projCode.toUpperCase(Locale.US)));429 ProjectionRegistry.setProjection(Projections.getProjectionByCode(projCode.toUpperCase(Locale.US))); 430 430 431 431 RightAndLefthandTraffic.initialize(); … … 449 449 RenderingArea determineRenderingArea(DataSet ds) { 450 450 451 Projection proj = Main.getProjection();451 Projection proj = ProjectionRegistry.getProjection(); 452 452 Double scale = null; // scale in east-north units per pixel 453 453 if (argZoom != null) { -
trunk/src/org/openstreetmap/josm/gui/mappaint/RenderingHelper.java
r12966 r14120 16 16 import java.util.Optional; 17 17 18 import org.openstreetmap.josm.Main;19 18 import org.openstreetmap.josm.data.Bounds; 20 19 import org.openstreetmap.josm.data.ProjectionBounds; … … 22 21 import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer; 23 22 import org.openstreetmap.josm.data.projection.Projection; 23 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 24 24 import org.openstreetmap.josm.gui.NavigatableComponent; 25 25 import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource; … … 65 65 this.scale = scale; 66 66 this.styles = styles; 67 Projection proj = Main.getProjection();67 Projection proj = ProjectionRegistry.getProjection(); 68 68 projBounds = new ProjectionBounds(); 69 69 projBounds.extend(proj.latlon2eastNorth(bounds.getMin())); -
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreference.java
r14119 r14120 62 62 import org.openstreetmap.josm.data.imagery.Shape; 63 63 import org.openstreetmap.josm.data.preferences.NamedColorProperty; 64 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 64 65 import org.openstreetmap.josm.gui.MainApplication; 65 66 import org.openstreetmap.josm.gui.download.DownloadDialog; … … 856 857 JButton add = new JButton(tr("Add")); 857 858 buttonPanel.add(add, GBC.std().insets(0, 5, 0, 0)); 858 add.addActionListener(e -> model.addRow(new OffsetBookmark( Main.getProjection().toCode(), "", "", "", 0, 0)));859 add.addActionListener(e -> model.addRow(new OffsetBookmark(ProjectionRegistry.getProjection().toCode(), "", "", "", 0, 0))); 859 860 860 861 JButton delete = new JButton(tr("Delete")); -
trunk/src/org/openstreetmap/josm/gui/preferences/projection/ProjectionPreference.java
r14005 r14120 32 32 import org.openstreetmap.josm.data.projection.CustomProjection; 33 33 import org.openstreetmap.josm.data.projection.Projection; 34 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 34 35 import org.openstreetmap.josm.data.projection.Projections; 35 36 import org.openstreetmap.josm.gui.ExtendedDialog; … … 493 494 pc.setPreferences(pref); 494 495 Projection proj = pc.getProjection(); 495 Main.setProjection(proj);496 ProjectionRegistry.setProjection(proj); 496 497 } 497 498 -
trunk/src/org/openstreetmap/josm/io/session/SessionWriter.java
r13901 r14120 26 26 import javax.xml.transform.stream.StreamResult; 27 27 28 import org.openstreetmap.josm.Main;29 28 import org.openstreetmap.josm.data.coor.EastNorth; 30 29 import org.openstreetmap.josm.data.coor.LatLon; 30 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 31 31 import org.openstreetmap.josm.gui.MainApplication; 32 32 import org.openstreetmap.josm.gui.MapView; … … 264 264 MapView mapView = MainApplication.getMap().mapView; 265 265 EastNorth center = mapView.getCenter(); 266 LatLon centerLL = Main.getProjection().eastNorth2latlon(center);266 LatLon centerLL = ProjectionRegistry.getProjection().eastNorth2latlon(center); 267 267 centerEl.setAttribute("lat", Double.toString(centerLL.lat())); 268 268 centerEl.setAttribute("lon", Double.toString(centerLL.lon())); … … 293 293 } 294 294 } 295 String code = Main.getProjection().toCode();295 String code = ProjectionRegistry.getProjection().toCode(); 296 296 if (code != null) { 297 297 Element codeEl = doc.createElement("code"); -
trunk/src/org/openstreetmap/josm/tools/Geometry.java
r13807 r14120 37 37 import org.openstreetmap.josm.data.osm.visitor.paint.relations.MultipolygonCache; 38 38 import org.openstreetmap.josm.data.projection.Projection; 39 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 39 40 import org.openstreetmap.josm.data.projection.Projections; 40 41 … … 164 165 } 165 166 166 Node newNode = new Node( Main.getProjection().eastNorth2latlon(intersection));167 Node newNode = new Node(ProjectionRegistry.getProjection().eastNorth2latlon(intersection)); 167 168 Node intNode = newNode; 168 169 boolean insertInSeg1 = false; … … 1053 1054 double area = 0; 1054 1055 double perimeter = 0; 1055 Projection useProjection = projection == null ? Main.getProjection() : projection;1056 Projection useProjection = projection == null ? ProjectionRegistry.getProjection() : projection; 1056 1057 1057 1058 if (!nodes.isEmpty()) {
Note:
See TracChangeset
for help on using the changeset viewer.