Class LatLonFormatter

java.lang.Object
org.ka2ddo.yaac.util.LatLonFormatter

public class LatLonFormatter extends Object
Provide a formatter for a latitude or longitude value in degrees/minutes/fractional minutes and direction (or some other format style for GUI display).
Author:
Andrew Pavlin, KA2DDO
  • Field Details

  • Constructor Details

    • LatLonFormatter

      public LatLonFormatter(boolean isLat, boolean forDisplay)
      Create a LatLonFormatter.
      Parameters:
      isLat - boolean true if for formatting latitudes, false for formatting longitudes.
      forDisplay - boolean true if for formatting human-readable displays, false for formatting for machine-to-machine transfers
    • LatLonFormatter

      public LatLonFormatter(boolean isLat, boolean forDisplay, LatLonFormatter.Format latLonFormat)
      Create a LatLonFormatter.
      Parameters:
      isLat - boolean true if for formatting latitudes, false for formatting longitudes.
      forDisplay - boolean true if for formatting human-readable displays, false for formatting for machine-to-machine transfers
      latLonFormat - Format for this formatter, ignoring the global format value
      See Also:
  • Method Details

    • getGlobalLatLonFormat

      public static LatLonFormatter.Format getGlobalLatLonFormat()
      Get the current default format to use for formatting latitudes and longitudes.
      Returns:
      Format enum
    • setGlobalLatLonFormat

      public static void setGlobalLatLonFormat(LatLonFormatter.Format globalLatLonFormat)
      Set the default format to use for formatting latitudes and longitudes.
      Parameters:
      globalLatLonFormat - Format enum identifying the desired format
    • addPropertyChangeListener

      public static void addPropertyChangeListener(PropertyChangeListener l)
      Register a PropertyChangeListener to be informed of changes to the global format value.
      Parameters:
      l - PropertyChangeListener to register
    • removePropertyChangeListener

      public static void removePropertyChangeListener(PropertyChangeListener l)
      Unregister a PropertyChangeListener so it will no longer be informed of changes to the global format value.
      Parameters:
      l - PropertyChangeListener to unregister
    • format

      public String format(double value)
      Format the specified latitude or longitude value into a String.
      Parameters:
      value - double latitude or longitude in fractional degrees North or East
      Returns:
      String formatted according to the format, isLat, and forDisplay properties of this LatLonFormatter
    • format

      public static String format(double latValue, double lonValue)
      Format the specified latitude and longitude pair according to the current global format. This allows formatting in UTM format (which implicitly merges latitude and longitude together).
      Parameters:
      latValue - latitude in fractional degrees North
      lonValue - longitude in fractional degrees East
      Returns:
      formatted String