public class AreaListenerImpl extends Object implements PolylineListener
Listener for calculating the area of a polygon, defined in the associated MapControl
object.
If the view port of the associated MapControl
isn't projected gets the area according the
geographical coordinates.
Modifier and Type | Field and Description |
---|---|
protected MeasureEvent |
event
Information about all vertexes and
GeneralPathX s of the polyline. |
protected MapControl |
mapCtrl
Reference to the
MapControl object that uses. |
Constructor and Description |
---|
AreaListenerImpl(MapControl mc)
Creates a new listener for calculating the area of a polygon.
|
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. |
Image |
getImageCursor()
Gets the
Cursor associated to this tool. |
static void |
main(String[] args) |
void |
pointFixed(MeasureEvent event)
Called when user executes a mouse click and selects a vertex of the polyline.
|
void |
points(MeasureEvent event)
Called when user moves the mouse after selecting a vertex of the polyline.
|
void |
polylineFinished(MeasureEvent event)
Called when user executes a double click with the mouse, finishing the
drawn of the polyline.
|
protected double |
returnArea(Point2D point)
Returns the area of the polygon, using
returnCoordsArea
if the ViewPort of the associated MapControl is projected, or using
returnGeoCArea if isn't. |
double |
returnCoordsArea(Double[] xs,
Double[] ys,
Point2D point)
Returns the area of the polygon using point as initial, in
real values with the current measure unit, according the projection in the
ViewPort
of the MapControl . |
double |
returnGeoCArea(Double[] xs,
Double[] ys,
Point2D point)
Returns the area in geographical coordinates of the polygon, according the
Haversine function.
|
protected MapControl mapCtrl
MapControl
object that uses.protected MeasureEvent event
GeneralPathX
s of the polyline.public AreaListenerImpl(MapControl mc)
Creates a new listener for calculating the area of a polygon.
mc
- the MapControl
where is calculated the areapublic void points(MeasureEvent event)
PolylineListener
Called when user moves the mouse after selecting a vertex of the polyline.
Each kind of polyline listener calculates different information with the data of the
MeasureEvent
, according its nature.
points
in interface PolylineListener
event
- information about the mouse event, and geometry data of the polylineprotected double returnArea(Point2D point)
Returns the area of the polygon, using returnCoordsArea
if the ViewPort
of the associated MapControl
is projected, or using
returnGeoCArea
if isn't.
point
- unused parameterMapControl
isn't projected, in geographical coordinatesreturnCoordsArea(Double[], Double[], Point2D)
,
returnGeoCArea(Double[], Double[], Point2D)
public double returnCoordsArea(Double[] xs, Double[] ys, Point2D point)
Returns the area of the polygon using point as initial, in
real values with the current measure unit, according the projection in the ViewPort
of the MapControl
.
xs
- abscissa coordinate of all vertexes of the polygonys
- ordinate coordinate of all vertexes of the polygonpoint
- point 2D used as first vertex in the calculation of the areapublic static void main(String[] args)
public double returnGeoCArea(Double[] xs, Double[] ys, Point2D point)
Returns the area in geographical coordinates of the polygon, according the Haversine function.
public Image getImageCursor()
ToolListener
Gets the Cursor
associated to this tool.
getImageCursor
in interface ToolListener
public void pointFixed(MeasureEvent event)
PolylineListener
Called when user executes a mouse click and selects a vertex of the polyline.
pointFixed
in interface PolylineListener
event
- information about the mouse event, and geometry data of the polylinepublic void polylineFinished(MeasureEvent event)
PolylineListener
Called when user executes a double click with the mouse, finishing the drawn of the polyline.
All features of the active and vector layers of the associated MapControl
object that
their area intersect with the polygonal area defined in the event, will be selected.
polylineFinished
in interface PolylineListener
event
- information about the mouse event, and geometry data of the polylinepublic 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