Class TLcdMapLocation

java.lang.Object
com.luciad.view.map.TLcdMapLocation
All Implemented Interfaces:
MouseListener, MouseMotionListener, EventListener

public class TLcdMapLocation extends Object implements MouseListener, MouseMotionListener
A utility to retrieve and display the geographical location of a mouse position on an ILcdGXYView.

Configuring a view will add this TLcdMapLocation as a mouseMotionListener.

The mouse location can be retrieved as lon - lat values (WGS84 by default), or as a formatted String. The format can be changed. In addition, convenience formatting modes are available.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Constant for center alignment.
    static final int
    Mode for a custom Format.
    static final String
    Constant for 'GXYView' property.
    static final int
    Constant for left alignment.
    static final int
    Mode for the location in latitude-longitude (dd°mm'ss",ddd°mm'ss").
    static final int
    Mode for the location in latitude-longitude (xx.xxxx°,xxx.xxxx°).
    static final int
    Mode for the location in latitude-longitude (xx°xx',xxx°xx).
    static final int
    Mode for the location in latitude-longitude (xx°xx.xx',xxx°xx.xx').
    static final int
    Mode for the location in Georef coordinates.
    static final int
    Mode for the location in latitude-longitude (ddmmssNdddmmssW).
    static final int
    Mode for the location in UTM-MGRS coordinates, with 10 meter precision.
    static final int
    Mode for the location in UTM-MGRS coordinates, with 100 meter precision.
    static final int
    Mode for the location in UTM-MGRS coordinates, with km precision.
    static final int
    Mode for the location in UTM-MGRS coordinates, with meter precision.
    static final int
    Mode for the location in longitude-latitude (dddmmssWddmmssN).
    static final String
    Constant for mode property.
    static final int
    Constant for right alignment.
    static final int
    Mode for the scale as meter/pixel.
    static final int
    Mode for the scale as km/pixel.
    static final int
    Mode for the scale as miles/pixel.
    static final int
    Mode for the window width in meters.
    static final int
    Mode for the window width in kilometers.
    static final int
    Mode for the window width in miles.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Expresses the coordinate of the mouse location in longitude, latitude coordinates on the WGS84 geodetic datum.
    Expresses the coordinate of the mouse location in longitude, latitude coordinates on the given geodetic datum.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a property change listener.
    int
    Returns how the location information will be aligned.
    Returns the format to format the location as a string.
    Returns the view in which the location is computed.
    double
    Returns the latitude of the current (computed) location.
    double
    Returns the longitude of the current (computed) location.
    int
    Returns the format in which the coordinates of the (computed) location will be expressed.
    char
    Returns the character to separate the zone and the coordinates.
    char
    Returns the character to separate the UTM grid zone and the 100km squares.
    boolean
    Deprecated.
    This method has been deprecated.
    void
    This implementation is empty.
    void
    This implementation is empty.
    void
    This implementation is empty.
    void
    This implementation is empty.
    void
    The MouseEvent me causes the properties of importance to the current mode to be updated.
    void
    The MouseEvent me causes the properties of importance to the current mode to be updated.
    void
    This implementation is empty.
    void
    paint(Graphics aGraphics, Rectangle aRectangle)
    This method draws the information pertaining to the current mode as a string centered vertically in the Rectangle aRectangle, having getAlignment() as alignment.
    protected void
    The MouseEvent aMouseEvent causes the properties of importance to the current mode to be updated.
    void
    Removes a property change listener.
    void
    setAlignment(int aAlignment)
    The property of alignment determines whether to center, left or right align the location information.
    static void
    setClassTraceOn(boolean aClassTraceOn)
    Deprecated.
    This method has been deprecated.
    void
    setFormat(Format aFormat)
    Sets a custom format to format the location as a string.
    void
    Sets the view for which the location will be determined.
    void
    setMode(int aMode)
    Sets the format in which the coordinates of the (computed) location will be expressed.
    void
    setTraceOn(boolean aTraceOn)
    Deprecated.
    This method has been deprecated.
    void
    setUTMCoordinateSeparator(char aUTMCoordinateSeparator)
    Set the character to separate the zone and the coordinates and between the coordinates.
    void
    setZoneSeparator(char aZoneSeparator)
    Sets the character to use as separator between the UTM grid zone and the 100km squares.
    protected void
    Updates the properties of this class using the current lon,lat position in accordance with the property of mode.
    protected void
    updateWithLocation(int aX, int aY)
    Updates the properties of this class by retrieving the location of the ILcdGXYView point (aX,aY) in a format in accordance with the property of mode.
    Returns the information using the current mode and (computed) location as a String.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • TLcdMapLocation

      public TLcdMapLocation()
      Expresses the coordinate of the mouse location in longitude, latitude coordinates on the WGS84 geodetic datum. After construction, a view should be configured.
      See Also:
    • TLcdMapLocation

      public TLcdMapLocation(ILcdGeodeticDatum aGeodeticDatum)
      Expresses the coordinate of the mouse location in longitude, latitude coordinates on the given geodetic datum.
      Parameters:
      aGeodeticDatum - the datum to express the coordinates in. After construction, a view should be configured.
      See Also:
  • Method Details

    • setClassTraceOn

      public static void setClassTraceOn(boolean aClassTraceOn)
      Deprecated.
      This method has been deprecated. It is recommended to use the standard Java logging framework directly.
      Enables tracing for all instances of this class. If the argument is true then all log messages are recorded, otherwise only the informative, warning and error messages are recorded.
      Parameters:
      aClassTraceOn - if true then all log messages are recorded, otherwise only the informative, warning and error messages are recorded.
    • setTraceOn

      public void setTraceOn(boolean aTraceOn)
      Deprecated.
      This method has been deprecated. It is recommended to use the standard Java logging framework directly.
      Enables tracing for this class instance. Calling this method with either true or false as argument automatically turns off tracing for all other class instances for which setTraceOn has not been called. If the argument is false then only the informative, warning and error log messages are recorded.
      Parameters:
      aTraceOn - if true then all log messages are recorded for this instance. If false, then only the informative, warning and error log messages are recorded.
    • isTraceOn

      public boolean isTraceOn()
      Deprecated.
      This method has been deprecated. It is recommended to use the standard Java logging framework directly.
      Returns true if tracing is enabled for this class.
      Returns:
      true if tracing is enabled for this class, false otherwise.
    • valueAsString

      public String valueAsString()
      Returns the information using the current mode and (computed) location as a String.
      Returns:
      the information using the current mode and (computed) location as a String.
    • addPropertyChangeListener

      public void addPropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
      Adds a property change listener. Possible values for property IDs are MODE and GXYVIEW.
      Parameters:
      aPropertyChangeListener - listens to mode and view property changes.
      See Also:
    • removePropertyChangeListener

      public void removePropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
      Removes a property change listener.
      Parameters:
      aPropertyChangeListener - listened to mode and view property changes.
      See Also:
    • setMode

      public void setMode(int aMode)
      Sets the format in which the coordinates of the (computed) location will be expressed. 3 types of modes are possible:
      • geographical location (constants starting with LOCATION)
      • the scale (unit of length / pixel) of the ILcdGXYView (constants starting with SCALE)
      • the width of the current view (constants starting with WINDOW_WIDTH)
      In addition, a custom format can be set using setFormat. This will change the mode to CUSTOM_FORMAT.
      Parameters:
      aMode - the format in which the coordinates of the (computed) location will be expressed.
      See Also:
    • getMode

      public int getMode()
      Returns the format in which the coordinates of the (computed) location will be expressed.
      Returns:
      the format in which the coordinates of the (computed) location will be expressed.
      See Also:
    • setFormat

      public void setFormat(Format aFormat)
      Sets a custom format to format the location as a string. The format is passed an ILcdPoint object. This will change the mode to CUSTOM_FORMAT.
      Parameters:
      aFormat - a format to be used
    • getFormat

      public Format getFormat()
      Returns the format to format the location as a string. This is used if the mode is set to CUSTOM_FORMAT.
      Returns:
      the used format
    • getLon

      public double getLon()
      Returns the longitude of the current (computed) location.
      Returns:
      the longitude of the current (computed) location.
    • getLat

      public double getLat()
      Returns the latitude of the current (computed) location.
      Returns:
      the latitude of the current (computed) location.
    • setAlignment

      public void setAlignment(int aAlignment)
      The property of alignment determines whether to center, left or right align the location information. This can be RIGHT, LEFT or CENTER. Sets the property of alignment to aAlignment.
      Parameters:
      aAlignment - the new alignment, can be RIGHT, LEFT or CENTER.
      See Also:
    • getAlignment

      public int getAlignment()
      Returns how the location information will be aligned. The property of alignment determines whether to center, left or right align the location information.
      Returns:
      RIGHT, LEFT or CENTER.
      See Also:
    • setGXYView

      public void setGXYView(ILcdGXYView aGXYView)
      Sets the view for which the location will be determined. The ILcdGXYView must have a ILcdGridReference as XYWorldReference property. The map location is added as a mouse motion listener to the view.
      Parameters:
      aGXYView - the view to determine the location in.
      See Also:
    • getGXYView

      public ILcdGXYView getGXYView()
      Returns the view in which the location is computed.
      Returns:
      the view in which the location is computed.
      See Also:
    • setUTMCoordinateSeparator

      public void setUTMCoordinateSeparator(char aUTMCoordinateSeparator)
      Set the character to separate the zone and the coordinates and between the coordinates. Set the value 0 (not the character '0') to have no spaces between the zone and the coordinates. This setting only applies to the UTM modes.
      Parameters:
      aUTMCoordinateSeparator - the character to separate the zone and the coordinates and between the coordinates.
      See Also:
    • getUTMCoordinateSeparator

      public char getUTMCoordinateSeparator()
      Returns the character to separate the zone and the coordinates.
      Returns:
      the character to separate the zone and the coordinates.
      See Also:
    • setZoneSeparator

      public void setZoneSeparator(char aZoneSeparator)

      Sets the character to use as separator between the UTM grid zone and the 100km squares. Set the value to 0 (not the character '0') to have no separator between the UTM grid zone and the 100km squares.

      The default is 0.

      This setting only applies to the UTM modes.

      Parameters:
      aZoneSeparator - the character to separate the UTM grid zone and the 100km squares.
      See Also:
    • getZoneSeparator

      public char getZoneSeparator()

      Returns the character to separate the UTM grid zone and the 100km squares.

      This setting only applies to the UTM modes.

      Returns:
      the character to separate the UTM grid zone and the 100km squares.
      See Also:
    • updateWithLocation

      protected void updateWithLocation(int aX, int aY)
      Updates the properties of this class by retrieving the location of the ILcdGXYView point (aX,aY) in a format in accordance with the property of mode. This method is called by processMouseEvent(java.awt.event.MouseEvent).
      Parameters:
      aX - the first coordinate of the location in view (AWT) coordinates.
      aY - the second coordinate of the location in view (AWT) coordinates.
    • updateWithCurrentLocation

      protected void updateWithCurrentLocation()
      Updates the properties of this class using the current lon,lat position in accordance with the property of mode. Useful when changing of mode.
    • paint

      public void paint(Graphics aGraphics, Rectangle aRectangle)
      This method draws the information pertaining to the current mode as a string centered vertically in the Rectangle aRectangle, having getAlignment() as alignment.
      Parameters:
      aGraphics - the graphics to paint on.
      aRectangle - the rectangle to fit the information in. If the information does not fit into the box, it is abbreviated.
    • processMouseEvent

      protected void processMouseEvent(MouseEvent aMouseEvent)
      The MouseEvent aMouseEvent causes the properties of importance to the current mode to be updated. This method is called by mouseMoved(java.awt.event.MouseEvent) and mousePressed(java.awt.event.MouseEvent).
      Parameters:
      aMouseEvent - the mouse event based on which the properties will be updated.
    • mouseMoved

      public void mouseMoved(MouseEvent me)
      The MouseEvent me causes the properties of importance to the current mode to be updated.
      Specified by:
      mouseMoved in interface MouseMotionListener
    • mouseDragged

      public void mouseDragged(MouseEvent me)
      This implementation is empty. MouseEvent me is ignored.
      Specified by:
      mouseDragged in interface MouseMotionListener
    • mousePressed

      public void mousePressed(MouseEvent me)
      The MouseEvent me causes the properties of importance to the current mode to be updated.
      Specified by:
      mousePressed in interface MouseListener
    • mouseClicked

      public void mouseClicked(MouseEvent me)
      This implementation is empty. MouseEvent me is ignored.
      Specified by:
      mouseClicked in interface MouseListener
    • mouseReleased

      public void mouseReleased(MouseEvent me)
      This implementation is empty. MouseEvent me is ignored.
      Specified by:
      mouseReleased in interface MouseListener
    • mouseEntered

      public void mouseEntered(MouseEvent me)
      This implementation is empty. MouseEvent me is ignored.
      Specified by:
      mouseEntered in interface MouseListener
    • mouseExited

      public void mouseExited(MouseEvent me)
      This implementation is empty. MouseEvent me is ignored.
      Specified by:
      mouseExited in interface MouseListener