Package org.geotools.swing
Class MouseDragBox
- Object
-
- MouseAdapter
-
- MouseInputAdapter
-
- MouseDragBox
-
- All Implemented Interfaces:
MouseListener
,MouseMotionListener
,MouseWheelListener
,EventListener
,MouseInputListener
public class MouseDragBox extends MouseInputAdapter
Draws a box on the parent component (e.g. JMapPane) as the mouse is dragged.- Since:
- 8.0
- Author:
- Michael Bedward
-
-
Constructor Summary
Constructors Constructor Description MouseDragBox(JComponent component)
Creates a new instance to work with the given component.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
mouseDragged(MouseEvent ev)
If the box is enabled, draws the box with the diagonal running from the start position to the current mouse position.void
mousePressed(MouseEvent ev)
If the box is enabled, records the start position for subsequent drawing as the mouse is dragged.void
mouseReleased(MouseEvent ev)
If the box is enabled, removes the final box.void
setEnabled(boolean state)
Enables or disables the drag box.-
Methods inherited from class MouseAdapter
mouseClicked, mouseEntered, mouseExited, mouseMoved, mouseWheelMoved
-
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface MouseListener
mouseClicked, mouseEntered, mouseExited
-
Methods inherited from interface MouseMotionListener
mouseMoved
-
-
-
-
Constructor Detail
-
MouseDragBox
public MouseDragBox(JComponent component)
Creates a new instance to work with the given component.- Parameters:
component
- the component on which the box will be drawn
-
-
Method Detail
-
setEnabled
public void setEnabled(boolean state)
Enables or disables the drag box. When enabled, the box is drawn on mouse dragging.- Parameters:
state
-true
to enable;false
to disable
-
mousePressed
public void mousePressed(MouseEvent ev)
If the box is enabled, records the start position for subsequent drawing as the mouse is dragged.- Specified by:
mousePressed
in interfaceMouseListener
- Overrides:
mousePressed
in classMouseAdapter
- Parameters:
ev
- input mouse event
-
mouseDragged
public void mouseDragged(MouseEvent ev)
If the box is enabled, draws the box with the diagonal running from the start position to the current mouse position.- Specified by:
mouseDragged
in interfaceMouseMotionListener
- Overrides:
mouseDragged
in classMouseAdapter
- Parameters:
ev
- input mouse event
-
mouseReleased
public void mouseReleased(MouseEvent ev)
If the box is enabled, removes the final box.- Specified by:
mouseReleased
in interfaceMouseListener
- Overrides:
mouseReleased
in classMouseAdapter
- Parameters:
ev
- the input mouse event
-
-