Package ptolemy.kernel.util

Examples of ptolemy.kernel.util.Attribute


     @param name The name of the attribute, relative or absolute.
     *  @return The attribute.
     *  @exception XmlException If the attribute is not found.
     */
    private Attribute _searchForAttribute(String name) throws XmlException {
        Attribute result = null;

        // If the name is absolute, strip the prefix.
        String currentName = "(no top level)";

        if (_current != null) {
View Full Code Here


                }

                // FIXME: The following is not called on EntityLibrary,
                // which means no tooltip for those. Does calling it
                // force expansion of the library?
                Attribute tooltipAttribute = object.getAttribute("tooltip");

                if ((tooltipAttribute != null)
                        && tooltipAttribute instanceof Documentation) {
                    // FIXME: This doesn't work with calling this
                    // on either this or component.
View Full Code Here

                // is a visible attribute if it contains an instance
                // of Locatable.
                Iterator attributes = composite.attributeList().iterator();

                while (attributes.hasNext()) {
                    Attribute attribute = (Attribute) attributes.next();
                    List locations = attribute.attributeList(Locatable.class);

                    if ((locations.size() > 0)
                            && (attribute.getAttribute("_renderFirst") != null)) {
                        nodes.add(locations.get(0));
                    }
                }

                if (composite instanceof CompositeEntity) {
                    // Add a graph node for every class definition.
                    // The node is actually the location contained by the entity.
                    // If the entity does not contain a location, then create one.
                    Iterator classes = ((CompositeEntity) composite)
                            .classDefinitionList().iterator();

                    while (classes.hasNext()) {
                        ComponentEntity entity = (ComponentEntity) classes
                                .next();
                        nodes.add(_getLocation(entity));
                    }

                    // Add a graph node for every entity.
                    // The node is actually the location contained by the entity.
                    // If the entity does not contain a location, then create one.
                    Iterator entities = ((CompositeEntity) composite)
                            .entityList().iterator();

                    while (entities.hasNext()) {
                        ComponentEntity entity = (ComponentEntity) entities
                                .next();
                        nodes.add(_getLocation(entity));
                    }
                }

                if (composite instanceof Entity) {
                    // Add a graph node for every external port.
                    // 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) {
                    // Add a node for every relation that has a vertex and
                    // doesn't connect exactly two ports.
                    // NOTE: This particular part of the graph model is irrelevant
                    // for FSMs, but it is harmless to include it, so there is no
                    // real need to subclass this to remove it.
                    Iterator relations = ((CompositeEntity) composite)
                            .relationList().iterator();

                    while (relations.hasNext()) {
                        ComponentRelation relation = (ComponentRelation) relations
                                .next();
                        List vertexList = relation.attributeList(Vertex.class);

                        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!");
                                }
                            }
                        }
                    }
                }

                // Add a node for every director or visible attribute.
                // The node is again the location.
                // For directors, if there is no location, then create one.
                // For visible attributes, add them only if they already
                // create a location.
                attributes = composite.attributeList().iterator();

                while (attributes.hasNext()) {
                    Attribute attribute = (Attribute) attributes.next();

                    if ((attribute.getAttribute("_renderFirst") != null)
                            || (attribute.getAttribute("_renderLast") != null)) {
                        // Already rendered, or to be rendered later.
                        continue;
                    }

                    if (attribute instanceof Director) {
                        nodes.add(_getLocation(attribute));
                    } else {
                        // The object is not a director, so only give a location
                        // if one exists already.
                        List locations = attribute
                                .attributeList(Locatable.class);

                        if (locations.size() > 0) {
                            nodes.add(locations.get(0));
                        }
                    }
                }
            }

            if (after) {
                // Add a node for visible attributes that contains
                // an attribute named "_renderLast".  An attribute
                // is a visible attribute if it contains an instance
                // of Locatable.
                Iterator attributes = composite.attributeList().iterator();

                while (attributes.hasNext()) {
                    Attribute attribute = (Attribute) attributes.next();
                    List locations = attribute.attributeList(Locatable.class);

                    if ((locations.size() > 0)
                            && (attribute.getAttribute("_renderLast") != null)) {
                        nodes.add(locations.get(0));
                    }
                }
            }
