public class TLcdMapLocation extends Object implements MouseListener, MouseMotionListener
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.Modifier and Type | Field and Description |
---|---|
static int |
CENTER
Constant for center alignment.
|
static int |
CUSTOM_FORMAT
Mode for a custom Format.
|
static String |
GXYVIEW
Constant for 'GXYView' property.
|
static int |
LEFT
Constant for left alignment.
|
static int |
LOCATION_DDMMSS
Mode for the location in latitude-longitude (dd°mm'ss",ddd°mm'ss").
|
static int |
LOCATION_DEC_DEG
Mode for the location in latitude-longitude (xx.xxxx°,xxx.xxxx°).
|
static int |
LOCATION_DEC_MIN
Mode for the location in latitude-longitude (xx°xx',xxx°xx).
|
static int |
LOCATION_DEC_MIN_2
Mode for the location in latitude-longitude (xx°xx.xx',xxx°xx.xx').
|
static int |
LOCATION_GEOREF_0
Mode for the location in Georef coordinates.
|
static int |
LOCATION_NSWE
Mode for the location in latitude-longitude (ddmmssNdddmmssW).
|
static int |
LOCATION_UTM_DM
Mode for the location in UTM-MGRS coordinates, with 10 meter precision.
|
static int |
LOCATION_UTM_HM
Mode for the location in UTM-MGRS coordinates, with 100 meter precision.
|
static int |
LOCATION_UTM_KM
Mode for the location in UTM-MGRS coordinates, with km precision.
|
static int |
LOCATION_UTM_M
Mode for the location in UTM-MGRS coordinates, with meter precision.
|
static int |
LOCATION_WENS
Mode for the location in longitude-latitude (dddmmssWddmmssN).
|
static String |
MODE
Constant for mode property.
|
static int |
RIGHT
Constant for right alignment.
|
static int |
SCALE
Mode for the scale as meter/pixel.
|
static int |
SCALE_KM
Mode for the scale as km/pixel.
|
static int |
SCALE_MILES
Mode for the scale as miles/pixel.
|
static int |
WINDOW_WIDTH
Mode for the window width in meters.
|
static int |
WINDOW_WIDTH_KM
Mode for the window width in kilometers.
|
static int |
WINDOW_WIDTH_MILES
Mode for the window width in miles.
|
Constructor and Description |
---|
TLcdMapLocation()
Expresses 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.
|
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
Adds a property change listener.
|
int |
getAlignment()
Returns how the location information will be aligned.
|
Format |
getFormat()
Returns the format to format the location as a string.
|
ILcdGXYView |
getGXYView()
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 |
getUTMCoordinateSeparator()
Returns the character to separate the zone and the coordinates.
|
char |
getZoneSeparator()
Returns the character to separate the UTM grid zone and the 100km squares.
|
boolean |
isTraceOn()
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
void |
mouseClicked(MouseEvent me)
This implementation is empty.
|
void |
mouseDragged(MouseEvent me)
This implementation is empty.
|
void |
mouseEntered(MouseEvent me)
This implementation is empty.
|
void |
mouseExited(MouseEvent me)
This implementation is empty.
|
void |
mouseMoved(MouseEvent me)
The
MouseEvent me causes the properties of importance to the
current mode to be updated. |
void |
mousePressed(MouseEvent me)
The
MouseEvent me causes the properties of importance to the
current mode to be updated. |
void |
mouseReleased(MouseEvent me)
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 |
processMouseEvent(MouseEvent aMouseEvent)
The
MouseEvent 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. It is recommended to use the
standard Java logging framework directly.
|
void |
setFormat(Format aFormat)
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. It is recommended to use the
standard Java logging framework directly.
|
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 |
updateWithCurrentLocation()
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. |
String |
valueAsString()
Returns the information using the current mode and (computed) location as a String.
|
public static final int LOCATION_DDMMSS
public static final int LOCATION_NSWE
public static final int LOCATION_WENS
public static final int LOCATION_DEC_DEG
public static final int LOCATION_DEC_MIN
public static final int LOCATION_DEC_MIN_2
public static final int LOCATION_UTM_M
public static final int LOCATION_UTM_DM
public static final int LOCATION_UTM_HM
public static final int LOCATION_UTM_KM
public static final int LOCATION_GEOREF_0
public static final int SCALE
public static final int SCALE_MILES
public static final int SCALE_KM
public static final int WINDOW_WIDTH
public static final int WINDOW_WIDTH_KM
public static final int WINDOW_WIDTH_MILES
public static final int CUSTOM_FORMAT
public static final int LEFT
setAlignment(int)
,
Constant Field Valuespublic static final int CENTER
setAlignment(int)
,
Constant Field Valuespublic static final int RIGHT
setAlignment(int)
,
Constant Field Valuespublic static final String MODE
public static final String GXYVIEW
public TLcdMapLocation()
public TLcdMapLocation(ILcdGeodeticDatum aGeodeticDatum)
aGeodeticDatum
- the datum to express the coordinates in.
After construction, a view should be configured.setGXYView(com.luciad.view.gxy.ILcdGXYView)
public static void setClassTraceOn(boolean aClassTraceOn)
true
then all log messages are recorded, otherwise only
the informative, warning and error messages are recorded.aClassTraceOn
- if true then all log messages are recorded,
otherwise only the informative, warning and error messages are recorded.public void setTraceOn(boolean aTraceOn)
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.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.public boolean isTraceOn()
true
if tracing is enabled for this class.public String valueAsString()
public void addPropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
aPropertyChangeListener
- listens to mode and view property changes.removePropertyChangeListener(java.beans.PropertyChangeListener)
public void removePropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
aPropertyChangeListener
- listened to mode and view property changes.addPropertyChangeListener(java.beans.PropertyChangeListener)
public void setMode(int aMode)
ILcdGXYView
(constants starting with SCALE)setFormat
. This will change the mode to CUSTOM_FORMAT
.aMode
- the format in which the coordinates of the (computed) location will be expressed.getMode()
,
setFormat(java.text.Format)
public int getMode()
setMode(int)
public void setFormat(Format aFormat)
ILcdPoint
object.
This will change the mode
to CUSTOM_FORMAT
.aFormat
- a format to be usedpublic Format getFormat()
mode
is set to CUSTOM_FORMAT
.public double getLon()
public double getLat()
public void setAlignment(int aAlignment)
aAlignment
- the new alignment, can be RIGHT, LEFT or CENTER.getAlignment()
public int getAlignment()
setAlignment(int)
public void setGXYView(ILcdGXYView aGXYView)
ILcdGXYView
must have a ILcdGridReference
as XYWorldReference property.
The map location is added as a mouse motion listener to the view.aGXYView
- the view to determine the location in.getGXYView()
public ILcdGXYView getGXYView()
setGXYView(com.luciad.view.gxy.ILcdGXYView)
public void setUTMCoordinateSeparator(char aUTMCoordinateSeparator)
aUTMCoordinateSeparator
- the character to separate the zone and the coordinates and between the coordinates.getUTMCoordinateSeparator()
public char getUTMCoordinateSeparator()
setUTMCoordinateSeparator(char)
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.
aZoneSeparator
- the character to separate the UTM grid zone and the 100km squares.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.
setZoneSeparator(char)
protected void updateWithLocation(int aX, int aY)
ILcdGXYView
point (aX,aY) in a format
in accordance with the property of mode.
This method is called by processMouseEvent(java.awt.event.MouseEvent)
.aX
- the first coordinate of the location in view (AWT) coordinates.aY
- the second coordinate of the location in view (AWT) coordinates.protected void updateWithCurrentLocation()
public void paint(Graphics aGraphics, Rectangle aRectangle)
Rectangle
aRectangle, having getAlignment()
as alignment.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.protected void processMouseEvent(MouseEvent aMouseEvent)
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)
.aMouseEvent
- the mouse event based on which the properties will be updated.public void mouseMoved(MouseEvent me)
MouseEvent
me causes the properties of importance to the
current mode to be updated.mouseMoved
in interface MouseMotionListener
public void mouseDragged(MouseEvent me)
MouseEvent
me is ignored.mouseDragged
in interface MouseMotionListener
public void mousePressed(MouseEvent me)
MouseEvent
me causes the properties of importance to the
current mode to be updated.mousePressed
in interface MouseListener
public void mouseClicked(MouseEvent me)
MouseEvent
me is ignored.mouseClicked
in interface MouseListener
public void mouseReleased(MouseEvent me)
MouseEvent
me is ignored.mouseReleased
in interface MouseListener
public void mouseEntered(MouseEvent me)
MouseEvent
me is ignored.mouseEntered
in interface MouseListener
public void mouseExited(MouseEvent me)
MouseEvent
me is ignored.mouseExited
in interface MouseListener