Class StatusBarListener

java.lang.Object
org.gvsig.app.project.documents.view.toolListeners.StatusBarListener
All Implemented Interfaces:
org.gvsig.fmap.mapcontrol.tools.Listeners.PointListener, org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener

public class StatusBarListener extends Object implements org.gvsig.fmap.mapcontrol.tools.Listeners.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:

  • uses formatDegrees(p.get{X or Y}() if the associated MapControl object isn't projected.
  • uses 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.
  • uses {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:

  • Longitude "Long =" and latitude "Lat =", if the associated MapControl object isn't projected, or the current distance unit of the MapControl's view port is in degrees.
  • X "X =" and Y "Y =", otherwise.

And the sufix value:

  • If the associated MapControl object isn't projected, or the current distance unit of the MapControl's view port is in degrees(expected latitude or longitude), according this pattern:
    S?GÂș M' S'', having:
    • S? : optionally, if the value is negative, sets a "-" symbol.
    • G : equivalent grades.
    • M : equivalent minutes.
    • S : equivalent seconds.
  • Otherwise a decimal number according this rules:
    • 8 decimals, if is using any of the following geographic coordinate systems:
      • EPSG:4230 (known as ED50).
      • EPSG:4326 (known as WGS84).
    • 2 decimals, otherwise.

Author:
Vicente Caballero Navarro
  • Constructor Summary

    Constructors
    Constructor
    Description
    StatusBarListener(org.gvsig.fmap.mapcontrol.MapControl mc)
    Creates a new StatusBarListener object.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    Returns the coordinates equivalent to p: Uses formatDegrees(p.get{X or Y}() if the associated MapControl object isn't projected. Uses 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. Uses {NumberFormat according to #setFractionDigits(Point2D)}.format((p.get{X or Y}()/MapContext.CHANGEM[mapControl.getViewPort().getDistanceUnits()])*MapContext.CHANGEM[mapControl.getViewPort().getMapUnits()]) otherwise.
     
    void
    point(org.gvsig.fmap.mapcontrol.tools.Events.PointEvent event)
     
    void
    pointDoubleClick(org.gvsig.fmap.mapcontrol.tools.Events.PointEvent event)
     
    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. X and Y, otherwise.
    void
    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). EPSG:4326 (known as WGS84). 2 decimals, otherwise.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • StatusBarListener

      public StatusBarListener(org.gvsig.fmap.mapcontrol.MapControl mc)

      Creates a new StatusBarListener object.

      Parameters:
      mc - the MapControl where will be applied the changes
  • Method Details

    • getImageCursor

      public Image getImageCursor()
      Specified by:
      getImageCursor in interface org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener
    • cancelDrawing

      public boolean cancelDrawing()
      Specified by:
      cancelDrawing in interface org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener
    • point

      public void point(org.gvsig.fmap.mapcontrol.tools.Events.PointEvent event) throws org.gvsig.fmap.mapcontrol.tools.BehaviorException
      Specified by:
      point in interface org.gvsig.fmap.mapcontrol.tools.Listeners.PointListener
      Throws:
      org.gvsig.fmap.mapcontrol.tools.BehaviorException
    • setFractionDigits

      public 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).
        • EPSG:4326 (known as WGS84).
      • 2 decimals, otherwise.

      Parameters:
      p - unused parameter
    • setCoorDisplayText

      public 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.
      • X and Y, otherwise.

      Parameters:
      p - array of at least two String, where text will be stored and returned
      Returns:
      text describing the coordinate value:
      • If isn't projected:
        • String[0] : "Long = "
        • String[1] : "Lat = "
      • Otherwise:
        • String[0] : "X = "
        • String[1] : "Y = "
    • getCoords

      public 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.
      • Uses 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.
      • Uses {NumberFormat according to #setFractionDigits(Point2D)}.format((p.get{X or Y}()/MapContext.CHANGEM[mapControl.getViewPort().getDistanceUnits()])*MapContext.CHANGEM[mapControl.getViewPort().getMapUnits()]) otherwise.

      Parameters:
      p - point 2D to convert in text coordinates according the projection of the associated MapControl and the distance units of its ViewPort.
      Returns:
      coordinates equivalent to p, according to the algorithm explained up
    • pointDoubleClick

      public void pointDoubleClick(org.gvsig.fmap.mapcontrol.tools.Events.PointEvent event) throws org.gvsig.fmap.mapcontrol.tools.BehaviorException
      Specified by:
      pointDoubleClick in interface org.gvsig.fmap.mapcontrol.tools.Listeners.PointListener
      Throws:
      org.gvsig.fmap.mapcontrol.tools.BehaviorException