Class EdgeSelectingGraphMousePlugin<V,E>
- java.lang.Object
-
- org.jungrapht.visualization.control.AbstractGraphMousePlugin
-
- org.jungrapht.visualization.control.EdgeSelectingGraphMousePlugin<V,E>
-
- Type Parameters:
V- vertex typeE- edge type
- All Implemented Interfaces:
MouseListener,MouseMotionListener,EventListener,GraphMousePlugin
public class EdgeSelectingGraphMousePlugin<V,E> extends AbstractGraphMousePlugin implements MouseListener, MouseMotionListener
EdgeSelectingGraphMousePlugin supports the selecting of graph elements with the mouse. MouseButtonOne selects a single vertex or edge, and MouseButtonTwo adds to the set of selected Vertices or EdgeType. If a Vertex is selected and the mouse is dragged while on the selected Vertex, then that Vertex will be repositioned to follow the mouse until the button is released.- Author:
- Tom Nelson
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.jungrapht.visualization.control.AbstractGraphMousePlugin
AbstractGraphMousePlugin.Selecting
-
-
Field Summary
Fields Modifier and Type Field Description protected intaddSingleSelectionMaskprotected Point2DdeltaDownprotected Eedgethe selected Edge, if anyprotected Rectangle2DfootprintRectangleprotected ColorlensColorcolor for the picking rectangleprotected VisualizationServer.PaintablepickFootprintPaintableprotected intpickSizeprotected intsingleSelectionMask-
Fields inherited from class org.jungrapht.visualization.control.AbstractGraphMousePlugin
cursor, down, modifiers
-
-
Constructor Summary
Constructors Constructor Description EdgeSelectingGraphMousePlugin(int singleSelectionMask, int addSingleSelectionMask)create an instance with overrides
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ColorgetLensColor()protected Point2DinverseTransform(VisualizationViewer<V,E> vv, Point2D p)override to consider Lens effectsvoidmouseClicked(MouseEvent e)voidmouseDragged(MouseEvent e)no opvoidmouseEntered(MouseEvent e)voidmouseExited(MouseEvent e)voidmouseMoved(MouseEvent e)voidmousePressed(MouseEvent e)For primary modifiers (default, MouseButton1): pick a single Vertex or Edge that is under the mouse pointer.voidmouseReleased(MouseEvent e)If the mouse is dragging a rectangle, pick the Vertices contained in that rectanglevoidsetLensColor(Color lensColor)protected booleansingleEdgeSelection(MouseEvent e, Point2D layoutPoint, boolean addToSelection)protected Shapetransform(VisualizationViewer<V,E> vv, Shape shape)override to consider Lens effects-
Methods inherited from class org.jungrapht.visualization.control.AbstractGraphMousePlugin
checkModifiers, getCursor, getModifiersEx, setCursor, setModifiers
-
-
-
-
Field Detail
-
pickSize
protected int pickSize
-
edge
protected E edge
the selected Edge, if any
-
footprintRectangle
protected Rectangle2D footprintRectangle
-
pickFootprintPaintable
protected VisualizationServer.Paintable pickFootprintPaintable
-
lensColor
protected Color lensColor
color for the picking rectangle
-
deltaDown
protected Point2D deltaDown
-
singleSelectionMask
protected int singleSelectionMask
-
addSingleSelectionMask
protected int addSingleSelectionMask
-
-
Method Detail
-
getLensColor
public Color getLensColor()
- Returns:
- Returns the lensColor.
-
setLensColor
public void setLensColor(Color lensColor)
- Parameters:
lensColor- The lensColor to set.
-
mousePressed
public void mousePressed(MouseEvent e)
For primary modifiers (default, MouseButton1): pick a single Vertex or Edge that is under the mouse pointer. If no Vertex or edge is under the pointer, unselect all selected Vertices and edges, and set up to draw a rectangle for multiple selection of contained Vertices. For additional selection (default Shift+MouseButton1): Add to the selection, a single Vertex or Edge that is under the mouse pointer. If a previously selected Vertex or Edge is under the pointer, it is un-selected. If no vertex or Edge is under the pointer, set up to draw a multiple selection rectangle (as above) but do not unpick previously selected elements.- Specified by:
mousePressedin interfaceMouseListener- Parameters:
e- the event
-
singleEdgeSelection
protected boolean singleEdgeSelection(MouseEvent e, Point2D layoutPoint, boolean addToSelection)
-
mouseReleased
public void mouseReleased(MouseEvent e)
If the mouse is dragging a rectangle, pick the Vertices contained in that rectangleclean up settings from mousePressed
- Specified by:
mouseReleasedin interfaceMouseListener
-
mouseDragged
public void mouseDragged(MouseEvent e)
no op- Specified by:
mouseDraggedin interfaceMouseMotionListener
-
inverseTransform
protected Point2D inverseTransform(VisualizationViewer<V,E> vv, Point2D p)
override to consider Lens effects- Parameters:
vv-p-- Returns:
-
transform
protected Shape transform(VisualizationViewer<V,E> vv, Shape shape)
override to consider Lens effects- Parameters:
vv-shape-- Returns:
-
mouseClicked
public void mouseClicked(MouseEvent e)
- Specified by:
mouseClickedin interfaceMouseListener
-
mouseEntered
public void mouseEntered(MouseEvent e)
- Specified by:
mouseEnteredin interfaceMouseListener
-
mouseExited
public void mouseExited(MouseEvent e)
- Specified by:
mouseExitedin interfaceMouseListener
-
mouseMoved
public void mouseMoved(MouseEvent e)
- Specified by:
mouseMovedin interfaceMouseMotionListener
-
-