|
Nodenet Problem Set Javadocs | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object nodenet.Node
This class implements NodeNetElement. It is responsible for the
GUI and maintains its own thread. It relies on a class that
implements NodeBehavior to do anything. It repeatedly calls that
class's act method from within a while(true) {}
loop.
Note: the following methods are synchronized to prevent addition
or subtraction of a channel during
NodeBehavior.transmitPacket(InputChannelVector, OutputChannelVector)
public void addInputChannel(InputChannel c)
public void removeInputChannel(InputChannel c)
public void addOutputChannel(OutputChannel c)
public void removeOutputChannel(OutputChannel c)
public void run()
NodeNetElement
,
NodeBehavior
,
Serialized FormField Summary | |
static int |
GUISIZE
Diameter of the circle used to paint nodes. |
static java.awt.Color |
HIGHLIGHT_COLOR
|
Constructor Summary | |
Node(java.lang.Class nbc,
int x,
int y,
java.lang.String name,
boolean showName,
boolean enabled)
Build a node setting various properties. |
|
Node(NodeBehavior nb)
|
Method Summary | |
void |
addInputChannel(InputChannel c)
Adds a new InputChannel. |
void |
addOutputChannel(OutputChannel c)
Adds a new OutputChannel. |
void |
configure()
Display a configuratin dialog to the user and record changes made to the configuration via this dialog. |
boolean |
contains(int x,
int y)
Determine if this element contains the specified point. |
boolean |
contains(java.awt.Point p)
Determine if this element contains the specified point. |
void |
destroy()
Destroy the Node. |
boolean |
equals(java.lang.Object o)
|
protected void |
finalize()
|
static java.util.Enumeration |
getBehaviors()
Gets an Enumeration of all currently known NodeBehaviors. |
static java.awt.Color |
getColorFromBehavior(java.lang.String behavior)
Returns the current Color associated with the given NodeBehavior. |
NodeConfigurationBean |
getConfig()
|
int |
getMyID()
Getter for property myID. |
java.lang.String |
getName()
Get the name of this instance. |
java.awt.Point |
getPos()
|
boolean |
isDestroyed()
Test to see if this element has been destroyed. |
boolean |
isEditable()
|
boolean |
isEnabled()
Determine if this element is enabled. |
boolean |
isSelected()
Determine the selection stae of this element. |
void |
notifyOfDestruction(NodeNetElement bse)
Notify this that a NodeNetElement has been destroyed. |
void |
paint(java.awt.Graphics g)
Paint ourself to a graphics context. |
void |
removeInputChannel(InputChannel c)
Removes an InputChannel. |
void |
removeOutputChannel(OutputChannel c)
Removes an OutputChannel. |
void |
reset()
Return all properties and other state to the initial state of the object so long as such changes do not alter the network structure. |
void |
run()
Repeatedly calls the transmitPacket method for the
associated NodeBehavior. |
void |
setEnabled(boolean b)
Set the enabled property. |
void |
setName(java.lang.String n)
Set the name of this instance. |
void |
setPos(int a,
int b)
|
void |
setPos(java.awt.Point p)
|
void |
setSelected(boolean newState)
Notify this object that it should render itself as selected or unselected. |
void |
start()
Starts the node running. |
void |
stop()
Stops the node. |
java.lang.String |
templateXML()
Generate an xml element representing a template of this node. |
Methods inherited from class java.lang.Object |
clone, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int GUISIZE
public static final java.awt.Color HIGHLIGHT_COLOR
Constructor Detail |
public Node(NodeBehavior nb)
public Node(java.lang.Class nbc, int x, int y, java.lang.String name, boolean showName, boolean enabled)
Method Detail |
public static java.awt.Color getColorFromBehavior(java.lang.String behavior)
behavior
- the NodeBehavior whose Color will be returnedpublic static java.util.Enumeration getBehaviors()
public void setPos(java.awt.Point p)
public void setPos(int a, int b)
public java.awt.Point getPos()
public void setSelected(boolean newState)
NodeNetElement
setSelected
in interface NodeNetElement
newState
- the new selection statepublic boolean isSelected()
NodeNetElement
isSelected
in interface NodeNetElement
public void setEnabled(boolean b)
NodeNetElement
setEnabled
in interface NodeNetElement
b
- the new state of the enabled propertypublic boolean isEnabled()
NodeNetElement
isEnabled
in interface NodeNetElement
NodeNetElement.setEnabled(boolean)
public NodeConfigurationBean getConfig()
public void setName(java.lang.String n)
NodeNetElement
setName
in interface NodeNetElement
n
- The name to use for this element.public java.lang.String getName()
NodeNetElement
getName
in interface NodeNetElement
NodeNetElement.setName(String)
public boolean contains(java.awt.Point p)
NodeNetElement
contains
in interface NodeNetElement
p
- the point to test
public boolean contains(int x, int y)
NodeNetElement
contains
in interface NodeNetElement
x
- the x coordinate of the point to testy
- the y coordinate of the point to test
public boolean isEditable()
public void configure()
NodeNetElement
configure
in interface NodeNetElement
public void addInputChannel(InputChannel c)
equals
method), it is
not added again. This condition is silently ignored.
c
- the InputChannel to connectpublic void removeInputChannel(InputChannel c)
equals
method), this method does nothing.
c
- the InputChannel to disconnectpublic void addOutputChannel(OutputChannel c)
equals
method), it is
not added again. This condition is silently ignored.
c
- the OutputChannel to connectpublic void removeOutputChannel(OutputChannel c)
equals
method), this method does nothing.
c
- the OutputChannel to disconnectpublic void destroy()
destroy()
should be called
whenever a Node will no longer be used. When destroyed, Nodes
notify all connected input and output channels of the impending
destruction and remove refrences to those channels. Typically,
this will force their destruction as well. Note:
Node.finalize()
automatically calls
destroy()
.
destroy
in interface NodeNetElement
public boolean isDestroyed()
NodeNetElement
isDestroyed
in interface NodeNetElement
public int getMyID()
public java.lang.String templateXML()
public void notifyOfDestruction(NodeNetElement bse)
notifyOfDestruction
in interface NodeNetElement
bse
- the element that is being destroyedpublic void paint(java.awt.Graphics g)
NodeNetElement
paint
in interface NodeNetElement
g
- The graphics context on which to render ourselfpublic void start()
act
method for it's associated
NodeBehavior.
start
in interface NodeNetElement
public void stop()
stop
in interface NodeNetElement
public void run()
transmitPacket
method for the
associated NodeBehavior. Note: This method should never be
called directly. Instead, use the start()
method.
run
in interface java.lang.Runnable
public boolean equals(java.lang.Object o)
protected void finalize() throws java.io.IOException
java.io.IOException
public void reset()
Resettable
reset
in interface Resettable
|
Nodenet Problem Set Javadocs | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |