org.tigris.gef.graph.presentation
Class NetPort

java.lang.Object
  extended by org.tigris.gef.graph.presentation.NetPrimitive
      extended by org.tigris.gef.graph.presentation.NetPort
All Implemented Interfaces:
java.io.Serializable, GraphPortHooks
Direct Known Subclasses:
PortData, PortPower, SamplePort

public class NetPort
extends NetPrimitive
implements GraphPortHooks, java.io.Serializable

This class models a port in our underlying connected graph model. A port is place on a node where an edge can connect. For example, the power socket in a wall, ot the power cord socket on the back of a computer. This class is used by the DefaultGraphModel. You can also define your own GraphModel that uses your own application-specific objects as ports.

See Also:
Serialized Form

Field Summary
static java.lang.String DEFAULT_EDGE_CLASS
           
 
Fields inherited from class org.tigris.gef.graph.presentation.NetPrimitive
_changeSup, _highlight
 
Constructor Summary
NetPort(java.lang.Object parent)
          Construct a new NetPort with the given parent node and no arcs.
 
Method Summary
 void addEdge(NetEdge edge)
          Add an edge to the list of edge connected to this port.
 boolean canConnectTo(GraphModel gm, java.lang.Object anotherPort)
          Reply true if this port can legally be connected to the given port.
protected  java.lang.Class defaultEdgeClass(NetPort otherPort)
          reply the java Class to be used to make new arcs.
 void deleteFromModel()
          Remove this port from the underlying connected graph model and dispose all arcs connected to it.
 java.util.Vector getEdges()
          Reply a vector of NetEdges that are connected here.
 java.lang.String getId()
           
 java.lang.Object getParent()
           
 NetEdge getParentEdge()
           
 NetNode getParentNode()
          Reply the NetNode that owns this port.
 NetEdge makeEdgeFor(NetPort otherPort)
          reply a new NetEdge from this port to the given NetPort.
 void postConnect(GraphModel gm, java.lang.Object otherPort)
          Application specific hook that is called after a successful connection.
 void postDisconnect(GraphModel gm, java.lang.Object otherPort)
          Application specific hook that is called after a disconnection.
 void removeEdge(NetEdge edge)
          Remove an edge from the list of edge connected to this port.
 
Methods inherited from class org.tigris.gef.graph.presentation.NetPrimitive
addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, getHighlight, removePropertyChangeListener, setHighlight
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.tigris.gef.graph.GraphPortHooks
addPropertyChangeListener, removePropertyChangeListener, setHighlight
 

Field Detail

DEFAULT_EDGE_CLASS

public static java.lang.String DEFAULT_EDGE_CLASS
Constructor Detail

NetPort

public NetPort(java.lang.Object parent)
Construct a new NetPort with the given parent node and no arcs.

Method Detail

getId

public java.lang.String getId()
Specified by:
getId in class NetPrimitive

getParentNode

public NetNode getParentNode()
Reply the NetNode that owns this port.


getParentEdge

public NetEdge getParentEdge()

getParent

public java.lang.Object getParent()

getEdges

public java.util.Vector getEdges()
Reply a vector of NetEdges that are connected here.


addEdge

public void addEdge(NetEdge edge)
Add an edge to the list of edge connected to this port. Called when the user defines a new edge. Normally, you would not call this directly, you would call NetEdge#connect().


removeEdge

public void removeEdge(NetEdge edge)
Remove an edge from the list of edge connected to this port. Called when the user disposes an edge. Normally, you would not call this directly, you would call NetEdge#deleteFromModel().


deleteFromModel

public void deleteFromModel()
Remove this port from the underlying connected graph model and dispose all arcs connected to it.

Specified by:
deleteFromModel in interface GraphPortHooks

postConnect

public void postConnect(GraphModel gm,
                        java.lang.Object otherPort)
Application specific hook that is called after a successful connection.

Specified by:
postConnect in interface GraphPortHooks

postDisconnect

public void postDisconnect(GraphModel gm,
                           java.lang.Object otherPort)
Application specific hook that is called after a disconnection. (for now, all disconnections are assumed legal).

Specified by:
postDisconnect in interface GraphPortHooks

defaultEdgeClass

protected java.lang.Class defaultEdgeClass(NetPort otherPort)
reply the java Class to be used to make new arcs. This is a utility function called from NetPort#makeEdgeFor


makeEdgeFor

public NetEdge makeEdgeFor(NetPort otherPort)
reply a new NetEdge from this port to the given NetPort.


canConnectTo

public boolean canConnectTo(GraphModel gm,
                            java.lang.Object anotherPort)
Reply true if this port can legally be connected to the given port. Subclasses may implement this to reflect application specific connection constraints. By default, each port just defers that decision to its parent NetNode. By convention, your implementation should return false if super.canConnectTo() would return false (i.e., deeper subclasses get more constrained). I don't know if that is a good convention.

Specified by:
canConnectTo in interface GraphPortHooks