Package ptolemy.kernel

Examples of ptolemy.kernel.Relation


                // Create the appropriate links.
                ModalModel container = (ModalModel) getContainer();

                if (container != null) {
                    String relationName = name + "Relation";
                    Relation relation = container.getRelation(relationName);

                    if (relation == null) {
                        relation = container.newRelation(relationName);

                        Port containerPort = container.getPort(name);
View Full Code Here


                // Create the appropriate links.
                ModalModel container = (ModalModel) getContainer();

                if (container != null) {
                    String relationName = name + "Relation";
                    Relation relation = container.getRelation(relationName);

                    if (relation == null) {
                        relation = container.newRelation(relationName);

                        Port containerPort = container.getPort(name);
View Full Code Here

        IndexedList currentList = new IndexedList(relationList, 0);
        path.add(currentList);
        Path.Entry currentListEntry = path.getTail();

        for (Object relationObject : relationList) {
            Relation relation = (Relation) relationObject;
            if (visitedRelations.contains(relation)
                    || _ignoreRelation(relation)) {
                i++;
                continue;
            }

            currentList.setSecond(i);
            visitedRelations.add(relation);
            List<?> portList = relation.linkedPortList();

            int j = 0;
            IndexedList currentList2 = new IndexedList(portList, 0);
            path.add(currentList2);
            Path.Entry currentListEntry2 = path.getTail();
View Full Code Here

                        return true;
                    }

                    visitedPorts.remove(port);
                } else {
                    Relation relation = (Relation) nextObject;
                    if (visitedRelations.contains(relation)
                            || _ignoreRelation(relation)) {
                        continue;
                    }

                    visitedRelations.add(relation);
                    List<?> portList = relation.linkedPortList();

                    int i = 0;
                    for (Object portObject : portList) {
                        Port port = (Port) portObject;
                        if (visitedPorts.contains(port)) {
View Full Code Here

        // connect ctInc
        //ctInc.connect(ctIncIn, ctIncH.input);
        //ctInc.connect(ctIncH.output, ctIncI.input);
        ctInc.connect(ctIncIn, ctIncI.input);

        Relation ctIncR2 = ctInc.newRelation("R2");
        ctIncGF.output.link(ctIncR2);
        ctIncD.trigger.link(ctIncR2);
        ctIncTr.link(ctIncR2);
        ctInc.connect(ctIncD.output, ctIncOut);

        //ctInc.connect(ctIncS.output, ctIncSt);
        TypedIORelation ctIncR1 = (TypedIORelation) ctInc
                .newRelation("CTIncR1");
        ctIncI.output.link(ctIncR1);

        //ctIncS.input.link(ctIncR1);
        ctIncGFi.link(ctIncR1);
        ctIncSt.link(ctIncR1);

        CTEmbeddedDirector ctIncDir = new CTEmbeddedDirector(ctInc, "CTIncDir");

        //ctIncDir.addDebugListener(dbl);
        CTCompositeActor ctDec = new CTCompositeActor(hs, "Decreasing");

        //ctDec.addDebugListener(dbl);
        //ZeroOrderHold ctDecH = new ZeroOrderHold(ctDec, "Hold");
        Integrator ctDecI = new Integrator(ctDec, "Integrator");
        Scale ctGain = new Scale(ctDec, "Gain");
        ZeroCrossingDetector ctDecD = new ZeroCrossingDetector(ctDec, "ZD");

        Expression ctDecGF = new Expression(ctDec, "EXPRESSION");
        TypedIOPort ctDecGFi = (TypedIOPort) ctDecGF.newPort("in");
        ctDecGFi.setInput(true);
        ctDecGFi.setTypeEquals(BaseType.DOUBLE);
        ctDecGF.output.setTypeEquals(BaseType.DOUBLE);
        ctDecGF.expression.setExpression("in + 0.0");

        // the ports
        TypedIOPort ctDecIn = (TypedIOPort) ctDec.newPort("input");
        ctDecIn.setInput(true);
        ctDecIn.setTypeEquals(BaseType.DOUBLE);

        TypedIOPort ctDecOut = (TypedIOPort) ctDec.newPort("output");
        ctDecOut.setOutput(true);
        ctDecOut.setTypeEquals(BaseType.DOUBLE);

        TypedIOPort ctDecSt = (TypedIOPort) ctDec.newPort("state");
        ctDecSt.setOutput(true);
        ctDecSt.setTypeEquals(BaseType.DOUBLE);

        TypedIOPort ctDecTr = (TypedIOPort) ctDec.newPort("trig");
        ctDecTr.setOutput(true);
        ctDecTr.setTypeEquals(BaseType.DOUBLE);

        // connect ctDec
        //ctDec.connect(ctDecIn, ctDecH.input);
        //ctDec.connect(ctDecH.output, ctGain.input);
        ctDec.connect(ctDecIn, ctGain.input);
        ctDec.connect(ctGain.output, ctDecI.input);

        Relation ctDecR2 = ctDec.newRelation("R2");
        ctDecGF.output.link(ctDecR2);
        ctDecD.trigger.link(ctDecR2);
        ctDecTr.link(ctDecR2);
        ctDec.connect(ctDecD.output, ctDecOut);

        //ctDec.connect(ctDecS.output, ctDecSt);
        TypedIORelation ctDecR1 = (TypedIORelation) ctDec
                .newRelation("CTDecR1");
        ctDecI.output.link(ctDecR1);

        //ctDecS.input.link(ctDecR1);
        ctDecGFi.link(ctDecR1);
        ctDecSt.link(ctDecR1);

        CTEmbeddedDirector ctDecDir = new CTEmbeddedDirector(ctDec, "CTDecDir");

        //ctDecDir.addDebugListener(dbl);
        ctrlInc.refinementName.setExpression("Increasing");
        ctrlDec.refinementName.setExpression("Decreasing");

        // connect hs
        TypedIORelation hsr1 = (TypedIORelation) hs.newRelation("HSr1");
        hsin.link(hsr1);
        ctIncIn.link(hsr1);
        ctDecIn.link(hsr1);

        TypedIORelation hsr2 = (TypedIORelation) hs.newRelation("HSr2");
        ctrlIn.link(hsr2);
        ctIncOut.link(hsr2);
        ctDecOut.link(hsr2);

        TypedIORelation hsr3 = (TypedIORelation) hs.newRelation("HSr3");
        hsst.link(hsr3);
        ctIncSt.link(hsr3);
        ctDecSt.link(hsr3);
        ctrlSt.link(hsr3);

        Relation hsr4 = hs.newRelation("HSr4");

        //hstr.link(hsr4);
        ctIncTr.link(hsr4);
        ctDecTr.link(hsr4);
View Full Code Here

        public Figure render(Object node) {
            // Default values.
            double height = 12.0;
            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");

                if (relationSize instanceof DoubleToken) {
                    height = ((DoubleToken) relationSize).doubleValue();
                    width = height;
                }
            }

            Polygon2D.Double polygon = new Polygon2D.Double();
            polygon.moveTo(width / 2, 0);
            polygon.lineTo(0, height / 2);
            polygon.lineTo(-width / 2, 0);
            polygon.lineTo(0, -height / 2);
            polygon.closePath();

            Figure figure = new BasicFigure(polygon, Color.black);

            if (node != null) {
                ActorGraphModel model = (ActorGraphModel) getController()
                        .getGraphModel();
                figure
                        .setToolTipText(relation.getName(model
                                .getPtolemyModel()));
                // Old way to set the color.
                try {
                    StringAttribute colorAttr = (StringAttribute) (relation
                            .getAttribute("_color", StringAttribute.class));

                    if (colorAttr != null) {
                        String color = colorAttr.getExpression();
                        ((BasicFigure) figure).setFillPaint(SVGUtilities
                                .getColor(color));
                    }
                } catch (IllegalActionException e) {
                    // Ignore.
                }
                // New way to set the color
                try {
                    ColorAttribute colorAttr = (ColorAttribute) (relation
                            .getAttribute("_color", ColorAttribute.class));
                    if (colorAttr != null) {
                        Color color = colorAttr.asColor();
                        ((BasicFigure) figure).setFillPaint(color);
                    }
View Full Code Here

                // Create the appropriate links.
                ModalModel container = (ModalModel) getContainer();

                if (container != null) {
                    String relationName = name + "Relation";
                    Relation relation = container.getRelation(relationName);

                    if (relation == null) {
                        relation = container.newRelation(relationName);

                        Port containerPort = container.getPort(name);
View Full Code Here

                if (className != null) {
                    newClass = Class.forName(className, true, _classLoader);
                }

                Relation relation = container.getRelation(relationName);

                // Flag used to generate correct undo MoML
                boolean alreadyExisted = (relation != null);

                if (relation == null) {
View Full Code Here

        } else {
            // The entity is derived, so we should only include
            // relations that are not derived.
            Iterator relations = toDelete.linkedRelationList().iterator();
            while (relations.hasNext()) {
                Relation relation = (Relation) relations.next();
                if (relation != null) {
                    if (relation.getDerivedLevel() == Integer.MAX_VALUE) {
                        filter.add(relation);
                    }
                }
            }
        }
View Full Code Here

        // Get relation if given
        ComponentRelation relation = null;

        if (relationName != null) {
            Relation tmpRelation = context.getRelation(relationName);
            _checkForNull(tmpRelation, "No relation named \"" + relationName
                    + "\" in " + context.getFullName());
            relation = (ComponentRelation) tmpRelation;
        }
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.