Package ptolemy.kernel

Examples of ptolemy.kernel.Relation


         */
        public String getDeleteEdgeMoML(Object edge) {
            final Link link = (Link) edge;
            NamedObj linkHead = (NamedObj) link.getHead();
            NamedObj linkTail = (NamedObj) link.getTail();
            Relation linkRelation = link.getRelation();

            // This moml is parsed to execute the change
            StringBuffer moml = new StringBuffer();

            // Make the request in the context of the container.
View Full Code Here


         */
        public void setHead(final Object edge, final Object newLinkHead) {
            final Link link = (Link) edge;
            final NamedObj linkHead = (NamedObj) link.getHead();
            final NamedObj linkTail = (NamedObj) link.getTail();
            Relation linkRelation = link.getRelation();

            // This moml is parsed to execute the change
            final StringBuffer moml = new StringBuffer();

            // This moml is parsed in case the change fails.
View Full Code Here

         */
        public void setTail(final Object edge, final Object newLinkTail) {
            final Link link = (Link) edge;
            final NamedObj linkHead = (NamedObj) link.getHead();
            final NamedObj linkTail = (NamedObj) link.getTail();
            Relation linkRelation = link.getRelation();

            // This moml is parsed to execute the change
            final StringBuffer moml = new StringBuffer();

            // This moml is parsed in case the change fails.
View Full Code Here

                new DFUtilities.NamedObjComparator());

        // Initialize the buffer size of each relation to zero.
        for (Iterator relations = container.relationList().iterator(); relations
                .hasNext();) {
            Relation relation = (Relation) relations.next();
            minimumBufferSize.put(relation, Integer.valueOf(0));
        }

        // First solve the balance equations
        Map entityToFiringsPerIteration = _solveBalanceEquations(container,
View Full Code Here

                fromType = "port";
                Port port = (Port) link.from;
                fromName = port.getContainer().getName() + "." + port.getName();
            } else if (link.from instanceof Relation) {
                fromType = "relation";
                Relation relation = (Relation) link.from;
                fromName = relation.getName();
            } else {
                throw new InternalErrorException(
                        "Expected link.from type to be either "
                                + "Port or Relation.");
            }

            // Set up To information.
            String toType;
            String toName;
            if (link.to instanceof Port) {
                toType = "port";
                Port port = (Port) link.to;
                toName = port.getContainer().getName() + "." + port.getName();
            } else if (link.to instanceof Relation) {
                toType = "relation";
                Relation relation = (Relation) link.to;
                toName = relation.getName();
            } else {
                throw new InternalErrorException(
                        "Expected link.to type to be either "
                                + "Port or Relation.");
            }
View Full Code Here

            throw new InternalErrorException(
                    "Could not find port for From interface: " + interfaceFrom);
        }

        // Determine the From Relation.
        Relation relationFrom;
        if (interfaceFrom.parameters == null) {
            if (_interfaceRelationTable.containsKey(interfaceFrom)) {
                // This is a single (non-parameterized) port, and
                // the relation already exists, so we reuse it.
                Object o = _interfaceRelationTable.get(interfaceFrom);
                if (!(o instanceof Relation)) {
                    throw new InternalErrorException(
                            "Single port should only be connected to a "
                                    + "Relation.");
                }
                relationFrom = (Relation) o;
            } else {
                // This is a single (non-parameterized) port, and
                // the relation does not already exist, so we
                // create a new relation, create a link and a
                // _Link from the port to the new relation, and
                // add the _Link to the list of links.
                String relationName = _relations.getNewRelationName();
                relationFrom = new IORelation(_compositeActor, relationName);
                _interfaceRelationTable.put(interfaceFrom, relationFrom);
                portFrom.link(relationFrom);
                _Link link = new _Link(portFrom, relationFrom);
                _linkList.add(link);
            }
        } else {
            // This is a multi (parameterized) port, so we create
            // a new relation, add it to the relation list of the
            // interface, create a link and a _Link from the port
            // to the new relation, and add the _Link to the list
            // of links.
            String relationName = _relations.getNewRelationName();
            relationFrom = new IORelation(_compositeActor, relationName);
            if (_interfaceRelationTable.containsKey(interfaceFrom)) {
                // If the interface already has a relation list,
                // add the new relation to the list.
                Object o = _interfaceRelationTable.get(interfaceFrom);
                if (!(o instanceof ArrayList)) {
                    throw new InternalErrorException(
                            "Multiport should only be connected to an "
                                    + "ArrayList of Relation.");
                }
                ArrayList arrayList = (ArrayList) o;
                arrayList.add(relationFrom);
            } else {
                // If the interface does not already have a
                // relation list, create it and add the new
                // relation to the list.
                ArrayList arrayList = new ArrayList();
                arrayList.add(relationFrom);
                _interfaceRelationTable.put(interfaceFrom, arrayList);
            }
            portFrom.link(relationFrom);
            _Link link = new _Link(portFrom, relationFrom);
            _linkList.add(link);
        }

        // Determine the To Relation.
        Relation relationTo;
        if (interfaceTo.parameters == null) {
            if (_interfaceRelationTable.containsKey(interfaceTo)) {
                // This is a single (non-parameterized) port, and
                // the relation already exists, so we reuse it.
                Object o = _interfaceRelationTable.get(interfaceTo);
View Full Code Here

        // any that don't have both ends in the model.
        Iterator links = _linkSet.iterator();

        while (links.hasNext()) {
            Link link = (Link) links.next();
            Relation relation = link.getRelation();

            // Undo needs this: Check that the relation hasn't been removed
            if ((relation == null) || (relation.getContainer() == null)
                    || _isHidden(relation)) {
                // NOTE: We used to not do the next three lines when
                // relation == null, but this seems better.
                // EAL 6/26/05.
                link.setHead(null);
                link.setTail(null);
                links.remove();
                continue;
            }

            boolean headOK = GraphUtilities.isContainedNode(link.getHead(),
                    getRoot(), this);
            boolean tailOK = GraphUtilities.isContainedNode(link.getTail(),
                    getRoot(), this);

            // If the head or tail has been removed, then remove this link.
            if (!(headOK && tailOK)) {
                Object headObj = getSemanticObject(link.getHead());
                Object tailObj = getSemanticObject(link.getTail());
                link.setHead(null);
                link.setTail(null);
                links.remove();

                if (headObj instanceof Port && tailObj instanceof Port
                        && (relation.getContainer() != null)) {
                    NamedObj container = getPtolemyModel();

                    // remove the relation  This should trigger removing the
                    // other link.  This avoids turning a direct connection
                    // into a half connection with a diamond.
                    // Note that the source is NOT the graphmodel, so this
                    // will trigger the changerequest listener to
                    // redraw the graph again.
                    MoMLChangeRequest request = new MoMLChangeRequest(
                            container, container, "<deleteRelation name=\""
                                    + relation.getName(container) + "\"/>\n");
                    request.setUndoable(true);

                    // Need to merge the undo for this request in with one that
                    // triggered it
                    request.setMergeWithPreviousUndo(true);
View Full Code Here

                        objectNameToCreatorName);
            }

            for (Iterator relations = composite.relationList().iterator(); relations
                    .hasNext();) {
                Relation relation = (Relation) relations.next();
                updateCreatedSet(prefix, context, relation,
                        objectNameToCreatorName);
            }
        }
View Full Code Here

            CompositeActor composite, EntitySootClass modelClass) {
        _relationLocalMap = new HashMap();

        for (Iterator relations = composite.relationList().iterator(); relations
                .hasNext();) {
            Relation relation = (Relation) relations.next();
            String className = relation.getClass().getName();
            //String fieldName = getFieldNameForRelation(relation, composite);

            // Create a new local variable.
            Local local = PtolemyUtilities.createNamedObjAndLocal(body,
                    className, thisLocal, relation.getName());
            _relationLocalMap.put(relation, local);

            //             SootUtilities.createAndSetFieldFromLocal(body,
            //                     local, modelClass, PtolemyUtilities.relationType,
            //                     fieldName);
View Full Code Here

                        }
                    }
                }

                // Rename the corresponding relation.
                Relation relation = container.getRelation(oldName + "Relation");

                if (relation != null) {
                    relation.setName(name + "Relation");
                }
            }
        } finally {
            _workspace.doneWriting();
        }
View Full Code Here

TOP

Related Classes of ptolemy.kernel.Relation

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.