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>nodesFields inherited from class mgui.interfaces.graphs.InterfaceAbstractGraph
attributes, graphListeners, isDestroyed, name, treeNode, treeNodes, xml_block, xml_count, xml_itr, xml_nodesFields 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 booleanaddGraphEdge(AbstractGraphEdge edge)Adds an edge to this graph.booleanaddGraphEdge(AbstractGraphEdge edge, edu.uci.ics.jung.graph.util.EdgeType type)Adds an edge to this graph.booleanaddGraphNode(AbstractGraphNode node)Adds a node to this graph.booleanaddVertex(AbstractGraphNode vertex)java.lang.Objectclone()InterfacePopupMenugetPopupMenu()Produces and returns a popup menu for this object.java.lang.StringgetTreeLabel()Returns the label text to appear in a tree node.AbstractGraphNodegetVertexByLabel(java.lang.String label)Returns the node corresponding tolabel.voidhandlePopupEvent(java.awt.event.ActionEvent e)Handles an event on this object's popup menu.booleanremoveGraphEdge(AbstractGraphEdge edge)Removes the given graph edge.booleanremoveGraphNode(java.lang.String label)Removes the node corresponding tolabel.booleanremoveGraphNode(AbstractGraphNode node)Removes the given node.protected voidsetFromGraph(InterfaceAbstractGraph g)voidshowPopupMenu(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, writeXMLMethods 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, removeVertexMethods 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, outDegreeMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface edu.uci.ics.jung.graph.Graph
addEdge, getOpposite, getPredecessorCount, getSuccessorCount, inDegree, isPredecessor, isSuccessor, outDegreeMethods 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:
addVertexin interfaceedu.uci.ics.jung.graph.Hypergraph<AbstractGraphNode,AbstractGraphEdge>- Overrides:
addVertexin classedu.uci.ics.jung.graph.SparseGraph<AbstractGraphNode,AbstractGraphEdge>
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException- Overrides:
clonein classInterfaceAbstractGraph- Throws:
java.lang.CloneNotSupportedException
-
getTreeLabel
public java.lang.String getTreeLabel()Description copied from interface:TreeObjectReturns the label text to appear in a tree node.- Specified by:
getTreeLabelin interfaceTreeObject- Overrides:
getTreeLabelin classInterfaceAbstractGraph- Returns:
-
addGraphNode
Adds a node to this graph. Returnstrueif the node was added; returnsfalseif 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. Returnstrueif it was removed;falseif it was not found.- Parameters:
label-- Returns:
-
removeGraphNode
Removes the given node. Returnstrueif it was removed;falseif 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:
trueis edge was added;falseotherwise
-
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:
trueis edge was added;falseotherwise
-
removeGraphEdge
Removes the given graph edge. Returnstrueif it was removed successfully;falseotherwise.- Parameters:
edge-- Returns:
-
getVertexByLabel
Returns the node corresponding tolabel. Returnsnullif there is no corresponding label.- Parameters:
label-- Returns:
- The node corresponding to
label
-
setFromGraph
-
getPopupMenu
Description copied from interface:PopupMenuObjectProduces and returns a popup menu for this object.- Specified by:
getPopupMenuin interfacePopupMenuObject- Overrides:
getPopupMenuin classInterfaceAbstractGraph- Returns:
-
handlePopupEvent
public void handlePopupEvent(java.awt.event.ActionEvent e)Description copied from interface:PopupMenuObjectHandles an event on this object's popup menu.- Specified by:
handlePopupEventin interfacePopupMenuObject- Overrides:
handlePopupEventin classInterfaceAbstractGraph
-
showPopupMenu
public void showPopupMenu(java.awt.event.MouseEvent e)Description copied from interface:PopupMenuObjectShows a popup menu at the point of the givenMouseEvent.- Specified by:
showPopupMenuin interfacePopupMenuObject- Overrides:
showPopupMenuin classInterfaceAbstractGraph
-