be.ugent.caagt.swirl.mouse

Class MouseOverlay

Implemented Interfaces:
MouseListener, MouseMotionListener

public class MouseOverlay
extends JComponent
implements MouseListener, MouseMotionListener

Invisible component which overlays another component in order to handle mouse operations for it.

The mouse operations are delegated to a MouseTool which in turn is managed by a GenericSelectionModel.

Constructor Summary

MouseOverlay(JComponent parent)
Creates a new instance of this class with a default model.
MouseOverlay(JComponent parent, GenericSelectionModel mouseToolModel)
Creates a new instance of this class.

Method Summary

GenericSelectionModel
getMouseToolModel()
Return the underlying model which keeps track of what mouse tool is currently active.
protected void
handleDelayedPressed(MouseEvent mouseEvent)
Handles delayed pressed event.
protected void
handleDragged(MouseEvent mouseEvent)
Handles dragged event.
void
mouseClicked(MouseEvent mouseEvent)
void
mouseDragged(MouseEvent mouseEvent)
Dispatch the dragged event to the currently active handler.
void
mouseEntered(MouseEvent mouseEvent)
void
mouseExited(MouseEvent mouseEvent)
void
mouseMoved(MouseEvent mouseEvent)
void
mousePressed(MouseEvent mouseEvent)
If the event is a popup trigger, dispatch it as a popup event to the first handler that takes it.
void
mouseReleased(MouseEvent mouseEvent)
If a drag event preceeds this event, send it to the active handler.
void
setTool(MouseTool tool)
Change the tool to be used by this overlay.
@Override
void doLayout()
Overridden to make this component always the same size as its parent.
protected @Override
void paintComponent(Graphics g)
Let the active handler provide mouse feedback during a mouse gesture.

Constructor Details

MouseOverlay

public MouseOverlay(JComponent parent)
Creates a new instance of this class with a default model.
Parameters:
parent - Parent component for this overlay

MouseOverlay

public MouseOverlay(JComponent parent,
                    GenericSelectionModel mouseToolModel)
Creates a new instance of this class.
Parameters:
parent - Parent component for this overlay
mouseToolModel - Underlying model which keeps track of the current mouse tool to be used

Method Details

getMouseToolModel

public GenericSelectionModel getMouseToolModel()
Return the underlying model which keeps track of what mouse tool is currently active.

handleDelayedPressed

protected void handleDelayedPressed(MouseEvent mouseEvent)
Handles delayed pressed event. Dispatches the mouse event to the first handler that will take it and mark that handler as active.

handleDragged

protected void handleDragged(MouseEvent mouseEvent)
Handles dragged event. Dispatches the event to the active handler.

mouseClicked

public void mouseClicked(MouseEvent mouseEvent)

mouseDragged

public void mouseDragged(MouseEvent mouseEvent)

mouseEntered

public void mouseEntered(MouseEvent mouseEvent)

mouseExited

public void mouseExited(MouseEvent mouseEvent)

mouseMoved

public void mouseMoved(MouseEvent mouseEvent)

mousePressed

public void mousePressed(MouseEvent mouseEvent)
If the event is a popup trigger, dispatch it as a popup event to the first handler that takes it. Otherwise remember state so it can be dispatched during the first drag or release.

mouseReleased

public void mouseReleased(MouseEvent mouseEvent)
If a drag event preceeds this event, send it to the active handler. Otherwise, check whether this is a popup trigger. If true, hand it as a popup event to the first handler that will take it. Otherwise send it as a clicked event to the first handler that will take it. Dispatch the released event to the currently active handler.

setTool

public void setTool(MouseTool tool)
Change the tool to be used by this overlay.

IllegalArgumentException when this tool cannot handle the parent of this panel.


void doLayout

public @Override void doLayout()
Overridden to make this component always the same size as its parent.

void paintComponent

protected @Override void paintComponent(Graphics g)
Let the active handler provide mouse feedback during a mouse gesture.