Package org.jgraph.graph
Class BasicMarqueeHandler
- java.lang.Object
-
- org.jgraph.graph.BasicMarqueeHandler
-
public class BasicMarqueeHandler extends java.lang.Object
A simple implementation of a marquee handler for JGraph.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.awt.geom.Point2D
currentPoint
protected java.awt.geom.Rectangle2D
marqueeBounds
protected java.awt.Cursor
previousCursor
protected java.awt.geom.Point2D
startPoint
-
Constructor Summary
Constructors Constructor Description BasicMarqueeHandler()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.geom.Point2D
getCurrentPoint()
Returns the currentPoint.static JGraph
getGraphForEvent(java.awt.event.MouseEvent event)
java.awt.geom.Rectangle2D
getMarqueeBounds()
Returns the marqueeBounds.java.awt.Cursor
getPreviousCursor()
Returns the previousCursor.java.awt.geom.Point2D
getStartPoint()
Returns the startPoint.void
handleMarqueeEvent(java.awt.event.MouseEvent e, JGraph graph, java.awt.geom.Rectangle2D bounds)
Hook for subclassers.boolean
isForceMarqueeEvent(java.awt.event.MouseEvent event)
boolean
isMarqueeTriggerEvent(java.awt.event.MouseEvent e, JGraph graph)
Hook for subclassers.void
mouseDragged(java.awt.event.MouseEvent e)
Includes the specified startPoint in the marquee selection.void
mouseMoved(java.awt.event.MouseEvent e)
Empty.void
mousePressed(java.awt.event.MouseEvent e)
Start the marquee at the specified startPoint.void
mouseReleased(java.awt.event.MouseEvent e)
Stops the current marquee selection.void
overlay(JGraph graph, java.awt.Graphics g, boolean clear)
Draw the current state of the handler.void
paint(JGraph graph, java.awt.Graphics g)
Called after the component was repainted (after autoscroll).protected void
processMouseDraggedEvent(java.awt.event.MouseEvent e)
Called from mouse dragged to update the marquee state during a repaint.void
setCurrentPoint(java.awt.geom.Point2D currentPoint)
Sets the currentPoint.void
setMarqueeBounds(java.awt.geom.Rectangle2D marqueeBounds)
Sets the marqueeBounds.void
setPreviousCursor(java.awt.Cursor previousCursor)
Sets the previousCursor.void
setStartPoint(java.awt.geom.Point2D startPoint)
Sets the startPoint.
-
-
-
Method Detail
-
isForceMarqueeEvent
public boolean isForceMarqueeEvent(java.awt.event.MouseEvent event)
-
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent e)
Stops the current marquee selection.
-
handleMarqueeEvent
public void handleMarqueeEvent(java.awt.event.MouseEvent e, JGraph graph, java.awt.geom.Rectangle2D bounds)
Hook for subclassers. Current implementation checks if graph selection is enabled. This is called from mouseReleased to execute the marquee selection.
-
mouseDragged
public void mouseDragged(java.awt.event.MouseEvent e)
Includes the specified startPoint in the marquee selection. Calls overlay.
-
processMouseDraggedEvent
protected void processMouseDraggedEvent(java.awt.event.MouseEvent e)
Called from mouse dragged to update the marquee state during a repaint.
-
paint
public void paint(JGraph graph, java.awt.Graphics g)
Called after the component was repainted (after autoscroll). This is used to indicate that the graphics is no more dirty.
-
overlay
public void overlay(JGraph graph, java.awt.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
-
-
mousePressed
public void mousePressed(java.awt.event.MouseEvent e)
Start the marquee at the specified startPoint. This invokes expandMarqueeToPoint to initialize marquee selection.
-
isMarqueeTriggerEvent
public boolean isMarqueeTriggerEvent(java.awt.event.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.
-
mouseMoved
public void mouseMoved(java.awt.event.MouseEvent e)
Empty.
-
getCurrentPoint
public java.awt.geom.Point2D getCurrentPoint()
Returns the currentPoint.- Returns:
- Point
-
getMarqueeBounds
public java.awt.geom.Rectangle2D getMarqueeBounds()
Returns the marqueeBounds.- Returns:
- Rectangle
-
getPreviousCursor
public java.awt.Cursor getPreviousCursor()
Returns the previousCursor.- Returns:
- Cursor
-
getStartPoint
public java.awt.geom.Point2D getStartPoint()
Returns the startPoint.- Returns:
- Point
-
setCurrentPoint
public void setCurrentPoint(java.awt.geom.Point2D currentPoint)
Sets the currentPoint.- Parameters:
currentPoint
- The currentPoint to set
-
setMarqueeBounds
public void setMarqueeBounds(java.awt.geom.Rectangle2D marqueeBounds)
Sets the marqueeBounds.- Parameters:
marqueeBounds
- The marqueeBounds to set
-
setPreviousCursor
public void setPreviousCursor(java.awt.Cursor previousCursor)
Sets the previousCursor.- Parameters:
previousCursor
- The previousCursor to set
-
setStartPoint
public void setStartPoint(java.awt.geom.Point2D startPoint)
Sets the startPoint.- Parameters:
startPoint
- The startPoint to set
-
getGraphForEvent
public static JGraph getGraphForEvent(java.awt.event.MouseEvent event)
- Returns:
- Returns the source of the event as a graph.
-
-