org.grinvin.gred.mouse

Class SelectRectangle


public class SelectRectangle
extends NullMouseHandler

Mouse handler which allows elements on a GraphPanel to be selected by means of a 'rubber band' rectangle. Consumes all first button pressed events, also when pressed on a vertex or edge.

Method Summary

@Override
boolean canHandle(JComponent parent)
static SelectRectangle
getHandler()
Return the singleton object of this type.
@Override
void doMouseClicked(JComponent parent, MouseEvent mouseEvent)
Clear the selection when the mouse was clicked (but not ctrl-clicked)
@Override
void doMouseDragged(JComponent parent, MouseEvent mouseEvent, MouseEvent previousEvent, MouseEvent pressedEvent)
Performs a drag.
@Override
void doMousePressed(JComponent parent, MouseEvent mouseEvent)
Consume the event when pressed.
@Override
void doMouseReleased(JComponent parent, MouseEvent mouseEvent, MouseEvent pressedEvent)
Sets the selection to the elements within the current rectangle or adds these elements to the selection when 'Control' is down.
@Override
void paintDragging(JComponent parent, Graphics g, MouseEvent mouseEvent, MouseEvent previousEvent, MouseEvent pressedEvent)
Paints the rubber band rectangle.

Method Details

boolean canHandle

public @Override boolean canHandle(JComponent parent)

getHandler

public static SelectRectangle getHandler()
Return the singleton object of this type.

void doMouseClicked

public @Override void doMouseClicked(JComponent parent,
                                     MouseEvent mouseEvent)
Clear the selection when the mouse was clicked (but not ctrl-clicked)

void doMouseDragged

public @Override void doMouseDragged(JComponent parent,
                                     MouseEvent mouseEvent,
                                     MouseEvent previousEvent,
                                     MouseEvent pressedEvent)
Performs a drag.

void doMousePressed

public @Override void doMousePressed(JComponent parent,
                                     MouseEvent mouseEvent)
Consume the event when pressed.

void doMouseReleased

public @Override void doMouseReleased(JComponent parent,
                                      MouseEvent mouseEvent,
                                      MouseEvent pressedEvent)
Sets the selection to the elements within the current rectangle or adds these elements to the selection when 'Control' is down.

void paintDragging

public @Override void paintDragging(JComponent parent,
                                    Graphics g,
                                    MouseEvent mouseEvent,
                                    MouseEvent previousEvent,
                                    MouseEvent pressedEvent)
Paints the rubber band rectangle.