Class Location
- java.lang.Object
- 
- ptolemy.kernel.util.NamedObj
- 
- ptolemy.kernel.util.Attribute
- 
- ptolemy.kernel.util.SingletonAttribute
- 
- ptolemy.kernel.util.Location
 
 
 
 
- 
- All Implemented Interfaces:
- java.lang.Cloneable,- Changeable,- Debuggable,- DebugListener,- Derivable,- Locatable,- ModelErrorHandler,- MoMLExportable,- Moveable,- Nameable,- Settable,- Singleton
 - Direct Known Subclasses:
- RelativeLocation,- Vertex
 
 public class Location extends SingletonAttribute implements Locatable An attribute that represents the center location of a node in a schematic.By default, an instance of this class is not visible in a user interface. This is indicated to the user interface by returning NONE to the getVisibility() method. The location is specified by calling setExpression() with a string that has the form "x,y" or "[x,y]" or "{x,y}", where x and y can be parsed into doubles. The default location is a two dimensional location with value {0.0, 0.0}. This class can also handle locations with greater than two dimensions. - Since:
- Ptolemy II 2.1
- Version:
- $Id$
- Author:
- Steve Neuendorffer and Edward A. Lee
- Pt.AcceptedRating:
- Green (cxh)
- Pt.ProposedRating:
- Green (cxh)
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObjNamedObj.ContainedObjectsIterator
 - 
Nested classes/interfaces inherited from interface ptolemy.kernel.util.SettableSettable.Visibility
 
- 
 - 
Field Summary- 
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.SettableEXPERT, FULL, NONE, NOT_EDITABLE
 
- 
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void_propagateValue(NamedObj destination)Propagate the value of this object to the specified object.voidaddValueListener(ValueListener listener)Add a listener to be notified when the value of this attribute changes.java.lang.Objectclone(Workspace workspace)Clone the location into the specified workspace.voidexportMoML(java.io.Writer output, int depth, java.lang.String name)Write a MoML description of this object.java.lang.StringgetDefaultExpression()Return the default value of this Settable, if there is one.java.lang.StringgetDisplayName()Return a name to present to the user, which is the same as the name returned by getName().java.lang.StringgetExpression()Get the value that has been set by setExpression() or by setLocation(), whichever was most recently called, or return an empty string if neither has been called.double[]getLocation()Get the center location in some cartesian coordinate system.java.lang.StringgetValueAsString()Get the value of the attribute, which is the evaluated expression.Settable.VisibilitygetVisibility()Get the visibility of this attribute, as set by setVisibility().voidremoveValueListener(ValueListener listener)Remove a listener from the list of listeners that is notified when the value of this variable changes.voidsetExpression(java.lang.String expression)Set the value of the attribute by giving some expression.voidsetLocation(double[] location)Set the center location in some cartesian coordinate system, and notify the container and any value listeners of the new location.voidsetVisibility(Settable.Visibility visibility)Set the visibility of this attribute.java.lang.StringtoString()Get a description of the class, which is the class name and the location in parentheses.java.util.Collectionvalidate()Parse the location specification given by setExpression(), if there has been one, and otherwise set the location to 0.0, 0.0.- 
Methods inherited from class ptolemy.kernel.util.SingletonAttributesetContainer
 - 
Methods inherited from class ptolemy.kernel.util.Attribute_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, 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, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeChanged, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, 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, uniqueName, validateSettables, workspace
 - 
Methods inherited from class java.lang.Objectequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface ptolemy.kernel.util.Nameabledescription, getContainer, getFullName, getName, getName, setName
 
- 
 
- 
- 
- 
Constructor Detail- 
Locationpublic Location(Workspace workspace) Construct an attribute in the specified workspace with an empty string as a name. If the workspace argument is null, then use the default workspace. The object is added to the directory of the workspace. Increment the version number of the workspace.- Parameters:
- workspace- The workspace that will list the attribute.
 
 - 
Locationpublic Location(NamedObj container, java.lang.String name) throws IllegalActionException, NameDuplicationException Construct an attribute with the given container and name.- Parameters:
- container- The container.
- name- The name of the vertex.
- Throws:
- IllegalActionException- If the attribute is not of an acceptable class for the container.
- NameDuplicationException- If the name coincides with an attribute already in the container.
 
 
- 
 - 
Method Detail- 
addValueListenerpublic void addValueListener(ValueListener listener) Add a listener to be notified when the value of this attribute changes. If the listener is already on the list of listeners, then do nothing.- Specified by:
- addValueListenerin interface- Settable
- Parameters:
- listener- The listener to add.
- See Also:
- removeValueListener(ValueListener)
 
 - 
clonepublic java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException Clone the location into the specified workspace. The new object is not added to the directory of that workspace (you must do this yourself if you want it there).- Overrides:
- clonein class- Attribute
- Parameters:
- workspace- The workspace for the cloned object.
- Returns:
- A new Location.
- Throws:
- java.lang.CloneNotSupportedException- If the base class throws it.
- See Also:
- NamedObj.exportMoML(Writer, int, String),- NamedObj.setDeferringChangeRequests(boolean)
 
 - 
