Package ptolemy.moml

Class Vertex

  • All Implemented Interfaces:
    java.lang.Cloneable, Changeable, Debuggable, DebugListener, Derivable, Locatable, ModelErrorHandler, MoMLExportable, Moveable, Nameable, Settable, Singleton

    public class Vertex
    extends Location
    This attribute represents a waypoint in a relation. It extends Location, meaning that can be associated with a physical location in a visual rendition. It can optionally be associated with another instance of Vertex to indicate that there is a path from this one to the other one. Cyclic paths are not permitted, although currently that is not enforced by this class.
    Since:
    Ptolemy II 0.4
    Version:
    $Id$
    Author:
    Steve Neuendorffer and Edward A. Lee
    Pt.AcceptedRating:
    Red (reviewmoderator)
    Pt.ProposedRating:
    Red (eal)
    • Constructor Detail

      • Vertex

        public Vertex​(Workspace workspace)
        Construct an attribute in the specified workspace with an empty string as a name. You can then change the name with setName(). If the workspace argument is null, then use the default workspace. The object is added to the directory of the workspace. Increment the version number of the workspace.
        Parameters:
        workspace - The workspace that will list the attribute.
    • Method Detail

      • addLinkedPort

        public void addLinkedPort​(Port port)
        Add the specified port to the list of ports linked to this vertex.
        Parameters:
        port - The port to link.
      • exportMoML

        public void exportMoML​(java.io.Writer output,
                               int depth,
                               java.lang.String name)
                        throws java.io.IOException
        Write a MoML description of this object. MoML is an XML modeling markup language. In this class, the object is identified by the "property" element, with "name", "class", and "value" (XML) attributes. The body of the element, between the "<property>" and "</property>", is written using the _exportMoMLContents() protected method, so that derived classes can override that method alone to alter only how the contents of this object are described. The text that is written is indented according to the specified depth, with each line (including the last one) terminated with a newline. If the object is non-persistent, then write nothing.
        Specified by:
        exportMoML in interface MoMLExportable
        Overrides:
        exportMoML in class Location
        Parameters:
        output - The output stream to write to.
        depth - The depth in the hierarchy, to determine indenting.
        name - The name to use instead of the current name.
        Throws:
        java.io.IOException - If an I/O error occurs.
        See Also:
        NamedObj.isPersistent()
      • getLinkedVertex

        public Vertex getLinkedVertex()
        Return the other vertex to which there is a path from this vertex, or null if there is none. Note that the paths are one directional, so this vertex might return null even though there is another vertex with a path to it.
        Returns:
        The other vertex or null.
        See Also:
        setLinkedVertex(Vertex)
      • linkedPorts

        public java.util.List linkedPorts()
        Get the list of ports linked to this vertex.
        Returns:
        A list of ports connected to this vertex.
      • removeLinkedPort

        public void removeLinkedPort​(Port port)
        Remove the specified port from the list of ports linked to this vertex. If the port is not linked, do nothing.
        Parameters:
        port - The port to remove.
      • setLinkedVertex

        public void setLinkedVertex​(Vertex vertex)
        Set the other vertex to which there is a path from this vertex. If the argument is null, remove the path.
        Parameters:
        vertex - The vertex to link to this one.
        See Also:
        getLinkedVertex()
      • toString

        public java.lang.String toString()
        Get a description of the class, which is the class name and the location in parentheses.
        Overrides:
        toString in class Location
        Returns:
        A string describing the object.
      • _exportMoMLContents

        protected void _exportMoMLContents​(java.io.Writer output,
                                           int depth)
                                    throws java.io.IOException
        Write a MoML description of the contents of this object, which in this base class is the attributes. This method is called by _exportMoML(). If there are attributes, then each attribute description is indented according to the specified depth and terminated with a newline character.
        Overrides:
        _exportMoMLContents in class NamedObj
        Parameters:
        output - The output stream to write to.
        depth - The depth in the hierarchy, to determine indenting.
        Throws:
        java.io.IOException - If an I/O error occurs.
        See Also:
        NamedObj._exportMoMLContents(java.io.Writer, int)