Package ptolemy.kernel

Examples of ptolemy.kernel.ComponentPort


                NamedObj head = (NamedObj) getSemanticObject(linkHead);
                NamedObj tail = (NamedObj) getSemanticObject(linkTail);

                if (head instanceof ComponentPort
                        && tail instanceof ComponentPort) {
                    ComponentPort headPort = (ComponentPort) head;
                    ComponentPort tailPort = (ComponentPort) tail;
                    NamedObj ptolemyModel = getPtolemyModel();

                    // Linking two ports with a new relation.
                    String relationName = ptolemyModel.uniqueName("relation");

                    // If the context is not the entity that we're editing,
                    // then we need to set the context correctly.
                    if (ptolemyModel != container) {
                        String contextString = "<entity name=\""
                                + ptolemyModel.getName(container) + "\">\n";
                        moml.append(contextString);
                        failmoml.append(contextString);
                    }

                    // Note that we use no class so that we use the container's
                    // factory method when this gets parsed
                    moml.append("<relation name=\"" + relationName + "\"/>\n");
                    moml.append("<link port=\""
                            + headPort.getName(ptolemyModel) + "\" relation=\""
                            + relationName + "\"/>\n");
                    moml.append("<link port=\""
                            + tailPort.getName(ptolemyModel) + "\" relation=\""
                            + relationName + "\"/>\n");

                    // Record moml so that we can blow away these
                    // links in case we can't create them
                    failmoml.append("<unlink port=\""
                            + headPort.getName(ptolemyModel) + "\" relation=\""
                            + relationName + "\"/>\n");
                    failmoml.append("<unlink port=\""
                            + tailPort.getName(ptolemyModel) + "\" relation=\""
                            + relationName + "\"/>\n");
                    failmoml.append("<deleteRelation name=\"" + relationName
                            + "\"/>\n");

                    // close the context
View Full Code Here


         @param node The node, which is assumed to be a port.
         *  @return The (presumably unique) icon contained in the port's
         *   container.
         */
        public Object getParent(Object node) {
            ComponentPort port = (ComponentPort) node;
            Entity entity = (Entity) port.getContainer();

            if (entity == null) {
                return null;
            }

View Full Code Here

         *   the root of this graph model.
         *  @return An iterator of Link objects, all of which have their
         *   head as the given node.
         */
        public Iterator inEdges(Object node) {
            ComponentPort port = (ComponentPort) node;

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

         *   the root of this graph model.
         *  @return An iterator of Link objects, all of which have their
         *   tail as the given node.
         */
        public Iterator outEdges(Object node) {
            ComponentPort port = (ComponentPort) node;

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

         @param eventSource The source of the event that will be dispatched,
         *   e.g. the view that made this call.
         *  @param node The node.
         */
        public void removeNode(final Object eventSource, Object node) {
            ComponentPort port = (ComponentPort) node;
            NamedObj container = port.getContainer();
            ;

            // Delete the port.
            String moml = "<deletePort name=\"" + port.getName() + "\"/>\n";

            // Note: The source is NOT the graph model.
            MoMLChangeRequest request = new MoMLChangeRequest(this, container,
                    moml);
            request.setUndoable(true);
View Full Code Here

         @param node The node.
         *  @return A valid MoML string.
         */
        public String getDeleteNodeMoML(Object node) {
            Locatable location = (Locatable) node;
            ComponentPort port = (ComponentPort) location.getContainer();
            StringBuffer moml = new StringBuffer();
            moml.append("<deletePort name=\"" + port.getName() + "\"/>\n");
            return moml.toString();
        }
View Full Code Here

         *   e.g. the view that made this call.
         *  @param node The node.
         */
        public void removeNode(final Object eventSource, Object node) {
            Locatable location = (Locatable) node;
            ComponentPort port = (ComponentPort) location.getContainer();
            NamedObj container = port.getContainer();
            ;

            StringBuffer moml = new StringBuffer();
            moml.append("<deletePort name=\"" + port.getName(container)
                    + "\"/>\n");

            // Note: The source is NOT the graph model.
            MoMLChangeRequest request = new MoMLChangeRequest(this, container,
                    moml.toString());
View Full Code Here

                    // The node is actually the location contained by the port.
                    // If the port does not contain a location, then create one.
                    Iterator ports = ((Entity) composite).portList().iterator();

                    while (ports.hasNext()) {
                        ComponentPort port = (ComponentPort) ports.next();
                        nodes.add(_getLocation(port));
                    }
                }

                if (composite instanceof CompositeEntity) {
View Full Code Here

    private static void _links(JimpleBody body, CompositeActor composite) {
        // To get the ordering right,
        // we read the links from the ports, not from the relations.
        // First, produce the inside links on contained ports.
        for (Iterator ports = composite.portList().iterator(); ports.hasNext();) {
            ComponentPort port = (ComponentPort) ports.next();
            Iterator relations = port.insideRelationList().iterator();
            int index = -1;

            while (relations.hasNext()) {
                index++;
View Full Code Here

        for (Iterator entities = composite.deepEntityList().iterator(); entities
                .hasNext();) {
            ComponentEntity entity = (ComponentEntity) entities.next();

            for (Iterator ports = entity.portList().iterator(); ports.hasNext();) {
                ComponentPort port = (ComponentPort) ports.next();

                Local portLocal;

                // If we already have a local reference to the port
                if (_portLocalMap.keySet().contains(port)) {
                    // then just get the reference.
                    portLocal = (Local) _portLocalMap.get(port);
                } else {
                    throw new RuntimeException("Found a port: " + port
                            + " that does not have a local variable!");
                }

                Iterator relations = port.linkedRelationList().iterator();
                int index = -1;

                while (relations.hasNext()) {
                    index++;
View Full Code Here

TOP

Related Classes of ptolemy.kernel.ComponentPort

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.