Class MapScale

java.lang.Object
com.luciad.maps.MapScale
All Implemented Interfaces:
Comparable<MapScale>

public final class MapScale extends Object implements Comparable<MapScale>
This class represents a map scale, a ratio of a distance on the map to the corresponding actual distance.

For example: a map scale of 1:50000 means that 1 centimeter on a map corresponds with 500 meters on the ground.

This class gives a natural ordering to map scales, from zoomed out to zoomed in. When a part of the API takes an ordered collection as input, it must be ordered according to this natural ordering (unless stated otherwise).

In order for a Map instance to interpret MapScale values correctly, it needs to know the DPI (see Map#getDpi) value of the screen on which it is rendered.

See also the related article

  • Field Details Link icon

    • MaxZoomedOut Link icon

      public static final MapScale MaxZoomedOut
      The value that represents a maximally zoomed out map scale (1:inf == 0)
    • MaxZoomedIn Link icon

      public static final MapScale MaxZoomedIn
      The value that represents a maximally zoomed in map scale (1:0 ≈ the maximum double value)
  • Constructor Details Link icon

    • MapScale Link icon

      public MapScale(double value) throws IllegalArgumentException
      Creates a new MapScale based on the given ratio.
      Parameters:
      value - a value that represents 1 / denominator. For example: a MapScale of 1:50000 can be created using 0.00002 (=1/50000) as value.
      Throws:
      IllegalArgumentException - when the map scale is smaller than 0.
  • Method Details Link icon

    • fromDenominator Link icon

      @NotNull public static MapScale fromDenominator(double denominator) throws IllegalArgumentException
      Creates a map scale from a denominator value.

      For example when using 1:50000 as map scale, the denominator is 50000.

      Parameters:
      denominator - the scale denominator.
      Returns:
      a map scale that corresponds to 1:denominator
      Throws:
      IllegalArgumentException - when the denominator is negative.
    • zoomOut Link icon

      @NotNull public MapScale zoomOut(double factor)
      Creates a new MapScale which is zoomed outn with a given factor.

      For example, when applying this method on a 1:50000 scale, with a factor or 2, the resulting map scale will be 1:100000.

      Parameters:
      factor - the factor using which to zoom out
      Returns:
      a new map scale that is zoomed out using the given factor.
    • zoomIn Link icon

      @NotNull public MapScale zoomIn(double factor)
      Creates a new MapScale which is zoomed in with a given factor.

      For example, when applying this method on a 1:50000 scale, with a factor or 2, the resulting map scale will be 1:25000.

      Parameters:
      factor - the factor using which to zoom in
      Returns:
      a new map scale that is zoomed in using the given factor.
    • getValue Link icon

      public double getValue()
      Returns the scale value.
      Returns:
      the scale value.
    • getDenominator Link icon

      public double getDenominator()
      Returns the denominator of this map scale.

      For example when the Map Scale is 1:50000, this method returns 50000.

      Returns:
      the denominator of this map scale.
    • equals Link icon

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode Link icon

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString Link icon

      @NotNull public String toString()
      Overrides:
      toString in class Object
    • compareTo Link icon

      public int compareTo(@NotNull MapScale other)
      Specified by:
      compareTo in interface Comparable<MapScale>