Class EditingGraphMousePlugin<V,E>
- java.lang.Object
-
- org.jungrapht.visualization.control.AbstractGraphMousePlugin
-
- org.jungrapht.visualization.control.EditingGraphMousePlugin<V,E>
-
- Type Parameters:
V- vertex typeE- edge type
- All Implemented Interfaces:
MouseListener,MouseMotionListener,EventListener,GraphMousePlugin
public class EditingGraphMousePlugin<V,E> extends AbstractGraphMousePlugin implements MouseListener, MouseMotionListener
A plugin that can create vertices, undirected edges, and directed edges using mouse gestures.vertexSupport and edgeSupport member classes are responsible for actually creating the new graph elements, and for repainting the view when changes were made.
- 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 EdgeSupport<V,E>edgeSupportprotected intmodifiersprotected VertexSupport<V,E>vertexSupport-
Fields inherited from class org.jungrapht.visualization.control.AbstractGraphMousePlugin
cursor, down
-
-
Constructor Summary
Constructors Constructor Description EditingGraphMousePlugin(int modifiers, Supplier<V> vertexFactory, Supplier<E> edgeFactory)Creates an instance and prepares shapes for visual effects.EditingGraphMousePlugin(Supplier<V> vertexFactory, Supplier<E> edgeFactory)Creates an instance and prepares shapes for visual effects, using the default modifiers of BUTTON1_DOWN_MASK.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancheckModifiers(MouseEvent e)Overridden to be more flexible, and pass events with key combinations.EdgeSupport<V,E>edgesupport()VertexSupport<V,E>getVertexSupport()voidmouseClicked(MouseEvent e)voidmouseDragged(MouseEvent e)If startVertex is non-null, stretch an edge shape between startVertex and the mouse pointer to simulate edge creationvoidmouseEntered(MouseEvent e)voidmouseExited(MouseEvent e)voidmouseMoved(MouseEvent e)voidmousePressed(MouseEvent e)If the mouse is pressed in an empty area, create a new vertex there.voidmouseReleased(MouseEvent e)If startVertex is non-null, and the mouse is released over an existing vertex, create an edge from startVertex to the vertex under the mouse pointer.voidsetEdgeSupport(EdgeSupport<V,E> edgeSupport)voidsetVertexSupport(VertexSupport<V,E> vertexSupport)-
Methods inherited from class org.jungrapht.visualization.control.AbstractGraphMousePlugin
getCursor, getModifiersEx, setCursor, setModifiers
-
-
-
-
Field Detail
-
vertexSupport
protected VertexSupport<V,E> vertexSupport
-
edgeSupport
protected EdgeSupport<V,E> edgeSupport
-
modifiers
protected int modifiers
-
-
Constructor Detail
-
EditingGraphMousePlugin
public EditingGraphMousePlugin(Supplier<V> vertexFactory, Supplier<E> edgeFactory)
Creates an instance and prepares shapes for visual effects, using the default modifiers of BUTTON1_DOWN_MASK.- Parameters:
vertexFactory- for creating verticesedgeFactory- for creating edges
-
EditingGraphMousePlugin
public EditingGraphMousePlugin(int modifiers, Supplier<V> vertexFactory, Supplier<E> edgeFactory)Creates an instance and prepares shapes for visual effects.- Parameters:
modifiers- the mouse event modifiers to usevertexFactory- for creating verticesedgeFactory- for creating edges
-
-
Method Detail
-
checkModifiers
public boolean checkModifiers(MouseEvent e)
Overridden to be more flexible, and pass events with key combinations. The default responds to both ButtonOne and ButtonOne+Shift- Specified by:
checkModifiersin interfaceGraphMousePlugin- Overrides:
checkModifiersin classAbstractGraphMousePlugin- Parameters:
e- an event to compare to- Returns:
- whether the member modifiers match the event modifiers
-
mousePressed
public void mousePressed(MouseEvent e)
If the mouse is pressed in an empty area, create a new vertex there. If the mouse is pressed on an existing vertex, prepare to create an edge from that vertex to another- Specified by:
mousePressedin interfaceMouseListener
-
mouseReleased
public void mouseReleased(MouseEvent e)
If startVertex is non-null, and the mouse is released over an existing vertex, create an edge from startVertex to the vertex under the mouse pointer.- Specified by:
mouseReleasedin interfaceMouseListener
-
mouseDragged
public void mouseDragged(MouseEvent e)
If startVertex is non-null, stretch an edge shape between startVertex and the mouse pointer to simulate edge creation- Specified by:
mouseDraggedin interfaceMouseMotionListener
-
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
-
getVertexSupport
public VertexSupport<V,E> getVertexSupport()
-
setVertexSupport
public void setVertexSupport(VertexSupport<V,E> vertexSupport)
-
edgesupport
public EdgeSupport<V,E> edgesupport()
-
setEdgeSupport
public void setEdgeSupport(EdgeSupport<V,E> edgeSupport)
-
-