Package com.luciad.view.map
Class TLcdMapLocation
java.lang.Object
com.luciad.view.map.TLcdMapLocation
- All Implemented Interfaces:
MouseListener
,MouseMotionListener
,EventListener
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
Modifier and TypeFieldDescriptionstatic 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
ConstructorDescriptionExpresses the coordinate of the mouse location in longitude, latitude coordinates on the WGS84 geodetic datum.TLcdMapLocation
(ILcdGeodeticDatum aGeodeticDatum) Expresses the coordinate of the mouse location in longitude, latitude coordinates on the given geodetic datum. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPropertyChangeListener
(PropertyChangeListener aPropertyChangeListener) 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
getLat()
Returns the latitude of the current (computed) location.double
getLon()
Returns the longitude of the current (computed) location.int
getMode()
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
mouseMoved
(MouseEvent me) TheMouseEvent
me causes the properties of importance to the current mode to be updated.void
TheMouseEvent
me causes the properties of importance to the current mode to be updated.void
This implementation is empty.void
This method draws the information pertaining to the current mode as a string centered vertically in theRectangle
aRectangle, havinggetAlignment()
as alignment.protected void
processMouseEvent
(MouseEvent aMouseEvent) TheMouseEvent
aMouseEvent causes the properties of importance to the current mode to be updated.void
removePropertyChangeListener
(PropertyChangeListener aPropertyChangeListener) 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
Sets a custom format to format the location as a string.void
setGXYView
(ILcdGXYView aGXYView) 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 theILcdGXYView
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.
-
Field Details
-
LOCATION_DDMMSS
public static final int LOCATION_DDMMSSMode for the location in latitude-longitude (dd°mm'ss",ddd°mm'ss").- See Also:
-
LOCATION_NSWE
public static final int LOCATION_NSWEMode for the location in latitude-longitude (ddmmssNdddmmssW).- See Also:
-
LOCATION_WENS
public static final int LOCATION_WENSMode for the location in longitude-latitude (dddmmssWddmmssN).- See Also:
-
LOCATION_DEC_DEG
public static final int LOCATION_DEC_DEGMode for the location in latitude-longitude (xx.xxxx°,xxx.xxxx°).- See Also:
-
LOCATION_DEC_MIN
public static final int LOCATION_DEC_MINMode for the location in latitude-longitude (xx°xx',xxx°xx).- See Also:
-
LOCATION_DEC_MIN_2
public static final int LOCATION_DEC_MIN_2Mode for the location in latitude-longitude (xx°xx.xx',xxx°xx.xx').- See Also:
-
LOCATION_UTM_M
public static final int LOCATION_UTM_MMode for the location in UTM-MGRS coordinates, with meter precision.- See Also:
-
LOCATION_UTM_DM
public static final int LOCATION_UTM_DMMode for the location in UTM-MGRS coordinates, with 10 meter precision.- See Also:
-
LOCATION_UTM_HM
public static final int LOCATION_UTM_HMMode for the location in UTM-MGRS coordinates, with 100 meter precision.- See Also:
-
LOCATION_UTM_KM
public static final int LOCATION_UTM_KMMode for the location in UTM-MGRS coordinates, with km precision.- See Also:
-
LOCATION_GEOREF_0
public static final int LOCATION_GEOREF_0Mode for the location in Georef coordinates.- See Also:
-
SCALE
public static final int SCALEMode for the scale as meter/pixel.- See Also:
-
SCALE_MILES
public static final int SCALE_MILESMode for the scale as miles/pixel.- See Also:
-
SCALE_KM
public static final int SCALE_KMMode for the scale as km/pixel.- See Also:
-
WINDOW_WIDTH
public static final int WINDOW_WIDTHMode for the window width in meters.- See Also:
-
WINDOW_WIDTH_KM
public static final int WINDOW_WIDTH_KMMode for the window width in kilometers.- See Also:
-
WINDOW_WIDTH_MILES
public static final int WINDOW_WIDTH_MILESMode for the window width in miles.- See Also:
-
CUSTOM_FORMAT
public static final int CUSTOM_FORMATMode for a custom Format.- See Also:
-
LEFT
public static final int LEFTConstant for left alignment.- See Also:
-
CENTER
public static final int CENTERConstant for center alignment.- See Also:
-
RIGHT
public static final int RIGHTConstant for right alignment.- See Also:
-
MODE
Constant for mode property.- See Also:
-
GXYVIEW
Constant for 'GXYView' property.- See Also:
-
-
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
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 istrue
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 eithertrue
orfalse
as argument automatically turns off tracing for all other class instances for whichsetTraceOn
has not been called. If the argument isfalse
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.Returnstrue
if tracing is enabled for this class.- Returns:
- true if tracing is enabled for this class, false otherwise.
-
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
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
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)
setFormat
. This will change the mode toCUSTOM_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
Sets a custom format to format the location as a string. The format is passed anILcdPoint
object. This will change themode
toCUSTOM_FORMAT
.- Parameters:
aFormat
- a format to be used
-
getFormat
Returns the format to format the location as a string. This is used if themode
is set toCUSTOM_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
Sets the view for which the location will be determined. TheILcdGXYView
must have aILcdGridReference
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
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 theILcdGXYView
point (aX,aY) in a format in accordance with the property of mode. This method is called byprocessMouseEvent(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
This method draws the information pertaining to the current mode as a string centered vertically in theRectangle
aRectangle, havinggetAlignment()
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
TheMouseEvent
aMouseEvent causes the properties of importance to the current mode to be updated. This method is called bymouseMoved(java.awt.event.MouseEvent)
andmousePressed(java.awt.event.MouseEvent)
.- Parameters:
aMouseEvent
- the mouse event based on which the properties will be updated.
-
mouseMoved
TheMouseEvent
me causes the properties of importance to the current mode to be updated.- Specified by:
mouseMoved
in interfaceMouseMotionListener
-
mouseDragged
This implementation is empty.MouseEvent
me is ignored.- Specified by:
mouseDragged
in interfaceMouseMotionListener
-
mousePressed
TheMouseEvent
me causes the properties of importance to the current mode to be updated.- Specified by:
mousePressed
in interfaceMouseListener
-
mouseClicked
This implementation is empty.MouseEvent
me is ignored.- Specified by:
mouseClicked
in interfaceMouseListener
-
mouseReleased
This implementation is empty.MouseEvent
me is ignored.- Specified by:
mouseReleased
in interfaceMouseListener
-
mouseEntered
This implementation is empty.MouseEvent
me is ignored.- Specified by:
mouseEntered
in interfaceMouseListener
-
mouseExited
This implementation is empty.MouseEvent
me is ignored.- Specified by:
mouseExited
in interfaceMouseListener
-