Class MapMouseEvent

  • All Implemented Interfaces:
    Serializable

    public final class MapMouseEvent
    extends MouseEvent
    A MouseEvent with methods to retrieve position in world coordinates.
    Since:
    2.6
    Author:
    Michael Bedward (adapted from code by Cameron Shorter)
    See Also:
    Serialized Form
    • Constructor Detail

      • MapMouseEvent

        public MapMouseEvent​(MapPane pane,
                             MouseEvent event)
        Creates a new event instance.
        Parameters:
        pane - the source map pane
        event - the source mouse event
      • MapMouseEvent

        public MapMouseEvent​(MapPane pane,
                             MouseWheelEvent event)
        Creates a new event instance for a mouse wheel event.
        Parameters:
        pane - the source map pane
        event - the source mouse wheel event
    • Method Detail

      • isWheelEvent

        public boolean isWheelEvent()
        Queries whether this event was generated by a mouse wheel action.
        Returns:
        if a mouse event
      • getWheelAmount

        public int getWheelAmount()
        Gets the wheel travel amount for a mouse wheel event.
        Returns:
        wheel travel, or 0 if this is not a mouse wheel event
      • getWorldPos

        public Position2D getWorldPos()
        Gets the mouse position in world coordinates.
        Returns:
        world position
      • getEnvelopeByWorld

        public ReferencedEnvelope getEnvelopeByWorld​(double widthWorld)
        Gets an envelope of specified width (in world distance units) which is centred on the mouse position.
        Parameters:
        widthWorld - envelope width in world units
        Returns:
        the envelope
        Throws:
        IllegalArgumentException - if widthWorld is less than zero
      • getEnvelopeByPixels

        public ReferencedEnvelope getEnvelopeByPixels​(double widthPixels)
        Gets an envelope of specified width (in pixels) which is centred on the mouse position.
        Parameters:
        widthPixels - envelope width in pixels
        Returns:
        the envelope
        Throws:
        IllegalArgumentException - if widthPixels is less than zero