Class MapTheme

java.lang.Object
edu.cnu.mdi.mapping.theme.MapTheme

public final class MapTheme extends Object
Immutable value object that encapsulates the complete visual style used when rendering a map and its decorations (graticule, country borders, city markers, labels, ocean fill, and projection outline).

Usage

Obtain an instance either from one of the built-in presets (light(), dark(), blue()) or by constructing a custom theme with the nested MapTheme.Builder:


 MapTheme custom = new MapTheme.Builder()
         .backgroundColor(Color.WHITE)
         .oceanColor(new Color(0xADD8E6))
         .landColor(new Color(0x90EE90))
         .build();
 

To tweak an existing theme without rebuilding it from scratch use toBuilder(), which copies every field into a new MapTheme.Builder ready for modification.

Thread safety

MapTheme instances are effectively immutable once constructed and may be shared freely across threads and rendering layers.

Projection integration

Each IMapProjection holds a reference to its active MapTheme. The projection consults the theme when drawing the map outline, graticule lines, and the ocean fill. Renderers such as CountryRenderer and CityPointRenderer obtain the theme via the projection so that all layers remain visually consistent.

  • Method Details

    • getBackgroundColor

      public Color getBackgroundColor()
      Returns the background color drawn behind the entire map panel.
      Returns:
      background Color; never null
    • getOceanColor

      public Color getOceanColor()
      Returns the color used to fill the ocean region inside the projection boundary.
      Returns:
      ocean fill Color; never null
    • getLandColor

      public Color getLandColor()
      Returns the color used to fill land (country) polygons.
      Returns:
      land fill Color; never null
    • getOutlineColor

      public Color getOutlineColor()
      Returns the color used to stroke the outer boundary of the projection domain (e.g., the bounding rectangle for Mercator or the ellipse for Mollweide).
      Returns:
      outline stroke Color; never null
    • getGraticuleColor

      public Color getGraticuleColor()
      Returns the color used to draw graticule lines (latitude parallels and longitude meridians).

      All projection implementations must use this value rather than hardcoding a color so that theme switching takes full effect.

      Returns:
      graticule Color; never null
    • getLabelColor

      public Color getLabelColor()
      Returns the color used to render text labels such as city names.
      Returns:
      label text Color; never null
    • getCityColor

      public Color getCityColor()
      Returns the color used to draw city marker dots.

      CityPointRenderer uses this color for point markers and falls back to getLabelColor() if this value is null.

      Returns:
      city marker Color, or null to use the label color
    • getBorderColor

      public Color getBorderColor()
      Returns the color used to stroke country political borders.
      Returns:
      border stroke Color; never null
    • getOutlineStrokeWidth

      public float getOutlineStrokeWidth()
      Returns the stroke width in points used for the projection boundary outline.
      Returns:
      outline stroke width (≥ 0)
    • getGraticuleStrokeWidth

      public float getGraticuleStrokeWidth()
      Returns the stroke width in points used for graticule lines.
      Returns:
      graticule stroke width (≥ 0)
    • getBorderStroke

      public Stroke getBorderStroke()
      Returns the Stroke used to draw country political borders.

      Renderers that respect the theme (e.g., CountryRenderer) should use this stroke rather than constructing their own.

      Returns:
      border Stroke; never null
    • toBuilder

      public MapTheme.Builder toBuilder()
      Creates a new MapTheme.Builder pre-populated with every field from this theme. Useful for creating a variation without specifying every value:
      
       MapTheme brighter = existingTheme.toBuilder()
               .landColor(Color.GREEN)
               .build();
       
      Returns:
      a mutable MapTheme.Builder that reproduces this theme
    • light

      public static MapTheme light()
      Returns a light-background theme suitable for daytime use or printing.
      • Background: near-white (#F0F0F0)
      • Ocean: light blue (#CDE8FF)
      • Land: pale green (#E3F2D9)
      • Cities: red
      Returns:
      a new light MapTheme instance
    • dark

      public static MapTheme dark()
      Returns a dark-background theme suitable for low-light environments or stylistic preference.
      • Background: near-black (#20232A)
      • Ocean: dark navy (#273746)
      • Land: dark blue-grey (#34495E)
      • Cities: cyan
      Returns:
      a new dark MapTheme instance
    • blue

      public static MapTheme blue()
      Returns a blue-toned theme with a nautical aesthetic.
      • Background: pale blue (#E9F2FF)
      • Ocean: medium blue (#90CAF9)
      • Land: desaturated teal (#D8E5E9)
      • Cities: deep navy (#0D47A1)
      Returns:
      a new blue MapTheme instance