Package ptolemy.moml

Examples of ptolemy.moml.Vertex


         *   a relation.
         *  @return An iterator of Link objects, all of which have their
         *   head as the given node.
         */
        public Iterator inEdges(Object node) {
            Vertex vertex = (Vertex) node;

            // Go through all the links, creating a list of
            // those we are connected to.
            List vertexLinkList = new LinkedList();
            Iterator links = _linkSet.iterator();
View Full Code Here


         *   a relation.
         *  @return An iterator of Link objects, all of which have their
         *   tail as the given node.
         */
        public Iterator outEdges(Object node) {
            Vertex vertex = (Vertex) node;

            // Go through all the links, creating a list of
            // those we are connected to.
            List vertexLinkList = new LinkedList();
            Iterator links = _linkSet.iterator();
View Full Code Here

            return;
        }

        // Get the Root vertex.  This is where we will manufacture links.
        // The root vertex is the one with no linked vertices.
        Vertex rootVertex = null;
        Iterator vertexes = relation.attributeList(Vertex.class).iterator();

        while (vertexes.hasNext()) {
            Vertex v = (Vertex) vertexes.next();

            if (v.getLinkedVertex() == null) {
                rootVertex = v;
            }
        }

        // If there are no verticies, and the relation has exactly
        // two connections, neither of which has been made yet, then
        // create a link without a vertex for the relation.
        if ((rootVertex == null) && (linkedObjectsCount == 2)
                && (unlinkedPortCount == 2)
                && linkedObjects.get(0) instanceof Port
                && linkedObjects.get(1) instanceof Port) {
            Port port1 = (Port) linkedObjects.get(0);
            Port port2 = (Port) linkedObjects.get(1);
            Object head = null;
            Object tail = null;

            if (port1.getContainer().equals(getRoot())) {
                head = _getLocation(port1);
            } else {
                head = port1;
            }

            if (port2.getContainer().equals(getRoot())) {
                tail = _getLocation(port2);
            } else {
                tail = port2;
            }

            Link link;

            try {
                link = new Link();
                _linkSet.add(link);
            } catch (Exception e) {
                throw new InternalErrorException("Failed to create "
                        + "new link, even though one does not "
                        + "already exist:" + e.getMessage());
            }

            link.setRelation(relation);
            link.setHead(head);
            link.setTail(tail);
        } else {
            // A regular relation with a diamond.
            // Create a vertex if one is not found.
            if (rootVertex == null) {
                try {
                    String name = relation.uniqueName("vertex");
                    rootVertex = new Vertex(relation, name);

                    // Have to manually handle propagation, since
                    // the MoML parser is not involved.
                    // FIXME: This could cause a name collision!
                    // (Unlikely though since auto naming will take
                    // into account subclasses).
                    rootVertex.propagateExistence();
                } catch (Throwable throwable) {
                    throw new InternalErrorException(null, throwable,
                            "Failed to create "
                                    + "new vertex, even though one does not "
                                    + "already exist:" + throwable.getMessage());
                }
            }

            // Create any required links for this relation.
            Iterator linkedObjectsIterator = linkedObjects.iterator();

            while (linkedObjectsIterator.hasNext()) {
                Object portOrRelation = linkedObjectsIterator.next();

                // Set the head to the port or relation. More precisely:
                //   If it is a port belonging to the composite, then
                //   set the head to a Location contained by the port.
                //   If is a port belonging to an actor, then set
                //   the head to the port.
                //   If it is a relation, then set the head to the
                //   root vertex of the relation.
                Object head = null;

                if (portOrRelation instanceof Port) {
                    Port port = (Port) portOrRelation;

                    if (port.getContainer().equals(getRoot())) {
                        head = _getLocation(port);
                    } else {
                        head = port;
                    }
                } else {
                    // Get the Root vertex of the other relation.
                    // The root vertex is the one with no linked vertices.
                    vertexes = ((Relation) portOrRelation).attributeList(
                            Vertex.class).iterator();

                    while (vertexes.hasNext()) {
                        Vertex v = (Vertex) vertexes.next();

                        if (v.getLinkedVertex() == null) {
                            head = v;
                        }
                    }
                }
View Full Code Here

                        if (vertexList.size() != 0) {
                            // Add in all the vertexes.
                            Iterator vertexes = vertexList.iterator();

                            while (vertexes.hasNext()) {
                                Vertex v = (Vertex) vertexes.next();
                                nodes.add(v);
                            }
                        } else {
                            // See if we need to create a vertex.
                            // Count the linked ports.
                            int count = relation.linkedPortList().size();

                            if (count != 2) {
                                // A vertex is needed, so create one.
                                try {
                                    String name = relation.uniqueName("vertex");
                                    Vertex vertex = new Vertex(relation, name);
                                    nodes.add(vertex);

                                    // Have to manually handle propagation, since
                                    // the MoML parser is not involved.
                                    // FIXME: Could get name collision here!
                                    // (Unlikely though since auto naming will take
                                    // into account subclasses).
                                    vertex.propagateExistence();
                                } catch (Throwable throwable) {
                                    throw new InternalErrorException(null,
                                            throwable,
                                            "Failed to create a vertex!");
                                }
View Full Code Here

            double width = 12.0;

            Relation relation = null;

            if (node != null) {
                Vertex vertex = (Vertex) node;
                relation = (Relation) vertex.getContainer();

                // NOTE: The preferences mechanism may set this.
                Token relationSize = PtolemyPreferences.preferenceValue(
                        relation, "_relationSize");
View Full Code Here

TOP

Related Classes of ptolemy.moml.Vertex

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.