Class EditingGraphMousePlugin<V,E>
- java.lang.Object
-
- edu.uci.ics.jung.visualization.control.AbstractGraphMousePlugin
-
- edu.uci.ics.jung.visualization.control.EditingGraphMousePlugin<V,E>
-
- All Implemented Interfaces:
GraphMousePlugin,java.awt.event.MouseListener,java.awt.event.MouseMotionListener,java.util.EventListener
public class EditingGraphMousePlugin<V,E> extends AbstractGraphMousePlugin implements java.awt.event.MouseListener, java.awt.event.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classEditingGraphMousePlugin.Creating
-
Field Summary
Fields Modifier and Type Field Description private EditingGraphMousePlugin.CreatingcreateModeprotected EdgeSupport<V,E>edgeSupportprotected VertexSupport<V,E>vertexSupport-
Fields inherited from class edu.uci.ics.jung.visualization.control.AbstractGraphMousePlugin
cursor, down, modifiers
-
-
Constructor Summary
Constructors Constructor Description EditingGraphMousePlugin(int modifiers, com.google.common.base.Supplier<V> vertexFactory, com.google.common.base.Supplier<E> edgeFactory)Creates an instance and prepares shapes for visual effects.EditingGraphMousePlugin(com.google.common.base.Supplier<V> vertexFactory, com.google.common.base.Supplier<E> edgeFactory)Creates an instance and prepares shapes for visual effects, using the default modifiers of BUTTON1_MASK.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancheckModifiers(java.awt.event.MouseEvent e)Overridden to be more flexible, and pass events with key combinations.EdgeSupport<V,E>getEdgeSupport()VertexSupport<V,E>getVertexSupport()voidmouseClicked(java.awt.event.MouseEvent e)voidmouseDragged(java.awt.event.MouseEvent e)If startVertex is non-null, stretch an edge shape between startVertex and the mouse pointer to simulate edge creationvoidmouseEntered(java.awt.event.MouseEvent e)voidmouseExited(java.awt.event.MouseEvent e)voidmouseMoved(java.awt.event.MouseEvent e)voidmousePressed(java.awt.event.MouseEvent e)If the mouse is pressed in an empty area, create a new vertex there.voidmouseReleased(java.awt.event.MouseEvent e)If startVertex is non-null, and the mouse is released over an existing vertex, create an undirected edge from startVertex to the vertex under the mouse pointer.voidsetEdgeSupport(EdgeSupport<V,E> edgeSupport)voidsetVertexSupport(VertexSupport<V,E> vertexSupport)-
Methods inherited from class edu.uci.ics.jung.visualization.control.AbstractGraphMousePlugin
getCursor, getModifiers, setCursor, setModifiers
-
-
-
-
Field Detail
-
vertexSupport
protected VertexSupport<V,E> vertexSupport
-
edgeSupport
protected EdgeSupport<V,E> edgeSupport
-
createMode
private EditingGraphMousePlugin.Creating createMode
-
-
Constructor Detail
-
EditingGraphMousePlugin
public EditingGraphMousePlugin(com.google.common.base.Supplier<V> vertexFactory, com.google.common.base.Supplier<E> edgeFactory)
Creates an instance and prepares shapes for visual effects, using the default modifiers of BUTTON1_MASK.- Parameters:
vertexFactory- for creating verticesedgeFactory- for creating edges
-
EditingGraphMousePlugin
public EditingGraphMousePlugin(int modifiers, com.google.common.base.Supplier<V> vertexFactory, com.google.common.base.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(java.awt.event.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(java.awt.event.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 interfacejava.awt.event.MouseListener
-
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent e)
If startVertex is non-null, and the mouse is released over an existing vertex, create an undirected edge from startVertex to the vertex under the mouse pointer. If shift was also pressed, create a directed edge instead.- Specified by:
mouseReleasedin interfacejava.awt.event.MouseListener
-
mouseDragged
public void mouseDragged(java.awt.event.MouseEvent e)
If startVertex is non-null, stretch an edge shape between startVertex and the mouse pointer to simulate edge creation- Specified by:
mouseDraggedin interfacejava.awt.event.MouseMotionListener
-
mouseClicked
public void mouseClicked(java.awt.event.MouseEvent e)
- Specified by:
mouseClickedin interfacejava.awt.event.MouseListener
-
mouseEntered
public void mouseEntered(java.awt.event.MouseEvent e)
- Specified by:
mouseEnteredin interfacejava.awt.event.MouseListener
-
mouseExited
public void mouseExited(java.awt.event.MouseEvent e)
- Specified by:
mouseExitedin interfacejava.awt.event.MouseListener
-
mouseMoved
public void mouseMoved(java.awt.event.MouseEvent e)
- Specified by:
mouseMovedin interfacejava.awt.event.MouseMotionListener
-
getVertexSupport
public VertexSupport<V,E> getVertexSupport()
-
setVertexSupport
public void setVertexSupport(VertexSupport<V,E> vertexSupport)
-
getEdgeSupport
public EdgeSupport<V,E> getEdgeSupport()
-
setEdgeSupport
public void setEdgeSupport(EdgeSupport<V,E> edgeSupport)
-
-