|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectchemaxon.marvin.modules.datatransfer.MarvinTransferable
public abstract class MarvinTransferable
Abstract Adapter implementation of the MTransferable interface used by Marvin.
The infrastructure in Marvin is developed to transfer Molecule data to the clipboard, and Marvin has many predefined clipboard formats. If you would like to extend Marvin's clipboard features programmatically in your application with another formats, you can use this adapter to make your work a bit simpler.
The adapter introduces some new functionality, which is not part of the MTransferable interface, those methods should not be called from outside of the class hierarchy, and have been made to make the implementation of clipboard formats of marvin simpler.
The Java Transferable interface provides support to implementors handling
more DataFlavors per Transferable, but in Marvin we recommend to
use only one DataFlavor with one Transferable. This is important to make the Copy As
dialog easier to understand, and ensures the possibility to
add clipboard types one by one to the dialog.
Since this adapter supports only one DataFlavor, handling more DataFlavors per Transferable
requires an own MTransferable implementation.
| Field Summary | |
|---|---|
protected int |
clipboardOperation
Clipboard operation type. |
protected java.awt.datatransfer.DataFlavor |
extraFlavor
|
protected java.awt.datatransfer.DataFlavor |
flavor
The DataFlavor represented by the implementation. |
protected java.lang.String |
format
The format string. |
protected Molecule |
molecule
The Molecule which will be transferred to the clipboard. |
protected java.util.Properties |
properties
Display properties of the Molecule. |
protected java.awt.datatransfer.Transferable |
transfer
The Transferable which represents the clipboard data. |
| Fields inherited from interface chemaxon.marvin.modules.datatransfer.MTransferable |
|---|
CLIPBOARD_OPERATION_GET, CLIPBOARD_OPERATION_PUT, CLIPBOARD_OPERATION_UNDEFINED |
| Constructor Summary | |
|---|---|
MarvinTransferable()
|
|
| Method Summary | |
|---|---|
protected java.lang.Object |
createMoleculeFromInputStream(java.io.InputStream is)
Helper function to get Molecule or MacroMolecule from the given InputStream with MolImporter. |
protected abstract java.lang.Object |
getDataFromClipboard(java.awt.datatransfer.DataFlavor flv)
Returns the Molecule from the Transferable object. |
protected abstract java.lang.Object |
getDataToClipboard(java.awt.datatransfer.DataFlavor flv)
Returns the clipboard representation of the given Molecule. |
protected java.io.InputStream |
getInputStreamFromClipboard()
Gets an InputStream from the clipboard data if the format is supported by this MTransferable |
java.lang.Object |
getTransferData(java.awt.datatransfer.DataFlavor flv)
Returns the result of the transfer operation. |
java.awt.datatransfer.DataFlavor[] |
getTransferDataFlavors()
Returns the DataFlavors supported by the actual implementation. |
boolean |
isDataFlavorSupported(java.awt.datatransfer.DataFlavor flv)
Checks whether the flavor equals with the given parameter. |
boolean |
isInputAvailable()
Checks that the implementation supports input from clipboard. |
void |
registerNativeNames()
Registers the Native names supported by the implementation. |
void |
setMolecule(Molecule mol)
Sets the Molecule which will be represented by the MTransferable. |
void |
setProperties(java.util.Properties props)
Sets display properties of the Molecule. |
void |
setTransfer(java.awt.datatransfer.Transferable transfer)
Sets the Transferable which contains the Molecule that should be retrieved. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.awt.datatransfer.DataFlavor flavor
protected java.lang.String format
protected int clipboardOperation
getTransferData(DataFlavor) to determine what to do and handled
internally from setMolecule(Molecule) and from
setTransfer(Transferable) functions.
protected Molecule molecule
Molecule which will be transferred to the clipboard. The
system will call the getTransferData(DataFlavor) - as defined in
the java documentation - to gather the data for the Clipboard.
protected java.util.Properties properties
UserSettings
, and in the result of
MDocument.getGUIPropertyContainer()
ImageExportUtilprotected java.awt.datatransfer.Transferable transfer
Transferable which represents the clipboard data. From this
object a Molecule should be retrieved and returned as object in the
getTransferData(DataFlavor) method.
protected java.awt.datatransfer.DataFlavor extraFlavor
| Constructor Detail |
|---|
public MarvinTransferable()
| Method Detail |
|---|
public java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor flv)
throws java.awt.datatransfer.UnsupportedFlavorException
Molecule, which was wrapped from transfer depending on
clipboardOperationgetDataFromClipboard(DataFlavor) getDataToClipboard(DataFlavor)
getTransferData in interface java.awt.datatransfer.Transferableflv - the DataFlavor of the format.
clipboardOperation if the flavor of this MTransferable
is equals with the given parameter
java.awt.datatransfer.UnsupportedFlavorException - if the flavor of this MTransferable does not equal with the
given parameter),
)public boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flv)
flavor equals with the given parameter.
isDataFlavorSupported in interface java.awt.datatransfer.Transferableflv - the DataFlavor which should be checked
protected abstract java.lang.Object getDataToClipboard(java.awt.datatransfer.DataFlavor flv)
Molecule. The
Object has to be an instance of the representationClass defined by the
flavor of this MTransferable
flv - the DataFlavor of the format.
protected abstract java.lang.Object getDataFromClipboard(java.awt.datatransfer.DataFlavor flv)
Transferable object. The transferable
object should be gathered from the clipboard, and set to MTransferable
through the setTransfer(Transferable) method.
flv - the DataFlavor of the format.
public java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
getTransferDataFlavors in interface java.awt.datatransfer.Transferablepublic void registerNativeNames()
registerNativeNames in interface MTransferablepublic void setMolecule(Molecule mol)
clipboardOperation to
MTransferable.CLIPBOARD_OPERATION_PUT
setMolecule in interface MTransferablemol - the Molecule object which will be put to the clipboardpublic void setProperties(java.util.Properties props)
UserSettings , and in the result of
MDocument.getGUIPropertyContainer()
setProperties in interface MTransferableprops - the PropertiesImageExportUtilpublic boolean isInputAvailable()
isInputAvailable in interface MTransferablepublic void setTransfer(java.awt.datatransfer.Transferable transfer)
clipboardOperation to
MTransferable.CLIPBOARD_OPERATION_GET.
setTransfer in interface MTransferabletransfer - The Transferable containing the MoleculeMTransferable.isInputAvailable()protected java.lang.Object createMoleculeFromInputStream(java.io.InputStream is)
Helper function to get Molecule or MacroMolecule from the given InputStream with MolImporter. If the format variable is set to "source" or "file" then the function will call the recognizer subsystem to recognize the format, otherwise it tries to import in the format.
If PDB format recognized as the input, the MacroMolecule instance will be returned, otherwise a Molecule instance or null if the format is unrecognizable.
If copying a simple text, which contains multiple lines, but recognized as a one line format, then the function is trying to interpret the whole string without line ending characters, if copying a file (this happens while dragging a file into the canvas) the lines will be interpreted one by one, and the first will be imported.
is - the InputStream representing the Molecule
protected java.io.InputStream getInputStreamFromClipboard()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||