org.jgraph.graph

Class BasicMarqueeHandler


public class BasicMarqueeHandler
extends java.lang.Object

A simple implementation of a marquee handler for JGraph.

Field Summary

protected Point2D
currentPoint
protected Rectangle2D
marqueeBounds
protected Cursor
previousCursor
protected Point2D
startPoint

Method Summary

Point2D
getCurrentPoint()
Returns the currentPoint.
static JGraph
getGraphForEvent(MouseEvent event)
Rectangle2D
getMarqueeBounds()
Returns the marqueeBounds.
Cursor
getPreviousCursor()
Returns the previousCursor.
Point2D
getStartPoint()
Returns the startPoint.
void
handleMarqueeEvent(MouseEvent e, JGraph graph, Rectangle2D bounds)
Hook for subclassers.
boolean
isForceMarqueeEvent(MouseEvent event)
boolean
isMarqueeTriggerEvent(MouseEvent e, JGraph graph)
Hook for subclassers.
void
mouseDragged(MouseEvent e)
Includes the specified startPoint in the marquee selection.
void
mouseMoved(MouseEvent e)
Empty.
void
mousePressed(MouseEvent e)
Start the marquee at the specified startPoint.
void
mouseReleased(MouseEvent e)
Stops the current marquee selection.
void
overlay(JGraph graph, Graphics g, boolean clear)
Draw the current state of the handler.
void
paint(JGraph graph, Graphics g)
Called after the component was repainted (after autoscroll).
protected void
processMouseDraggedEvent(MouseEvent e)
Called from mouse dragged to update the marquee state during a repaint.
void
setCurrentPoint(Point2D currentPoint)
Sets the currentPoint.
void
setMarqueeBounds(Rectangle2D marqueeBounds)
Sets the marqueeBounds.
void
setPreviousCursor(Cursor previousCursor)
Sets the previousCursor.
void
setStartPoint(Point2D startPoint)
Sets the startPoint.

Field Details

currentPoint

protected Point2D currentPoint

marqueeBounds

protected Rectangle2D marqueeBounds

previousCursor

protected Cursor previousCursor

startPoint

protected Point2D startPoint

Method Details

getCurrentPoint

public Point2D getCurrentPoint()
Returns the currentPoint.
Returns:
Point

getGraphForEvent

public static JGraph getGraphForEvent(MouseEvent event)
Returns:
Returns the source of the event as a graph.

getMarqueeBounds

public Rectangle2D getMarqueeBounds()
Returns the marqueeBounds.
Returns:
Rectangle

getPreviousCursor

public Cursor getPreviousCursor()
Returns the previousCursor.
Returns:
Cursor

getStartPoint

public Point2D getStartPoint()
Returns the startPoint.
Returns:
Point

handleMarqueeEvent

public void handleMarqueeEvent(MouseEvent e,
                               JGraph graph,
                               Rectangle2D bounds)
Hook for subclassers. Current implementation checks if graph selection is enabled. This is called from mouseReleased to execute the marquee selection.

isForceMarqueeEvent

public boolean isForceMarqueeEvent(MouseEvent event)

isMarqueeTriggerEvent

public boolean isMarqueeTriggerEvent(MouseEvent e,
                                     JGraph graph)
Hook for subclassers. Current implementation checks if graph selection is enabled. This is called from mousePressed before initiating the marquee selection.

mouseDragged

public void mouseDragged(MouseEvent e)
Includes the specified startPoint in the marquee selection. Calls overlay.

mouseMoved

public void mouseMoved(MouseEvent e)
Empty.

mousePressed

public void mousePressed(MouseEvent e)
Start the marquee at the specified startPoint. This invokes expandMarqueeToPoint to initialize marquee selection.

mouseReleased

public void mouseReleased(MouseEvent e)
Stops the current marquee selection.

overlay

public void overlay(JGraph graph,
                    Graphics g,
                    boolean clear)
Draw the current state of the handler. This is called twice by the overlay method and also by the paint method. The caller's intention is that the overlay method draws exactly the current state of the handler so that it may be used for XOR paint. The drag method calls overlay, changes the state, and calls overlay again to use this. However, since it is not always possible to clear the screen with an exact repaint the caller passes a flag to indicate if the graphics object should be cleared with this call (eg. if a subsequent call follows).
Parameters:
g -

paint

public void paint(JGraph graph,
                  Graphics g)
Called after the component was repainted (after autoscroll). This is used to indicate that the graphics is no more dirty.

processMouseDraggedEvent

protected void processMouseDraggedEvent(MouseEvent e)
Called from mouse dragged to update the marquee state during a repaint.

setCurrentPoint

public void setCurrentPoint(Point2D currentPoint)
Sets the currentPoint.
Parameters:
currentPoint - The currentPoint to set

setMarqueeBounds

public void setMarqueeBounds(Rectangle2D marqueeBounds)
Sets the marqueeBounds.
Parameters:
marqueeBounds - The marqueeBounds to set

setPreviousCursor

public void setPreviousCursor(Cursor previousCursor)
Sets the previousCursor.
Parameters:
previousCursor - The previousCursor to set

setStartPoint

public void setStartPoint(Point2D startPoint)
Sets the startPoint.
Parameters:
startPoint - The startPoint to set

Copyright (C) 2001-2006 Gaudenz Alder. All rights reserved.