de.sciss.jcollider
Class NodeEvent

java.lang.Object
  extended by java.util.EventObject
      extended by de.sciss.app.BasicEvent
          extended by de.sciss.jcollider.NodeEvent
All Implemented Interfaces:
java.io.Serializable

public class NodeEvent
extends de.sciss.app.BasicEvent

These kind of events get delivered by a node watcher to inform listeners about node status changes.

Version:
0.33, 19-Mar-08
Author:
Hanns Holger Rutz
See Also:
Serialized Form

Field Summary
static int END
          returned by getID() : the node was destroyed
static int GO
          returned by getID() : the node was created
static int GROUP
          returned by getType() : the node is a group
static int INFO
          returned by getID() : the event was created by a /n_query command
static int MOVE
          returned by getID() : the node has moved
static int OFF
          returned by getID() : the node was paused
static int ON
          returned by getID() : the node was resumed
static int SYNTH
          returned by getType() : the node is a synth
static int UNKNOWN
          returned by getType() : the node type is unknown
 
Fields inherited from class java.util.EventObject
source
 
Constructor Summary
protected NodeEvent(java.lang.Object source, int ID, long when, Node node, int nodeID, int parentID, int predID, int succID, int nodeType, int headID, int tailID)
          Constructs a NodeEvent from a detailed description.
 
Method Summary
static NodeEvent fromOSCMessage(de.sciss.net.OSCMessage msg, java.lang.Object source, long when)
           
static NodeEvent fromOSCMessage(de.sciss.net.OSCMessage msg, java.lang.Object source, long when, Node node)
          Constructs a NodeEvent from a valid node notification OSC message.
 int getHeadNodeID()
           
static int getIDFromOSCMessage(de.sciss.net.OSCMessage msg)
          Queries the event ID which would be used if the event was generated from a provided OSC message.
 Node getNode()
           
 int getNodeID()
           
 int getNodeType()
           
 int getOldParentGroupID()
           
 int getOldPredNodeID()
           
 int getOldSuccNodeID()
           
 int getParentGroupID()
           
 int getPredNodeID()
           
 int getSuccNodeID()
           
 int getTailNodeID()
           
static java.util.List getValidOSCCommands()
          Returns a list of strings describing all known OSC command names that form valid node notification messages, that is "/n_go", "/n_end" etc.
 boolean incorporate(de.sciss.app.BasicEvent oldEvent)
          Used by the EventManager to fuse successive events together when they queue.
 
Methods inherited from class de.sciss.app.BasicEvent
getID, getWhen
 
Methods inherited from class java.util.EventObject
getSource, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

GO

public static final int GO
returned by getID() : the node was created

See Also:
Constant Field Values

END

public static final int END
returned by getID() : the node was destroyed

See Also:
Constant Field Values

ON

public static final int ON
returned by getID() : the node was resumed

See Also:
Constant Field Values

OFF

public static final int OFF
returned by getID() : the node was paused

See Also:
Constant Field Values

MOVE

public static final int MOVE
returned by getID() : the node has moved

See Also:
Constant Field Values

INFO

public static final int INFO
returned by getID() : the event was created by a /n_query command

See Also:
Constant Field Values

SYNTH

public static final int SYNTH
returned by getType() : the node is a synth

See Also:
Constant Field Values

GROUP

public static final int GROUP
returned by getType() : the node is a group

See Also:
Constant Field Values

UNKNOWN

public static final int UNKNOWN
returned by getType() : the node type is unknown

See Also:
Constant Field Values
Constructor Detail

NodeEvent

protected NodeEvent(java.lang.Object source,
                    int ID,
                    long when,
                    Node node,
                    int nodeID,
                    int parentID,
                    int predID,
                    int succID,
                    int nodeType,
                    int headID,
                    int tailID)
Constructs a NodeEvent from a detailed description. Note that the provided node (which may be null) is considered not to be up-to-date, it is examined to fill in the old-fields (oldParentID, oldPredID) etc. It will be returned by getNode. The caller is responsible for updating the node's fields accordingly, after processing the event.

Parameters:
source - who fired the event
ID - the type of status change, e.g. GO
when - timestamp of the event (e.g. System.currentTimeMillis())
node - the representation of the node whose status changed
nodeID - the ID of the node whose status changed
parentID - the ID of the node's parent group
predID - the node's predecessor or -1
succID - the node's successor or -1
nodeType - either of GROUP or SYNTH
headID - (for groups) ID of the group's head (first) node
tailID - (for groups) ID of the group's tail (last) node
Method Detail

