Package ptolemy.kernel.util

Examples of ptolemy.kernel.util.StringAttribute


        description = new StringParameter(this, "description");
        TextStyle style = new TextStyle(description, "_style");
        style.height.setExpression("10");
        style.width.setExpression("70");

        author = new StringAttribute(this, "author");
        version = new StringAttribute(this, "version");
        since = new StringAttribute(this, "since");

        refreshParametersAndPorts();

        // Hide the name, if this gets instantiated in Vergil.
        SingletonParameter hide = new SingletonParameter(this, "_hideName");
View Full Code Here


     @param name The name of the port.
     *  @return The documentation for the given port, or null if there
     *   is none.
     */
    public String getPortDoc(String name) {
        StringAttribute portAttribute = (StringAttribute) getAttribute(name
                + " (port)");
        if (portAttribute != null) {
            return portAttribute.getExpression();
        }
        return null;
    }
View Full Code Here

                    continue;
                }
                String name = port.getName() + " (port)";
                if (getAttribute(name) == null) {
                    try {
                        new StringAttribute(this, name);
                    } catch (KernelException e) {
                        throw new InternalErrorException(e);
                    }
                }
            }
View Full Code Here

        public Factory(NamedObj container, String name)
                throws IllegalActionException, NameDuplicationException {
            super(container, name);

            attributeName = new StringAttribute(this, "attributeName");
        }
View Full Code Here

     */
    public AttributeValueIcon(NamedObj container, String name)
            throws NameDuplicationException, IllegalActionException {
        super(container, name);

        attributeName = new StringAttribute(this, "attributeName");

        displayWidth = new Parameter(this, "displayWidth");
        displayWidth.setExpression("6");
        displayWidth.setTypeEquals(BaseType.INT);

View Full Code Here

     */
    public Effigy(Workspace workspace) {
        super(workspace);

        try {
            identifier = new StringAttribute(this, "identifier");
            identifier.setExpression("Unnamed");
            uri = new URIAttribute(this, "uri");
        } catch (Throwable throwable) {
            throw new InternalErrorException(this, throwable,
                    "Can't create identifier!");
View Full Code Here

     *   an entity already in the container.
     */
    public Effigy(CompositeEntity container, String name)
            throws IllegalActionException, NameDuplicationException {
        super(container, name);
        identifier = new StringAttribute(this, "identifier");
        identifier.setExpression("Unnamed");
        uri = new URIAttribute(this, "uri");
    }
View Full Code Here

        // re-order the ports according to _ordinal property
        private void _reOrderPorts(Vector ports) {
            int size = ports.size();
            Enumeration enumeration = ports.elements();
            Port port;
            StringAttribute ordinal = null;
            int number = 0;
            int index = 0;

            while (enumeration.hasMoreElements()) {
                port = (Port) enumeration.nextElement();
                ordinal = (StringAttribute) port.getAttribute("_ordinal");

                if (ordinal != null) {
                    number = Integer.parseInt(ordinal.getExpression());

                    if (number >= size) {
                        ports.remove(index);

                        try {
                            ordinal.setExpression(Integer.toString(size - 1));
                        } catch (Exception e) {
                            MessageHandler.error(
                                    "Error setting ordinal property", e);
                        }

                        ports.add(port);
                    } else if (number < 0) {
                        ports.remove(index);

                        try {
                            ordinal.setExpression(Integer.toString(0));
                        } catch (Exception e) {
                            MessageHandler.error(
                                    "Error setting ordinal property", e);
                        }
View Full Code Here

                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);
                    }
                } catch (IllegalActionException e) {
                    // Ignore.
                }
View Full Code Here

    public IDAttribute(Entity container, String name)
            throws IllegalActionException, NameDuplicationException {
        super(container, name);

        // name for the model
        this.name = new StringAttribute(this, "name");
        this.name.setExpression(container.getName());

        // This should not be persistent, in case the name changes outside
        // of this parameter.
        this.name.setPersistent(false);

        // This should not be editable, since the name is set by saveAs.
        this.name.setVisibility(Settable.NOT_EDITABLE);

        // FIXME: Need to listen for changes to the name.
        // How to do that?
        // The current design is also a solution in that the name of this
        // attribute and model must be consistent with the name of the file.
        // boolean isClass = false;
        //if (container instanceof InstantiableNamedObj) {
        /* isClass = */((InstantiableNamedObj) container).isClassDefinition();
        //}

        String className = container.getClassName();

        baseClass = new StringAttribute(this, "baseClass");
        baseClass.setExpression(className);

        // This should not be persistent, because the base class
        // is set already, generally.
        baseClass.setPersistent(false);

        // Cannot change the base class.
        baseClass.setVisibility(Settable.NOT_EDITABLE);

        URIAttribute modelURI = (URIAttribute) container.getAttribute("_uri",
                URIAttribute.class);

        if (modelURI != null) {
            StringAttribute definedIn = new StringAttribute(this, "definedIn");
            definedIn.setExpression(modelURI.getURI().toString());
            definedIn.setPersistent(false);
            definedIn.setVisibility(Settable.NOT_EDITABLE);
        }

        // The date when this model is created.
        // Actually, it is the date when this attribute is created.
        // We assume that when the model is created, this attribute
        // is also created.
        // We may force this to happen.:-) Further more, we may force
        // that only the top level contains an model ID.
        created = new StringAttribute(this, "created");
        created.setExpression(DateFormat.getDateTimeInstance().format(
                new Date()));
        created.setVisibility(Settable.NOT_EDITABLE);
        created.setPersistent(true);

        // The date when this model is modified.
        // Everytime the model gets modified, the updateContent method
        // defined below is called and the lastUpdated attribute gets
        // updated.
        lastUpdated = new StringAttribute(this, "lastUpdated");
        _updateDate();
        lastUpdated.setVisibility(Settable.NOT_EDITABLE);
        lastUpdated.setPersistent(true);

        // The name of the author who creates the model.
        // This attribute can not be changed so that the
        // intellectual property (IP) is preserved.
        author = new StringAttribute(this, "author");
        author.setVisibility(Settable.NOT_EDITABLE);

        String userName = null;

        try {
            userName = StringUtilities.getProperty("user.name");
        } catch (Exception ex) {
            System.out.println("Warning, in IDAttribute, failed to read "
                    + "'user.name' property (-sandbox or applets always cause "
                    + "this)");
        }

        if (userName != null) {
            author.setExpression(userName);
        }

        author.setPersistent(true);

        // The names of the contributors who modify the model.
        contributors = new StringAttribute(this, "contributors");

        String contributorsNames = "";
        contributors.setExpression(contributorsNames);
        author.setPersistent(true);

View Full Code Here

TOP

Related Classes of ptolemy.kernel.util.StringAttribute

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.