Package com.mxgraph.swing.util
Class mxGraphTransferable
- java.lang.Object
-
- com.mxgraph.swing.util.mxGraphTransferable
-
- All Implemented Interfaces:
java.awt.datatransfer.Transferable
,java.io.Serializable
,javax.swing.plaf.UIResource
public class mxGraphTransferable extends java.lang.Object implements java.awt.datatransfer.Transferable, javax.swing.plaf.UIResource, java.io.Serializable
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected mxRectangle
bounds
protected java.lang.Object[]
cells
static java.awt.datatransfer.DataFlavor
dataFlavor
Serialized Data Flavor.static boolean
enableImageSupport
Global switch to disable image support in transferables.protected javax.swing.ImageIcon
image
-
Constructor Summary
Constructors Constructor Description mxGraphTransferable(java.lang.Object[] cells, mxRectangle bounds)
mxGraphTransferable(java.lang.Object[] cells, mxRectangle bounds, javax.swing.ImageIcon image)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description mxRectangle
getBounds()
Returns the unscaled, untranslated bounding box of the cells.java.lang.Object[]
getCells()
protected java.lang.String
getHtmlData()
Fetch the data in a text/html formatjavax.swing.ImageIcon
getImage()
protected java.lang.String
getPlainData()
Fetch the data in a text/plain format.java.lang.Object
getRicherData(java.awt.datatransfer.DataFlavor flavor)
protected java.awt.datatransfer.DataFlavor[]
getRicherFlavors()
Some subclasses will have flavors that are more descriptive than HTML or plain text.java.lang.Object
getTransferData(java.awt.datatransfer.DataFlavor flavor)
Returns an object which represents the data to be transferred.java.awt.datatransfer.DataFlavor[]
getTransferDataFlavors()
boolean
isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
Returns whether or not the specified data flavor is supported for this object.protected boolean
isHtmlFlavor(java.awt.datatransfer.DataFlavor flavor)
Returns whether or not the specified data flavor is an HTML flavor that is supported.protected boolean
isHtmlSupported()
Whether the HTML flavors are offered.protected boolean
isImageFlavor(java.awt.datatransfer.DataFlavor flavor)
boolean
isImageSupported()
protected boolean
isPlainFlavor(java.awt.datatransfer.DataFlavor flavor)
Returns whether or not the specified data flavor is an plain flavor that is supported.protected boolean
isPlainSupported()
Whether the plain text flavors are offered.protected boolean
isRicherFlavor(java.awt.datatransfer.DataFlavor flavor)
protected boolean
isStringFlavor(java.awt.datatransfer.DataFlavor flavor)
Returns whether or not the specified data flavor is a String flavor that is supported.
-
-
-
Field Detail
-
enableImageSupport
public static boolean enableImageSupport
Global switch to disable image support in transferables. Set this to false as a workaround for Data translation failed: not an image format in Java 1.7 on Mac OS X.
-
dataFlavor
public static java.awt.datatransfer.DataFlavor dataFlavor
Serialized Data Flavor. Use the following code to switch to local reference flavor:try { mxGraphTransferable.dataFlavor = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType + "; class=com.mxgraph.swing.util.mxGraphTransferable"); } catch (ClassNotFoundException cnfe) { // do nothing }
If you get a class not found exception, try the following instead:mxGraphTransferable.dataFlavor = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType + "; class=com.mxgraph.swing.util.mxGraphTransferable", null, new com.mxgraph.swing.util.mxGraphTransferable(null, null).getClass().getClassLoader());
-
cells
protected java.lang.Object[] cells
-
bounds
protected mxRectangle bounds
-
image
protected javax.swing.ImageIcon image
-
-
Constructor Detail
-
mxGraphTransferable
public mxGraphTransferable(java.lang.Object[] cells, mxRectangle bounds)
-
mxGraphTransferable
public mxGraphTransferable(java.lang.Object[] cells, mxRectangle bounds, javax.swing.ImageIcon image)
-
-
Method Detail
-
getCells
public java.lang.Object[] getCells()
- Returns:
- Returns the cells.
-
getBounds
public mxRectangle getBounds()
Returns the unscaled, untranslated bounding box of the cells.
-
getImage
public javax.swing.ImageIcon getImage()
-
getTransferDataFlavors
public java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
- Specified by:
getTransferDataFlavors
in interfacejava.awt.datatransfer.Transferable
-
getRicherFlavors
protected java.awt.datatransfer.DataFlavor[] getRicherFlavors()
Some subclasses will have flavors that are more descriptive than HTML or plain text. If this method returns a non-null value, it will be placed at the start of the array of supported flavors.
-
isDataFlavorSupported
public boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
Returns whether or not the specified data flavor is supported for this object.- Specified by:
isDataFlavorSupported
in interfacejava.awt.datatransfer.Transferable
- Parameters:
flavor
- the requested flavor for the data- Returns:
- boolean indicating whether or not the data flavor is supported
-
getTransferData
public java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor flavor) throws java.awt.datatransfer.UnsupportedFlavorException, java.io.IOException
Returns an object which represents the data to be transferred. The class of the object returned is defined by the representation class of the flavor.- Specified by:
getTransferData
in interfacejava.awt.datatransfer.Transferable
- Parameters:
flavor
- the requested flavor for the data- Throws:
java.io.IOException
- if the data is no longer available in the requested flavor.java.awt.datatransfer.UnsupportedFlavorException
- if the requested data flavor is not supported.- See Also:
DataFlavor.getRepresentationClass()
-
isRicherFlavor
protected boolean isRicherFlavor(java.awt.datatransfer.DataFlavor flavor)
- Parameters:
flavor
-- Returns:
- Returns true if the given flavor is a richer flavor of this transferable.
-
getRicherData
public java.lang.Object getRicherData(java.awt.datatransfer.DataFlavor flavor) throws java.awt.datatransfer.UnsupportedFlavorException
- Parameters:
flavor
-- Returns:
- the richer data flavor of this and the specified
- Throws:
java.awt.datatransfer.UnsupportedFlavorException
-
isHtmlFlavor
protected boolean isHtmlFlavor(java.awt.datatransfer.DataFlavor flavor)
Returns whether or not the specified data flavor is an HTML flavor that is supported.- Parameters:
flavor
- the requested flavor for the data- Returns:
- boolean indicating whether or not the data flavor is supported
-
isHtmlSupported
protected boolean isHtmlSupported()
Whether the HTML flavors are offered. If so, the method getHTMLData should be implemented to provide something reasonable.
-
getHtmlData
protected java.lang.String getHtmlData()
Fetch the data in a text/html format
-
isImageFlavor
protected boolean isImageFlavor(java.awt.datatransfer.DataFlavor flavor)
- Parameters:
flavor
-- Returns:
- Returns true if the given flavor is an image flavor of this transferable.
-
isImageSupported
public boolean isImageSupported()
-
isPlainFlavor
protected boolean isPlainFlavor(java.awt.datatransfer.DataFlavor flavor)
Returns whether or not the specified data flavor is an plain flavor that is supported.- Parameters:
flavor
- the requested flavor for the data- Returns:
- boolean indicating whether or not the data flavor is supported
-
isPlainSupported
protected boolean isPlainSupported()
Whether the plain text flavors are offered. If so, the method getPlainData should be implemented to provide something reasonable.
-
getPlainData
protected java.lang.String getPlainData()
Fetch the data in a text/plain format.
-
isStringFlavor
protected boolean isStringFlavor(java.awt.datatransfer.DataFlavor flavor)
Returns whether or not the specified data flavor is a String flavor that is supported.- Parameters:
flavor
- the requested flavor for the data- Returns:
- boolean indicating whether or not the data flavor is supported
-
-