exportMoMLpublic void exportMoML(java.io.Writer output, int depth, java.lang.String name) throws java.io.IOExceptionWrite a MoML description of this object. MoML is an XML modeling markup language. In this class, the object is identified by the "property" element, with "name", "class", and "value" (XML) attributes. The body of the element, between the "<property>" and "</property>", is written using the _exportMoMLContents() protected method, so that derived classes can override that method alone to alter only how the contents of this object are described. The text that is written is indented according to the specified depth, with each line (including the last one) terminated with a newline. If this object is non-persistent, then nothing is written.- Specified by:
- exportMoMLin interface- MoMLExportable
- Overrides:
- exportMoMLin class- NamedObj
- Parameters:
- output- The output writer to write to.
- depth- The depth in the hierarchy, to determine indenting.
- name- The name to use instead of the current name.
- Throws:
- java.io.IOException- If an I/O error occurs.
- See Also:
- NamedObj.isPersistent()
 
 - 
getDefaultExpressionpublic java.lang.String getDefaultExpression() Return the default value of this Settable, if there is one. If this is a derived object, then the default is the value of the object from which this is derived (the "prototype"). If this is not a derived object, then the default is the first value set using setExpression(), or null if setExpression() has not been called.- Specified by:
- getDefaultExpressionin interface- Settable
- Returns:
- The default value of this attribute, or null if there is none.
- See Also:
- setExpression(String)
 
 - 
getDisplayNamepublic java.lang.String getDisplayName() Return a name to present to the user, which is the same as the name returned by getName().- Specified by:
- getDisplayNamein interface- Nameable
- Specified by:
- getDisplayNamein interface- Settable
- Overrides:
- getDisplayNamein class- NamedObj
- Returns:
- A name to present to the user.
- See Also:
- NamedObj.setDisplayName(String)
 
 - 
getExpressionpublic java.lang.String getExpression() Get the value that has been set by setExpression() or by setLocation(), whichever was most recently called, or return an empty string if neither has been called.If setExpression(String value) was called, then the return value is exactly what ever was passed in as the argument to setExpression. This means that there is no guarantee that the return value of getExpression() is a well formed Ptolemy array expression. If setLocation(double[] location) was called, then the return value is a well formed Ptolemy array expression that starts with "{" and ends with "}", for example "{0.0, 0.0}" - Specified by:
- getExpressionin interface- Settable
- Returns:
- The expression.
- See Also:
- setExpression(String)
 
 - 
getLocationpublic double[] getLocation() Get the center location in some cartesian coordinate system.- Specified by:
- getLocationin interface- Locatable
- Returns:
- The location.
- See Also:
- setLocation(double[])
 
 - 
getValueAsStringpublic java.lang.String getValueAsString() Get the value of the attribute, which is the evaluated expression.- Specified by:
- getValueAsStringin interface- Settable
- Returns:
- The same as getExpression().
- See Also:
- getExpression()
 
 - 
getVisibilitypublic Settable.Visibility getVisibility() Get the visibility of this attribute, as set by setVisibility(). The visibility is set by default to NONE.- Specified by:
- getVisibilityin interface- Settable
- Returns:
- The visibility of this attribute.
- See Also:
- setVisibility(Settable.Visibility)
 
 - 
removeValueListenerpublic void removeValueListener(ValueListener listener) Remove a listener from the list of listeners that is notified when the value of this variable changes. If no such listener exists, do nothing.- Specified by:
- removeValueListenerin interface- Settable
- Parameters:
- listener- The listener to remove.
- See Also:
- addValueListener(ValueListener)
 
 - 
setExpressionpublic void setExpression(java.lang.String expression) Set the value of the attribute by giving some expression. This expression is not parsed until validate() is called, and the container and value listeners are not notified until validate() is called. See the class comment for a description of the format.- Specified by:
- setExpressionin interface- Settable
- Parameters:
- expression- The value of the attribute.
- See Also:
- getExpression()
 
 - 
setLocationpublic void setLocation(double[] location) throws IllegalActionExceptionSet the center location in some cartesian coordinate system, and notify the container and any value listeners of the new location. Setting the location involves maintaining a local copy of the passed parameter. No notification is done if the location is the same as before. This method propagates the value to any derived objects.- Specified by:
- setLocationin interface- Locatable
- Parameters:
- location- The location.
- Throws:
- IllegalActionException- If throw when attributeChanged() is called.
- See Also:
- getLocation()
 
 - 
setVisibilitypublic void setVisibility(Settable.Visibility visibility) Set the visibility of this attribute. The argument should be one of the public static instances in Settable.- Specified by:
- setVisibilityin interface- Settable
- Parameters:
- visibility- The visibility of this attribute.
- See Also:
- getVisibility()
 
 - 
toStringpublic java.lang.String toString() Get a description of the class, which is the class name and the location in parentheses.
 - 
validatepublic java.util.Collection validate() throws IllegalActionExceptionParse the location specification given by setExpression(), if there has been one, and otherwise set the location to 0.0, 0.0. Notify the container and any value listeners of the new location, if it has changed. See the class comment for a description of the format.- Specified by:
- validatein interface- Settable
- Returns:
- Null, indicating that no other instances of Settable are validated.
- Throws:
- IllegalActionException- If the expression is invalid.
 
 - 
_propagateValueprotected void _propagateValue(NamedObj destination) throws IllegalActionException Propagate the value of this object to the specified object. The specified object is required to be an instance of the same class as this one, or a ClassCastException will be thrown.- Overrides:
- _propagateValuein class- NamedObj
- Parameters:
- destination- Object to which to propagate the value.
- Throws:
- IllegalActionException- If the value cannot be propagated.
 
 
- 
 
-