edu.uci.ics.jung.visualization.control
Class EditingGraphMousePlugin<V,E>

java.lang.Object
  extended by edu.uci.ics.jung.visualization.control.AbstractGraphMousePlugin
      extended by edu.uci.ics.jung.visualization.control.EditingGraphMousePlugin<V,E>
All Implemented Interfaces:
GraphMousePlugin, MouseListener, MouseMotionListener, EventListener

public class EditingGraphMousePlugin<V,E>
extends AbstractGraphMousePlugin
implements MouseListener, MouseMotionListener

A plugin that can create vertices, undirected edges, and directed edges using mouse gestures.

Author:
Tom Nelson

Field Summary
protected  VisualizationServer.Paintable arrowPaintable
           
protected  Shape arrowShape
           
protected  Point2D down
           
protected  org.apache.commons.collections15.Factory<E> edgeFactory
           
protected  EdgeType edgeIsDirected
           
protected  VisualizationServer.Paintable edgePaintable
           
protected  Shape edgeShape
           
protected  Shape rawArrowShape
           
protected  CubicCurve2D rawEdge
           
protected  V startVertex
           
protected  org.apache.commons.collections15.Factory<V> vertexFactory
           
 
Fields inherited from class edu.uci.ics.jung.visualization.control.AbstractGraphMousePlugin
cursor, modifiers
 
Constructor Summary
EditingGraphMousePlugin(org.apache.commons.collections15.Factory<V> vertexFactory, org.apache.commons.collections15.Factory<E> edgeFactory)
           
EditingGraphMousePlugin(int modifiers, org.apache.commons.collections15.Factory<V> vertexFactory, org.apache.commons.collections15.Factory<E> edgeFactory)
          create instance and prepare shapes for visual effects
 
Method Summary
 boolean checkModifiers(MouseEvent e)
          Overridden to be more flexible, and pass events with key combinations.
 void mouseClicked(MouseEvent e)
           
 void mouseDragged(MouseEvent e)
          If startVertex is non-null, stretch an edge shape between startVertex and the mouse pointer to simulate edge creation
 void mouseEntered(MouseEvent e)
           
 void mouseExited(MouseEvent e)
           
 void mouseMoved(MouseEvent e)
           
 void mousePressed(MouseEvent e)
          If the mouse is pressed in an empty area, create a new vertex there.
 void mouseReleased(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.
 
Methods inherited from class edu.uci.ics.jung.visualization.control.AbstractGraphMousePlugin
getCursor, getModifiers, setCursor, setModifiers
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

startVertex

protected V startVertex

down

protected Point2D down

rawEdge

protected CubicCurve2D rawEdge

edgeShape

protected Shape edgeShape

rawArrowShape

protected Shape rawArrowShape

arrowShape

protected Shape arrowShape

edgePaintable

protected VisualizationServer.Paintable edgePaintable

arrowPaintable

protected VisualizationServer.Paintable arrowPaintable

edgeIsDirected

protected EdgeType edgeIsDirected

vertexFactory

protected org.apache.commons.collections15.Factory<V> vertexFactory

edgeFactory

protected org.apache.commons.collections15.Factory<E> edgeFactory
Constructor Detail

EditingGraphMousePlugin

public EditingGraphMousePlugin(org.apache.commons.collections15.Factory<V> vertexFactory,
                               org.apache.commons.collections15.Factory<E> edgeFactory)

EditingGraphMousePlugin

public EditingGraphMousePlugin(int modifiers,
                               org.apache.commons.collections15.Factory<V> vertexFactory,
                               org.apache.commons.collections15.Factory<E> edgeFactory)
create instance and prepare shapes for visual effects

Parameters:
modifiers -
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:
checkModifiers in interface GraphMousePlugin
Overrides:
checkModifiers in class AbstractGraphMousePlugin
Parameters:
e - an event to compare to
Returns:
whether the member modifers 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:
mousePressed in interface MouseListener

mouseReleased

public void mouseReleased(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:
mouseReleased in interface MouseListener

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:
mouseDragged in interface MouseMotionListener

mouseClicked

public void mouseClicked(MouseEvent e)
Specified by:
mouseClicked in interface MouseListener

mouseEntered

public void mouseEntered(MouseEvent e)
Specified by:
mouseEntered in interface MouseListener

mouseExited

public void mouseExited(MouseEvent e)
Specified by:
mouseExited in interface MouseListener

mouseMoved

public void mouseMoved(MouseEvent e)
Specified by:
mouseMoved in interface MouseMotionListener


Copyright © 2009. All Rights Reserved.