Package ptolemy.vergil.kernel.attributes
Class AttributeValueAttribute
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.util.Attribute
-
- ptolemy.vergil.kernel.attributes.VisibleAttribute
-
- ptolemy.vergil.kernel.attributes.AbstractTextAttribute
-
- ptolemy.vergil.kernel.attributes.AttributeValueAttribute
-
- All Implemented Interfaces:
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$
- Author:
- Steve Neuendorffer
- Pt.AcceptedRating:
- Red (cxh)
- Pt.ProposedRating:
- 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
Fields Modifier and Type Field Description protected Settable
_attribute
The associated attribute.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.Parameter
useExpression
If true, display the expression rather than the value.-
Fields inherited from class ptolemy.vergil.kernel.attributes.AbstractTextAttribute
_icon, anchor, bold, fontFamily, italic, textColor, textSize
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _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
Constructors Constructor Description AttributeValueAttribute(NamedObj container, java.lang.String name)
Construct an attribute with the given name contained by the specified container.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _description, _executeChangeRequests, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, decorators, 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, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, 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.
-
useExpression
public Parameter useExpression
If true, display the expression rather than the value. This is a boolean that defaults to false.
-
_displayWidth
protected int _displayWidth
Most recent value of the rounding parameter.
-
_attribute
protected Settable _attribute
The associated attribute.
-
-
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 classAbstractTextAttribute
- 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 interfaceValueListener
- 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 interfaceSettable
- 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 interfaceSettable
- 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 interfaceNameable
- Specified by:
getDisplayName
in interfaceSettable
- Overrides:
getDisplayName
in classNamedObj
- 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 interfaceSettable
- 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 interfaceSettable
- 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 interfaceSettable
- 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 interfaceSettable
- 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 interfaceSettable
- 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 interfaceSettable
- 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 interfaceSettable
- 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.
-
-