Class ProjectionRegistry
- java.lang.Object
-
- org.openstreetmap.josm.data.projection.ProjectionRegistry
-
public final class ProjectionRegistry extends java.lang.Object
Registry for a single, global projection instance.- Since:
- 14120
-
-
Field Summary
Fields Modifier and Type Field Description private static ProjectionBoundsProviderboundsProviderprivate static java.util.List<java.lang.ref.WeakReference<ProjectionChangeListener>>listenersprivate static ProjectionprojThe projection method used.
-
Constructor Summary
Constructors Modifier Constructor Description privateProjectionRegistry()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddProjectionChangeListener(ProjectionChangeListener listener)Register a projection change listener.static voidclearProjectionChangeListeners()Remove all projection change listeners.private static voidfireProjectionChanged(Projection oldValue, Projection newValue, Bounds oldBounds)static ProjectionBoundsProvidergetBoundsProvider()Returns the bounds provider called in projection events.static ProjectiongetProjection()Replies the current projection.static voidremoveProjectionChangeListener(ProjectionChangeListener listener)Removes a projection change listener.static voidsetboundsProvider(ProjectionBoundsProvider provider)Sets the bounds provider called in projection events.static voidsetProjection(Projection p)Sets the current projection
-
-
-
Field Detail
-
proj
private static volatile Projection proj
The projection method used. UsegetProjection()andsetProjection(Projection)for access. UsesetProjection(Projection)in order to trigger a projection change event.
-
boundsProvider
private static ProjectionBoundsProvider boundsProvider
-
listeners
private static final java.util.List<java.lang.ref.WeakReference<ProjectionChangeListener>> listeners
-
-
Constructor Detail
-
ProjectionRegistry
private ProjectionRegistry()
-
-
Method Detail
-
getProjection
public static Projection getProjection()
Replies the current projection.- Returns:
- the currently active projection
-
setProjection
public static void setProjection(Projection p)
Sets the current projection- Parameters:
p- the projection
-
fireProjectionChanged
private static void fireProjectionChanged(Projection oldValue, Projection newValue, Bounds oldBounds)
-
addProjectionChangeListener
public static void addProjectionChangeListener(ProjectionChangeListener listener)
Register a projection change listener. The listener is registered to be weak, so keep a reference of it if you want it to be preserved.- Parameters:
listener- the listener. Ignored ifnull.
-
removeProjectionChangeListener
public static void removeProjectionChangeListener(ProjectionChangeListener listener)
Removes a projection change listener.- Parameters:
listener- the listener. Ignored ifnull.
-
clearProjectionChangeListeners
public static void clearProjectionChangeListeners()
Remove all projection change listeners. For testing purposes only.
-
getBoundsProvider
public static ProjectionBoundsProvider getBoundsProvider()
Returns the bounds provider called in projection events.- Returns:
- the bounds provider
-
setboundsProvider
public static void setboundsProvider(ProjectionBoundsProvider provider)
Sets the bounds provider called in projection events. Must not be null- Parameters:
provider- the bounds provider
-
-