Class VertexSelectingGraphMousePlugin<V,E>
- java.lang.Object
-
- org.jungrapht.visualization.control.AbstractGraphMousePlugin
-
- org.jungrapht.visualization.control.VertexSelectingGraphMousePlugin<V,E>
-
- Type Parameters:
V- vertex typeE- edge type
- All Implemented Interfaces:
MouseListener,MouseMotionListener,EventListener,GraphMousePlugin
- Direct Known Subclasses:
LensVertexSelectingGraphMousePlugin
public class VertexSelectingGraphMousePlugin<V,E> extends AbstractGraphMousePlugin implements MouseListener, MouseMotionListener
VertexSelectingGraphMousePlugin supports the selecting of graph vertices with the mouse. MouseButtonOne selects a single vertex. 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 classVertexSelectingGraphMousePlugin.Builder<V,E,T extends VertexSelectingGraphMousePlugin,B extends VertexSelectingGraphMousePlugin.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 Rectangle2DfootprintRectangleprotected ColorlensColorcolor for the picking rectangleprotected booleanlockedcontrols whether the Vertices may be moved with the mouseprotected 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 Constructor Description VertexSelectingGraphMousePlugin()VertexSelectingGraphMousePlugin(int singleSelectionMask, int addSingleSelectionMask)create an instance with overridesVertexSelectingGraphMousePlugin(VertexSelectingGraphMousePlugin.Builder<V,E,?,?> builder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <V,E>
VertexSelectingGraphMousePlugin.Builder<V,E,?,?>builder()static <V,E>
voidconfigure(VisualizationViewer<V,E> visualizationViewer)Configure the passed VisualizationViewer to use vertex selection only.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 booleansingleVertexSelection(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
-
vertex
protected V vertex
the selected Vertex, if any
-
deselectedVertex
protected V deselectedVertex
-
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
-
singleSelectionMask
protected int singleSelectionMask
-
addSingleSelectionMask
protected int addSingleSelectionMask
-
vertexDragged
protected boolean vertexDragged
-
-
Constructor Detail
-
VertexSelectingGraphMousePlugin
public VertexSelectingGraphMousePlugin(VertexSelectingGraphMousePlugin.Builder<V,E,?,?> builder)
-
VertexSelectingGraphMousePlugin
public VertexSelectingGraphMousePlugin()
-
VertexSelectingGraphMousePlugin
public VertexSelectingGraphMousePlugin(int singleSelectionMask, int addSingleSelectionMask)create an instance with overrides
-
-
Method Detail
-
builder
public static <V,E> VertexSelectingGraphMousePlugin.Builder<V,E,?,?> builder()
-
configure
public static <V,E> void configure(VisualizationViewer<V,E> visualizationViewer)
Configure the passed VisualizationViewer to use vertex selection only. No edge selection with the mouse. Edges will be 'selected' only when both endpoint vertices are selected.- Type Parameters:
V- vertex typeE- edge type- Parameters:
visualizationViewer- to configure
-
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. 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.- Specified by:
mousePressedin interfaceMouseListener- Parameters:
e- the event
-
singleVertexSelection
protected boolean singleVertexSelection(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.
-
-