Class MapScale
- All Implemented Interfaces:
Comparable<MapScale>
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 Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
boolean
static MapScale
fromDenominator
(double denominator) Creates a map scale from a denominator value.double
Returns the denominator of this map scale.double
getValue()
Returns the scale value.int
hashCode()
toString()
zoomIn
(double factor) Creates a new MapScale which is zoomed in with a given factor.zoomOut
(double factor) Creates a new MapScale which is zoomed outn with a given factor.
-
Field Details
-
Constructor Details
-
MapScale
Creates a newMapScale
based on the given ratio.- Parameters:
value
- a value that represents 1 / denominator. For example: aMapScale
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
-
fromDenominator
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
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
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
public double getValue()Returns the scale value.- Returns:
- the scale value.
-
getDenominator
public double getDenominator()Returns the denominator of this map scale.For example when the
Map
Scale is1:50000
, this method returns50000
.- Returns:
- the denominator of this map scale.
-
equals
-
hashCode
public int hashCode() -
toString
-
compareTo
- Specified by:
compareTo
in interfaceComparable<MapScale>
-