org.tigris.gef.graph.presentation
Class NetNode

java.lang.Object
  extended by org.tigris.gef.graph.presentation.NetPrimitive
      extended by org.tigris.gef.graph.presentation.NetNode
All Implemented Interfaces:
java.io.Serializable, GraphNodeHooks
Direct Known Subclasses:
NodeCPU, NodePrinter, NodeWall, SampleNode

public abstract class NetNode
extends NetPrimitive
implements GraphNodeHooks, java.io.Serializable

This class models a node in our underlying connected graph model. Nodes have ports that are their connection points to other nodes. This class is used by DefaultGraphModel, if you implement your own GraphModel, you can use your own application-specific objects as nodes.

See Also:
NetEdge, NetPort, Serialized Form

Field Summary
 
Fields inherited from class org.tigris.gef.graph.presentation.NetPrimitive
_changeSup, _highlight
 
Constructor Summary
NetNode()
          Construct a new NetNode with no default attributes and no ports.
NetNode(NetNode deft, java.util.List ports)
          Construct a new node from the given default node and number of ports.
 
Method Summary
 void addPort(NetPort p)
           
 boolean canConnectTo(GraphModel gm, java.lang.Object otherNode, java.lang.Object otherPort, java.lang.Object myPort)
          Allow for application specific rules about which nodes can be connected to which other nodes.
 void deleteFromModel()
          Remove this node from the underling connected graph model.
 java.lang.Object getAttributes()
          Returns the attribute table of the node.
 NetPort getPort(int i)
          reply my NetPort with the given index.
 java.util.List getPorts()
          reply my NetPorts.
abstract  void initialize(java.util.Hashtable args)
          Usually when nodes are created it is deon through newInstance and there is no chance to supply a default node or to connect this node to some other application level object.
abstract  FigNode makePresentation(Layer lay)
          Construct and return a new FigNode to present this NetNode in the given Layer.
 void postConnect(GraphModel gm, java.lang.Object anotherNode, java.lang.Object myPort, java.lang.Object otherPort)
          Do some application specific action just after this node is connected to another node.
 void postDisconnect(GraphModel gm, java.lang.Object anotherNode, java.lang.Object myPort, java.lang.Object otherPort)
          Do some application specific action just after this node is disconnected from another node.
 void postPlacement(Editor ed)
          Do some application specific actions after the node is placed in a drawing area.
 FigNode presentationFor(Layer lay)
          Reply the FigNode that is appropriate for visualizing this node in the given Layer.
 void setPorts(java.util.List ports)
           
 
Methods inherited from class org.tigris.gef.graph.presentation.NetPrimitive
addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, getHighlight, getId, 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.GraphNodeHooks
addPropertyChangeListener, removePropertyChangeListener, setHighlight
 

Constructor Detail

NetNode

public NetNode(NetNode deft,
               java.util.List ports)
Construct a new node from the given default node and number of ports. The attributes of the default node will be used if they are not overridden in this node (i.e., nodes have attributes and there is a virual copy relationship between some nodes).


NetNode

public NetNode()
Construct a new NetNode with no default attributes and no ports.

Method Detail

initialize

public abstract void initialize(java.util.Hashtable args)
Usually when nodes are created it is deon through newInstance and there is no chance to supply a default node or to connect this node to some other application level object. So after a node is constructed initialize is called to supply that information.

Needs-More-Work: what is the class protocol design here?

Specified by:
initialize in interface GraphNodeHooks

getAttributes

public java.lang.Object getAttributes()
Returns the attribute table of the node.


getPort

public NetPort getPort(int i)
reply my NetPort with the given index.


getPorts

public java.util.List getPorts()
reply my NetPorts.


setPorts

public void setPorts(java.util.List ports)

addPort

public void addPort(NetPort p)

deleteFromModel

public void deleteFromModel()
Remove this node from the underling connected graph model.

Specified by:
deleteFromModel in interface GraphNodeHooks

presentationFor

public FigNode presentationFor(Layer lay)
Reply the FigNode that is appropriate for visualizing this node in the given Layer. If no such FigNode already exists, instanciate a new one.


makePresentation

public abstract FigNode makePresentation(Layer lay)
Construct and return a new FigNode to present this NetNode in the given Layer. A default implementation is supplied as an example, but all subclasses should override this method. NetPorts of this NetNode should be associated with individual Figs that make up the FigNode.


postConnect

public void postConnect(GraphModel gm,
                        java.lang.Object anotherNode,
                        java.lang.Object myPort,
                        java.lang.Object otherPort)
Do some application specific action just after this node is connected to another node. the arguments contain some info about what ports were connected.

Specified by:
postConnect in interface GraphNodeHooks

postDisconnect

public void postDisconnect(GraphModel gm,
                           java.lang.Object anotherNode,
                           java.lang.Object myPort,
                           java.lang.Object otherPort)
Do some application specific action just after this node is disconnected from another node. the arguments contain some info about what ports were connected.

Specified by:
postDisconnect in interface GraphNodeHooks

canConnectTo

public boolean canConnectTo(GraphModel gm,
                            java.lang.Object otherNode,
                            java.lang.Object otherPort,
                            java.lang.Object myPort)
Allow for application specific rules about which nodes can be connected to which other nodes. This is called from the NetPort, so the port has first say as to whether it can be connected to some other port. NetPort.canConnectTo() just calls NetNode.canConnectTo(). By default anything can be connected to anything.

Specified by:
canConnectTo in interface GraphNodeHooks

postPlacement

public void postPlacement(Editor ed)
Do some application specific actions after the node is placed in a drawing area.

Specified by:
postPlacement in interface GraphNodeHooks