ptolemy.actor.gui
Class SizeAttribute

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.util.Attribute
          extended by ptolemy.kernel.util.AbstractSettableAttribute
              extended by ptolemy.data.expr.Variable
                  extended by ptolemy.data.expr.Parameter
                      extended by ptolemy.actor.gui.SizeAttribute
All Implemented Interfaces:
java.awt.event.ComponentListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, HasTypeConstraints, Typeable, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable, Settable, ValueListener

public class SizeAttribute
extends Parameter
implements java.awt.event.ComponentListener

This attribute stores the width and height of a graphical component. The token in this attribute is an IntMatrixToken containing a matrix of dimension 1x2, containing the width and the height, in that order. By default, this attribute has visibility NONE, so the user will not see it in parameter editing dialogs.

Note that this attribute is typically used to record the size of a component within a frame (a top-level window). To record the size and position of the frame, use WindowPropertiesAttribute.

Since:
Ptolemy II 1.0
Version:
$Id: SizeAttribute.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Edward A. Lee
See Also:
WindowPropertiesAttribute, Serialized Form
Accepted Rating:
Red (johnr)
Proposed Rating:
Red (eal)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.data.expr.Variable
Variable.VariableScope
 
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
private  java.awt.Component _listeningTo
          The component we are listening to.
 
Fields inherited from class ptolemy.data.expr.Variable
_currentExpression, _needsEvaluation, _parserScope, _parseTreeValid, _valueListeners
 
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
SizeAttribute(NamedObj container, java.lang.String name)
          Construct an attribute with the given name contained by the specified entity.
 
Method Summary
 void componentHidden(java.awt.event.ComponentEvent event)
          Do nothing.
 void componentMoved(java.awt.event.ComponentEvent event)
          Do nothing.
 void componentResized(java.awt.event.ComponentEvent event)
          Record the new size.
 void componentShown(java.awt.event.ComponentEvent event)
          Do nothing.
 void recordSize(java.awt.Component component)
          Set the value of the attribute to match those of the specified component.
 boolean setSize(java.awt.Component component)
          Set the size of the specified component to match the current value of the attribute.
 
Methods inherited from class ptolemy.data.expr.Parameter
addChoice, exportMoML, getChoices, removeAllChoices, removeChoice
 
Methods inherited from class ptolemy.data.expr.Variable
_description, _evaluate, _notifyValueListeners, _parseIfNecessary, _propagate, _propagateToValueListeners, _propagateValue, _setToken, _setTokenAndNotify, addValueListener, clone, getDeclaredType, getExpression, getFreeIdentifiers, getParserScope, getScope, getScope, getToken, getType, getTypeTerm, getValueAsString, getVariable, getVisibility, invalidate, isKnown, isLazy, isStringMode, isTypeAcceptable, removeValueListener, reset, setContainer, setExpression, setLazy, setName, setParseTreeEvaluator, setStringMode, setToken, setToken, setTypeAtLeast, setTypeAtLeast, setTypeAtMost, setTypeEquals, setTypeSameAs, setUnknown, setVisibility, stringRepresentation, toString, typeConstraintList, typeConstraints, validate, valueChanged
 
Methods inherited from class ptolemy.kernel.util.AbstractSettableAttribute
getDefaultExpression
 
Methods inherited from class ptolemy.kernel.util.Attribute
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, updateContent
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, 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, 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.Settable
getDisplayName
 
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getFullName, getName, getName
 

Field Detail

_listeningTo

private java.awt.Component _listeningTo
The component we are listening to.

Constructor Detail

SizeAttribute

public SizeAttribute(NamedObj container,
                     java.lang.String name)
              throws IllegalActionException,
                     NameDuplicationException
Construct an attribute with the given name contained by the specified entity. 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

componentHidden

public void componentHidden(java.awt.event.ComponentEvent event)
Do nothing. This method is invoked when the component has been made invisible.

Specified by:
componentHidden in interface java.awt.event.ComponentListener
Parameters:
event - The component event.

componentMoved

public void componentMoved(java.awt.event.ComponentEvent event)
Do nothing. This method is invoked when the component's position changes.

Specified by:
componentMoved in interface java.awt.event.ComponentListener
Parameters:
event - The component event.

componentResized

public void componentResized(java.awt.event.ComponentEvent event)
Record the new size. This method is invoked when the component's size changes.

Specified by:
componentResized in interface java.awt.event.ComponentListener
Parameters:
event - The component event.

componentShown

public void componentShown(java.awt.event.ComponentEvent event)
Do nothing. This method is invoked when the component has been made visible.

Specified by:
componentShown in interface java.awt.event.ComponentListener
Parameters:
event - The component event.

recordSize

public void recordSize(java.awt.Component component)
Set the value of the attribute to match those of the specified component.

Parameters:
component - The component whose size is to be recorded.

setSize

public boolean setSize(java.awt.Component component)
Set the size of the specified component to match the current value of the attribute. If the value of the attribute has not been set, then do nothing. If it has not already done so, this method also registers with the component as a listener for component events like resizing.

Parameters:
component - The component whose size is to be set.
Returns:
True if successful.