uci.gef
Class NetPort

java.lang.Object
  |
  +--uci.gef.NetPrimitive
        |
        +--uci.gef.NetPort
Direct Known Subclasses:
PortData, PortPower, SamplePort

public class NetPort
extends NetPrimitive
implements GraphPortHooks, 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. Needs-more-work: this should probably move to package uci.graph.

See Also:
Serialized Form

Field Summary
protected  Vector _edges
          The NetEdges that are connected to this port.
protected  Object _parent
          The NetNode that this port is a part of.
static String DEFAULT_EDGE_CLASS
           
 
Fields inherited from class uci.gef.NetPrimitive
_changeSup, _highlight
 
Constructor Summary
NetPort(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, Object anotherPort)
          Reply true if this port can legally be connected to the given port.
protected  Class defaultEdgeClass(NetPort otherPort)
          reply the java Class to be used to make new arcs.
 void dispose()
          Remove this port from the underlying connected graph model and dispose all arcs connected to it.
 Vector getEdges()
          Reply a vector of NetEdges that are connected here.
 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, Object otherPort)
          Application specific hook that is called after a successful connection.
 void postDisconnect(GraphModel gm, 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 uci.gef.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
 

Field Detail

DEFAULT_EDGE_CLASS

public static String DEFAULT_EDGE_CLASS

_edges

protected Vector _edges
The NetEdges that are connected to this port.

_parent

protected Object _parent
The NetNode that this port is a part of.
Constructor Detail

NetPort

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

getParentNode

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

getParentEdge

public NetEdge getParentEdge()

getParent

public Object getParent()

getEdges

public 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#dispose().

dispose

public void dispose()
Remove this port from the underlying connected graph model and dispose all arcs connected to it.
Specified by:
dispose in interface GraphPortHooks

postConnect

public void postConnect(GraphModel gm,
                        Object otherPort)
Application specific hook that is called after a successful connection.
Specified by:
postConnect in interface GraphPortHooks

postDisconnect

public void postDisconnect(GraphModel gm,
                           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 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,
                            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