ptolemy.vergil.kernel.attributes
Class AttributeValueAttribute

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.util.Attribute
          extended by ptolemy.vergil.kernel.attributes.VisibleAttribute
              extended by ptolemy.vergil.kernel.attributes.AbstractTextAttribute
                  extended by ptolemy.vergil.kernel.attributes.AttributeValueAttribute
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable, Settable, ValueListener
Direct Known Subclasses:
AttributeExpressionAttribute

public class AttributeValueAttribute
extends AbstractTextAttribute
implements ValueListener, Settable

This is a text attribute whose text string shows the value of a parameter.

Since:
Ptolemy II 4.1
Version:
$Id: AttributeValueAttribute.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Steve Neuendorffer
See Also:
Serialized Form
Accepted Rating:
Red (cxh)
Proposed Rating:
Yellow (eal)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
 
Nested classes/interfaces inherited from interface ptolemy.kernel.util.Settable
Settable.Visibility
 
Field Summary
protected  Settable _attribute
          The associated attribute.
private  boolean _deferred
          Flag indicating that we have already tried deferring evaluation.
protected  int _displayWidth
          Most recent value of the rounding parameter.
 StringAttribute attributeName
          The name of the attribute of the container whose value to display.
 Parameter displayWidth
          The number of characters to display.
 
Fields inherited from class ptolemy.vergil.kernel.attributes.AbstractTextAttribute
_icon, bold, center, fontFamily, italic, textColor, textSize
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Fields inherited from interface ptolemy.kernel.util.Settable
EXPERT, FULL, NONE, NOT_EDITABLE
 
Constructor Summary
AttributeValueAttribute(NamedObj container, java.lang.String name)
          Construct an attribute with the given name contained by the specified container.
 
Method Summary
protected  java.lang.String _getText()
          Return a new string that contains the expression of the referred to attribute.
protected  void _setAttributeName(java.lang.String attributeName)
          Set the attribute name.
 void addValueListener(ValueListener listener)
          Add a listener to be notified when the value of this settable object changes.
 void attributeChanged(Attribute attribute)
          React to a changes in the attributes by changing the icon.
 java.lang.String getDefaultExpression()
          Return the default value of this attribute, if there is one, or null if there is none.
 java.lang.String getDisplayName()
          Return a name to present to the user, which is the same as the name returned by getName().
 java.lang.String getExpression()
          Get the value of the attribute that has been set by setExpression(), or null if there is none.
 java.lang.String getValueAsString()
          Get the value of the attribute, which is the evaluated expression.
 Settable.Visibility getVisibility()
          Get the visibility of this Settable, as set by setVisibility().
 void removeValueListener(ValueListener listener)
          Remove a listener from the list of listeners that are notified when the value of this variable changes.
 void setExpression(java.lang.String expression)
          Set the value of the attribute by giving some expression.
 void setVisibility(Settable.Visibility visibility)
          Set the visibility of this Settable.
 java.util.Collection validate()
          Set the attribute name to match the current expression.
 void valueChanged(Settable settable)
          React to a change in the value of the associated attribute.
 
Methods inherited from class ptolemy.vergil.kernel.attributes.AbstractTextAttribute
clone
 
Methods inherited from class ptolemy.vergil.kernel.attributes.VisibleAttribute
moveToFirst, moveToLast
 
Methods inherited from class ptolemy.kernel.util.Attribute
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToIndex, moveUp, setContainer, setName, updateContent
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _description, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getFullName, getName, getName, setName
 

Field Detail

attributeName

public StringAttribute attributeName
The name of the attribute of the container whose value to display.


displayWidth

public Parameter displayWidth
The number of characters to display. This is an integer, with default value 6.


_displayWidth

protected int _displayWidth
Most recent value of the rounding parameter.


_attribute

protected Settable _attribute
The associated attribute.


_deferred

private boolean _deferred
Flag indicating that we have already tried deferring evaluation.

Constructor Detail

AttributeValueAttribute

public AttributeValueAttribute(NamedObj container,
                               java.lang.String name)
                        throws IllegalActionException,
                               NameDuplicationException
