Class AreaListenerImpl

java.lang.Object
org.gvsig.fmap.mapcontrol.tools.AreaListenerImpl
All Implemented Interfaces:
PolylineListener, ToolListener

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.

Author:
Vicente Caballero Navarro
  • Field Details

    • mapCtrl

      protected MapControl mapCtrl
      Reference to the MapControl object that uses.
    • event

      protected MeasureEvent event
      Information about all vertexes and GeneralPathXs of the polyline.
  • Constructor Details

    • AreaListenerImpl

      public AreaListenerImpl(MapControl mc)

      Creates a new listener for calculating the area of a polygon.

      Parameters:
      mc - the MapControl where is calculated the area
  • Method Details

    • points

      public void points(MeasureEvent event)
      Description copied from interface: 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.

      Specified by:
      points in interface PolylineListener
      Parameters:
      event - information about the mouse event, and geometry data of the polyline
    • returnArea

      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.

      Parameters:
      point - unused parameter
      Returns:
      area from the vertexes stored at the measure event in real coordinates, or, if the MapControl isn't projected, in geographical coordinates
      See Also:
    • returnCoordsArea

      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.

      Parameters:
      xs - abscissa coordinate of all vertexes of the polygon
      ys - ordinate coordinate of all vertexes of the polygon
      point - point 2D used as first vertex in the calculation of the area
      Returns:
      the area of the polygon
    • main

      public static void main(String[] args)
    • returnGeoCArea

      public double returnGeoCArea(Double[] xs, Double[] ys, Point2D point)

      Returns the area in geographical coordinates of the polygon, according the Haversine function.

      See Also:
    • getImageCursor

      public Image getImageCursor()
      Description copied from interface: ToolListener

      Gets the Cursor associated to this tool.

      Specified by:
      getImageCursor in interface ToolListener
      Returns:
      component with the bitmap associated to this tool
    • pointFixed

      public void pointFixed(MeasureEvent event)
      Description copied from interface: PolylineListener

      Called when user executes a mouse click and selects a vertex of the polyline.

      Specified by:
      pointFixed in interface PolylineListener
      Parameters:
      event - information about the mouse event, and geometry data of the polyline
    • polylineFinished

      public void polylineFinished(MeasureEvent event)
      Description copied from interface: 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.

      Specified by:
      polylineFinished in interface PolylineListener
      Parameters:
      event - information about the mouse event, and geometry data of the polyline
    • cancelDrawing

      public boolean cancelDrawing()
      Description copied from interface: ToolListener

      Determines if the drawing process that this tool executes on the MapControl instance could be canceled or not.

      Specified by:
      cancelDrawing in interface ToolListener
      Returns:
      true if is cancellable; otherwise returns false