Package mgui.interfaces.graphs
Class DefaultGraph
java.lang.Object
edu.uci.ics.jung.graph.AbstractGraph<V,E>
edu.uci.ics.jung.graph.SparseGraph<AbstractGraphNode,AbstractGraphEdge>
mgui.interfaces.graphs.InterfaceAbstractGraph
mgui.interfaces.graphs.DefaultGraph
- All Implemented Interfaces:
edu.uci.ics.jung.graph.Graph<AbstractGraphNode,AbstractGraphEdge>
,edu.uci.ics.jung.graph.Hypergraph<AbstractGraphNode,AbstractGraphEdge>
,java.io.Serializable
,NetworkGraphListener
,AttributeListener
,AttributeObject
,InterfaceObject
,PopupMenuObject
,NamedObject
,TreeObject
,CleanableObject
,XMLObject
,IconObject
- Direct Known Subclasses:
AbstractNetworkGraph
public class DefaultGraph extends InterfaceAbstractGraph
Default implementation of a Graph in ModelGUI. Nodes are associated with unique
labels.
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Andrew Reid
- See Also:
- Serialized Form
-
Nested Class Summary
Nested classes/interfaces inherited from interface mgui.interfaces.xml.XMLObject
XMLObject.XMLEncoding, XMLObject.XMLType
-
Field Summary
Fields Modifier and Type Field Description protected java.util.HashMap<java.lang.String,AbstractGraphNode>
nodes
Fields inherited from class mgui.interfaces.graphs.InterfaceAbstractGraph
attributes, graphListeners, isDestroyed, name, treeNode, treeNodes, xml_block, xml_count, xml_itr, xml_nodes
Fields inherited from class edu.uci.ics.jung.graph.SparseGraph
directed_edges, INCIDENT, INCOMING, OUTGOING, undirected_edges, vertex_maps
-
Constructor Summary
Constructors Constructor Description DefaultGraph()
DefaultGraph(java.lang.String name)
DefaultGraph(InterfaceAbstractGraph graph)
Construct a new graph as a copy ofgraph
. -
Method Summary
Modifier and Type Method Description boolean
addGraphEdge(AbstractGraphEdge edge)
Adds an edge to this graph.boolean
addGraphEdge(AbstractGraphEdge edge, edu.uci.ics.jung.graph.util.EdgeType type)
Adds an edge to this graph.boolean
addGraphNode(AbstractGraphNode node)
Adds a node to this graph.boolean
addVertex(AbstractGraphNode vertex)
java.lang.Object
clone()
InterfacePopupMenu
getPopupMenu()
Produces and returns a popup menu for this object.java.lang.String
getTreeLabel()
Returns the label text to appear in a tree node.AbstractGraphNode
getVertexByLabel(java.lang.String label)
Returns the node corresponding tolabel
.void
handlePopupEvent(java.awt.event.ActionEvent e)
Handles an event on this object's popup menu.boolean
removeGraphEdge(AbstractGraphEdge edge)
Removes the given graph edge.boolean
removeGraphNode(java.lang.String label)
Removes the node corresponding tolabel
.boolean
removeGraphNode(AbstractGraphNode node)
Removes the given node.protected void
setFromGraph(InterfaceAbstractGraph g)
void
showPopupMenu(java.awt.event.MouseEvent e)
Shows a popup menu at the point of the givenMouseEvent
.Methods inherited from class mgui.interfaces.graphs.InterfaceAbstractGraph
addEdge, addEdge, addEdge, addGraphListener, attributeUpdated, clean, destroy, fireGraphListeners, fireGraphListeners, getAttribute, getAttributes, getAttributeValue, getDefaultLayout, getDTD, getLabelEdges, getLabelNodes, getLocalName, getName, getNodes, getObjectIcon, getPopupMenu, getShortXML, getXML, getXML, getXMLSchema, graphUpdated, handleXMLElementEnd, handleXMLElementStart, handleXMLString, init, isDestroyed, issueTreeNode, removeAllEdges, removeAllNodes, removeGraphListener, setAttribute, setAttributes, setName, setTreeNode, toString, writeXML, writeXML, writeXML
Methods inherited from class edu.uci.ics.jung.graph.SparseGraph
addEdge, containsEdge, containsVertex, findEdge, findEdgeSet, getDefaultEdgeType, getDest, getEdgeCount, getEdgeCount, getEdges, getEdges, getEdgeType, getEndpoints, getFactory, getIncidentEdges, getInEdges, getNeighbors, getOutEdges, getPredecessors, getSource, getSuccessors, getVertexCount, getVertices, isDest, isSource, removeEdge, removeVertex
Methods inherited from class edu.uci.ics.jung.graph.AbstractGraph
addEdge, addEdge, addEdge, addEdge, degree, getIncidentCount, getIncidentVertices, getNeighborCount, getOpposite, getPredecessorCount, getSuccessorCount, getValidatedEndpoints, inDegree, isIncident, isNeighbor, isPredecessor, isSuccessor, outDegree
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface edu.uci.ics.jung.graph.Graph
addEdge, getOpposite, getPredecessorCount, getSuccessorCount, inDegree, isPredecessor, isSuccessor, outDegree
Methods inherited from interface edu.uci.ics.jung.graph.Hypergraph
addEdge, addEdge, degree, getIncidentCount, getIncidentVertices, getNeighborCount, isIncident, isNeighbor
-
Field Details
-
nodes
-
-
Constructor Details
-
DefaultGraph
public DefaultGraph() -
DefaultGraph
public DefaultGraph(java.lang.String name) -
DefaultGraph
Construct a new graph as a copy ofgraph
.- Parameters:
graph
-
-
-
Method Details
-
addVertex
- Specified by:
addVertex
in interfaceedu.uci.ics.jung.graph.Hypergraph<AbstractGraphNode,AbstractGraphEdge>
- Overrides:
addVertex
in classedu.uci.ics.jung.graph.SparseGraph<AbstractGraphNode,AbstractGraphEdge>
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException- Overrides:
clone
in classInterfaceAbstractGraph
- Throws:
java.lang.CloneNotSupportedException
-
getTreeLabel
public java.lang.String getTreeLabel()Description copied from interface:TreeObject
Returns the label text to appear in a tree node.- Specified by:
getTreeLabel
in interfaceTreeObject
- Overrides:
getTreeLabel
in classInterfaceAbstractGraph
- Returns:
-
addGraphNode
Adds a node to this graph. Returnstrue
if the node was added; returnsfalse
if it (or a node of the same label) already exists.- Parameters:
node
-- Returns:
-
removeGraphNode
public boolean removeGraphNode(java.lang.String label)Removes the node corresponding tolabel
. Returnstrue
if it was removed;false
if it was not found.- Parameters:
label
-- Returns:
-
removeGraphNode
Removes the given node. Returnstrue
if it was removed;false
if it was not found.- Parameters:
label
-- Returns:
-
addGraphEdge
Adds an edge to this graph. The endpoints of the edge must exists as nodes in this graph; otherwise, this method returnsfalse
.- Parameters:
edge
-- Returns:
true
is edge was added;false
otherwise
-
addGraphEdge
Adds an edge to this graph. The endpoints of the edge must exists as nodes in this graph; otherwise, this method returnsfalse
.- Parameters:
edge
-- Returns:
true
is edge was added;false
otherwise
-
removeGraphEdge
Removes the given graph edge. Returnstrue
if it was removed successfully;false
otherwise.- Parameters:
edge
-- Returns:
-
getVertexByLabel
Returns the node corresponding tolabel
. Returnsnull
if there is no corresponding label.- Parameters:
label
-- Returns:
- The node corresponding to
label
-
setFromGraph
-
getPopupMenu
Description copied from interface:PopupMenuObject
Produces and returns a popup menu for this object.- Specified by:
getPopupMenu
in interfacePopupMenuObject
- Overrides:
getPopupMenu
in classInterfaceAbstractGraph
- Returns:
-
handlePopupEvent
public void handlePopupEvent(java.awt.event.ActionEvent e)Description copied from interface:PopupMenuObject
Handles an event on this object's popup menu.- Specified by:
handlePopupEvent
in interfacePopupMenuObject
- Overrides:
handlePopupEvent
in classInterfaceAbstractGraph
-
showPopupMenu
public void showPopupMenu(java.awt.event.MouseEvent e)Description copied from interface:PopupMenuObject
Shows a popup menu at the point of the givenMouseEvent
.- Specified by:
showPopupMenu
in interfacePopupMenuObject
- Overrides:
showPopupMenu
in classInterfaceAbstractGraph
-