Class SelectionManager

  • All Implemented Interfaces:
    MouseListener, MouseMotionListener, PropertyChangeListener, EventListener

    public class SelectionManager
    extends Object
    implements MouseListener, MouseMotionListener, PropertyChangeListener
    Manages the selection of a rectangle or a lasso loop. Listening to left and right mouse button presses and to mouse motions and draw the rectangle accordingly. Left mouse button selects a rectangle from the press until release. Pressing right mouse button while left is still pressed enable the selection area to move around. Releasing the left button fires an action event to the listener given at constructor, except if the right is still pressed, which just remove the selection rectangle and does nothing. It is possible to switch between lasso selection and rectangle selection by using setLassoMode(boolean). The point where the left mouse button was pressed and the current mouse position are two opposite corners of the selection rectangle. For rectangle mode, it is possible to specify an aspect ratio (width per height) which the selection rectangle always must have. In this case, the selection rectangle will be the largest window with this aspect ratio, where the position the left mouse button was pressed and the corner of the current mouse position are at opposite sites (the mouse position corner is the corner nearest to the mouse cursor). When the left mouse button was released, an ActionEvent is send to the ActionListener given at constructor. The source of this event is this manager.