fromOSCMessage

public static NodeEvent fromOSCMessage(de.sciss.net.OSCMessage msg,
                                       java.lang.Object source,
                                       long when,
                                       Node node)
Constructs a NodeEvent from a valid node notification OSC message. The provided node object is simply stored for future reference through getNode and must be updated by the caller according to the returned event.

Parameters:
msg - OSC message such as /n_go
source - who shall be known as the source of the generated event
when - what is proposed time of the event generation
node - a client side representation node to use for the event, or null if no representation is known. The caller is responsible for updating the node's status from the returned event.
Throws:
java.lang.IllegalArgumentException - if the message doesn't contain a valid node message; you can use getIDFromOSCMessage to determine if the message is valid.

fromOSCMessage

public static NodeEvent fromOSCMessage(de.sciss.net.OSCMessage msg,
                                       java.lang.Object source,
                                       long when)

getIDFromOSCMessage

public static int getIDFromOSCMessage(de.sciss.net.OSCMessage msg)
Queries the event ID which would be used if the event was generated from a provided OSC message.

Parameters:
msg - the message to parse
Returns:
the corresponding event ID or -1 if the message command is not in the list of valid notification commands

getNode

public Node getNode()
Returns:
the representation of the node whose status changed. this may return null if the client side object is not known. in this case, use getNodeID to query the node's identifier.

getNodeID

public int getNodeID()
Returns:
the ID of the node whose status changed

getParentGroupID

public int getParentGroupID()
Returns:
the ID of the group in which this node sits. Note that if getNode returns a valid node, you can also use getParentGroup on the returned node.

getOldParentGroupID

public int getOldParentGroupID()
Returns:
the ID of the group in which this node was sitting before the modification occurred, or -1, if the node was not placed in a group.

getPredNodeID

public int getPredNodeID()
Returns:
the ID of the node sitting just before the modified node in the graph, or -1 if there is no predecessor. Note that if getNode returns a valid node, you can also use getPredNode on the returned node.

getOldPredNodeID

public int getOldPredNodeID()
Returns:
the ID of the node which was sitting just before the modified node before the modification occured, or -1 if there was no predecessor.

getOldSuccNodeID

public int getOldSuccNodeID()
Returns:
the ID of the node which was sitting just after the modified node before the modification occured, or -1 if there was no successor.

getSuccNodeID

public int getSuccNodeID()
Returns:
the ID of the node sitting just after the modified node in the graph, or -1 if there is no successor. Note that if getNode returns a valid node, you can also use getSuccNode on the returned node.

getNodeType

public int getNodeType()
Returns:
the type node that was modified, one of SYNTH or GROUP. other values might be returned if a new version of supercollider introduces other node classes.

getHeadNodeID

public int getHeadNodeID()
Returns:
if the modified node is a group, returns the ID of the node being the group's head element. otherwise (or when the group is empty) returns -1. Note that if getNode returns a valid group, you can also use getHeadNode on the returned group.

getTailNodeID

public int getTailNodeID()
Returns:
if the modified node is a group, returns the ID of the node being the group's tail element. otherwise (or when the group is empty) returns -1. Note that if getNode returns a valid group, you can also use getTailNode on the returned group.

getValidOSCCommands

public static java.util.List getValidOSCCommands()
Returns a list of strings describing all known OSC command names that form valid node notification messages, that is "/n_go", "/n_end" etc. The returned list is immutable.

Returns:
a list whose elements are of class String, each element corresponding to a valid OSC command. Note that the element index reflects the event IDs, so returnedList.get( GO ) == "/n_go" etc.

incorporate

public boolean incorporate(de.sciss.app.BasicEvent oldEvent)
Used by the EventManager to fuse successive events together when they queue. Do not call this method.

Specified by:
incorporate in class de.sciss.app.BasicEvent
Parameters:
oldEvent - the most recent event in the queue which might be incorporated by this new event.
Returns:
true if this object was able to incorporate the older event. in this case the oldEvent is removed from the event queue. false states that the oldEvent was incompatible and should remain in the queue.
See Also:
javax.swing.undo.UndoableEdit#replaceEdit( UndoableEdit )