public class StatusBarListener extends Object implements PointListener
Listener that displays at the status bar of the application's main frame, the value of the point coordinates of the mouse's
cursor on the associated MapControl
, just as is received a PointEvent
event.
Calculates the coordinates equivalent to the point according this rules:
formatDegrees(p.get{X or Y}()
if the associated MapControl
object isn't projected.formatDegrees({MapControl's projection}.toGeo(p.get{X or Y}())
if the associated
MapControl
object is projected and its ViewPort
's distance units are in degrees.{NumberFormat according to #setFractionDigits(Point2D)
}.format((p.get{X or Y}()/MapContext.CHANGEM[mapControl.getViewPort().getDistanceUnits()])*MapContext.CHANGEM[mapControl.getViewPort().getMapUnits()])
otherwise.The prefix of the coordinate expressions will be:
MapControl
's view port is in degrees.And the sufix value:
MapControl
's view port is in degrees(expected latitude or longitude), according this pattern:S?Gš M' S''
, having:Constructor and Description |
---|
StatusBarListener(MapControl mc)
Creates a new
StatusBarListener object. |
Modifier and Type | Method and Description |
---|---|
boolean |
cancelDrawing()
Determines if the drawing process that this tool executes on the
MapControl
instance could be canceled or not. |
String[] |
getCoords(Point2D p)
Returns the coordinates equivalent to
p :
Uses formatDegrees(p.get{X or Y}() if the associated MapControl object isn't projected. |
Image |
getImageCursor()
Gets the
Cursor associated to this tool. |
void |
point(PointEvent event)
Called when one click is pressed on the associated
MapControl , or the location of the cursor
of the mouse has changed on it. |
void |
pointDoubleClick(PointEvent event)
Called when a double click is pressed on the associated
MapControl . |
String[] |
setCoorDisplayText(String[] axisText)
Gets the name of the coordinates:
Longitude and Latitude, if the associated MapControl object isn't projected, or the current distance unit
of the
MapControl 's view port is in degrees. |
void |
setFractionDigits(Point2D p)
Sets the number of decimals of the coordinates that will be displayed, according the current projection
of the associated
MapControl :
8 decimals, if is using geographical coordinates:
EPSG:4230 (known as ED50). |
public StatusBarListener(MapControl mc)
Creates a new StatusBarListener
object.
mc
- the MapControl
where will be applied the changespublic Image getImageCursor()
ToolListener
Gets the Cursor
associated to this tool.
getImageCursor
in interface ToolListener
public boolean cancelDrawing()
ToolListener
Determines if the drawing process that this tool executes on the MapControl
instance could be canceled or not.
cancelDrawing
in interface ToolListener
true
if is cancellable; otherwise returns false
public void point(PointEvent event) throws BehaviorException
PointListener
Called when one click is pressed on the associated MapControl
, or the location of the cursor
of the mouse has changed on it.
point
in interface PointListener
event
- mouse event with the coordinates of the point selected on the associated MapControl
BehaviorException
- will be thrown when fails the process of this toolpublic void setFractionDigits(Point2D p)
Sets the number of decimals of the coordinates that will be displayed, according the current projection
of the associated MapControl
:
p
- unused parameterpublic String[] setCoorDisplayText(String[] axisText)
Gets the name of the coordinates:
MapControl
's view port is in degrees.p
- array of at least two String
, where text will be stored and returnedString[0]
: "Long = "String[1]
: "Lat = "String[0]
: "X = "String[1]
: "Y = "public String[] getCoords(Point2D p)
Returns the coordinates equivalent to p
:
formatDegrees(p.get{X or Y}()
if the associated MapControl
object isn't projected.formatDegrees({MapControl's projection}.toGeo(p.get{X or Y}())
if the associated
MapControl
object is projected and its ViewPort
's distance units are in degrees.{NumberFormat according to #setFractionDigits(Point2D)
}.format((p.get{X or Y}()/MapContext.CHANGEM[mapControl.getViewPort().getDistanceUnits()])*MapContext.CHANGEM[mapControl.getViewPort().getMapUnits()])
otherwise.p
- point 2D to convert in text coordinates according the projection of the associated MapControl
and the
distance units of its ViewPort
.p
, according to the algorithm explained uppublic void pointDoubleClick(PointEvent event) throws BehaviorException
PointListener
Called when a double click is pressed on the associated MapControl
.
pointDoubleClick
in interface PointListener
event
- mouse event and the coordinates of the point selected on the associated MapControl
BehaviorException
- will be thrown when fails the process of this tool