Construct an attribute with the given name contained by the specified container. The container argument must not be null, or a NullPointerException will be thrown. This attribute will use the workspace of the container for synchronization and version counts. If the name argument is null, then the name is set to the empty string. Increment the version of the workspace.

Parameters:
container - The container.
name - The name of this attribute.
Throws:
IllegalActionException - If the attribute is not of an acceptable class for the container, or if the name contains a period.
NameDuplicationException - If the name coincides with an attribute already in the container.
Method Detail

attributeChanged

public void attributeChanged(Attribute attribute)
                      throws IllegalActionException
React to a changes in the attributes by changing the icon.

Overrides:
attributeChanged in class AbstractTextAttribute
Parameters:
attribute - The attribute that changed.
Throws:
IllegalActionException - If the change is not acceptable to this container (should not be thrown).

valueChanged

public void valueChanged(Settable settable)
React to a change in the value of the associated attribute.

Specified by:
valueChanged in interface ValueListener
Parameters:
settable - The object that has changed value.

addValueListener

public void addValueListener(ValueListener listener)
Add a listener to be notified when the value of this settable object changes. This implementation ignores the argument, so listeners to this object are not notified of changes in value.

Specified by:
addValueListener in interface Settable
Parameters:
listener - The listener to add.
See Also:
removeValueListener(ValueListener)

getDefaultExpression

public java.lang.String getDefaultExpression()
Return the default value of this attribute, if there is one, or null if there is none.

Specified by:
getDefaultExpression in interface Settable
Returns:
The default value of this attribute, or null if there is none.

getDisplayName

public java.lang.String getDisplayName()
Return a name to present to the user, which is the same as the name returned by getName().

Specified by:
getDisplayName in interface Nameable
Specified by:
getDisplayName in interface Settable
Overrides:
getDisplayName in class NamedObj
Returns:
A name to present to the user.
See Also:
NamedObj.setDisplayName(String)

getExpression

public java.lang.String getExpression()
Get the value of the attribute that has been set by setExpression(), or null if there is none.

Specified by:
getExpression in interface Settable
Returns:
The expression. This base class always returns the empty string "".
See Also:
setExpression(String)

getValueAsString

public java.lang.String getValueAsString()
Get the value of the attribute, which is the evaluated expression.

Specified by:
getValueAsString in interface Settable
Returns:
The same as getExpression().
See Also:
getExpression()

getVisibility

public Settable.Visibility getVisibility()
Get the visibility of this Settable, as set by setVisibility(). If setVisibility() has not been called, then implementations of this interface should return some default, not null, indicating user-level visibility. The returned value is one of the static instances of the Visibility inner class.

Specified by:
getVisibility in interface Settable
Returns:
The visibility of this Settable.
See Also:
setVisibility(Settable.Visibility)

removeValueListener

public void removeValueListener(ValueListener listener)
Remove a listener from the list of listeners that are notified when the value of this variable changes. This implementation ignores the argument.

Specified by:
removeValueListener in interface Settable
Parameters:
listener - The listener to remove.
See Also:
addValueListener(ValueListener)

setExpression

public void setExpression(java.lang.String expression)
                   throws IllegalActionException
Set the value of the attribute by giving some expression. In this implementation, the specified value is ignored.

Specified by:
setExpression in interface Settable
Parameters:
expression - The value of the attribute, which is ignored.
Throws:
IllegalActionException - If the expression is invalid.
See Also:
getExpression()

setVisibility

public void setVisibility(Settable.Visibility visibility)
Set the visibility of this Settable. This call does nothing.

Specified by:
setVisibility in interface Settable
Parameters:
visibility - The visibility of this Settable.
See Also:
getVisibility()

validate

public java.util.Collection validate()
                              throws IllegalActionException
Set the attribute name to match the current expression.

Specified by:
validate in interface Settable
Returns:
Null, indicating that no other instances of Settable are validated.
Throws:
IllegalActionException - If the expression is not valid, or its value is not acceptable to the container or the listeners.

_setAttributeName

protected void _setAttributeName(java.lang.String attributeName)
Set the attribute name.

Parameters:
attributeName - The attribute name.

_getText

protected java.lang.String _getText()
Return a new string that contains the expression of the referred to attribute.

Returns:
A new shape.