Package ptolemy.cg.lib.syntactic
Class SyntacticNode
- java.lang.Object
- 
- ptolemy.kernel.util.NamedObj
- 
- ptolemy.kernel.InstantiableNamedObj
- 
- ptolemy.kernel.Entity<T>
- 
- ptolemy.kernel.ComponentEntity
- 
- ptolemy.cg.lib.syntactic.SyntacticNode
 
 
 
 
 
- 
- All Implemented Interfaces:
- java.lang.Cloneable,- SyntacticTerm,- Changeable,- Debuggable,- DebugListener,- Derivable,- Instantiable,- ModelErrorHandler,- MoMLExportable,- Moveable,- Nameable
 
 public class SyntacticNode extends ComponentEntity implements SyntacticTerm Represent nodes in the context of SyntacticGraphs. Existing and generated elements of models are represented and their ports are represented syntactically as enumerated lists of input and output ports. This enumeration is used for combinatorial composition in syntaxes with unnamed ports.Inheriting classes should use protected methods for constructing representation from existing elements. - Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Chris Shaver
- Pt.AcceptedRating:
- red
- Pt.ProposedRating:
- red (shaver)
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classSyntacticNode.NodeTypeInternal enum representing the types of nodes and how they are ordered, compared, and categorized.- 
Nested classes/interfaces inherited from class ptolemy.kernel.EntityEntity.ContainedObjectsIterator
 
- 
 - 
Field SummaryFields Modifier and Type Field Description protected java.util.LinkedList<SyntacticPort>_inputsList of references to ports syntactically marked as inputs.protected java.util.LinkedList<SyntacticPort>_outputsList of references to ports syntactically marked as outputs.- 
Fields inherited from class ptolemy.kernel.util.NamedObj_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
- 
 - 
Constructor SummaryConstructors Constructor Description SyntacticNode()Create new instance of SyntacticNode with no connections.SyntacticNode(CompositeEntity container, java.lang.String name)Construct an entity with the given name contained by the specified entity.SyntacticNode(Workspace workspace)Create new instance of SyntacticNode with no connections.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.String_makeMediatorIcon()Generate icon for mediator node.protected java.lang.String_makePermutationIcon(int[] permutation)Generate icon for permutation node.protected SyntacticPort_mapInputPort(Port port, int offset)Get the SyntacticPort corresponding to a channel of a represented input port.protected SyntacticPort_mapOutputPort(Port port, int offset)Get the SyntacticPort corresponding to a channel of a represented output port.intaddPorts(Port port, boolean isin)Add a port node with a directionality.java.lang.StringboundaryCode()Generate a string signifying the boundary of a node.java.lang.Stringdescription(java.lang.String prefix, java.lang.String suffix)Print description of Node.java.lang.StringgenerateCode()Generate code for node.java.util.List<SyntacticNode>getConnectedNode(java.util.List<SyntacticPort> ports)Get a unique list of connected nodes from a given list of ports.SyntacticNodegetConnectedNode(SyntacticPort port)Get the connected node from a given port.java.util.List<SyntacticNode>getDownstreamNodes()Get a list of nodes immediately downstream from outgoing connections.PortgetExteriorPort()Get the exterior Port syntactically represented by the node.SyntacticPortgetFirstInput()Get the first input or return null.SyntacticPortgetFirstOutput()Get the first output or return null.java.lang.StringgetIdentifier()Get string identifier (non-unique) for node.java.util.List<SyntacticPort>getInputs()Get the list of ordered inputs.java.lang.StringgetLabel()Get the label of the node.doublegetLayoutVerticalSpace()Get the vertical offset for visually representing node.SyntacticNode.NodeTypegetNodeType()Get the NodeType.intgetOrder()Get the relative order of the node by types.java.util.List<SyntacticPort>getOutputs()Get the list of ordered outputs.EntitygetRepresented()Get the Entity syntactically represented by the node.java.util.List<SyntacticNode>getUpstreamNodes()Get a list of nodes immediately upstream from outgoing connections.booleanhasCode()Determine whether or not code should be generated.java.lang.IntegerinputIndex(SyntacticPort port)Get index represented by the first channel of given port.java.lang.IntegerinputPortIndex(Port port)Get index represented by the first channel of given port.booleanisCap()Determine whether node is a cap.booleanisExterior()Determine whether node represents an exterior port.booleanisFeedback()Determine whether node represents feedback.booleanisIdentity()Determine whether node represents an identity.booleanisIncoming()Determine whether node is incoming to the expression.booleanisInitial()Determine whether node is initial, having no inputs.booleanisIsolated()Determine whether node is isolated from the network.booleanisMarked()Get whether the node has been marked.booleanisMediator()Determine whether node represents a mediator.booleanisOutgoing()Determine whether node is outgoing to the expression.booleanisPermutation()Determine whether node is a permutation.booleanisRepresentative()Determine whether node represents an Entity or is purely syntactic.booleanisTerminal()Determine whether node is terminal, having no outputs.booleanisVisited()Get whether the node has been visited.java.lang.IntegeroutputIndex(SyntacticPort port)Get index represented by the first channel of given port.java.lang.IntegeroutputPortIndex(Port port)Get index represented by the first channel of given port.SyntacticRankrank()Get the Syntactic rank of the node.voidremark()Recalculate properties of node.booleanrepresentEntity(Entity entity)Represent an Entity and its ports for use in a SyntacticGraph.voidrepresentExteriorPort(Port port)Represent an exterior port with a purely syntactic Node.voidsetCap(boolean direction)Set node as a initial or terminal node in specified direction, true being out.voidsetFeedback(boolean direction)Set node as a feedback node in specified direction, true being feed out.voidsetIdentity()Set node as an identity.voidsetLabel(java.lang.String label)Set the label used to lexically represent the node.voidsetLocation(double x, double y)Set the location of the node in layout.voidsetMarked(boolean b)Set the marked marker.voidsetMediator(boolean direction, int valence)Set node as a mediator node in specified direction.voidsetPermutation(int[] permutation)Set node as a bijective permutation node with a specified permutation.voidsetSyntactic(int inputs, int outputs)Set node as purely syntactic, not representing any Entity.voidsetVisited(boolean b)Set the visited marker.intsizeInputs()Get the number of inputs to the node.intsizeOutputs()Get the number of outputs to the node.- 
Methods inherited from class ptolemy.kernel.ComponentEntity_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, clone, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, newPort, propagateExistence, setContainer, setName
 - 
