Changeset 14120 in josm


Ignore:
Timestamp:
2018-08-11T17:29:48+02:00 (6 weeks ago)
Author:
Don-vip
Message:

see #15229 - deprecate all Main methods related to projections. New ProjectionRegistry class

Location:
trunk
Files:
2 added
68 edited

Legend:

Unmodified
Added
Removed
  • trunk/scripts/TagInfoExtract.groovy

    r14119 r14120  
    3333import org.openstreetmap.josm.data.preferences.JosmBaseDirectories;
    3434import org.openstreetmap.josm.data.preferences.JosmUrls
     35import org.openstreetmap.josm.data.projection.ProjectionRegistry
    3536import org.openstreetmap.josm.data.projection.Projections
    3637import org.openstreetmap.josm.gui.NavigatableComponent
     
    418419        Config.setBaseDirectoriesProvider(JosmBaseDirectories.getInstance())
    419420        Config.setUrlsProvider(JosmUrls.getInstance())
    420         Main.setProjection(Projections.getProjectionByCode("EPSG:3857"))
     421        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857"))
    421422        Path tmpdir = Files.createTempDirectory(FileSystems.getDefault().getPath(base_dir), "pref")
    422423        tmpdir.toFile().deleteOnExit()
  • trunk/src/org/openstreetmap/josm/Main.java

    r14119 r14120  
    77import java.awt.GraphicsEnvironment;
    88import java.io.IOException;
    9 import java.lang.ref.WeakReference;
    109import java.net.URL;
    1110import java.nio.file.InvalidPathException;
     
    1615import java.util.List;
    1716import java.util.Map;
    18 import java.util.Objects;
    1917import java.util.Set;
    2018import java.util.concurrent.Callable;
    21 import java.util.concurrent.CopyOnWriteArrayList;
    2219import java.util.concurrent.ExecutionException;
    2320import java.util.concurrent.ExecutorService;
     
    2522import java.util.concurrent.Future;
    2623
    27 import org.openstreetmap.josm.data.Bounds;
    2824import org.openstreetmap.josm.data.Preferences;
    2925import org.openstreetmap.josm.data.UndoRedoHandler;
     
    3834import org.openstreetmap.josm.data.projection.Projection;
    3935import org.openstreetmap.josm.data.projection.ProjectionChangeListener;
     36import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    4037import org.openstreetmap.josm.io.FileWatcher;
    4138import org.openstreetmap.josm.io.OnlineResource;
     
    364361    }
    365362
    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 
    379363    /**
    380364     * Replies the current projection.
    381365     *
    382366     * @return the currently active projection
    383      */
     367     * @deprecated Use {@link ProjectionRegistry#getProjection}
     368     */
     369    @Deprecated
    384370    public static Projection getProjection() {
    385         return proj;
     371        return ProjectionRegistry.getProjection();
    386372    }
    387373
     
    390376     *
    391377     * @param p the projection
    392      */
     378     * @deprecated Use {@link ProjectionRegistry#setProjection}
     379     */
     380    @Deprecated
    393381    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);
    437383    }
    438384
     
    442388     *
    443389     * @param listener the listener. Ignored if <code>null</code>.
    444      */
     390     * @deprecated Use {@link ProjectionRegistry#addProjectionChangeListener}
     391     */
     392    @Deprecated
    445393    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);
    452395    }
    453396
     
    456399     *
    457400     * @param listener the listener. Ignored if <code>null</code>.
    458      */
     401     * @deprecated Use {@link ProjectionRegistry#removeProjectionChangeListener}
     402     */
     403    @Deprecated
    459404    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);
    463406    }
    464407
     
    466409     * Remove all projection change listeners. For testing purposes only.
    467410     * @since 13322
    468      */
     411     * @deprecated Use {@link ProjectionRegistry#clearProjectionChangeListeners}
     412     */
     413    @Deprecated
    469414    public static void clearProjectionChangeListeners() {
    470         listeners.clear();
     415        ProjectionRegistry.clearProjectionChangeListeners();
    471416    }
    472417
  • trunk/src/org/openstreetmap/josm/actions/CreateCircleAction.java

    r13434 r14120  
    1818import javax.swing.JOptionPane;
    1919
    20 import org.openstreetmap.josm.Main;
    2120import org.openstreetmap.josm.command.AddCommand;
    2221import org.openstreetmap.josm.command.ChangeCommand;
     
    3029import org.openstreetmap.josm.data.osm.OsmPrimitive;
    3130import org.openstreetmap.josm.data.osm.Way;
     31import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    3232import org.openstreetmap.josm.gui.MainApplication;
    3333import org.openstreetmap.josm.gui.Notification;
     
    180180
    181181        // 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);
    184184
    185185        double radiusInMeters = ll1.greatCircleDistance(ll2);
     
    218218                double x = center.east() + r*Math.cos(alpha);
    219219                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));
    221221                if (ll.isOutSideWorld()) {
    222222                    notifyNodesNotOnCircle();
  • trunk/src/org/openstreetmap/josm/actions/ImageryAdjustAction.java

    r13867 r14120  
    2626import org.openstreetmap.josm.data.coor.LatLon;
    2727import org.openstreetmap.josm.data.imagery.OffsetBookmark;
     28import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2829import org.openstreetmap.josm.gui.ExtendedDialog;
    2930import org.openstreetmap.josm.gui.MainApplication;
     
    7475        }
    7576        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());
    7778        LatLon center;
    7879        if (MainApplication.isDisplayingMapView()) {
    79             center = Main.getProjection().eastNorth2latlon(MainApplication.getMap().mapView.getCenter());
     80            center = ProjectionRegistry.getProjection().eastNorth2latlon(MainApplication.getMap().mapView.getCenter());
    8081        } else {
    8182            center = LatLon.ZERO;
    8283        }
    8384        tempOffset = new OffsetBookmark(
    84                 Main.getProjection().toCode(),
     85                ProjectionRegistry.getProjection().toCode(),
    8586                layer.getInfo().getId(),
    8687                layer.getInfo().getName(),
     
    258259                    "You can also enter east and north offset in the {0} coordinates.\n" +
    259260                    "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());
    261262            pnl.add(new JLabel(tr("Offset:")), GBC.std());
    262263            pnl.add(tOffset, GBC.eol().fill(GBC.HORIZONTAL).insets(0, 0, 0, 5));
     
    313314            if (layer != null) {
    314315                // 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;
    316317                // US locale to force decimal separator to be '.'
    317318                try (Formatter us = new Formatter(Locale.US)) {
  • trunk/src/org/openstreetmap/josm/actions/JoinNodeWayAction.java

    r13434 r14120  
    1919import java.util.TreeSet;
    2020
    21 import org.openstreetmap.josm.Main;
    2221import org.openstreetmap.josm.command.ChangeCommand;
    2322import org.openstreetmap.josm.command.Command;
     
    3029import org.openstreetmap.josm.data.osm.Way;
    3130import org.openstreetmap.josm.data.osm.WaySegment;
     31import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    3232import org.openstreetmap.josm.gui.MainApplication;
    3333import org.openstreetmap.josm.gui.MapView;
     
    143143                                node.getEastNorth());
    144144                        MoveCommand c = new MoveCommand(
    145                                 node, Main.getProjection().eastNorth2latlon(newPosition));
     145                                node, ProjectionRegistry.getProjection().eastNorth2latlon(newPosition));
    146146                        // Avoid moving a given node several times at the same position in case of overlapping ways
    147147                        if (!cmds.contains(c)) {
  • trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java

    r13712 r14120  
    3030import org.openstreetmap.josm.data.osm.OsmPrimitive;
    3131import org.openstreetmap.josm.data.osm.Way;
     32import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    3233import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil;
    3334import org.openstreetmap.josm.gui.MainApplication;
     
    148149        if (!isEnabled())
    149150            return;
    150         if ("EPSG:4326".equals(Main.getProjection().toString())) {
     151        if ("EPSG:4326".equals(ProjectionRegistry.getProjection().toString())) {
    151152            String msg = tr("<html>You are using the EPSG:4326 projection which might lead<br>" +
    152153                    "to undesirable results when doing rectangular alignments.<br>" +
     
    307308            throw new InvalidUserInputException("Unable to orthogonalize " + singleNode);
    308309        }
    309         return new MoveCommand(singleNode, Main.getProjection().eastNorth2latlon(Geometry.getCentroidEN(rightAnglePositions)));
     310        return new MoveCommand(singleNode, ProjectionRegistry.getProjection().eastNorth2latlon(Geometry.getCentroidEN(rightAnglePositions)));
    310311    }
    311312
  • trunk/src/org/openstreetmap/josm/actions/SessionLoadAction.java

    r13437 r14120  
    2020
    2121import org.openstreetmap.josm.Main;
     22import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2223import org.openstreetmap.josm.gui.HelpAwareOptionPane;
    2324import org.openstreetmap.josm.gui.MainApplication;
     
    147148                }
    148149                if (noMap && viewport != null) {
    149                     MainApplication.getMap().mapView.scheduleZoomTo(viewport.getEastNorthViewport(Main.getProjection()));
     150                    MainApplication.getMap().mapView.scheduleZoomTo(viewport.getEastNorthViewport(ProjectionRegistry.getProjection()));
    150151                }
    151152            }
  • trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java

    r13434 r14120  
    2929import javax.swing.JMenuItem;
    3030
    31 import org.openstreetmap.josm.Main;
    3231import org.openstreetmap.josm.actions.JosmAction;
    3332import org.openstreetmap.josm.actions.MergeNodesAction;
     
    4645import org.openstreetmap.josm.data.osm.WaySegment;
    4746import org.openstreetmap.josm.data.preferences.NamedColorProperty;
     47import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    4848import org.openstreetmap.josm.gui.MainApplication;
    4949import org.openstreetmap.josm.gui.MainMenu;
     
    655655            //move existing node
    656656            Node n1Old = selectedSegment.getFirstNode();
    657             cmds.add(new MoveCommand(n1Old, Main.getProjection().eastNorth2latlon(newN1en)));
     657            cmds.add(new MoveCommand(n1Old, ProjectionRegistry.getProjection().eastNorth2latlon(newN1en)));
    658658            changedNodes.add(n1Old);
    659659        } else if (ignoreSharedNodes && segmentAngleZero && !alwaysCreateNodes && hasOtherWays) {
    660660            // replace shared node with new one
    661661            Node n1Old = selectedSegment.getFirstNode();
    662             Node n1New = new Node(Main.getProjection().eastNorth2latlon(newN1en));
     662            Node n1New = new Node(ProjectionRegistry.getProjection().eastNorth2latlon(newN1en));
    663663            wnew.addNode(insertionPoint, n1New);
    664664            wnew.removeNode(n1Old);
     
    668668        } else {
    669669            //introduce new node
    670             Node n1New = new Node(Main.getProjection().eastNorth2latlon(newN1en));
     670            Node n1New = new Node(ProjectionRegistry.getProjection().eastNorth2latlon(newN1en));
    671671            wnew.addNode(insertionPoint, n1New);
    672672            wayWasModified = true;
     
    685685            //move existing node
    686686            Node n2Old = selectedSegment.getSecondNode();
    687             cmds.add(new MoveCommand(n2Old, Main.getProjection().eastNorth2latlon(newN2en)));
     687            cmds.add(new MoveCommand(n2Old, ProjectionRegistry.getProjection().eastNorth2latlon(newN2en)));
    688688            changedNodes.add(n2Old);
    689689        } else if (ignoreSharedNodes && segmentAngleZero && !alwaysCreateNodes && hasOtherWays) {
    690690            // replace shared node with new one
    691691            Node n2Old = selectedSegment.getSecondNode();
    692             Node n2New = new Node(Main.getProjection().eastNorth2latlon(newN2en));
     692            Node n2New = new Node(ProjectionRegistry.getProjection().eastNorth2latlon(newN2en));
    693693            wnew.addNode(insertionPoint, n2New);
    694694            wnew.removeNode(n2Old);
     
    698698        } else {
    699699            //introduce new node
    700             Node n2New = new Node(Main.getProjection().eastNorth2latlon(newN2en));
     700            Node n2New = new Node(ProjectionRegistry.getProjection().eastNorth2latlon(newN2en));
    701701            wnew.addNode(insertionPoint, n2New);
    702702            wayWasModified = true;
     
    937937
    938938        // 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));
    941941        MainApplication.getMap().statusLine.setDist(distance);
    942942        updateStatusLine();
  • trunk/src/org/openstreetmap/josm/command/MoveCommand.java

    r12778 r14120  
    1414import javax.swing.Icon;
    1515
    16 import org.openstreetmap.josm.Main;
    1716import org.openstreetmap.josm.data.coor.EastNorth;
    1817import org.openstreetmap.josm.data.coor.LatLon;
     
    2120import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2221import org.openstreetmap.josm.data.osm.visitor.AllNodesVisitor;
     22import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2323import org.openstreetmap.josm.tools.ImageProvider;
    2424
     
    7373    public MoveCommand(Node node, LatLon position) {
    7474        this(Collections.singleton((OsmPrimitive) node),
    75                 Main.getProjection().latlon2eastNorth(position).subtract(node.getEastNorth()));
     75                ProjectionRegistry.getProjection().latlon2eastNorth(position).subtract(node.getEastNorth()));
    7676    }
    7777
  • trunk/src/org/openstreetmap/josm/data/coor/CachedLatLon.java

    r12161 r14120  
    44import java.util.Objects;
    55
    6 import org.openstreetmap.josm.Main;
    76import org.openstreetmap.josm.data.projection.Projecting;
    87import org.openstreetmap.josm.data.projection.Projection;
     8import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    99
    1010/**
     
    4646     */
    4747    public CachedLatLon(EastNorth eastNorth) {
    48         this(eastNorth, Main.getProjection());
     48        this(eastNorth, ProjectionRegistry.getProjection());
    4949    }
    5050
  • trunk/src/org/openstreetmap/josm/data/coor/LatLon.java

    r14091 r14120  
    1717import java.util.Objects;
    1818
    19 import org.openstreetmap.josm.Main;
    2019import org.openstreetmap.josm.data.Bounds;
     20import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2121import org.openstreetmap.josm.tools.Logging;
    2222import org.openstreetmap.josm.tools.Utils;
     
    195195     */
    196196    public boolean isOutSideWorld() {
    197         Bounds b = Main.getProjection().getWorldBoundsLatLon();
     197        Bounds b = ProjectionRegistry.getProjection().getWorldBoundsLatLon();
    198198        return lat() < b.getMinLat() || lat() > b.getMaxLat() ||
    199199                lon() < b.getMinLon() || lon() > b.getMaxLon();
  • trunk/src/org/openstreetmap/josm/data/coor/conversion/ProjectedCoordinateFormat.java

    r12741 r14120  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    6 import org.openstreetmap.josm.Main;
    76import org.openstreetmap.josm.data.coor.ILatLon;
     7import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    88
    99/**
     
    2525    @Override
    2626    public String latToString(ILatLon ll) {
    27         return cDdFormatter.format(ll.getEastNorth(Main.getProjection()).north());
     27        return cDdFormatter.format(ll.getEastNorth(ProjectionRegistry.getProjection()).north());
    2828    }
    2929
    3030    @Override
    3131    public String lonToString(ILatLon ll) {
    32         return cDdFormatter.format(ll.getEastNorth(Main.getProjection()).east());
     32        return cDdFormatter.format(ll.getEastNorth(ProjectionRegistry.getProjection()).east());
    3333    }
    3434}
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java

    r13257 r14120  
    2020import java.util.stream.Stream;
    2121
    22 import org.openstreetmap.josm.Main;
    2322import org.openstreetmap.josm.data.Bounds;
    2423import org.openstreetmap.josm.data.Data;
     
    2625import org.openstreetmap.josm.data.coor.EastNorth;
    2726import org.openstreetmap.josm.data.gpx.GpxTrack.GpxTrackChangeListener;
     27import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2828import org.openstreetmap.josm.gui.MainApplication;
    2929import org.openstreetmap.josm.gui.layer.GpxLayer;
     
    539539                WayPoint r = null;
    540540                for (WayPoint wpSeg : seg.getWayPoints()) {
    541                     EastNorth en = wpSeg.getEastNorth(Main.getProjection());
     541                    EastNorth en = wpSeg.getEastNorth(ProjectionRegistry.getProjection());
    542542                    if (r == null) {
    543543                        r = wpSeg;
     
    586586                }
    587587                if (r != null) {
    588                     EastNorth c = r.getEastNorth(Main.getProjection());
     588                    EastNorth c = r.getEastNorth(ProjectionRegistry.getProjection());
    589589                    /* if there is only one point in the seg, it will do this twice, but no matter */
    590590                    rx = c.east();
     
    603603        if (bestEN == null)
    604604            return null;
    605         WayPoint best = new WayPoint(Main.getProjection().eastNorth2latlon(bestEN));
     605        WayPoint best = new WayPoint(ProjectionRegistry.getProjection().eastNorth2latlon(bestEN));
    606606        best.time = bestTime;
    607607        return best;
  • trunk/src/org/openstreetmap/josm/data/imagery/OffsetBookmark.java

    r13798 r14120  
    1010import java.util.stream.Collectors;
    1111
    12 import org.openstreetmap.josm.Main;
    1312import org.openstreetmap.josm.data.StructUtils;
    1413import org.openstreetmap.josm.data.StructUtils.StructEntry;
     
    1817import org.openstreetmap.josm.data.coor.LatLon;
    1918import org.openstreetmap.josm.data.projection.Projection;
     19import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2020import org.openstreetmap.josm.data.projection.Projections;
    2121import org.openstreetmap.josm.gui.MainApplication;
     
    4949    public boolean isUsable(ImageryLayer layer) {
    5050        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;
    5252        ImageryInfo info = layer.getInfo();
    5353        return imagery_id != null ? Objects.equals(info.getId(), imagery_id) : Objects.equals(info.getName(), imagery_name);
     
    363363        LatLon center;
    364364        if (MainApplication.isDisplayingMapView()) {
    365             center = Main.getProjection().eastNorth2latlon(MainApplication.getMap().mapView.getCenter());
     365            center = ProjectionRegistry.getProjection().eastNorth2latlon(MainApplication.getMap().mapView.getCenter());
    366366        } else {
    367367            center = LatLon.ZERO;
    368368        }
    369369        OffsetBookmark nb = new OffsetBookmark(
    370                 Main.getProjection().toCode(), layer.getInfo().getId(), layer.getInfo().getName(),
     370                ProjectionRegistry.getProjection().toCode(), layer.getInfo().getId(), layer.getInfo().getName(),
    371371                name, layer.getDisplaySettings().getDisplacement(), center);
    372372        for (ListIterator<OffsetBookmark> it = allBookmarks.listIterator(); it.hasNext();) {
  • trunk/src/org/openstreetmap/josm/data/imagery/TemplatedWMSTileSource.java

    r13733 r14120  
    1616
    1717import org.openstreetmap.gui.jmapviewer.interfaces.TemplatedTileSource;
    18 import org.openstreetmap.josm.Main;
    1918import org.openstreetmap.josm.data.coor.EastNorth;
    2019import org.openstreetmap.josm.data.projection.Projection;
     20import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2121import org.openstreetmap.josm.gui.layer.WMSLayer;
    2222import org.openstreetmap.josm.tools.CheckParameterUtil;
     
    108108        } else if (baseUrl.toLowerCase(Locale.US).contains("crs=")) {
    109109            // assume WMS 1.3.0
    110             switchLatLon = Main.getProjection().switchXY();
     110            switchLatLon = ProjectionRegistry.getProjection().switchXY();
    111111        }
    112112        String bbox = getBbox(zoom, tilex, tiley, switchLatLon);
  • trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java

    r13879 r14120  
    5050import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType;
    5151import org.openstreetmap.josm.data.projection.Projection;
     52import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    5253import org.openstreetmap.josm.data.projection.Projections;
    5354import org.openstreetmap.josm.gui.ExtendedDialog;
     
    346347            List<Layer> ls = layerById.entrySet().iterator().next().getValue()
    347348                    .stream().filter(
    348                             u -> u.tileMatrixSet.crs.equals(Main.getProjection().toCode()))
     349                            u -> u.tileMatrixSet.crs.equals(ProjectionRegistry.getProjection().toCode()))
    349350                    .collect(Collectors.toList());
    350351            if (ls.size() == 1) {
     
    631632    private static TileMatrix parseTileMatrix(XMLStreamReader reader, String matrixCrs) throws XMLStreamException {
    632633        Projection matrixProj = Optional.ofNullable(Projections.getProjectionByCode(matrixCrs))
    633                 .orElseGet(Main::getProjection); // use current projection if none found. Maybe user is using custom string
     634                .orElseGet(ProjectionRegistry::getProjection); // use current projection if none found. Maybe user is using custom string
    634635        TileMatrix ret = new TileMatrix();
    635636        for (int event = reader.getEventType();
  • trunk/src/org/openstreetmap/josm/data/osm/DataSet.java

    r14119 r14120  
    2525import java.util.stream.Stream;
    2626
    27 import org.openstreetmap.josm.Main;
    2827import org.openstreetmap.josm.data.APIDataSet.APIOperation;
    2928import org.openstreetmap.josm.data.Bounds;
     
    5453import org.openstreetmap.josm.data.projection.Projection;
    5554import org.openstreetmap.josm.data.projection.ProjectionChangeListener;
     55import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    5656import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    5757import org.openstreetmap.josm.spi.preferences.Config;
     
    175175        // Transparently register as projection change listener. No need to explicitly remove
    176176        // the listener, projection change listeners are managed as WeakReferences.
    177         Main.addProjectionChangeListener(this);
     177        ProjectionRegistry.addProjectionChangeListener(this);
    178178        addSelectionListener((DataSelectionListener) e -> fireSelectionChange(e.getSelection()));
    179179    }
     
    10451045     */
    10461046    public void invalidateEastNorthCache() {
    1047         if (Main.getProjection() == null)
     1047        if (ProjectionRegistry.getProjection() == null)
    10481048            return; // sanity check
    10491049        beginUpdate();
  • trunk/src/org/openstreetmap/josm/data/osm/INode.java

    r13669 r14120  
    66import org.openstreetmap.josm.data.coor.ILatLon;
    77import org.openstreetmap.josm.data.coor.LatLon;
     8import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    89
    910/**
     
    3435     */
    3536    default EastNorth getEastNorth() {
    36         return getEastNorth(Main.getProjection());
     37        return getEastNorth(ProjectionRegistry.getProjection());
    3738    }
    3839
  • trunk/src/org/openstreetmap/josm/data/osm/Node.java

    r13669 r14120  
    1010import java.util.function.Predicate;
    1111
    12 import org.openstreetmap.josm.Main;
    1312import org.openstreetmap.josm.data.coor.EastNorth;
    1413import org.openstreetmap.josm.data.coor.LatLon;
     
    1615import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor;
    1716import org.openstreetmap.josm.data.projection.Projecting;
     17import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    1818import org.openstreetmap.josm.tools.CheckParameterUtil;
    1919import org.openstreetmap.josm.tools.Utils;
     
    114114            invalidateEastNorthCache();
    115115        } else if (eastNorth != null) {
    116             LatLon ll = Main.getProjection().eastNorth2latlon(eastNorth);
     116            LatLon ll = ProjectionRegistry.getProjection().eastNorth2latlon(eastNorth);
    117117            this.lat = ll.lat();
    118118            this.lon = ll.lon();
    119119            this.east = eastNorth.east();
    120120            this.north = eastNorth.north();
    121             this.eastNorthCacheKey = Main.getProjection().getCacheKey();
     121            this.eastNorthCacheKey = ProjectionRegistry.getProjection().getCacheKey();
    122122        } else {
    123123            this.lat = Double.NaN;
  • trunk/src/org/openstreetmap/josm/data/osm/NodeData.java

    r13764 r14120  
    22package org.openstreetmap.josm.data.osm;
    33
    4 import org.openstreetmap.josm.Main;
    54import org.openstreetmap.josm.data.coor.EastNorth;
    65import org.openstreetmap.josm.data.coor.LatLon;
    76import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor;
     7import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    88
    99/**
     
    7777    @Override
    7878    public void setEastNorth(EastNorth eastNorth) {
    79         setCoor(Main.getProjection().eastNorth2latlon(eastNorth));
     79        setCoor(ProjectionRegistry.getProjection().eastNorth2latlon(eastNorth));
    8080    }
    8181
  • trunk/src/org/openstreetmap/josm/data/osm/search/SearchCompiler.java

    r14098 r14120  
    2323import java.util.stream.Collectors;
    2424
    25 import org.openstreetmap.josm.Main;
    2625import org.openstreetmap.josm.data.Bounds;
    2726import org.openstreetmap.josm.data.coor.LatLon;
     
    3635import org.openstreetmap.josm.data.osm.search.PushbackTokenizer.Range;
    3736import org.openstreetmap.josm.data.osm.search.PushbackTokenizer.Token;
     37import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    3838import org.openstreetmap.josm.gui.mappaint.Environment;
    3939import org.openstreetmap.josm.gui.mappaint.mapcss.Selector;
     
    18951895        protected Collection<Bounds> getBounds(OsmPrimitive primitive) {
    18961896            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;
    18981899        }
    18991900
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/BoundingXYVisitor.java

    r13906 r14120  
    44import java.util.Collection;
    55
    6 import org.openstreetmap.josm.Main;
    76import org.openstreetmap.josm.data.Bounds;
    87import org.openstreetmap.josm.data.ProjectionBounds;
     
    1918import org.openstreetmap.josm.data.osm.Relation;
    2019import org.openstreetmap.josm.data.osm.Way;
     20import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2121import org.openstreetmap.josm.gui.MainApplication;
    2222import org.openstreetmap.josm.gui.MapFrame;
     
    7676    public void visit(Bounds b) {
    7777        if (b != null) {
    78             Main.getProjection().visitOutline(b, this::visit);
     78            ProjectionRegistry.getProjection().visitOutline(b, this::visit);
    7979        }
    8080    }
     
    9898    public void visit(ILatLon latlon) {
    9999        if (latlon != null) {
    100             visit(latlon.getEastNorth(Main.getProjection()));
     100            visit(latlon.getEastNorth(ProjectionRegistry.getProjection()));
    101101        }
    102102    }
     
    159159        if (bounds == null)
    160160            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());
    163163        bounds = new ProjectionBounds(new LatLon(
    164164                        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()),
    166166                new LatLon(
    167167                        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()));
    169169    }
    170170
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/relations/MultipolygonCache.java

    r14000 r14120  
    99import java.util.concurrent.ConcurrentHashMap;
    1010
    11 import org.openstreetmap.josm.Main;
    1211import org.openstreetmap.josm.data.osm.DataSelectionListener;
    1312import org.openstreetmap.josm.data.osm.DataSet;
     
    2928import org.openstreetmap.josm.data.projection.Projection;
    3029import org.openstreetmap.josm.data.projection.ProjectionChangeListener;
     30import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    3131import org.openstreetmap.josm.gui.MainApplication;
    3232import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent;
     
    4949
    5050    private MultipolygonCache() {
    51         Main.addProjectionChangeListener(this);
     51        ProjectionRegistry.addProjectionChangeListener(this);
    5252        SelectionEventManager.getInstance().addSelectionListener(this);
    5353        MainApplication.getLayerManager().addLayerChangeListener(this);
  • trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java

    r13672 r14120  
    3131import org.openstreetmap.josm.Main;
    3232import org.openstreetmap.josm.data.preferences.sources.ValidatorPrefHelper;
     33import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    3334import org.openstreetmap.josm.data.validation.tests.Addresses;
    3435import org.openstreetmap.josm.data.validation.tests.ApiCapabilitiesTest;
     
    352353     */
    353354    public static void initializeGridDetail() {
    354         String code = Main.getProjection().toCode();
     355        String code = ProjectionRegistry.getProjection().toCode();
    355356        if (Arrays.asList(ProjectionPreference.wgs84.allCodes()).contains(code)) {
    356357            OsmValidator.griddetail = 10_000;
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r14119 r14120  
    102102import org.openstreetmap.josm.data.preferences.JosmUrls;
    103103import org.openstreetmap.josm.data.preferences.sources.SourceType;
     104import org.openstreetmap.josm.data.projection.ProjectionBoundsProvider;
    104105import org.openstreetmap.josm.data.projection.ProjectionCLI;
     106import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    105107import org.openstreetmap.josm.data.projection.datum.NTV2GridShiftFileSource;
    106108import org.openstreetmap.josm.data.projection.datum.NTV2GridShiftFileWrapper;
     
    258260    };
    259261
     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
    260276    private static final List<CLIModule> cliModules = new ArrayList<>();
    261277
     
    341357        undoRedo = super.undoRedo;
    342358        getLayerManager().addLayerChangeListener(undoRedoCleaner);
     359        ProjectionRegistry.setboundsProvider(mainBoundsProvider);
    343360    }
    344361
     
    511528        } catch (SecurityException e) {
    512529            Logging.log(Logging.LEVEL_ERROR, "Unable to shutdown worker", e);
    513         }
    514     }
    515 
    516     @Override
    517     protected Bounds getRealBounds() {
    518         return isDisplayingMapView() ? map.mapView.getRealBounds() : null;
    519     }
    520 
    521     @Override
    522     protected void restoreOldBounds(Bounds oldBounds) {
    523         if (isDisplayingMapView()) {
    524             map.mapView.zoomTo(oldBounds);
    525530        }
    526531    }
  • trunk/src/org/openstreetmap/josm/gui/MapView.java

    r13890 r14120  
    3737import javax.swing.SwingUtilities;
    3838
    39 import org.openstreetmap.josm.Main;
    4039import org.openstreetmap.josm.actions.mapmode.MapMode;
    4140import org.openstreetmap.josm.data.Bounds;
     
    4847import org.openstreetmap.josm.data.osm.visitor.paint.Rendering;
    4948import org.openstreetmap.josm.data.osm.visitor.paint.relations.MultipolygonCache;
     49import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    5050import org.openstreetmap.josm.gui.MapViewState.MapViewRectangle;
    5151import org.openstreetmap.josm.gui.autofilter.AutoFilterManager;
     
    358358
    359359                layer.addPropertyChangeListener(this);
    360                 Main.addProjectionChangeListener(layer);
     360                ProjectionRegistry.addProjectionChangeListener(layer);
    361361                invalidatedListener.addTo(layer);
    362362                AudioPlayer.reset();
     
    398398        }
    399399        painter.detachFromMapView(new MapViewEvent(this, false));
    400         Main.removeProjectionChangeListener(layer);
     400        ProjectionRegistry.removeProjectionChangeListener(layer);
    401401        layer.removePropertyChangeListener(this);
    402402        invalidatedListener.removeFrom(layer);
  • trunk/src/org/openstreetmap/josm/gui/MapViewState.java

    r14052 r14120  
    1616import javax.swing.JComponent;
    1717
    18 import org.openstreetmap.josm.Main;
    1918import org.openstreetmap.josm.data.Bounds;
    2019import org.openstreetmap.josm.data.ProjectionBounds;
     
    2524import org.openstreetmap.josm.data.projection.Projecting;
    2625import org.openstreetmap.josm.data.projection.Projection;
     26import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2727import org.openstreetmap.josm.gui.download.DownloadDialog;
    2828import org.openstreetmap.josm.tools.CheckParameterUtil;
     
    394394     */
    395395    public static MapViewState createDefaultState(int width, int height) {
    396         Projection projection = Main.getProjection();
     396        Projection projection = ProjectionRegistry.getProjection();
    397397        double scale = projection.getDefaultZoomInPPD();
    398398        MapViewState state = new MapViewState(projection, width, height, scale, new EastNorth(0, 0));
     
    403403    private static EastNorth calculateDefaultCenter() {
    404404        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());
    407407    }
    408408
  • trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java

    r14052 r14120  
    3232import javax.swing.SwingUtilities;
    3333
    34 import org.openstreetmap.josm.Main;
    3534import org.openstreetmap.josm.data.Bounds;
    3635import org.openstreetmap.josm.data.ProjectionBounds;
     
    5352import org.openstreetmap.josm.data.projection.Projection;
    5453import org.openstreetmap.josm.data.projection.ProjectionChangeListener;
     54import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    5555import org.openstreetmap.josm.gui.help.Helpful;
    5656import org.openstreetmap.josm.gui.layer.NativeScaleLayer;
     
    188188        setLayout(null);
    189189        state = MapViewState.createDefaultState(getWidth(), getHeight());
    190         Main.addProjectionChangeListener(projectionChangeListener);
     190        ProjectionRegistry.addProjectionChangeListener(projectionChangeListener);
    191191    }
    192192
     
    334334     */
    335335    public void fixProjection() {
    336         state = state.usingProjection(Main.getProjection());
     336        state = state.usingProjection(ProjectionRegistry.getProjection());
    337337        repaint();
    338338    }
     
    492492     */
    493493    public Bounds getLatLonBounds(Rectangle r) {
    494         return Main.getProjection().getLatLonBoundsBox(getProjectionBounds(r));
     494        return ProjectionRegistry.getProjection().getLatLonBoundsBox(getProjectionBounds(r));
    495495    }
    496496
     
    525525            return new Point();
    526526        } else {
    527             return getPoint2D(latlon.getEastNorth(Main.getProjection()));
     527            return getPoint2D(latlon.getEastNorth(ProjectionRegistry.getProjection()));
    528528        }
    529529    }
  • trunk/src/org/openstreetmap/josm/gui/datatransfer/importers/PrimitiveDataPaster.java

    r13907 r14120  
    2323import org.openstreetmap.josm.data.osm.RelationMemberData;
    2424import org.openstreetmap.josm.data.osm.WayData;
     25import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2526import org.openstreetmap.josm.gui.ExtendedDialog;
    2627import org.openstreetmap.josm.gui.MainApplication;
     
    7374                if (data instanceof NodeData) {
    7475                    NodeData nodeData = (NodeData) data;
    75                     nodeData.setEastNorth(nodeData.getEastNorth(Main.getProjection()).add(offset));
     76                    nodeData.setEastNorth(nodeData.getEastNorth(ProjectionRegistry.getProjection()).add(offset));
    7677                } else if (data instanceof WayData) {
    7778                    updateNodes(newIds.get(OsmPrimitiveType.NODE), data);
  • trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDataText.java

    r13953 r14120  
    88import java.util.List;
    99
    10 import org.openstreetmap.josm.Main;
    1110import org.openstreetmap.josm.data.conflict.Conflict;
    1211import org.openstreetmap.josm.data.coor.EastNorth;
     
    2221import org.openstreetmap.josm.data.osm.OsmData;
    2322import org.openstreetmap.josm.data.osm.OsmPrimitive;
     23import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2424import org.openstreetmap.josm.data.projection.proj.TransverseMercator;
    2525import org.openstreetmap.josm.data.projection.proj.TransverseMercator.Hemisphere;
     
    171171            addBbox(o);
    172172            add(tr("Centroid: "),
    173                     toStringCSV(", ", Main.getProjection().eastNorth2latlon(
     173                    toStringCSV(", ", ProjectionRegistry.getProjection().eastNorth2latlon(
    174174                            Geometry.getCentroid(((IWay<?>) o).getNodes()))));
    175175            addWayNodes((IWay<?>) o);
     
    203203        if (bbox != null) {
    204204            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());
    207207            add(tr("Bounding box (projected): "),
    208208                    Double.toString(topLeft.east()), ", ",
  • trunk/src/org/openstreetmap/josm/gui/dialogs/LatLonDialog.java

    r13050 r14120  
    2323import javax.swing.event.DocumentListener;
    2424
    25 import org.openstreetmap.josm.Main;
    2625import org.openstreetmap.josm.data.coor.EastNorth;
    2726import org.openstreetmap.josm.data.coor.LatLon;
    2827import org.openstreetmap.josm.data.coor.conversion.CoordinateFormatManager;
    2928import org.openstreetmap.josm.data.coor.conversion.LatLonParser;
     29import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    3030import org.openstreetmap.josm.gui.ExtendedDialog;
    3131import org.openstreetmap.josm.gui.util.WindowGeometry;
     
    196196        tfLatLon.setText(CoordinateFormatManager.getDefaultFormat().latToString(llc) + ' ' +
    197197                         CoordinateFormatManager.getDefaultFormat().lonToString(llc));
    198         EastNorth en = Main.getProjection().latlon2eastNorth(llc);
     198        EastNorth en = ProjectionRegistry.getProjection().latlon2eastNorth(llc);
    199199        tfEastNorth.setText(Double.toString(en.east()) + ' ' + Double.toString(en.north()));
    200200        // Both latLonCoordinates and eastNorthCoordinates may have been reset to null if ll is out of the world
     
    213213        } else {
    214214            if (eastNorthCoordinates == null) return null;
    215             return Main.getProjection().eastNorth2latlon(eastNorthCoordinates);
     215            return ProjectionRegistry.getProjection().eastNorth2latlon(eastNorthCoordinates);
    216216        }
    217217    }
  • trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java

    r13967 r14120  
    9191import org.openstreetmap.josm.data.preferences.IntegerProperty;
    9292import org.openstreetmap.josm.data.projection.Projection;
     93import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    9394import org.openstreetmap.josm.data.projection.Projections;
    9495import org.openstreetmap.josm.gui.ExtendedDialog;
     
    328329        if (coordinateConverter.requiresReprojection()) {
    329330            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()));
    331332        }
    332333        content.add(Arrays.asList(tr("Current zoom"), Integer.toString(currentZoomLevel)));
     
    449450                    content.add(Arrays.asList(tr("Reprojection"),
    450451                            tile.getTileSource().getServerCRS() +
    451                             " -> " + Main.getProjection().toCode()));
     452                            " -> " + ProjectionRegistry.getProjection().toCode()));
    452453                    BufferedImage img = tile.getImage();
    453454                    if (img != null) {
     
    566567            }
    567568            // check if projection is supported
    568             projectionChanged(null, Main.getProjection());
     569            projectionChanged(null, ProjectionRegistry.getProjection());
    569570            initTileSource(this.tileSource);
    570571        }
     
    14121413                    CoordinateConversion.projToEn(topLeftUnshifted),
    14131414                    CoordinateConversion.projToEn(botRightUnshifted));
    1414             ProjectionBounds bbox = projServer.getEastNorthBoundsBox(projBounds, Main.getProjection());
     1415            ProjectionBounds bbox = projServer.getEastNorthBoundsBox(projBounds, ProjectionRegistry.getProjection());
    14151416            t1 = tileSource.projectedToTileXY(CoordinateConversion.enToProj(bbox.getMin()), zoom);
    14161417            t2 = tileSource.projectedToTileXY(CoordinateConversion.enToProj(bbox.getMax()), zoom);
     
    19621963        @Override
    19631964        public boolean isActive() {
    1964             EastNorth offset = bookmark.getDisplacement(Main.getProjection());
     1965            EastNorth offset = bookmark.getDisplacement(ProjectionRegistry.getProjection());
    19651966            EastNorth active = getDisplaySettings().getDisplacement();
    19661967            return Utils.equalsEpsilon(offset.east(), active.east()) && Utils.equalsEpsilon(offset.north(), active.north());
  • trunk/src/org/openstreetmap/josm/gui/layer/ImageryLayer.java

    r13967 r14120  
    2929import javax.swing.JTextField;
    3030
    31 import org.openstreetmap.josm.Main;
    3231import org.openstreetmap.josm.data.ProjectionBounds;
    3332import org.openstreetmap.josm.data.imagery.ImageryInfo;
    3433import org.openstreetmap.josm.data.preferences.IntegerProperty;
     34import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    3535import org.openstreetmap.josm.gui.MainApplication;
    3636import org.openstreetmap.josm.gui.MapView;
     
    8585    public double getPPD() {
    8686        if (!MainApplication.isDisplayingMapView())
    87             return Main.getProjection().getDefaultZoomInPPD();
     87            return ProjectionRegistry.getProjection().getDefaultZoomInPPD();
    8888        MapView mapView = MainApplication.getMap().mapView;
    8989        ProjectionBounds bounds = mapView.getProjectionBounds();
  • trunk/src/org/openstreetmap/josm/gui/layer/WMSLayer.java

    r13742 r14120  
    1616import org.apache.commons.jcs.access.CacheAccess;
    1717import org.openstreetmap.gui.jmapviewer.interfaces.TileLoader;
    18 import org.openstreetmap.josm.Main;
    1918import org.openstreetmap.josm.data.cache.BufferedImageCacheEntry;
    2019import org.openstreetmap.josm.data.coor.LatLon;
     
    2928import org.openstreetmap.josm.data.preferences.IntegerProperty;
    3029import org.openstreetmap.josm.data.projection.Projection;
     30import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    3131import org.openstreetmap.josm.data.projection.Projections;
    3232import org.openstreetmap.josm.gui.MainApplication;
     
    9696        AbstractWMSTileSource tileSource;
    9797        if (info.getImageryType() == ImageryType.WMS) {
    98             tileSource = new TemplatedWMSTileSource(info, chooseProjection(Main.getProjection()));
     98            tileSource = new TemplatedWMSTileSource(info, chooseProjection(ProjectionRegistry.getProjection()));
    9999        } else {
    100100            /*
     
    107107             *  * we always use current definitions returned by server
    108108             */
    109             WMSEndpointTileSource endpointTileSource = new WMSEndpointTileSource(info, Main.getProjection());
     109            WMSEndpointTileSource endpointTileSource = new WMSEndpointTileSource(info, ProjectionRegistry.getProjection());
    110110            this.serverProjections = endpointTileSource.getServerProjections();
    111             endpointTileSource.setTileProjection(chooseProjection(Main.getProjection()));
     111            endpointTileSource.setTileProjection(chooseProjection(ProjectionRegistry.getProjection()));
    112112            tileSource = endpointTileSource;
    113113        }
     
    182182        Logging.info(tr("Reprojecting layer {0} from {1} to {2}. For best image quality and performance,"
    183183                + " 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())));
    185185        return proj;
    186186    }
  • trunk/src/org/openstreetmap/josm/gui/layer/WMTSLayer.java

    r13733 r14120  
    77import org.apache.commons.jcs.access.CacheAccess;
    88import org.openstreetmap.gui.jmapviewer.interfaces.TileLoader;
    9 import org.openstreetmap.josm.Main;
    109import org.openstreetmap.josm.data.cache.BufferedImageCacheEntry;
    1110import org.openstreetmap.josm.data.imagery.ImageryInfo;
     
    1514import org.openstreetmap.josm.data.imagery.WMTSTileSource.WMTSGetCapabilitiesException;
    1615import org.openstreetmap.josm.data.projection.Projection;
     16import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    1717import org.openstreetmap.josm.gui.MainApplication;
    1818import org.openstreetmap.josm.gui.layer.imagery.TileSourceDisplaySettings;
     
    8181        double displayScale = MainApplication.getMap().mapView.getScale();
    8282        if (coordinateConverter.requiresReprojection()) {
    83             displayScale *= Main.getProjection().getMetersPerUnit();
     83            displayScale *= ProjectionRegistry.getProjection().getMetersPerUnit();
    8484        }
    8585        Scale snap = scaleList.getSnapScale(displayScale, false);
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/ImportAudioAction.java

    r13130 r14120  
    2525import org.openstreetmap.josm.data.gpx.GpxTrackSegment;
    2626import org.openstreetmap.josm.data.gpx.WayPoint;
     27import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2728import org.openstreetmap.josm.gui.HelpAwareOptionPane;
    2829import org.openstreetmap.josm.gui.MainApplication;
     
    189190                    continue;
    190191                }
    191                 WayPoint wNear = layer.data.nearestPointOnTrack(w.getEastNorth(Main.getProjection()), snapDistance);
     192                WayPoint wNear = layer.data.nearestPointOnTrack(w.getEastNorth(ProjectionRegistry.getProjection()), snapDistance);
    192193                if (wNear != null) {
    193194                    WayPoint wc = new WayPoint(w.getCoor());
  • trunk/src/org/openstreetmap/josm/gui/layer/imagery/ReprojectionTile.java

    r12846 r14120  
    88import org.openstreetmap.gui.jmapviewer.Tile;
    99import org.openstreetmap.gui.jmapviewer.interfaces.TileSource;
    10 import org.openstreetmap.josm.Main;
    1110import org.openstreetmap.josm.data.ProjectionBounds;
    1211import org.openstreetmap.josm.data.coor.EastNorth;
    1312import org.openstreetmap.josm.data.imagery.CoordinateConversion;
    1413import org.openstreetmap.josm.data.projection.Projection;
     14import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    1515import org.openstreetmap.josm.data.projection.Projections;
    1616import org.openstreetmap.josm.gui.MainApplication;
     
    122122        }
    123123
    124         Projection projCurrent = Main.getProjection();
     124        Projection projCurrent = ProjectionRegistry.getProjection();
    125125        Projection projServer = Projections.getProjectionByCode(source.getServerCRS());
    126126        EastNorth en00Server = tileToEastNorth(xtile, ytile, zoom);
  • trunk/src/org/openstreetmap/josm/gui/layer/imagery/TileCoordinateConverter.java

    r13387 r14120  
    1414import org.openstreetmap.gui.jmapviewer.interfaces.IProjected;
    1515import org.openstreetmap.gui.jmapviewer.interfaces.TileSource;
    16 import org.openstreetmap.josm.Main;
    1716import org.openstreetmap.josm.data.coor.EastNorth;
    1817import org.openstreetmap.josm.data.coor.LatLon;
    1918import org.openstreetmap.josm.data.imagery.CoordinateConversion;
    2019import org.openstreetmap.josm.data.projection.Projecting;
     20import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2121import org.openstreetmap.josm.data.projection.ShiftedProjecting;
    2222import org.openstreetmap.josm.gui.MapView;
     
    202202     */
    203203    public boolean requiresReprojection() {
    204         return !Objects.equals(tileSource.getServerCRS(), Main.getProjection().toCode());
     204        return !Objects.equals(tileSource.getServerCRS(), ProjectionRegistry.getProjection().toCode());
    205205    }
    206206}
  • trunk/src/org/openstreetmap/josm/gui/layer/imagery/TileSourceDisplaySettings.java

    r13244 r14120  
    77
    88import org.openstreetmap.gui.jmapviewer.interfaces.TileSource;
    9 import org.openstreetmap.josm.Main;
    109import org.openstreetmap.josm.data.coor.EastNorth;
    1110import org.openstreetmap.josm.data.imagery.OffsetBookmark;
    1211import org.openstreetmap.josm.data.preferences.BooleanProperty;
     12import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    1313import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer;
    1414import org.openstreetmap.josm.io.session.SessionAwareReadApply;
     
    206206            setDisplacement(EastNorth.ZERO);
    207207        } else {
    208             setDisplacement(offsetBookmark.getDisplacement(Main.getProjection()));
     208            setDisplacement(offsetBookmark.getDisplacement(ProjectionRegistry.getProjection()));
    209209        }
    210210    }
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/PlayHeadMarker.java

    r13281 r14120  
    2222import org.openstreetmap.josm.data.gpx.GpxTrackSegment;
    2323import org.openstreetmap.josm.data.gpx.WayPoint;
     24import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2425import org.openstreetmap.josm.gui.MainApplication;
    2526import org.openstreetmap.josm.gui.MapFrame;
     
    215216            for (Marker m : recent.parentLayer.data) {
    216217                if (m instanceof AudioMarker) {
    217                     double distanceSquared = m.getEastNorth(Main.getProjection()).distanceSq(en);
     218                    double distanceSquared = m.getEastNorth(ProjectionRegistry.getProjection()).distanceSq(en);
    218219                    if (distanceSquared < closestAudioMarkerDistanceSquared) {
    219220                        ca = (AudioMarker) m;
     
    348349            return;
    349350        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()),
    352353                            (audioTime - w1.time)/(w2.time - w1.time)));
    353354        time = audioTime;
  • trunk/src/org/openstreetmap/josm/gui/mappaint/RenderingCLI.java

    r14119 r14120  
    2121
    2222import org.openstreetmap.gui.jmapviewer.OsmMercator;
    23 import org.openstreetmap.josm.Main;
    2423import org.openstreetmap.josm.cli.CLIModule;
    2524import org.openstreetmap.josm.data.Bounds;
     
    3231import org.openstreetmap.josm.data.preferences.JosmUrls;
    3332import org.openstreetmap.josm.data.projection.Projection;
     33import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    3434import org.openstreetmap.josm.data.projection.Projections;
    3535import org.openstreetmap.josm.gui.mappaint.RenderingHelper.StyleData;
     
    427427        Config.getPref().putBoolean("mappaint.auto_reload_local_styles", false); // unnecessary to listen for external changes
    428428        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)));
    430430
    431431        RightAndLefthandTraffic.initialize();
     
    449449    RenderingArea determineRenderingArea(DataSet ds) {
    450450
    451         Projection proj = Main.getProjection();
     451        Projection proj = ProjectionRegistry.getProjection();
    452452        Double scale = null; // scale in east-north units per pixel
    453453        if (argZoom != null) {
  • trunk/src/org/openstreetmap/josm/gui/mappaint/RenderingHelper.java

    r12966 r14120  
    1616import java.util.Optional;
    1717
    18 import org.openstreetmap.josm.Main;
    1918import org.openstreetmap.josm.data.Bounds;
    2019import org.openstreetmap.josm.data.ProjectionBounds;
     
    2221import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer;
    2322import org.openstreetmap.josm.data.projection.Projection;
     23import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2424import org.openstreetmap.josm.gui.NavigatableComponent;
    2525import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource;
     
    6565        this.scale = scale;
    6666        this.styles = styles;
    67         Projection proj = Main.getProjection();
     67        Projection proj = ProjectionRegistry.getProjection();
    6868        projBounds = new ProjectionBounds();
    6969        projBounds.extend(proj.latlon2eastNorth(bounds.getMin()));
  • trunk/src/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreference.java

    r14119 r14120  
    6262import org.openstreetmap.josm.data.imagery.Shape;
    6363import org.openstreetmap.josm.data.preferences.NamedColorProperty;
     64import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    6465import org.openstreetmap.josm.gui.MainApplication;
    6566import org.openstreetmap.josm.gui.download.DownloadDialog;
     
    856857            JButton add = new JButton(tr("Add"));
    857858            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)));
    859860
    860861            JButton delete = new JButton(tr("Delete"));
  • trunk/src/org/openstreetmap/josm/gui/preferences/projection/ProjectionPreference.java

    r14005 r14120  
    3232import org.openstreetmap.josm.data.projection.CustomProjection;
    3333import org.openstreetmap.josm.data.projection.Projection;
     34import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    3435import org.openstreetmap.josm.data.projection.Projections;
    3536import org.openstreetmap.josm.gui.ExtendedDialog;
     
    493494        pc.setPreferences(pref);
    494495        Projection proj = pc.getProjection();
    495         Main.setProjection(proj);
     496        ProjectionRegistry.setProjection(proj);
    496497    }
    497498
  • trunk/src/org/openstreetmap/josm/io/session/SessionWriter.java

    r13901 r14120  
    2626import javax.xml.transform.stream.StreamResult;
    2727
    28 import org.openstreetmap.josm.Main;
    2928import org.openstreetmap.josm.data.coor.EastNorth;
    3029import org.openstreetmap.josm.data.coor.LatLon;
     30import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    3131import org.openstreetmap.josm.gui.MainApplication;
    3232import org.openstreetmap.josm.gui.MapView;
     
    264264        MapView mapView = MainApplication.getMap().mapView;
    265265        EastNorth center = mapView.getCenter();
    266         LatLon centerLL = Main.getProjection().eastNorth2latlon(center);
     266        LatLon centerLL = ProjectionRegistry.getProjection().eastNorth2latlon(center);
    267267        centerEl.setAttribute("lat", Double.toString(centerLL.lat()));
    268268        centerEl.setAttribute("lon", Double.toString(centerLL.lon()));
     
    293293            }
    294294        }
    295         String code = Main.getProjection().toCode();
     295        String code = ProjectionRegistry.getProjection().toCode();
    296296        if (code != null) {
    297297            Element codeEl = doc.createElement("code");
  • trunk/src/org/openstreetmap/josm/tools/Geometry.java

    r13807 r14120  
    3737import org.openstreetmap.josm.data.osm.visitor.paint.relations.MultipolygonCache;
    3838import org.openstreetmap.josm.data.projection.Projection;
     39import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    3940import org.openstreetmap.josm.data.projection.Projections;
    4041
     
    164165                                }
    165166
    166                                 Node newNode = new Node(Main.getProjection().eastNorth2latlon(intersection));
     167                                Node newNode = new Node(ProjectionRegistry.getProjection().eastNorth2latlon(intersection));
    167168                                Node intNode = newNode;
    168169                                boolean insertInSeg1 = false;
     
    10531054        double area = 0;
    10541055        double perimeter = 0;
    1055         Projection useProjection = projection == null ? Main.getProjection() : projection;
     1056        Projection useProjection = projection == null ? ProjectionRegistry.getProjection() : projection;
    10561057
    10571058        if (!nodes.isEmpty()) {
  • trunk/test/functional/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMergerTestFT.java

    r9546 r14120  
    66import javax.swing.JFrame;
    77
    8 import org.openstreetmap.josm.Main;
    98import org.openstreetmap.josm.data.conflict.Conflict;
    109import org.openstreetmap.josm.data.coor.LatLon;
    1110import org.openstreetmap.josm.data.osm.Node;
    1211import org.openstreetmap.josm.data.osm.OsmPrimitive;
     12import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    1313import org.openstreetmap.josm.data.projection.Projections;
    1414
     
    1818
    1919    protected void build() {
    20         Main.setProjection(Projections.getProjectionByCode("EPSG:4326")); // WGS 84
     20        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:4326")); // WGS 84
    2121
    2222        setLayout(new BorderLayout());
  • trunk/test/functional/org/openstreetmap/josm/gui/mappaint/MapCSSRendererTest.java

    r12996 r14120  
    3131import org.junit.runners.Parameterized;
    3232import org.junit.runners.Parameterized.Parameters;
    33 import org.openstreetmap.josm.Main;
    3433import org.openstreetmap.josm.TestUtils;
    3534import org.openstreetmap.josm.data.Bounds;
     
    3837import org.openstreetmap.josm.data.osm.OsmPrimitive;
    3938import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer;
     39import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    4040import org.openstreetmap.josm.io.IllegalDataException;
    4141import org.openstreetmap.josm.io.OsmReader;
     
    183183
    184184        ProjectionBounds pb = new ProjectionBounds();
    185         pb.extend(Main.getProjection().latlon2eastNorth(testConfig.getTestArea().getMin()));
    186         pb.extend(Main.getProjection().latlon2eastNorth(testConfig.getTestArea().getMax()));
     185        pb.extend(ProjectionRegistry.getProjection().latlon2eastNorth(testConfig.getTestArea().getMin()));
     186        pb.extend(ProjectionRegistry.getProjection().latlon2eastNorth(testConfig.getTestArea().getMax()));
    187187        double scale = (pb.maxEast - pb.minEast) / testConfig.imageWidth;
    188188
  • trunk/test/functional/org/openstreetmap/josm/io/OsmServerBackreferenceReaderTest.java

    r12850 r14120  
    2626import org.junit.Test;
    2727import org.openstreetmap.josm.JOSMFixture;
    28 import org.openstreetmap.josm.Main;
    2928import org.openstreetmap.josm.data.APIDataSet;
    3029import org.openstreetmap.josm.data.coor.LatLon;
     
    3837import org.openstreetmap.josm.data.osm.RelationMember;
    3938import org.openstreetmap.josm.data.osm.Way;
     39import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    4040import org.openstreetmap.josm.data.projection.Projections;
    4141import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
     
    167167        //
    168168        Config.getPref().putBoolean("osm-server.atomic-upload", false);
    169         Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
     169        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
    170170        Logging.setLogLevel(Logging.LEVEL_DEBUG);
    171171
  • trunk/test/performance/org/openstreetmap/josm/gui/mappaint/MapRendererPerformanceTest.java

    r13175 r14120  
    2626import org.junit.rules.Timeout;
    2727import org.openstreetmap.josm.JOSMFixture;
    28 import org.openstreetmap.josm.Main;
    2928import org.openstreetmap.josm.PerformanceTestUtils;
    3029import org.openstreetmap.josm.TestUtils;
     
    3635import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer.StyleRecord;
    3736import org.openstreetmap.josm.data.preferences.sources.SourceEntry;
     37import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    3838import org.openstreetmap.josm.gui.MainApplication;
    3939import org.openstreetmap.josm.gui.NavigatableComponent;
     
    197197                scale = SCALE_Z17;
    198198            }
    199             nc.zoomTo(Main.getProjection().latlon2eastNorth(center), scale);
     199            nc.zoomTo(ProjectionRegistry.getProjection().latlon2eastNorth(center), scale);
    200200            if (checkScale) {
    201201                int lvl = Selector.OptimizedGeneralSelector.scale2level(nc.getDist100Pixel());
  • trunk/test/unit/org/openstreetmap/josm/JOSMFixture.java

    r14119 r14120  
    1818import org.openstreetmap.josm.data.preferences.JosmBaseDirectories;
    1919import org.openstreetmap.josm.data.preferences.JosmUrls;
     20import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2021import org.openstreetmap.josm.data.projection.Projections;
    2122import org.openstreetmap.josm.gui.MainApplication;
     
    126127
    127128        // init projection
    128         Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
     129        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
    129130
    130131        // setup projection grid files
  • trunk/test/unit/org/openstreetmap/josm/MainTest.java

    r14119 r14120  
    1515import org.openstreetmap.josm.Main.InitStatusListener;
    1616import org.openstreetmap.josm.Main.InitializationTask;
     17import org.openstreetmap.josm.data.coor.conversion.CoordinateFormatManager;
    1718import org.openstreetmap.josm.io.OnlineResource;
    1819import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    3839    public void testPreConstructorInit() {
    3940        Main.preConstructorInit();
    40         assertNotNull(Main.getProjection());
     41        assertNotNull(CoordinateFormatManager.getDefaultFormat());
    4142    }
    4243
  • trunk/test/unit/org/openstreetmap/josm/command/MoveCommandTest.java

    r13489 r14120  
    1515import org.junit.Rule;
    1616import org.junit.Test;
    17 import org.openstreetmap.josm.Main;
    1817import org.openstreetmap.josm.TestUtils;
    1918import org.openstreetmap.josm.command.CommandTest.CommandTestDataWithRelation;
     
    2423import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2524import org.openstreetmap.josm.data.osm.User;
     25import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2626import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    2727import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    5757    public void testConstructors() {
    5858        EastNorth offset = new EastNorth(1, 2);
    59         LatLon destLatLon = Main.getProjection().eastNorth2latlon(offset);
     59        LatLon destLatLon = ProjectionRegistry.getProjection().eastNorth2latlon(offset);
    6060        EastNorth start = new EastNorth(2, 0);
    6161
  • trunk/test/unit/org/openstreetmap/josm/data/gpx/GpxDataTest.java

    r13210 r14120  
    2020import org.junit.Rule;
    2121import org.junit.Test;
    22 import org.openstreetmap.josm.Main;
    2322import org.openstreetmap.josm.TestUtils;
    2423import org.openstreetmap.josm.data.Bounds;
     
    2827import org.openstreetmap.josm.data.gpx.GpxData.GpxDataChangeEvent;
    2928import org.openstreetmap.josm.data.gpx.GpxData.GpxDataChangeListener;
     29import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    3030import org.openstreetmap.josm.testutils.JOSMTestRules;
    3131import org.openstreetmap.josm.tools.ListenerList;
     
    327327        List<WayPoint> points = Stream
    328328                .of(new EastNorth(10, 10), new EastNorth(10, 0), new EastNorth(-1, 0))
    329                 .map(Main.getProjection()::eastNorth2latlon)
     329                .map(ProjectionRegistry.getProjection()::eastNorth2latlon)
    330330                .map(WayPoint::new)
    331331                .collect(Collectors.toList());
     
    336336
    337337        WayPoint close = data.nearestPointOnTrack(new EastNorth(5, 5), 10);
    338         assertEquals(10, close.getEastNorth(Main.getProjection()).east(), .01);
    339         assertEquals(5, close.getEastNorth(Main.getProjection()).north(), .01);
     338        assertEquals(10, close.getEastNorth(ProjectionRegistry.getProjection()).east(), .01);
     339        assertEquals(5, close.getEastNorth(ProjectionRegistry.getProjection()).north(), .01);
    340340
    341341        close = data.nearestPointOnTrack(new EastNorth(15, 5), 10);
    342         assertEquals(10, close.getEastNorth(Main.getProjection()).east(), .01);
    343         assertEquals(5, close.getEastNorth(Main.getProjection()).north(), .01);
     342        assertEquals(10, close.getEastNorth(ProjectionRegistry.getProjection()).east(), .01);
     343        assertEquals(5, close.getEastNorth(ProjectionRegistry.getProjection()).north(), .01);
    344344
    345345        assertNull(data.nearestPointOnTrack(new EastNorth(5, 5), 1));
  • trunk/test/unit/org/openstreetmap/josm/data/imagery/TemplatedWMSTileSourceTest.java

    r12669 r14120  
    1010import org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate;
    1111import org.openstreetmap.gui.jmapviewer.tilesources.TemplatedTMSTileSource;
    12 import org.openstreetmap.josm.Main;
    1312import org.openstreetmap.josm.data.Bounds;
    1413import org.openstreetmap.josm.data.coor.EastNorth;
     
    1615import org.openstreetmap.josm.data.projection.CustomProjection;
    1716import org.openstreetmap.josm.data.projection.Projection;
     17import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    1818import org.openstreetmap.josm.data.projection.Projections;
    1919import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    4242    public void testEPSG3857() {
    4343        Projection projection = Projections.getProjectionByCode("EPSG:3857");
    44         Main.setProjection(projection);
     44        ProjectionRegistry.setProjection(projection);
    4545        TemplatedWMSTileSource source = new TemplatedWMSTileSource(testImageryWMS, projection);
    4646        verifyMercatorTile(source, 0, 0, 1);
     
    6767    public void testEPSG4326() {
    6868        Projection projection = Projections.getProjectionByCode("EPSG:4326");
    69         Main.setProjection(projection);
     69        ProjectionRegistry.setProjection(projection);
    7070        TemplatedWMSTileSource source = getSource(projection);
    7171
     
    8383    public void testEPSG4326widebounds() {
    8484        Projection projection = new CustomProjection("+proj=lonlat +datum=WGS84 +axis=neu +bounds=-180,53,180,54");
    85         Main.setProjection(projection);
     85        ProjectionRegistry.setProjection(projection);
    8686        TemplatedWMSTileSource source = getSource(projection);
    8787
     
    9696    public void testEPSG4326narrowbounds() {
    9797        Projection projection = new CustomProjection("+proj=lonlat +datum=WGS84 +axis=neu +bounds=18,-90,20,90");
    98         Main.setProjection(projection);
     98        ProjectionRegistry.setProjection(projection);
    9999        TemplatedWMSTileSource source = getSource(projection);
    100100
     
    109109    public void testEPSG2180() {
    110110        Projection projection = Projections.getProjectionByCode("EPSG:2180");
    111         Main.setProjection(projection);
     111        ProjectionRegistry.setProjection(projection);
    112112        TemplatedWMSTileSource source = getSource(projection);
    113113
     
    128128                new CustomProjection("+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 "
    129129                        + "+units=m +no_defs +axis=neu +wmssrs=EPSG:3006 +bounds=10.5700,55.2000,24.1800,69.1000 ");
    130         Main.setProjection(projection);
     130        ProjectionRegistry.setProjection(projection);
    131131        TemplatedWMSTileSource source = getSource(projection);
    132132
     
    144144                new CustomProjection("+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 "
    145145                        + "+units=m +no_defs +axis=neu +wmssrs=EPSG:3006");
    146         Main.setProjection(projection);
     146        ProjectionRegistry.setProjection(projection);
    147147        TemplatedWMSTileSource source = getSource(projection);
    148148
     
    174174
    175175    private void verifyLocation(TemplatedWMSTileSource source, LatLon location, int z) {
     176        Projection projection = ProjectionRegistry.getProjection();
    176177        assertTrue(
    177178                "Point outside world bounds",
    178                 Main.getProjection().getWorldBoundsLatLon().contains(location)
     179                projection.getWorldBoundsLatLon().contains(location)
    179180                );
    180181
     
    187188                tileIndex.getYIndex() <= source.getTileYMax(z));
    188189
    189         EastNorth locationEN = Main.getProjection().latlon2eastNorth(location);
    190         EastNorth x1 = Main.getProjection().latlon2eastNorth(getTileLatLon(source, tileIndex, z));
    191         EastNorth x2 = Main.getProjection().latlon2eastNorth(getTileLatLon(source, tileIndex.getXIndex() + 1, tileIndex.getYIndex() + 1, z));
     190        EastNorth locationEN = projection.latlon2eastNorth(location);
     191        EastNorth x1 = projection.latlon2eastNorth(getTileLatLon(source, tileIndex, z));
     192        EastNorth x2 = projection.latlon2eastNorth(getTileLatLon(source, tileIndex.getXIndex() + 1, tileIndex.getYIndex() + 1, z));
    192193        // test that location is within tile bounds
    193194        assertTrue(locationEN.toString() + " not within " + bboxStr(x1, x2) +
  • trunk/test/unit/org/openstreetmap/josm/data/imagery/WMSEndpointTileSourceTest.java

    r14092 r14120  
    1111import org.junit.Rule;
    1212import org.junit.Test;
    13 import org.openstreetmap.josm.Main;
    1413import org.openstreetmap.josm.TestUtils;
    1514import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType;
     15import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    1616import org.openstreetmap.josm.data.projection.Projections;
    1717import org.openstreetmap.josm.spi.preferences.Config;
     
    7878        ImageryInfo wmsImageryInfo = ImageryLayerInfo.instance.getDefaultLayers().get(0);
    7979        assertEquals("single_node_in_way", wmsImageryInfo.getDefaultLayers().get(0).getLayerName());
    80         WMSEndpointTileSource tileSource = new WMSEndpointTileSource(wmsImageryInfo, Main.getProjection());
     80        WMSEndpointTileSource tileSource = new WMSEndpointTileSource(wmsImageryInfo, ProjectionRegistry.getProjection());
    8181        tileSource.initProjection(Projections.getProjectionByCode("EPSG:3857"));
    8282        assertEquals("https://tools.geofabrik.de/osmi/views/geometry/wxs?FORMAT=image/png&TRANSPARENT=TRUE&VERSION=1.1.1&SERVICE=WMS&"
     
    122122        ImageryInfo wmsImageryInfo = ImageryLayerInfo.instance.getDefaultLayers().get(0);
    123123        wmsImageryInfo.setDefaultLayers(Arrays.asList(new DefaultLayer(ImageryType.WMS_ENDPOINT, "historiske-ortofoto", "", "")));
    124         WMSEndpointTileSource tileSource = new WMSEndpointTileSource(wmsImageryInfo, Main.getProjection());
     124        WMSEndpointTileSource tileSource = new WMSEndpointTileSource(wmsImageryInfo, ProjectionRegistry.getProjection());
    125125        tileSource.initProjection(Projections.getProjectionByCode("EPSG:3857"));
    126126        assertEquals("b8e36d51-119a-423b-b156-d744d54123d5", wmsImageryInfo.getCustomHttpHeaders().get("X-WAAPI-TOKEN"));
  • trunk/test/unit/org/openstreetmap/josm/data/imagery/WMTSTileSourceTest.java

    r14049 r14120  
    2121import org.openstreetmap.gui.jmapviewer.TileXY;
    2222import org.openstreetmap.gui.jmapviewer.tilesources.TemplatedTMSTileSource;
    23 import org.openstreetmap.josm.Main;
    2423import org.openstreetmap.josm.TestUtils;
    2524import org.openstreetmap.josm.data.Bounds;
     
    2726import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType;
    2827import org.openstreetmap.josm.data.imagery.WMTSTileSource.WMTSGetCapabilitiesException;
     28import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2929import org.openstreetmap.josm.data.projection.Projections;
    3030import org.openstreetmap.josm.spi.preferences.Config;
     
    8585    @Test
    8686    public void testPseudoMercator() throws IOException, WMTSGetCapabilitiesException {
    87         Main.setProjection(Projections.getProjectionByCode("EPSG:3857"));
     87        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857"));
    8888        WMTSTileSource testSource = new WMTSTileSource(testImageryPSEUDO_MERCATOR);
    89         testSource.initProjection(Main.getProjection());
     89        testSource.initProjection(ProjectionRegistry.getProjection());
    9090
    9191        verifyMercatorTile(testSource, 0, 0, 1);
     
    115115    @Test
    116116    public void testWALLONIE() throws IOException, WMTSGetCapabilitiesException {
    117         Main.setProjection(Projections.getProjectionByCode("EPSG:31370"));
     117        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:31370"));
    118118        WMTSTileSource testSource = new WMTSTileSource(testImageryWALLONIE);
    119         testSource.initProjection(Main.getProjection());
     119        testSource.initProjection(ProjectionRegistry.getProjection());
    120120
    121121        assertEquals("http://geoservices.wallonie.be/arcgis/rest/services/DONNEES_BASE/FOND_PLAN_ANNOTATIONS_2012_RW_NB/"
     
    135135    @Ignore("disable this test, needs further working") // XXX
    136136    public void testWALLONIENoMatrixDimension() throws IOException, WMTSGetCapabilitiesException {
    137         Main.setProjection(Projections.getProjectionByCode("EPSG:31370"));
     137        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:31370"));
    138138        WMTSTileSource testSource = new WMTSTileSource(getImagery("test/data/wmts/WMTSCapabilities-Wallonie-nomatrixdimension.xml"));
    139         testSource.initProjection(Main.getProjection());
     139        testSource.initProjection(ProjectionRegistry.getProjection());
    140140
    141141        Bounds wallonieBounds = new Bounds(
     
    159159    @Test
    160160    public void testWIEN() throws IOException, WMTSGetCapabilitiesException {
    161         Main.setProjection(Projections.getProjectionByCode("EPSG:3857"));
     161        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857"));
    162162        WMTSTileSource testSource = new WMTSTileSource(testImageryWIEN);
    163         testSource.initProjection(Main.getProjection());
     163        testSource.initProjection(ProjectionRegistry.getProjection());
    164164        int zoomOffset = 10;
    165165
     
    201201    @Test
    202202    public void testGeoportalTOPOPL() throws IOException, WMTSGetCapabilitiesException {
    203         Main.setProjection(Projections.getProjectionByCode("EPSG:4326"));
     203        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:4326"));
    204204        WMTSTileSource testSource = new WMTSTileSource(testImageryTOPO_PL);
    205         testSource.initProjection(Main.getProjection());
     205        testSource.initProjection(ProjectionRegistry.getProjection());
    206206        verifyTile(new LatLon(56, 12), testSource, 0, 0, 1);
    207207        verifyTile(new LatLon(56, 12), testSource, 0, 0, 2);
     
    223223    @Test
    224224    public void testGeoportalORTOPL4326() throws IOException, WMTSGetCapabilitiesException {
    225         Main.setProjection(Projections.getProjectionByCode("EPSG:4326"));
     225        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:4326"));
    226226        WMTSTileSource testSource = new WMTSTileSource(testImageryORTO_PL);
    227         testSource.initProjection(Main.getProjection());
     227        testSource.initProjection(ProjectionRegistry.getProjection());
    228228        verifyTile(new LatLon(53.60205873528009, 19.552206794646956), testSource, 12412, 3941, 13);
    229229        verifyTile(new LatLon(49.79005619189761, 22.778262259134397), testSource, 17714, 10206, 13);
     
    232232    @Test
    233233    public void testGeoportalORTOPL2180() throws IOException, WMTSGetCapabilitiesException {
    234         Main.setProjection(Projections.getProjectionByCode("EPSG:2180"));
     234        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:2180"));
    235235        WMTSTileSource testSource = new WMTSTileSource(testImageryORTO_PL);
    236         testSource.initProjection(Main.getProjection());
     236        testSource.initProjection(ProjectionRegistry.getProjection());
    237237
    238238        verifyTile(new LatLon(53.59940948387726, 19.560544913270064), testSource, 6453, 3140, 13);
     
    242242    @Test
    243243    public void testTicket12168() throws IOException, WMTSGetCapabilitiesException {
    244         Main.setProjection(Projections.getProjectionByCode("EPSG:3857"));
     244        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857"));
    245245        WMTSTileSource testSource = new WMTSTileSource(testImagery12168);
    246         testSource.initProjection(Main.getProjection());
     246        testSource.initProjection(ProjectionRegistry.getProjection());
    247247        assertEquals(
    248248                "http://www.ngi.be/cartoweb/1.0.0/topo/default/3857/7/1/1.png",
     
    252252    @Test
    253253    public void testTwoTileSetsForOneProjection() throws Exception {
    254         Main.setProjection(Projections.getProjectionByCode("EPSG:3857"));
     254        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857"));
    255255        ImageryInfo ontario = getImagery(TestUtils.getTestDataRoot() + "wmts/WMTSCapabilities-Ontario.xml");
    256256        ontario.setDefaultLayers(Arrays.asList(new DefaultLayer[] {
     
    258258        }));
    259259        WMTSTileSource testSource = new WMTSTileSource(ontario);
    260         testSource.initProjection(Main.getProjection());
     260        testSource.initProjection(ProjectionRegistry.getProjection());
    261261        assertEquals(
    262262                "http://maps.ottawa.ca/arcgis/rest/services/Basemap_Imagery_2014/MapServer/WMTS/tile/1.0.0/Basemap_Imagery_2014/default/"
     
    269269    @Test
    270270    public void testTwoTileSetsForOneProjectionSecondLayer() throws Exception {
    271         Main.setProjection(Projections.getProjectionByCode("EPSG:3857"));
     271        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857"));
    272272        ImageryInfo ontario = getImagery(TestUtils.getTestDataRoot() + "wmts/WMTSCapabilities-Ontario.xml");
    273273        ontario.setDefaultLayers(Arrays.asList(new DefaultLayer[] {
     
    275275        }));
    276276        WMTSTileSource testSource = new WMTSTileSource(ontario);
    277         testSource.initProjection(Main.getProjection());
     277        testSource.initProjection(ProjectionRegistry.getProjection());
    278278        assertEquals(
    279279                "http://maps.ottawa.ca/arcgis/rest/services/Basemap_Imagery_2014/MapServer/WMTS/tile/1.0.0/Basemap_Imagery_2014/default/"
     
    286286    @Test
    287287    public void testManyLayersScrollbars() throws Exception {
    288         Main.setProjection(Projections.getProjectionByCode("EPSG:3857"));
     288        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857"));
    289289        WMTSTileSource testSource = new WMTSTileSource(testLotsOfLayers);
    290         testSource.initProjection(Main.getProjection());
     290        testSource.initProjection(ProjectionRegistry.getProjection());
    291291    }
    292292
    293293    @Test
    294294    public void testParserForDuplicateTags() throws Exception {
    295         Main.setProjection(Projections.getProjectionByCode("EPSG:3857"));
     295        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857"));
    296296        WMTSTileSource testSource = new WMTSTileSource(testDuplicateTags);
    297         testSource.initProjection(Main.getProjection());
     297        testSource.initProjection(ProjectionRegistry.getProjection());
    298298        assertEquals(
    299299                "http://tile.informatievlaanderen.be/ws/raadpleegdiensten/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=grb_bsk&"
     
    305305    @Test
    306306    public void testParserForMissingStyleIdentifier() throws Exception {
    307         Main.setProjection(Projections.getProjectionByCode("EPSG:3857"));
     307        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857"));
    308308        WMTSTileSource testSource = new WMTSTileSource(testMissingStyleIdentifer);
    309         testSource.initProjection(Main.getProjection());
     309        testSource.initProjection(ProjectionRegistry.getProjection());
    310310    }
    311311
    312312    @Test
    313313    public void testForMultipleTileMatricesForOneLayerProjection() throws Exception {
    314         Main.setProjection(Projections.getProjectionByCode("EPSG:3857"));
     314        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857"));
    315315        ImageryInfo copy = new ImageryInfo(testMultipleTileMatrixForLayer);
    316316        List<DefaultLayer> defaultLayers = new ArrayList<>(1);
     
    318318        copy.setDefaultLayers(defaultLayers);
    319319        WMTSTileSource testSource = new WMTSTileSource(copy);
    320         testSource.initProjection(Main.getProjection());
     320        testSource.initProjection(ProjectionRegistry.getProjection());
    321321        assertEquals(
    322322                "http://188.253.0.155:6080/arcgis/rest/services/Mashhad_BaseMap_1/MapServer/WMTS/tile/1.0.0/Mashhad_BaseMap_1"
     
    333333    @Test
    334334    public void testDimension() throws IOException, WMTSGetCapabilitiesException {
    335         Main.setProjection(Projections.getProjectionByCode("EPSG:21781"));
     335        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:21781"));
    336336        ImageryInfo info = new ImageryInfo(testImageryGeoAdminCh);
    337337        List<DefaultLayer> defaultLayers = new ArrayList<>(1);
     
    339339        info.setDefaultLayers(defaultLayers);
    340340        WMTSTileSource testSource = new WMTSTileSource(info);
    341         testSource.initProjection(Main.getProjection());
     341        testSource.initProjection(ProjectionRegistry.getProjection());
    342342        assertEquals(
    343343                "http://wmts.geo.admin.ch/1.0.0/ch.are.agglomerationen_isolierte_staedte/default/20140101/21781/1/3/2.png",
     
    414414    @Test
    415415    public void testGisKtnGvAt() throws IOException, WMTSGetCapabilitiesException {
    416         Main.setProjection(Projections.getProjectionByCode("EPSG:31258"));
     416        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:31258"));
    417417        final WMTSTileSource source = new WMTSTileSource(testImageryGisKtnGvAt);
    418         source.initProjection(Main.getProjection());
     418        source.initProjection(ProjectionRegistry.getProjection());
    419419        final TileXY tile = source.latLonToTileXY(46.6103, 13.8558, 11);
    420420        assertEquals("https://gis.ktn.gv.at/arcgis/rest/services/tilecache/Ortho_2013_2015" +
  • trunk/test/unit/org/openstreetmap/josm/data/osm/DataSetMergerTest.java

    r12750 r14120  
    1919import org.junit.Rule;
    2020import org.junit.Test;
    21 import org.openstreetmap.josm.Main;
    2221import org.openstreetmap.josm.data.coor.LatLon;
     22import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2323import org.openstreetmap.josm.data.projection.Projections;
    2424import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    4949        their = new DataSet();
    5050        their.setVersion("0.6");
    51         Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
     51        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
    5252    }
    5353
  • trunk/test/unit/org/openstreetmap/josm/data/osm/OsmPrimitiveTest.java

    r10945 r14120  
    99import org.junit.Rule;
    1010import org.junit.Test;
    11 import org.openstreetmap.josm.Main;
    1211import org.openstreetmap.josm.data.coor.LatLon;
     12import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    1313import org.openstreetmap.josm.data.projection.Projections;
    1414import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    4040    @BeforeClass
    4141    public static void setUp() {
    42         Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
     42        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
    4343    }
    4444
  • trunk/test/unit/org/openstreetmap/josm/data/osm/QuadBucketsTest.java

    r14092 r14120  
    1717import org.junit.Rule;
    1818import org.junit.Test;
    19 import org.openstreetmap.josm.Main;
    2019import org.openstreetmap.josm.data.coor.LatLon;
     20import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2121import org.openstreetmap.josm.data.projection.Projections;
    2222import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
     
    8383    @Test
    8484    public void testRemove() throws Exception {
    85         Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
     85        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
    8686        try (InputStream fis = new FileInputStream("data_nodist/restriction.osm")) {
    8787            DataSet ds = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE);
     
    9696    @Test
    9797    public void testMove() throws Exception {
    98         Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
     98        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
    9999        try (InputStream fis = new FileInputStream("data_nodist/restriction.osm")) {
    100100            DataSet ds = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE);
  • trunk/test/unit/org/openstreetmap/josm/data/projection/SwissGridTest.java

    r13702 r14120  
    88import org.junit.Rule;
    99import org.junit.Test;
    10 import org.openstreetmap.josm.Main;
    1110import org.openstreetmap.josm.data.coor.EastNorth;
    1211import org.openstreetmap.josm.data.coor.LatLon;
     
    3433    @BeforeClass
    3534    public static void setUp() {
    36         Main.setProjection(Projections.getProjectionByCode(SWISS_EPSG_CODE)); // Swiss grid
     35        ProjectionRegistry.setProjection(Projections.getProjectionByCode(SWISS_EPSG_CODE)); // Swiss grid
    3736    }
    3837
     
    9796    public void testAlatlon2eastNorth() {
    9897        LatLon ll = new LatLon(46.518, 6.567);
    99         EastNorth en = Main.getProjection().latlon2eastNorth(ll);
     98        EastNorth en = ProjectionRegistry.getProjection().latlon2eastNorth(ll);
    10099        if (debug) {
    101100            System.out.println(en);
     
    105104
    106105        ll = new LatLon(47.78, 8.58);
    107         en = Main.getProjection().latlon2eastNorth(ll);
     106        en = ProjectionRegistry.getProjection().latlon2eastNorth(ll);
    108107        if (debug) {
    109108            System.out.println(en);
     
    113112
    114113        ll = new LatLon(46.58, 10.48);
    115         en = Main.getProjection().latlon2eastNorth(ll);
     114        en = ProjectionRegistry.getProjection().latlon2eastNorth(ll);
    116115        if (debug) {
    117116            System.out.println(en);
     
    121120
    122121        ll = new LatLon(46.0 + 57.0 / 60 + 3.89813884505 / 3600, 7.0 + 26.0 / 60 + 19.076595154147 / 3600);
    123         en = Main.getProjection().latlon2eastNorth(ll);
     122        en = ProjectionRegistry.getProjection().latlon2eastNorth(ll);
    124123        if (debug) {
    125124            System.out.println(en);
     
    130129        // http://geodesy.geo.admin.ch/reframe/lv03towgs84?easting=700000&northing=100000
    131130        ll = new LatLon(46.04412093223244, 8.730497366167727);
    132         en = Main.getProjection().latlon2eastNorth(ll);
     131        en = ProjectionRegistry.getProjection().latlon2eastNorth(ll);
    133132        if (debug) {
    134133            System.out.println(en);
     
    144143    public void testBeastNorth2latlon() {
    145144        EastNorth en = new EastNorth(533112.13, 152227.35);
    146         LatLon ll = Main.getProjection().eastNorth2latlon(en);
     145        LatLon ll = ProjectionRegistry.getProjection().eastNorth2latlon(en);
    147146        if (debug) {
    148147            System.out.println(ll);
     
    152151
    153152        en = new EastNorth(685542.97, 292783.21);
    154         ll = Main.getProjection().eastNorth2latlon(en);
     153        ll = ProjectionRegistry.getProjection().eastNorth2latlon(en);
    155154        if (debug) {
    156155            System.out.println(ll);
     
    160159
    161160        en = new EastNorth(833066.95, 163265.32);
    162         ll = Main.getProjection().eastNorth2latlon(en);
     161        ll = ProjectionRegistry.getProjection().eastNorth2latlon(en);
    163162        if (debug) {
    164163            System.out.println(ll);
     
    168167
    169168        en = new EastNorth(600000.0, 200000.0);
    170         ll = Main.getProjection().eastNorth2latlon(en);
     169        ll = ProjectionRegistry.getProjection().eastNorth2latlon(en);
    171170        if (debug) {
    172171            System.out.println(ll);
     
    177176        // http://geodesy.geo.admin.ch/reframe/lv03towgs84?easting=700000&northing=100000
    178177        en = new EastNorth(700000.0, 100000.0);
    179         ll = Main.getProjection().eastNorth2latlon(en);
     178        ll = ProjectionRegistry.getProjection().eastNorth2latlon(en);
    180179        if (debug) {
    181180            System.out.println(ll);
     
    191190    public void testCsendandreturn() {
    192191        EastNorth en = new EastNorth(533111.69, 152227.85);
    193         LatLon ll = Main.getProjection().eastNorth2latlon(en);
    194         EastNorth en2 = Main.getProjection().latlon2eastNorth(ll);
     192        LatLon ll = ProjectionRegistry.getProjection().eastNorth2latlon(en);
     193        EastNorth en2 = ProjectionRegistry.getProjection().latlon2eastNorth(ll);
    195194        if (debug) {
    196195            System.out.println(en.east() - en2.east());
     
    203202
    204203        en = new EastNorth(685544.16, 292782.91);
    205         ll = Main.getProjection().eastNorth2latlon(en);
    206         en2 = Main.getProjection().latlon2eastNorth(ll);
     204        ll = ProjectionRegistry.getProjection().eastNorth2latlon(en);
     205        en2 = ProjectionRegistry.getProjection().latlon2eastNorth(ll);
    207206        if (debug) {
    208207            System.out.println(en.east() - en2.east());
     
    215214
    216215        en = new EastNorth(833068.04, 163265.39);
    217         ll = Main.getProjection().eastNorth2latlon(en);
    218         en2 = Main.getProjection().latlon2eastNorth(ll);
     216        ll = ProjectionRegistry.getProjection().eastNorth2latlon(en);
     217        en2 = ProjectionRegistry.getProjection().latlon2eastNorth(ll);
    219218        if (debug) {
    220219            System.out.println(en.east() - en2.east());
     
    227226
    228227        en = new EastNorth(600000.0, 200000.0);
    229         ll = Main.getProjection().eastNorth2latlon(en);
    230         en2 = Main.getProjection().latlon2eastNorth(ll);
     228        ll = ProjectionRegistry.getProjection().eastNorth2latlon(en);
     229        en2 = ProjectionRegistry.getProjection().latlon2eastNorth(ll);
    231230        if (debug) {
    232231            System.out.println(en.east() - en2.east());
     
    239238
    240239        en = new EastNorth(700000.0, 100000.0);
    241         ll = Main.getProjection().eastNorth2latlon(en);
    242         en2 = Main.getProjection().latlon2eastNorth(ll);
     240        ll = ProjectionRegistry.getProjection().eastNorth2latlon(en);
     241        en2 = ProjectionRegistry.getProjection().latlon2eastNorth(ll);
    243242        if (debug) {
    244243            System.out.println(en.east() - en2.east());
  • trunk/test/unit/org/openstreetmap/josm/gui/MapViewStateTest.java

    r12076 r14120  
    1313import org.junit.Test;
    1414import org.openstreetmap.josm.JOSMFixture;
    15 import org.openstreetmap.josm.Main;
    1615import org.openstreetmap.josm.data.coor.EastNorth;
    1716import org.openstreetmap.josm.data.coor.LatLon;
     17import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    1818import org.openstreetmap.josm.gui.MapViewState.MapViewPoint;
    1919import org.openstreetmap.josm.gui.MapViewState.MapViewRectangle;
     
    111111
    112112        EastNorth eastnorth = p.getEastNorth();
    113         LatLon shouldLatLon = Main.getProjection().getWorldBoundsLatLon().getCenter();
    114         EastNorth shouldEastNorth = Main.getProjection().latlon2eastNorth(shouldLatLon);
     113        LatLon shouldLatLon = ProjectionRegistry.getProjection().getWorldBoundsLatLon().getCenter();
     114        EastNorth shouldEastNorth = ProjectionRegistry.getProjection().latlon2eastNorth(shouldLatLon);
    115115        assertEquals("east", shouldEastNorth.east(), eastnorth.east(), 0.01);
    116116        assertEquals("north", shouldEastNorth.north(), eastnorth.north(), 0.01);
  • trunk/test/unit/org/openstreetmap/josm/gui/NavigatableComponentTest.java

    r11867 r14120  
    1818import org.junit.Rule;
    1919import org.junit.Test;
    20 import org.openstreetmap.josm.Main;
    2120import org.openstreetmap.josm.data.Bounds;
    2221import org.openstreetmap.josm.data.ProjectionBounds;
    2322import org.openstreetmap.josm.data.coor.EastNorth;
    2423import org.openstreetmap.josm.data.coor.LatLon;
     24import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2525import org.openstreetmap.josm.gui.util.GuiHelper;
    2626import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    8282    @Test
    8383    public void testDefaultScale() {
    84         assertEquals(Main.getProjection().getDefaultZoomInPPD(), component.getScale(), 0.00001);
     84        assertEquals(ProjectionRegistry.getProjection().getDefaultZoomInPPD(), component.getScale(), 0.00001);
    8585    }
    8686
  • trunk/test/unit/org/openstreetmap/josm/gui/datatransfer/OsmTransferHandlerTest.java

    r12922 r14120  
    99import org.junit.Rule;
    1010import org.junit.Test;
    11 import org.openstreetmap.josm.Main;
    1211import org.openstreetmap.josm.actions.CopyAction;
    1312import org.openstreetmap.josm.data.coor.LatLon;
    1413import org.openstreetmap.josm.data.osm.DataSet;
    1514import org.openstreetmap.josm.data.osm.Node;
     15import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    1616import org.openstreetmap.josm.gui.MainApplication;
    1717import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     
    5555
    5656        LatLon pos = new LatLon(55, -5);
    57         transferHandler.pasteOn(target, Main.getProjection().latlon2eastNorth(pos));
     57        transferHandler.pasteOn(target, ProjectionRegistry.getProjection().latlon2eastNorth(pos));
    5858        assertTrue(pos.equalsEpsilon(ds2.getNodes().iterator().next().getCoor()));
    5959    }
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/MinimapDialogTest.java

    r14052 r14120  
    33
    44import static java.util.concurrent.TimeUnit.MILLISECONDS;
    5 import static org.openstreetmap.josm.tools.I18n.tr;
    65import static org.junit.Assert.assertEquals;
    76import static org.junit.Assert.assertFalse;
    87import static org.junit.Assert.assertTrue;
    98import static org.junit.Assert.fail;
     9import static org.openstreetmap.josm.tools.I18n.tr;
    1010
    1111import java.awt.Color;
     
    1919import java.util.regex.Matcher;
    2020
     21import javax.swing.JCheckBoxMenuItem;
    2122import javax.swing.JMenuItem;
    22 import javax.swing.JCheckBoxMenuItem;
    2323import javax.swing.JPopupMenu;
    2424
     
    3131import org.openstreetmap.josm.data.DataSource;
    3232import org.openstreetmap.josm.data.osm.DataSet;
     33import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    3334import org.openstreetmap.josm.data.projection.Projections;
    3435import org.openstreetmap.josm.gui.MainApplication;
     
    3637import org.openstreetmap.josm.gui.bbox.SlippyMapBBoxChooser;
    3738import org.openstreetmap.josm.gui.bbox.SourceButton;
     39import org.openstreetmap.josm.gui.layer.LayerManagerTest.TestLayer;
    3840import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    39 import org.openstreetmap.josm.gui.layer.LayerManagerTest.TestLayer;
    4041import org.openstreetmap.josm.gui.util.GuiHelper;
    4142import org.openstreetmap.josm.testutils.ImagePatternMatching;
     
    278279        Main.pref.put("slippy_map_chooser.mapstyle", "White Tiles");
    279280        // ensure projection matches JMapViewer's
    280         Main.setProjection(Projections.getProjectionByCode("EPSG:3857"));
     281        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857"));
    281282
    282283        MapView mapView = MainApplication.getMap().mapView;
  • trunk/test/unit/org/openstreetmap/josm/gui/layer/LayerTest.java

    r12990 r14120  
    1414import org.junit.Rule;
    1515import org.junit.Test;
    16 import org.openstreetmap.josm.Main;
    1716import org.openstreetmap.josm.data.preferences.AbstractProperty;
    1817import org.openstreetmap.josm.data.preferences.NamedColorProperty;
     18import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    1919import org.openstreetmap.josm.testutils.JOSMTestRules;
    2020
     
    181181    public void testIsProjectionSupported() {
    182182        assertFalse(testLayer.isProjectionSupported(null));
    183         assertTrue(testLayer.isProjectionSupported(Main.getProjection()));
     183        assertTrue(testLayer.isProjectionSupported(ProjectionRegistry.getProjection()));
    184184    }
    185185
  • trunk/test/unit/org/openstreetmap/josm/io/session/SessionWriterTest.java

    r13797 r14120  
    1313import org.junit.Rule;
    1414import org.junit.Test;
    15 import org.openstreetmap.josm.Main;
    1615import org.openstreetmap.josm.data.coor.LatLon;
    1716import org.openstreetmap.josm.data.gpx.GpxData;
     
    2120import org.openstreetmap.josm.data.notes.Note;
    2221import org.openstreetmap.josm.data.osm.DataSet;
     22import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2323import org.openstreetmap.josm.gui.MainApplication;
    2424import org.openstreetmap.josm.gui.layer.GpxLayer;
     
    144144        TMSLayer layer = new TMSLayer(new ImageryInfo("the name", "http://www.url.com/"));
    145145        layer.getDisplaySettings().setOffsetBookmark(
    146                 new OffsetBookmark(Main.getProjection().toCode(), layer.getInfo().getId(), layer.getInfo().getName(), "", 12, 34));
     146                new OffsetBookmark(ProjectionRegistry.getProjection().toCode(), layer.getInfo().getId(), layer.getInfo().getName(), "", 12, 34));
    147147        return layer;
    148148    }
  • trunk/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java

    r14119 r14120  
    3232import org.openstreetmap.josm.data.preferences.JosmBaseDirectories;
    3333import org.openstreetmap.josm.data.preferences.JosmUrls;
     34import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    3435import org.openstreetmap.josm.data.projection.Projections;
    3536import org.openstreetmap.josm.gui.MainApplication;
     
    472473
    473474        if (useProjection) {
    474             Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
     475            ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
    475476        }
    476477
     
    589590
    590591        // TODO: Remove global listeners and other global state.
    591         Main.clearProjectionChangeListeners();
     592        ProjectionRegistry.clearProjectionChangeListeners();
    592593        Main.pref.resetToInitialState();
    593594        Main.platform = null;
Note: See TracChangeset for help on using the changeset viewer.