ptolemy.vergil.toolbox
Class PtolemyTransferable

java.lang.Object
  extended byptolemy.vergil.toolbox.PtolemyTransferable
All Implemented Interfaces:
java.io.Serializable, java.awt.datatransfer.Transferable

public class PtolemyTransferable
extends java.lang.Object
implements java.awt.datatransfer.Transferable, java.io.Serializable

A transferable object that contains a local JVM reference to a number of named objects. To get a reference to an iterator on the objects, request data with the data flavor given in the static namedObjFlavor variable. This class will also return a MoML representation of the objects, if data is requested with the DataFlavor.stringFlavor or DataFlavor.plainTextFlavor.

Since:
Ptolemy II 1.0
Version:
$Id: PtolemyTransferable.java,v 1.26.2.1 2004/06/18 00:49:31 cxh Exp $
Author:
Steve Neuendorffer
See Also:
Serialized Form
Accepted Rating:
Red (johnr)
Proposed Rating:
Red (eal)

Field Summary
static java.awt.datatransfer.DataFlavor namedObjFlavor
          The flavor that requests a local virtual machine reference to the contained object.
 
Constructor Summary
PtolemyTransferable()
          Create a new transferable object that contains no objects.
 
Method Summary
 java.lang.String _getMoML()
           
 void addObject(NamedObj object)
          Add the given named object to the objects contained in this transferable.
 java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor flavor)
          Return an object that represents the data contained within this transferable with the given flavor.
 java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
          Return the data flavors that this transferable supports.
 boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
          Return true if the given data flavor is supported.
 void removeObject(NamedObj object)
          Remove the given object from this transferable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

namedObjFlavor

public static final java.awt.datatransfer.DataFlavor namedObjFlavor
The flavor that requests a local virtual machine reference to the contained object.

Constructor Detail

PtolemyTransferable

public PtolemyTransferable()
Create a new transferable object that contains no objects.

Method Detail

addObject

public void addObject(NamedObj object)
Add the given named object to the objects contained in this transferable. If the object already exists in this transferable, then do not add it again.


getTransferDataFlavors

public java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
Return the data flavors that this transferable supports.

Specified by:
getTransferDataFlavors in interface java.awt.datatransfer.Transferable

isDataFlavorSupported

public boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
Return true if the given data flavor is supported.

Specified by:
isDataFlavorSupported in interface java.awt.datatransfer.Transferable

getTransferData

public java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor flavor)
                                 throws java.awt.datatransfer.UnsupportedFlavorException,
                                        java.io.IOException
Return an object that represents the data contained within this transferable with the given flavor. If the flavor is namedObjFlavor, return an iterator of the objects that this transferable refers to. If the flavor is DataFlavor.plainTextFlavor, return an InputStream that contains a MoML representation of the objects. If the flavor is DataFlavor.stringFlavor return a string that contains the MoML representation.

Specified by:
getTransferData in interface java.awt.datatransfer.Transferable
Returns:
An object with the given flavor.
Throws:
java.awt.datatransfer.UnsupportedFlavorException - If the given flavor is not supported.
java.io.IOException

removeObject

public void removeObject(NamedObj object)
Remove the given object from this transferable. If the object does not exist in the transferable, then do nothing.


_getMoML

public java.lang.String _getMoML()
                          throws java.io.IOException
Throws:
java.io.IOException