Methods inherited from class ptolemy.kernel.Entity_addPort, _description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, connectionsChanged, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
 - 
Methods inherited from class ptolemy.kernel.InstantiableNamedObj_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
 - 
Methods inherited from class ptolemy.kernel.util.NamedObj_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeChanged, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
 - 
Methods inherited from class java.lang.Objectequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface ptolemy.kernel.util.DerivablegetDerivedLevel, getDerivedList, propagateValue
 - 
Methods inherited from interface ptolemy.kernel.util.Nameabledescription, getDisplayName, getFullName, getName, getName
 
- 
 
- 
- 
- 
Field Detail- 
_inputsprotected java.util.LinkedList<SyntacticPort> _inputs List of references to ports syntactically marked as inputs.
 - 
_outputsprotected java.util.LinkedList<SyntacticPort> _outputs List of references to ports syntactically marked as outputs.
 
- 
 - 
Constructor Detail- 
SyntacticNodepublic SyntacticNode() Create new instance of SyntacticNode with no connections.
 - 
SyntacticNodepublic SyntacticNode(Workspace workspace) Create new instance of SyntacticNode with no connections.- Parameters:
- workspace- Workspace in which to create the node.
 
 - 
SyntacticNodepublic SyntacticNode(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException Construct an entity with the given name contained by the specified entity. The container argument must not be null, or a NullPointerException will be thrown. This entity will use the workspace of the container for synchronization and version counts. If the name argument is null, then the name is set to the empty string. Increment the version of the workspace. This constructor write-synchronizes on the workspace.- Parameters:
- container- The container entity.
- name- The name of the entity.
- Throws:
- IllegalActionException- If the entity cannot be contained by the proposed container.
- NameDuplicationException- If the name coincides with an entity already in the container.
 
 
- 
 - 
Method Detail- 
representEntitypublic boolean representEntity(Entity entity) throws IllegalActionException, NameDuplicationException Represent an Entity and its ports for use in a SyntacticGraph.- Parameters:
- entity- The Entity to be represented with the SyntacticNode
- Returns:
- if the representation is total.
- Throws:
- IllegalActionException- If the entity is already represented, if there is a problem getting the width or creating a port or attribute.
- NameDuplicationException- If there is a problem creating a port or attribute.
 
 - 
addPortspublic int addPorts(Port port, boolean isin) throws IllegalActionException, NameDuplicationException Add a port node with a directionality. Given port is represented by constructed SyntacticPorts then added to the node in this form. The number of ports added from the given port is the width of the given port. Each channel is represented by a SyntacticPort and pointed back to the given Port.- Parameters:
- port- Port to add
- isin- True if input, False if output.
- Returns:
- number of SyntacticPorts added (= width).
- Throws:
- IllegalActionException- If thrown while getting the port width, creating a new port, creating a new StringAttribute or setting the expression.
- NameDuplicationException- If thrown while creating a new port.
 
 - 
representExteriorPortpublic void representExteriorPort(Port port) throws IllegalActionException, NameDuplicationException Represent an exterior port with a purely syntactic Node.- Parameters:
- port- The port to represent on the node.
- Throws:
- IllegalActionException- If thrown while creating a new port, creating a new cardinal attribute or setting the cardinal expression.
- NameDuplicationException- If thrown while creating a new port or creating a new cardinal attribute.
 
 - 
setSyntacticpublic void setSyntactic(int inputs, int outputs) throws IllegalActionException, NameDuplicationExceptionSet node as purely syntactic, not representing any Entity.- Parameters:
- inputs- Number of inputs.
- outputs- Number of outputs.
- Throws:
- IllegalActionException- If thrown while creating a new port, creating a new cardinal attribute or setting the cardinality.
- NameDuplicationException- If thrown while creating a new port or creating a new cardinal attribute.
 
 - 
setIdentitypublic void setIdentity() throws IllegalActionException, NameDuplicationExceptionSet node as an identity.- Throws:
- IllegalActionException- If thrown while setting the node as purely syntactic, not representing any Entity.
- NameDuplicationException- If thrown while setting the node as purely syntactic, not representing any Entity.
 
 - 
setFeedbackpublic void setFeedback(boolean direction) throws IllegalActionException, NameDuplicationExceptionSet node as a feedback node in specified direction, true being feed out.- Parameters:
- direction- The direction to make the feedback node.
- Throws:
- IllegalActionException- If thrown while setting the node as purely syntactic, not representing any Entity.
- NameDuplicationException- If thrown while setting the node as purely syntactic, not representing any Entity.
 
 - 
setMediatorpublic void setMediator(boolean direction, int valence) throws IllegalActionException, NameDuplicationExceptionSet node as a mediator node in specified direction. The true direction splits, the false merges.- Parameters:
- direction- The direction to make the mediator node.
- valence- The amount of endpoints on the opposite side.
- Throws:
- IllegalActionException- If thrown while setting the node as purely syntactic, not representing any Entity.
- NameDuplicationException- If thrown while setting the node as purely syntactic, not representing any Entity.
 
 - 
setCappublic void setCap(boolean direction) throws IllegalActionException, NameDuplicationExceptionSet node as a initial or terminal node in specified direction, true being out.- Parameters:
- direction- The direction to make the cap node.
- Throws:
- IllegalActionException- If thrown while setting the node as purely syntactic, not representing any Entity.
- NameDuplicationException- If thrown while setting the node as purely syntactic, not representing any Entity.
 
 - 
setPermutationpublic void setPermutation(int[] permutation) throws IllegalActionException, NameDuplicationExceptionSet node as a bijective permutation node with a specified permutation.- Parameters:
- permutation- The permutation to represent as the node.
- Throws:
- IllegalActionException- If thrown while setting the node as purely syntactic, not representing any Entity.
- NameDuplicationException- If thrown while setting the node as purely syntactic, not representing any Entity.
 
 - 
getConnectedNodepublic SyntacticNode getConnectedNode(SyntacticPort port) Get the connected node from a given port. If the graph is not made bijective this gives the first.- Parameters:
- port- The port to look out from.
- Returns:
- An immediately connected node.
 
 - 
getConnectedNodepublic java.util.List<SyntacticNode> getConnectedNode(java.util.List<SyntacticPort> ports) Get a unique list of connected nodes from a given list of ports.- Parameters:
- ports- The list of ports to look out from.
- Returns:
- A set list of immediately connected nodes.
 
 - 
getDownstreamNodespublic java.util.List<SyntacticNode> getDownstreamNodes() Get a list of nodes immediately downstream from outgoing connections.- Returns:
- A list of immediately downstream nodes.
 
 - 
getUpstreamNodespublic java.util.List<SyntacticNode> getUpstreamNodes() Get a list of nodes immediately upstream from outgoing connections.- Returns:
- A list of immediately upstream nodes.
 
 - 
remarkpublic void remark() Recalculate properties of node.
 - 
setVisitedpublic void setVisited(boolean b) Set the visited marker. This marker is used for algorithms that visit nodes.- Parameters:
- b- State of the visited flag.
 
 - 
setMarkedpublic void setMarked(boolean b) Set the marked marker. This marker is used for algorithms that traverse nodes.- Parameters:
- b- State of the marked flag.
 
 - 
setLabelpublic void setLabel(java.lang.String label) Set the label used to lexically represent the node.- Parameters:
- label- Label to set for node.
- See Also:
- getLabel()
 
 - 
setLocationpublic void setLocation(double x, double y) throws IllegalActionException, NameDuplicationExceptionSet the location of the node in layout.- Parameters:
- x- The x-coordinate
- y- The y-coordinate
- Throws:
- IllegalActionException- If thrown while creating a new location or setting the coordinates of the location.
- NameDuplicationException- If thrown while creating a new location.
 
 - 
getLayoutVerticalSpacepublic double getLayoutVerticalSpace() Get the vertical offset for visually representing node.- Returns:
- vertical offset down from baseline.
 
 - 
getIdentifierpublic java.lang.String getIdentifier() Get string identifier (non-unique) for node.- Returns:
- identifier string.
 
 - 
isVisitedpublic boolean isVisited() Get whether the node has been visited.- Returns:
- value of the visited flag.
 
 - 
isMarkedpublic boolean isMarked() Get whether the node has been marked.- Returns:
- value of the marked flag.
 
 - 
outputPortIndexpublic java.lang.Integer outputPortIndex(Port port) Get index represented by the first channel of given port.- Parameters:
- port- The Port represented in the node.
- Returns:
- base index object or null if not found.
 
 - 
inputPortIndexpublic java.lang.Integer inputPortIndex(Port port) Get index represented by the first channel of given port.- Parameters:
- port- The Port represented in the node.
- Returns:
- base index object or null if not found.
 
 - 
outputIndexpublic java.lang.Integer outputIndex(SyntacticPort port) Get index represented by the first channel of given port.- Specified by:
- outputIndexin interface- SyntacticTerm
- Parameters:
- port- The Port represented in the node.
- Returns:
- base index object or null if not found.
 
 - 
inputIndexpublic java.lang.Integer inputIndex(SyntacticPort port) Get index represented by the first channel of given port.- Specified by:
- inputIndexin interface- SyntacticTerm
- Parameters:
- port- The Port represented in the node.
- Returns:
- base index object or null if not found.
 
 - 
getInputspublic java.util.List<SyntacticPort> getInputs() Get the list of ordered inputs.- Specified by:
- getInputsin interface- SyntacticTerm
- Returns:
- The list of inputs.
 
 - 
getOutputspublic java.util.List<SyntacticPort> getOutputs() Get the list of ordered outputs.- Specified by:
- getOutputsin interface- SyntacticTerm
- Returns:
- The list of outputs.
 
 - 
sizeInputspublic int sizeInputs() Get the number of inputs to the node. For input nodes this returns 1 for the input it represents to the downstream node.- Specified by:
- sizeInputsin interface- SyntacticTerm
- Returns:
- number of inputs.
 
 - 
sizeOutputspublic int sizeOutputs() Get the number of outputs to the node. For output nodes this returns 1 for the output it represents to the upstream node.- Specified by:
- sizeOutputsin interface- SyntacticTerm
- Returns:
- number of outputs.
 
 - 
rankpublic SyntacticRank rank() Get the Syntactic rank of the node.- Specified by:
- rankin interface- SyntacticTerm
- Returns:
- rank of the node.
 
 - 
boundaryCodepublic java.lang.String boundaryCode() Generate a string signifying the boundary of a node. The boundary is the number of inputs and outputs.- Returns:
- string representing boundary of node.
 
 - 
getFirstInputpublic SyntacticPort getFirstInput() Get the first input or return null.- Returns:
- first input or null.
 
 - 
getFirstOutputpublic SyntacticPort getFirstOutput() Get the first output or return null.- Returns:
- first output or null.
 
 - 
getOrderpublic int getOrder() Get the relative order of the node by types. ... which order?- Specified by:
- getOrderin interface- SyntacticTerm
- Returns:
- the order of the node.
 
 - 
isFeedbackpublic boolean isFeedback() Determine whether node represents feedback.- Returns:
- Whether node is a feedback node
 
 - 
isIdentitypublic boolean isIdentity() Determine whether node represents an identity.- Returns:
- Whether node is identity
 
 - 
isExteriorpublic boolean isExterior() Determine whether node represents an exterior port.- Returns:
- Whether node is exterior
 
 - 
isMediatorpublic boolean isMediator() Determine whether node represents a mediator.- Returns:
- Whether node is a mediator
 
 - 
isInitialpublic boolean isInitial() Determine whether node is initial, having no inputs.- Returns:
- Whether node is initial
 
 - 
isTerminalpublic boolean isTerminal() Determine whether node is terminal, having no outputs.- Returns:
- Whether node is terminal
 
 - 
isIsolatedpublic boolean isIsolated() Determine whether node is isolated from the network.- Returns:
- Whether node is isolated
 
 - 
isCappublic boolean isCap() Determine whether node is a cap.- Returns:
- Whether node is a cap
 
 - 
isPermutationpublic boolean isPermutation() Determine whether node is a permutation.- Returns:
- Whether node is a permutation
 
 - 
isIncomingpublic boolean isIncoming() Determine whether node is incoming to the expression.- Returns:
- Whether node is incoming
 
 - 
isOutgoingpublic boolean isOutgoing() Determine whether node is outgoing to the expression.- Returns:
- Whether node is outgoing
 
 - 
hasCodepublic boolean hasCode() Determine whether or not code should be generated. If false, code should be suppressed such is the case for identity nodes.- Specified by:
- hasCodein interface- SyntacticTerm
- Returns:
- whether code should be generated.
 
 - 
getRepresentedpublic Entity getRepresented() Get the Entity syntactically represented by the node.- Returns:
- Represented Entity.
 
 - 
getExteriorPortpublic Port getExteriorPort() Get the exterior Port syntactically represented by the node.- Returns:
- Represented Port.
 
 - 
getNodeTypepublic SyntacticNode.NodeType getNodeType() Get the NodeType.- Returns:
- Represented NodeType.
 
 - 
getLabelpublic java.lang.String getLabel() Get the label of the node.- Returns:
- label of the node.
- See Also:
- setLabel(java.lang.String)
 
 - 
isRepresentativepublic boolean isRepresentative() Determine whether node represents an Entity or is purely syntactic. A purely syntactic node represents a relationship in the Ptolemy network as a SyntacticNode that can be expressed in syntax as an special atomic element rather than as a combinator.- Returns:
- Whether node is a representation.
 
 - 
generateCodepublic java.lang.String generateCode() Generate code for node.- Specified by:
- generateCodein interface- SyntacticTerm
- Returns:
- code representation of node.
 
 - 
descriptionpublic java.lang.String description(java.lang.String prefix, java.lang.String suffix)Print description of Node.- Parameters:
- prefix- Line prefix for embedding description
- suffix- Line suffix for embedding description
- Returns:
- Description of Node.
 
 - 
_mapInputPortprotected SyntacticPort _mapInputPort(Port port, int offset) Get the SyntacticPort corresponding to a channel of a represented input port.- Parameters:
- port- Port represented.
- offset- Offset channel of port, 0 if single port.
- Returns:
- corresponding SyntacticPort in node.
 
 - 
_mapOutputPortprotected SyntacticPort _mapOutputPort(Port port, int offset) Get the SyntacticPort corresponding to a channel of a represented output port.- Parameters:
- port- Port represented.
- offset- Offset channel of port, 0 if single port.
- Returns:
- corresponding SyntacticPort in node.
 
 - 
_makePermutationIconprotected java.lang.String _makePermutationIcon(int[] permutation) throws IllegalActionException, NameDuplicationExceptionGenerate icon for permutation node.- Parameters:
- permutation- Array of permutation values.
- Returns:
- svg code for generated icon.
- Throws:
- IllegalActionException- If thrown while creating a new variable with the name "_portSpread".
- NameDuplicationException- If thrown while creating a new variable with the name "_portSpread".*sh
 
 - 
_makeMediatorIconprotected java.lang.String _makeMediatorIcon() Generate icon for mediator node.- Returns:
- svg code for generated icon.
 
 
- 
 
-