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 class
VertexSelectingGraphMousePlugin.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 int
addSingleSelectionMask
protected Point2D
deltaDown
protected V
deselectedVertex
protected Rectangle2D
footprintRectangle
protected Color
lensColor
color for the picking rectangleprotected boolean
locked
controls whether the Vertices may be moved with the mouseprotected VisualizationServer.Paintable
pickFootprintPaintable
protected int
pickSize
protected int
singleSelectionMask
protected V
vertex
the selected Vertex, if anyprotected boolean
vertexDragged
-
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.Color
getLensColor()
protected Point2D
inverseTransform(VisualizationViewer<V,E> vv, Point2D p)
override to consider Lens effectsboolean
isLocked()
void
mouseClicked(MouseEvent e)
void
mouseDragged(MouseEvent e)
If the mouse is over a selected vertex, drag all selected vertices with the mouse.void
mouseEntered(MouseEvent e)
void
mouseExited(MouseEvent e)
void
mouseMoved(MouseEvent e)
void
mousePressed(MouseEvent e)
For primary modifiers (default, MouseButton1): pick a single Vertex or Edge that is under the mouse pointer.void
mouseReleased(MouseEvent e)
If the mouse is dragging a rectangle, pick the Vertices contained in that rectanglevoid
setLensColor(Color lensColor)
void
setLocked(boolean locked)
protected boolean
singleVertexSelection(MouseEvent e, Point2D layoutPoint, boolean addToSelection)
protected Shape
transform(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:
mousePressed
in 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:
mouseReleased
in 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:
mouseDragged
in 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:
mouseClicked
in interfaceMouseListener
-
mouseEntered
public void mouseEntered(MouseEvent e)
- Specified by:
mouseEntered
in interfaceMouseListener
-
mouseExited
public void mouseExited(MouseEvent e)
- Specified by:
mouseExited
in interfaceMouseListener
-
mouseMoved
public void mouseMoved(MouseEvent e)
- Specified by:
mouseMoved
in interfaceMouseMotionListener
-
isLocked
public boolean isLocked()
- Returns:
- Returns the locked.
-
setLocked
public void setLocked(boolean locked)
- Parameters:
locked
- The locked to set.
-
-