Class SelectingGraphMousePlugin<V,E>
- java.lang.Object
-
- org.jungrapht.visualization.control.AbstractGraphMousePlugin
-
- org.jungrapht.visualization.control.SelectingGraphMousePlugin<V,E>
-
- Type Parameters:
V- vertex typeE- edge type
- All Implemented Interfaces:
MouseListener,MouseMotionListener,EventListener,GraphMousePlugin
- Direct Known Subclasses:
LensKillingGraphMousePlugin,LensSelectingGraphMousePlugin
public class SelectingGraphMousePlugin<V,E> extends AbstractGraphMousePlugin implements MouseListener, MouseMotionListener
SelectingGraphMousePlugin 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 Modifier and Type Class Description static classSelectingGraphMousePlugin.Builder<V,E,T extends SelectingGraphMousePlugin,B extends SelectingGraphMousePlugin.Builder<V,E,T,B>>-
Nested classes/interfaces inherited from class org.jungrapht.visualization.control.AbstractGraphMousePlugin
AbstractGraphMousePlugin.Selecting
-
-
Field Summary
Fields Modifier and Type Field Description protected intaddSingleSelectionMaskprotected Point2DdeltaDownprotected VdeselectedVertexprotected Eedgethe selected Edge, if anyprotected Rectangle2DfootprintRectangleprotected ColorlensColorcolor for the picking rectangleprotected booleanlockedcontrols whether the Vertices may be moved with the mouseprotected MultiSelectionStrategymultiSelectionStrategyprotected VisualizationServer.PaintablepickFootprintPaintableprotected intpickSizeprotected intsingleSelectionMaskprotected Vvertexthe selected Vertex, if anyprotected booleanvertexDragged-
Fields inherited from class org.jungrapht.visualization.control.AbstractGraphMousePlugin
cursor, down, modifiers
-
-
Constructor Summary
Constructors Modifier Constructor Description SelectingGraphMousePlugin()protectedSelectingGraphMousePlugin(int singleSelectionMask, int addSingleSelectionMask)create an instance with overridesSelectingGraphMousePlugin(SelectingGraphMousePlugin.Builder<V,E,?,?> builder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <V,E>
SelectingGraphMousePlugin.Builder<V,E,?,?>builder()ColorgetLensColor()protected Point2DinverseTransform(VisualizationViewer<V,E> vv, Point2D p)override to consider Lens effectsbooleanisLocked()voidmouseClicked(MouseEvent e)voidmouseDragged(MouseEvent e)If the mouse is over a selected vertex, drag all selected vertices with the mouse.voidmouseEntered(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)voidsetLocked(boolean locked)protected booleansingleEdgeSelection(MouseEvent e, Point2D layoutPoint, boolean addToSelection)protected booleansingleVertexSelection(MouseEvent e, Point2D layoutPoint, boolean addToSelection)StringtoString()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
-
vertex
protected V vertex
the selected Vertex, if any
-
deselectedVertex
protected V deselectedVertex
-
edge
protected E edge
the selected Edge, if any
-
locked
protected boolean locked
controls whether the Vertices may be moved with the mouse
-
footprintRectangle
protected Rectangle2D footprintRectangle
-
pickFootprintPaintable
protected VisualizationServer.Paintable pickFootprintPaintable
-
lensColor
protected Color lensColor
color for the picking rectangle
-
deltaDown
protected Point2D deltaDown
-
multiSelectionStrategy
protected MultiSelectionStrategy multiSelectionStrategy
-
singleSelectionMask
protected int singleSelectionMask
-
addSingleSelectionMask
protected int addSingleSelectionMask
-
vertexDragged
protected boolean vertexDragged
-
-
Constructor Detail
-
SelectingGraphMousePlugin
public SelectingGraphMousePlugin(SelectingGraphMousePlugin.Builder<V,E,?,?> builder)
-
SelectingGraphMousePlugin
public SelectingGraphMousePlugin()
-
SelectingGraphMousePlugin
protected SelectingGraphMousePlugin(int singleSelectionMask, int addSingleSelectionMask)create an instance with overrides- Parameters:
singleSelectionMask- for primary selection of one vertexaddSingleSelectionMask- to add another vertex to the current selection
-
-
Method Detail
-
builder
public static <V,E> SelectingGraphMousePlugin.Builder<V,E,?,?> builder()
-
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
-
singleVertexSelection
protected boolean singleVertexSelection(MouseEvent e, Point2D layoutPoint, boolean addToSelection)
-
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)
If the mouse is over a selected vertex, drag all selected vertices with the mouse. If the mouse is not over a Vertex, draw the rectangle to select multiple Vertices- 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
-
isLocked
public boolean isLocked()
- Returns:
- Returns the locked.
-
setLocked
public void setLocked(boolean locked)
- Parameters:
locked- The locked to set.
-
-