View Full Code Here

    public List getChildren() {
        List results = new LinkedList();
        Iterator attributes = attributeList().iterator();
        while (attributes.hasNext()) {
            Attribute attribute = (Attribute) attributes.next();
            results.add(new WeakReference(attribute));
        }
        return results;
    }
View Full Code Here

                try {
                    result.setName("topLibrary");

                    // Put a marker in so that this is
                    // recognized as a library.
                    new Attribute(result, "_libraryMarker");
                } catch (Exception ex) {
                    throw new InternalErrorException(
                            "Library configuration failed: " + ex);
                }
            }
View Full Code Here

    private void _updateTypeDisplay(TypedIOPort port) {
        // Construct the name of the type label from the name
        // of the port relative to the top level.
        String portName = port.getName(_toplevel);
        String labelName = portName.replace('.', '_');
        Attribute label = _toplevel.getAttribute(labelName);

        if (label != null) {
            Configurable config = (Configurable) label
                    .getAttribute("_iconDescription");

            if (config != null) {
                String moml = "<property name=" + "\"_iconDescription\" "
                        + "class=\"ptolemy.kernel.util"
                        + ".SingletonConfigurableAttribute\">"
                        + "<configure><svg><text x=\"20\" "
                        + "style=\"font-size:14; font-family:sanserif; "
                        + "fill:red\" y=\"20\">" + port.getType()
                        + "</text></svg></configure></property>";
                label.requestChange(new MoMLChangeRequest(this, label, moml));
            }
        }
    }
View Full Code Here

                    // than 0, then return the value of _currentTime
                    // See codegen/kernel/StaticSchedulingCodeGenerator.java.
                    // FIXME: should we check for period being set anywhere
                    // in the hierarchy?
                    Director director = _actor.getDirector();
                    Attribute period = director.getAttribute("period");
                    if (period != null) {
                        Double periodValue = ((DoubleToken) ((Variable) period)
                                .getToken()).doubleValue();
                        if (periodValue != 0.0) {
                            return new ObjectToken("_currentTime");
                        }
                    }
                    return new DoubleToken("0.0");
                } else if (name.equals("iteration")) {
                    return new ObjectToken("$actorSymbol(iterationCount)");
                }

                for (int i = 0; i < _actor.inputPortList().size(); i++) {
                    if (((IOPort) _actor.inputPortList().get(i)).getName()
                            .equals(name)) {
                        return new ObjectToken("$ref(" + name + ")");
                    }
                }

                Attribute attribute = _actor.getAttribute(name);

                if (attribute == null) {
                    attribute = ModelScope
                            .getScopedVariable(null, _actor, name);
                }
View Full Code Here

            boolean match = false;

            NamedObj model = _toplevel;
            System.out.println("model = " + model.getFullName());

            Attribute attribute = model.getAttribute(name);

            if (attribute instanceof Settable) {
                match = true;
                ((Settable) attribute).setExpression(value);
View Full Code Here

    // Search in the container for an attribute with the given name.
    // Search recursively in any instance of ScopeExtender in the
    // container.
    private static Variable _searchIn(Variable exclude, NamedObj container,
            String name) {
        Attribute result = container.getAttribute(name);

        if ((result != null) && result instanceof Variable
                && (result != exclude)) {
            return (Variable) result;
        } else {
View Full Code Here

                    // Default values:
                    int widthValue = 30;
                    int heightValue = 10;

                    Attribute widthAttribute = ((NamedObj) attribute)
                            .getAttribute("_textWidthHint");
                    if (widthAttribute instanceof Variable) {
                        Token token = ((Variable) widthAttribute).getToken();
                        if (token instanceof IntToken) {
                            widthValue = ((IntToken) token).intValue();
                        }
                    }
                    Attribute heightAttribute = ((NamedObj) attribute)
                            .getAttribute("_textHeightHint");
                    if (heightAttribute instanceof Variable) {
                        Token token = ((Variable) heightAttribute).getToken();
                        if (token instanceof IntToken) {
                            heightValue = ((IntToken) token).intValue();
View Full Code Here

TOP

Related Classes of ptolemy.kernel.util.Attribute

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.