Package ptolemy.vergil.basic
Class RelativeLocation
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.util.Attribute
-
- ptolemy.kernel.util.SingletonAttribute
-
- ptolemy.kernel.util.Location
-
- ptolemy.vergil.basic.RelativeLocation
-
- All Implemented Interfaces:
java.lang.Cloneable
,Changeable
,Debuggable
,DebugListener
,Derivable
,Locatable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
,Settable
,Singleton
public class RelativeLocation extends Location
An attribute used to store a relative visual location. The location is relative to an object specified by the relativeTo attribute, which gives the name of an object that is expected to be contained by the container of the container of this attribute. In addition, the relativeToElementName specifies what kind of object this is relative to (an "entity", "property" (attribute), "port", or "relation").- Since:
- Ptolemy II 11.0
- Version:
- $Id$
- Author:
- Edward A. Lee, Christian Motika, Miro Spoenemann
- Pt.AcceptedRating:
- Red (cxh)
- Pt.ProposedRating:
- Yellow (cxh)
-
-
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 static double
BREAK_THRESHOLD
The maximal distance of the relative location.static double
INITIAL_OFFSET
The initial offset for new relative locatable objects.StringAttribute
relativeTo
The name of the object this location is relative to.StringAttribute
relativeToElementName
The element name of the object this location is relative to.-
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 RelativeLocation(NamedObj container, java.lang.String name)
Construct an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double[]
getLocation()
Get the location in some cartesian coordinate system.double[]
getRelativeLocation()
Get the relative location, relative to the relativeTo object, if there is one, and otherwise return the absolute location.NamedObj
getRelativeToNamedObj()
If the relativeTo object exists, return it.void
setLocation(double[] location)
Set the location in some cartesian coordinate system, and notify the container and any value listeners of the new location.-
Methods inherited from class ptolemy.kernel.util.Location
_propagateValue, addValueListener, clone, exportMoML, getDefaultExpression, getDisplayName, getExpression, getValueAsString, getVisibility, removeValueListener, setExpression, setVisibility, toString, validate
-
Methods inherited from class ptolemy.kernel.util.SingletonAttribute
setContainer
-
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.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
-
relativeTo
public StringAttribute relativeTo
The name of the object this location is relative to.
-
relativeToElementName
public StringAttribute relativeToElementName
The element name of the object this location is relative to. This defaults to "entity".
-
INITIAL_OFFSET
public static final double INITIAL_OFFSET
The initial offset for new relative locatable objects.- See Also:
- Constant Field Values
-
BREAK_THRESHOLD
public static final double BREAK_THRESHOLD
The maximal distance of the relative location. If this is exceeded after moving the relative locatable, the link is broken (seeLocatableNodeDragInteractor.mouseReleased(diva.canvas.event.LayerEvent)
).- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RelativeLocation
public RelativeLocation(NamedObj container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Construct an instance.- Parameters:
container
- The container (the object to have a relative location).name
- The name of this instance.- Throws:
IllegalActionException
- If the superclass throws it.NameDuplicationException
- If the superclass throws it.
-
-
Method Detail
-
getLocation
public double[] getLocation()
Get the location in some cartesian coordinate system. This method returns the absolute location of the object. If the relative location was previously attached to an object referenced in therelativeTo
property and that object is gone, then the internally stored location is updated so it contains the correct absolute location.- Specified by:
getLocation
in interfaceLocatable
- Overrides:
getLocation
in classLocation
- Returns:
- The location.
- See Also:
setLocation(double[])
-
getRelativeLocation
public double[] getRelativeLocation()
Get the relative location, relative to the relativeTo object, if there is one, and otherwise return the absolute location.- Returns:
- The relative location.
- See Also:
setLocation(double[])
-
getRelativeToNamedObj
public NamedObj getRelativeToNamedObj()
If the relativeTo object exists, return it. Otherwise, return null and clear the relativeTo parameter value.- Returns:
- The relativeTo object, or null if it does not exist.
-
setLocation
public void setLocation(double[] location) throws IllegalActionException
Set the 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. If the relative location is attached to an object referenced in therelativeTo
property, then only the relative location is stored internally.- Specified by:
setLocation
in interfaceLocatable
- Overrides:
setLocation
in classLocation
- Parameters:
location
- The location.- Throws:
IllegalActionException
- Thrown when attributeChanged() is called.- See Also:
getLocation()
-
-