Package edu.cnu.mdi.mapping.projection
Class ProjectionFactory
java.lang.Object
edu.cnu.mdi.mapping.projection.ProjectionFactory
Factory for creating
IMapProjection instances from
EProjection identifiers.
Purpose
Centralizing projection construction here means that calling code
(e.g. MapView2D) never depends directly on concrete classes such as
MercatorProjection or OrthographicProjection. Adding a new
projection requires only: a new EProjection constant, a new
case in create(EProjection, MapTheme, Point2D.Double), and
the concrete implementation class itself.
Theme guarantee
Every projection returned by this factory has its MapTheme set
before the instance is returned. Callers can therefore call drawing methods
immediately without risk of NullPointerException.
Typical usage
// Default center
IMapProjection mercator = ProjectionFactory.create(EProjection.MERCATOR, MapTheme.light());
// Explicit center (orthographic centred on the USA)
Point2D.Double center = new Point2D.Double(Math.toRadians(-100.0), Math.toRadians(40.0));
IMapProjection ortho = ProjectionFactory.create(EProjection.ORTHOGRAPHIC, MapTheme.dark(), center);
This class is not instantiable.
-
Method Summary
Modifier and TypeMethodDescriptionstatic IMapProjectioncreate(EProjection type, MapTheme theme) Creates a projection with the given type and theme, using each projection's built-in default center.static IMapProjectioncreate(EProjection type, MapTheme theme, Point2D.Double center) Creates a projection with the given type, theme, and optional center.
-
Method Details
-
create
Creates a projection with the given type and theme, using each projection's built-in default center.This is a convenience overload of
create(EProjection, MapTheme, Point2D.Double)that passesnullfor the center.- Parameters:
type- projection type; must not benulltheme- map theme; must not benull- Returns:
- a fully initialized
IMapProjectionwith the theme set - Throws:
IllegalArgumentException- iftypeorthemeisnull, ortypeis not yet handled by this factory
-
create
Creates a projection with the given type, theme, and optional center.Center conventions
- The
centerparameter is aPoint2D.Doublewithx = λ₀(longitude, radians) andy = φ₀(latitude, radians). - If
centerisnulla projection-specific default is used (see individual cases below). - Mercator, Mollweide, and Equal Earth use only the longitude component of
center; the latitude component is ignored.
Default centers
- MERCATOR — defaults to a central longitude of -70°.
- ORTHOGRAPHIC — defaults to (λ = 0°, φ = 50°), a balanced mid-latitude northern hemisphere view.
- MOLLWEIDE — defaults to a central longitude of -70°.
- EQUAL_EARTH — defaults to a central longitude of -70°.
- LAMBERT_EQUAL_AREA — defaults to (λ = 0°, φ = 0°), i.e., centered on the intersection of the equator and prime meridian.
- Parameters:
type- projection type; must not benulltheme- map theme; must not benullcenter- optional projection center in radians (x=λ, y=φ);nulluses the projection's built-in default- Returns:
- a fully initialized
IMapProjectionwith the theme set - Throws:
IllegalArgumentException- iftypeorthemeisnull, ortypeis not yet handled by this factory
- The
-