public class UnitsFormat extends AVListImpl
Constructor and Description |
---|
UnitsFormat()
Construct an instance that displays length in kilometers, area in square kilometers and angles in decimal
degrees.
|
UnitsFormat(String lengthUnits,
String areaUnits)
Constructs an instance that display length and area in specified units, and angles in decimal degrees.
|
UnitsFormat(String lengthUnits,
String areaUnits,
boolean showDMS)
Constructs an instance that display length and area in specified units, and angles in a specified format.
|
Modifier and Type | Method and Description |
---|---|
String |
angle(String label,
Angle angle)
Format an angle according to the current angle format.
|
String |
angleNL(String label,
Angle angle)
Format an angle according to the current angle format.
|
String |
area(String label,
double squareMeters)
Format an area value according to the current length configuration and prepend a specified label.
|
String |
areaNL(String label,
double squareMeters)
Format an area value according to the current length configuration.
|
String |
eyeAltitude(double metersAltitude)
Format an eye altitude according to the current eye altitude format.
|
String |
eyeAltitudeNL(double metersAltitude)
Format an eye altitude according to the current eye altitude format, and append a new-line character.
|
String |
getAltitudeUnits()
Returns the current altitude units.
|
double |
getAltitudeUnitsMultiplier()
Indicates the multiplier used to convert from meters to the current altitude units.
|
String |
getAltitudeUnitsSymbol()
Returns the units symbol for the current altitude units.
|
String |
getAreaUnits()
Returns the current area units.
|
double |
getAreaUnitsMultiplier()
Indicates the multiplier used to convert from square meters to the current area units.
|
String |
getAreaUnitsSymbol()
Returns the units symbol for the current area units.
|
String |
getAreaUnitsSystem()
Indicates the unit system of the current area units.
|
String |
getFormat(String formatName)
Returns the format for a specified value type.
|
String |
getLabel(String labelName)
Returns the label for a specified label name.
|
String |
getLengthUnits()
Returns the current length units.
|
double |
getLengthUnitsMultiplier()
Indicates the multiplier used to convert from meters to the current length units.
|
String |
getLengthUnitsSymbol()
Returns the units symbol for the current length units.
|
String |
getLengthUnitsSystem()
Indicates the unit system of the current length units.
|
String |
heading(Angle angle)
Format an angle of heading according to the current angle format.
|
String |
heading(double heading)
Format an angle of heading in degrees according to the current angle format.
|
String |
headingNL(Angle angle)
Format an angle of heading according to the current angle format, and append a new-line character.
|
String |
headingNL(double heading)
Format an angle of heading in degrees according to the current angle format, and append a new-line character.
|
boolean |
isShowDMS()
Indicates whether angles are displayed in degrees-minutes-seconds.
|
String |
latitude(Angle angle)
Format an angle of latitude.
|
String |
latitudeNL(Angle angle)
Format an angle of latitude and append a new-line character.
|
String |
latLon(LatLon latlon)
Format angles of latitude and longitude according to the current angle format.
|
String |
latLon2(LatLon latlon)
Format angles of latitude and longitude according to the current angle format and in the form "20°N
85°S".
|
String |
latLon2NL(LatLon latlon)
Format angles with
latLon2(gov.nasa.worldwind.geom.LatLon) and append a new-line character. |
String |
latLonNL(LatLon latlon)
Format angles of latitude and longitude according to the current angle format, and append a new-line character.
|
String |
length(String label,
double meters)
Format a length according to the current length configuration.
|
String |
lengthNL(String label,
double meters)
Format a length according to the current length configuration.
|
String |
longitude(Angle angle)
Format an angle of longitude.
|
String |
longitudeNL(Angle angle)
Format an angle of longitude and append a new-line character.
|
String |
pitch(double pitch)
Format an angle of pitch according to the current angle format.
|
String |
pitchNL(double pitch)
Format an angle of pitch according to the current angle format, and append a new-line character.
|
void |
setAltitudeUnits(String altitudeUnits)
Specifies the units in which to display altitude values.
|
void |
setAreaUnits(String areaUnits)
Specifies the units in which to display area values.
|
protected void |
setDefaultFormats()
Establishes the format declarations to use for certain values.
|
protected void |
setDefaultLabels()
Establishes the labels to use when displaying values other than length and area.
|
void |
setFormat(String formatName,
String format)
Set the format of a specified value type.
|
void |
setLabel(String labelName,
String label)
Set the label of a specified value type.
|
void |
setLengthUnits(String lengthUnits)
Specifies the units in which to display length values.
|
void |
setShowDMS(boolean showDMS)
Specifies whether angles are displayed in degrees-minutes-seconds.
|
void |
setUnitsSystem(String unitsSystem)
Sets the length and area units to those common for a given units system.
|
String |
terrainHeight(double metersElevation,
double verticalExaggeration)
Format a terrain height value according to the current configuration and append a new-line character.
|
String |
terrainHeightNL(double metersElevation,
double verticalExaggeration)
Format a terrain height value according to the current configuration and append a new-line character.
|
String |
utmEasting(double easting)
Format a UTM easting value according to the current UTM easting format.
|
String |
utmEastingNL(double easting)
Format a UTM easting value according to the current UTM easting format and append a new-line character.
|
String |
utmNorthing(double northing)
Format a UTM northing value according to the current UTM northing format.
|
String |
utmNorthingNL(double northing)
Format a UTM northing value according to the current UTM northing format and append a new-line character.
|
String |
utmZone(int zone)
Format a UTM zone according to the current UTM zone format.
|
String |
utmZoneNL(int zone)
Format a UTM zone according to the current UTM zone format and append a new-line character.
|
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getBooleanValue, getBooleanValue, getChangeSupport, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, getRestorableStateForAVPair, getStringValue, getStringValue, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
public static final String ACRE
protected String altitudeUnits
protected double altitudeUnitsMultiplier
protected String altitudeUnitsSymbol
protected String areaUnits
protected double areaUnitsMultiplier
protected String areaUnitsSymbol
public static final String FEET
public static final String FORMAT_AREA
public static final String FORMAT_DECIMAL_DEGREES
public static final String FORMAT_EYE_ALTITUDE
public static final String FORMAT_HEADING
public static final String FORMAT_LENGTH
public static final String FORMAT_PITCH
public static final String FORMAT_TERRAIN_HEIGHT
public static final String FORMAT_UTM_EASTING
public static final String FORMAT_UTM_NORTHING
public static final String HECTARE
public static final String IMPERIAL_SYSTEM
public static final String KILOMETERS
public static final String LABEL_DATUM
public static final String LABEL_EYE_ALTITUDE
public static final String LABEL_HEADING
public static final String LABEL_LATITUDE
public static final String LABEL_LATLON_LAT
public static final String LABEL_LATLON_LON
public static final String LABEL_LONGITUDE
public static final String LABEL_PITCH
public static final String LABEL_TERRAIN_HEIGHT
public static final String LABEL_UTM_EASTING
public static final String LABEL_UTM_NORTHING
public static final String LABEL_UTM_ZONE
protected String lengthUnits
protected double lengthUnitsMultiplier
protected String lengthUnitsSymbol
public static final String METERS
public static final String METRIC_SYSTEM
public static final String MILES
public static final String NAUTICAL_MILES
protected static final String NL
protected boolean showDMS
public static final String SQUARE_FEET
public static final String SQUARE_KILOMETERS
public static final String SQUARE_METERS
public static final String SQUARE_MILES
public static final String SQUARE_YARDS
public static final String SYMBOL_ACRE
public static final String SYMBOL_FEET
public static final String SYMBOL_HECTARE
public static final String SYMBOL_KILOMETERS
public static final String SYMBOL_METERS
public static final String SYMBOL_MILES
public static final String SYMBOL_NAUTICAL_MILES
public static final String SYMBOL_SQUARE_FEET
public static final String SYMBOL_SQUARE_KILOMETERS
public static final String SYMBOL_SQUARE_METERS
public static final String SYMBOL_SQUARE_MILES
public static final String SYMBOL_SQUARE_YARDS
public static final String SYMBOL_YARDS
public static final String YARDS
public UnitsFormat()
public UnitsFormat(String lengthUnits, String areaUnits)
lengthUnits
- the desired length units. Available length units are METERS, KILOMETERS, MILES,
NAUTICAL_MILES, YARDS
and FEET
areaUnits
- the desired area units. Available area units are SQUARE_METERS, SQUARE_KILOMETERS,
HECTARE, ACRE, SQUARE_YARD
and SQUARE_FEET
.
- Throws:
IllegalArgumentException
- if either lengthUnits
or areaUnits
is null.
public UnitsFormat(String lengthUnits, String areaUnits, boolean showDMS)
lengthUnits
- the desired length units. Available length units are METERS, KILOMETERS, MILES,
NAUTICAL_MILES, YARDS
and FEET
areaUnits
- the desired area units. Available area units are SQUARE_METERS, SQUARE_KILOMETERS,
HECTARE, ACRE, SQUARE_YARD
and SQUARE_FEET
.
showDMS
- true if the desired angle format is degrees-minutes-seconds, false if the format is decimal
degrees.
- Throws:
IllegalArgumentException
- if either lengthUnits
or areaUnits
is null.
public String angle(String label, Angle angle)
label
- a label to prepend to the formatted angle. May be null to indicate no label.angle
- the angle to format.IllegalArgumentException
- if the angle is null.public String angleNL(String label, Angle angle)
label
- a label to prepend to the formatted angle. May be null to indicate no label.angle
- the angle to format.IllegalArgumentException
- if the angle is null.public String area(String label, double squareMeters)
FORMAT_AREA
and area units symbol, and is converted to the
current area units prior to formatting. The default area format is " %,12.1f %s", where the %s specifier stands
for the units symbol.label
- the label to prepend to the formatted length. May be null to indicate no label.squareMeters
- the area value to format, in square meters.public String areaNL(String label, double squareMeters)
FORMAT_AREA
and area units symbol, and is converted to the
current area units prior to formatting. The default area format is " %,12.1f %s", where the %s specifier stands
for the units symbol.label
- the label to prepend to the formatted length. May be null to indicate no label.squareMeters
- the area value to format, in square meters.public String eyeAltitude(double metersAltitude)
LABEL_EYE_ALTITUDE
, FORMAT_EYE_ALTITUDE
and length
format.metersAltitude
- the eye altitude to format, in meters.public String eyeAltitudeNL(double metersAltitude)
LABEL_EYE_ALTITUDE
, FORMAT_EYE_ALTITUDE
and length
format.metersAltitude
- the eye altitude to format, in meters.public String getAltitudeUnits()
UnitsFormat(String, String, boolean)
for the list of those
available.public double getAltitudeUnitsMultiplier()
public String getAltitudeUnitsSymbol()
public String getAreaUnits()
UnitsFormat(String, String, boolean)
for the list of those
available.public double getAreaUnitsMultiplier()
public String getAreaUnitsSymbol()
public String getAreaUnitsSystem()
METRIC_SYSTEM
and IMPERIAL_SYSTEM
.public String getFormat(String formatName)
formatName
- the name of the value type whose format is desired.IllegalArgumentException
- if the format name is null.public String getLabel(String labelName)
labelName
- the name of the label to return.IllegalArgumentException
- if the label name is null.public String getLengthUnits()
UnitsFormat(String, String, boolean)
for the list of those
available.public double getLengthUnitsMultiplier()
public String getLengthUnitsSymbol()
public String getLengthUnitsSystem()
METRIC_SYSTEM
and
IMPERIAL_SYSTEM
.public String heading(Angle angle)
LABEL_HEADING
and angle format.angle
- the heading angle to format.IllegalArgumentException
- if the angle is null.public String heading(double heading)
LABEL_HEADING
and FORMAT_HEADING
. The default
FORMAT_HEADING
is " %9.2f°".heading
- the angle to format.public String headingNL(Angle angle)
LABEL_HEADING
and angle format.angle
- the heading angle to format.IllegalArgumentException
- if the angle is null.public String headingNL(double heading)
LABEL_HEADING
and FORMAT_HEADING
. The default
FORMAT_HEADING
is " %9.2f°".heading
- the angle to format.public boolean isShowDMS()
public String latitude(Angle angle)
LABEL_LATITUDE
and angle format.angle
- the angle to format.IllegalArgumentException
- if the angle is null.public String latitudeNL(Angle angle)
LABEL_LATITUDE
and angle format.angle
- the angle to format.IllegalArgumentException
- if the angle is null.public String latLon(LatLon latlon)
LABEL_LATLON_LAT
, LABEL_LATLON_LON
and angle
format.latlon
- the angles to format.IllegalArgumentException
- if latlon
is null.public String latLon2(LatLon latlon)
latlon
- the angles to format.IllegalArgumentException
- if latlon
is null.public String latLon2NL(LatLon latlon)
latLon2(gov.nasa.worldwind.geom.LatLon)
and append a new-line character.latlon
- the angles to format.IllegalArgumentException
- if latlon
is null.public String latLonNL(LatLon latlon)
LABEL_LATLON_LAT
, LABEL_LATLON_LON
and angle
format.latlon
- the angles to format.IllegalArgumentException
- if latlon
is null.public String length(String label, double meters)
FORMAT_LENGTH
and length units symbol, and is converted to the
current length units prior to formatting. The default length format is " %,12.1f %s", where the %s specifier
stands for the units symbol.label
- the label to prepend to the formatted length. May be null to indicate no label.meters
- the length to format, in meters.public String lengthNL(String label, double meters)
FORMAT_LENGTH
and length units symbol, and is converted to the
current length units prior to formatting. The default length format is " %,12.1f %s", where the %s specifier
stands for the units symbol.label
- the label to prepend to the formatted length. May be null to indicate no label.meters
- the length to format, in meters.public String longitude(Angle angle)
LABEL_LONGITUDE
and angle format.angle
- the angle to format.IllegalArgumentException
- if the angle is null.public String longitudeNL(Angle angle)
LABEL_LONGITUDE
and angle format.angle
- the angle to format.public String pitch(double pitch)
LABEL_PITCH
and FORMAT_PITCH
. The default
FORMAT_PITCH
is " %9.2f°".pitch
- the angle to format.public String pitchNL(double pitch)
LABEL_PITCH
and FORMAT_PITCH
. The default
FORMAT_PITCH
is " %9.2f°".pitch
- the angle to format.public void setAltitudeUnits(String altitudeUnits)
altitudeUnits
- the desired altitude units. See UnitsFormat(String, String, boolean)
for the list
of those available.IllegalArgumentException
- if lengthUnits
is null.public void setAreaUnits(String areaUnits)
areaUnits
- the desired length units. See UnitsFormat(String, String, boolean)
for the list of
those available.IllegalArgumentException
- if areaUnits
is null.protected void setDefaultFormats()
protected void setDefaultLabels()
public void setFormat(String formatName, String format)
setDefaultFormats()
for a description and examples of
formats.formatName
- a key identifying the value type that is to have the specified format. Available types are
those indicated by the "FORMAT_" constants defined by this class or by its subclassesformat
- the label to use for the specified value type.IllegalArgumentException
- if either the format or format name are null.public void setLabel(String labelName, String label)
setDefaultLabels()
for a description and examples of
labels.labelName
- a key identifying the label type. Available names are those indicated by the "LABEL_" constants
defined by this class or by its subclasseslabel
- the label to use for the specified value type.IllegalArgumentException
- if either the label or label name is null.public void setLengthUnits(String lengthUnits)
lengthUnits
- the desired length units. See UnitsFormat(String, String, boolean)
for the list of
those available.IllegalArgumentException
- if lengthUnits
is null.public void setShowDMS(boolean showDMS)
showDMS
- true to display angles in degrees-minutes seconds, false to display them in decimal degrees.public void setUnitsSystem(String unitsSystem)
METRIC_SYSTEM
, which uses kilometers and square kilometers, and IMPERIAL_SYSTEM
, which uses miles and
square miles.unitsSystem
- the desired units system, either METRIC_SYSTEM
or IMPERIAL_SYSTEM
.IllegalArgumentException
- if unitsSystem
is null.public String terrainHeight(double metersElevation, double verticalExaggeration)
LABEL_TERRAIN_HEIGHT
, FORMAT_TERRAIN_HEIGHT
and length
units symbol. The default terrain height format is " (ve %3.1f): %,6d %s", where the %3.1f specifier stands for
the vertical exaggeration, the %,6d specifier stands for the terrain height, and the %s specifier stands for the
units symbol.
Note: While the FORMAT_TERRAIN_HEIGHT
string may be specified by the application, the terrain height
components are always passed to the internal formatter in the order: vertical exaggeration, terrain height, units
symbol.metersElevation
- the terrain height in meters.verticalExaggeration
- the vertical exaggeration to apply to the terrain height.public String terrainHeightNL(double metersElevation, double verticalExaggeration)
terrainHeight(double, double)
for a description of the formatting.metersElevation
- the terrain height in meters.verticalExaggeration
- the vertical exaggeration to apply to the terrain height.public String utmEasting(double easting)
LABEL_UTM_EASTING
and current FORMAT_UTM_EASTING
. The
default UTM easting format is " %,11.1f". No units symbol is included in the formatted string because UTM easting
units are always meters.easting
- the UTM northing to format.public String utmEastingNL(double easting)
LABEL_UTM_EASTING
and current FORMAT_UTM_EASTING
. The
default UTM easting format is " %,11.1f". No units symbol is included in the formatted string because UTM easting
units are always meters.easting
- the UTM northing to format.public String utmNorthing(double northing)
LABEL_UTM_NORTHING
and current FORMAT_UTM_NORTHING
.
The default UTM northing format is " %,11.1f". No units symbol is included in the formatted string because UTM
northing units are always meters.northing
- the UTM northing to format.public String utmNorthingNL(double northing)
LABEL_UTM_NORTHING
and current FORMAT_UTM_NORTHING
.
The default UTM northing format is " %,11.1f". No units symbol is included in the formatted string because UTM
northing units are always meters.northing
- the UTM northing to format.public String utmZone(int zone)
LABEL_UTM_ZONE
.zone
- the UTM zone to format.public String utmZoneNL(int zone)
LABEL_UTM_ZONE
.zone
- the UTM zone to format.