ptolemy.vergil.basic
Class OffsetMoMLChangeRequest

java.lang.Object
  extended by ptolemy.kernel.util.ChangeRequest
      extended by ptolemy.moml.MoMLChangeRequest
          extended by ptolemy.vergil.basic.OffsetMoMLChangeRequest
Direct Known Subclasses:
TransformationEditor.PasteMoMLChangeRequest

public class OffsetMoMLChangeRequest
extends MoMLChangeRequest

A mutation request specified in MoML that offsets any objects that are created in the toplevel. This class is used by the paste action in Vergil so that the pasted icon does not overlap the original icon.

Since:
Ptolemy II 6.1
Version:
$Id: OffsetMoMLChangeRequest.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Christopher Brooks, based on code from BasicGraphFrame by Edward A. Lee
Accepted Rating:
Red (cxh)
Proposed Rating:
Red (cxh)

Field Summary
private static int _PASTE_OFFSET
          Offset used when pasting objects.
 
Constructor Summary
OffsetMoMLChangeRequest(java.lang.Object originator, NamedObj context, java.lang.String request)
          Construct a mutation request to be executed in the specified context.
 
Method Summary
protected  void _postParse(MoMLParser parser)
          Offset the locations of top level objects that are created by the change request.
protected  void _preParse(MoMLParser parser)
          Clear the list of top objects.
 
Methods inherited from class ptolemy.moml.MoMLChangeRequest
_execute, getContext, getDeferredToParent, setMergeWithPreviousUndo, setReportErrorsToHandler, setUndoable
 
Methods inherited from class ptolemy.kernel.util.ChangeRequest
addChangeListener, execute, getDescription, getLocality, getSource, isErrorReported, isPersistent, isStructuralChange, removeChangeListener, setDescription, setErrorReported, setListeners, setPersistent, waitForCompletion
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_PASTE_OFFSET

private static int _PASTE_OFFSET
Offset used when pasting objects.

Constructor Detail

OffsetMoMLChangeRequest

public OffsetMoMLChangeRequest(java.lang.Object originator,
                               NamedObj context,
                               java.lang.String request)
Construct a mutation request to be executed in the specified context. The context is typically a Ptolemy II container, such as an entity, within which the objects specified by the MoML code will be placed. This method resets and uses a parser that is a static member of this class. A listener to changes will probably want to check the originator so that when it is notified of errors or successful completion of changes, it can tell whether the change is one it requested. Alternatively, it can call waitForCompletion(). All external references are assumed to be absolute URLs. Whenever possible, use a different constructor that specifies the base.

Parameters:
originator - The originator of the change request.
context - The context in which to execute the MoML.
request - The mutation request in MoML.
Method Detail

_postParse

protected void _postParse(MoMLParser parser)
Offset the locations of top level objects that are created by the change request.

Overrides:
_postParse in class MoMLChangeRequest
Parameters:
parser - The parser

_preParse

protected void _preParse(MoMLParser parser)
Clear the list of top objects.

Overrides:
_preParse in class MoMLChangeRequest
Parameters:
parser - The parser