Package com.mxgraph.swing.handler
Class mxGraphTransferHandler
- java.lang.Object
-
- javax.swing.TransferHandler
-
- com.mxgraph.swing.handler.mxGraphTransferHandler
-
- All Implemented Interfaces:
java.io.Serializable
public class mxGraphTransferHandler extends javax.swing.TransferHandler- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.awt.ColorDEFAULT_BACKGROUNDCOLORSpecifies the background color of the transfer image.static booleanDEFAULT_TRANSFER_IMAGE_ENABLEDBoolean that specifies if an image of the cells should be created for each transferable.protected intimportCountCounter for the last imported cell array.protected intinitialImportCountSets the value for the initialImportCount.protected java.awt.datatransfer.TransferablelastImportedReference to the last imported cell array.protected java.awt.Pointlocationprotected java.awt.Pointoffsetprotected java.lang.Object[]originalCellsReference to the original cells for removal after a move.protected java.awt.ColortransferImageBackgroundSpecifies the background color for the transfer image.protected booleantransferImageEnabledSpecifies if a transfer image should be created for the transferable.
-
Constructor Summary
Constructors Constructor Description mxGraphTransferHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanImport(javax.swing.JComponent comp, java.awt.datatransfer.DataFlavor[] flavors)mxGraphTransferablecreateGraphTransferable(mxGraphComponent graphComponent, java.lang.Object[] cells, mxRectangle bounds, javax.swing.ImageIcon icon)mxGraphTransferablecreateGraphTransferable(mxGraphComponent graphComponent, java.lang.Object[] cells, javax.swing.ImageIcon icon)java.awt.datatransfer.TransferablecreateTransferable(javax.swing.JComponent c)(non-Javadoc)javax.swing.ImageIconcreateTransferableImage(mxGraphComponent graphComponent, java.lang.Object[] cells)voidexportDone(javax.swing.JComponent c, java.awt.datatransfer.Transferable data, int action)protected java.lang.ObjectgetDropTarget(mxGraphComponent graphComponent, mxGraphTransferable gt)Returns the drop target for the given transferable and location.intgetImportCount()intgetSourceActions(javax.swing.JComponent c)java.awt.ColorgetTransferImageBackground()protected java.lang.Object[]importCells(mxGraphComponent graphComponent, mxGraphTransferable gt, double dx, double dy)Gets a drop target using getDropTarget and imports the cells using mxGraph.splitEdge or mxGraphComponent.importCells depending on the drop target and the return values of mxGraph.isSplitEnabled and mxGraph.isSplitTarget.booleanimportData(javax.swing.JComponent c, java.awt.datatransfer.Transferable t)Checks if the mxGraphTransferable data flavour is supported and calls importGraphTransferable if possible.protected booleanimportGraphTransferable(mxGraphComponent graphComponent, mxGraphTransferable gt)Returns true if the cells have been imported using importCells.booleanisLocalDrag()Returns true if the DnD operation started from this handler.booleanisTransferImageEnabled()protected voidremoveCells(mxGraphComponent graphComponent, java.lang.Object[] cells)voidsetImportCount(int value)voidsetLocation(java.awt.Point value)voidsetOffset(java.awt.Point value)voidsetTransferImageBackground(java.awt.Color transferImageBackground)voidsetTransferImageEnabled(boolean transferImageEnabled)protected voidupdateImportCount(java.awt.datatransfer.Transferable t)Counts the number of times that the given transferable has been imported.
-
-
-
Field Detail
-
DEFAULT_TRANSFER_IMAGE_ENABLED
public static boolean DEFAULT_TRANSFER_IMAGE_ENABLED
Boolean that specifies if an image of the cells should be created for each transferable. Default is true.
-
DEFAULT_BACKGROUNDCOLOR
public static java.awt.Color DEFAULT_BACKGROUNDCOLOR
Specifies the background color of the transfer image. If no color is given here then the background color of the enclosing graph component is used. Default is Color.WHITE.
-
originalCells
protected java.lang.Object[] originalCells
Reference to the original cells for removal after a move.
-
lastImported
protected java.awt.datatransfer.Transferable lastImported
Reference to the last imported cell array.
-
initialImportCount
protected int initialImportCount
Sets the value for the initialImportCount. Default is 1. Updated in exportDone to contain 0 after a cut and 1 after a copy.
-
importCount
protected int importCount
Counter for the last imported cell array.
-
transferImageEnabled
protected boolean transferImageEnabled
Specifies if a transfer image should be created for the transferable. Default is DEFAULT_TRANSFER_IMAGE.
-
transferImageBackground
protected java.awt.Color transferImageBackground
Specifies the background color for the transfer image. Default is DEFAULT_BACKGROUNDCOLOR.
-
location
protected java.awt.Point location
-
offset
protected java.awt.Point offset
-
-
Method Detail
-
getImportCount
public int getImportCount()
-
setImportCount
public void setImportCount(int value)
-
setTransferImageEnabled
public void setTransferImageEnabled(boolean transferImageEnabled)
-
isTransferImageEnabled
public boolean isTransferImageEnabled()
-
setTransferImageBackground
public void setTransferImageBackground(java.awt.Color transferImageBackground)
-
getTransferImageBackground
public java.awt.Color getTransferImageBackground()
-
isLocalDrag
public boolean isLocalDrag()
Returns true if the DnD operation started from this handler.
-
setLocation
public void setLocation(java.awt.Point value)
-
setOffset
public void setOffset(java.awt.Point value)
-
canImport
public boolean canImport(javax.swing.JComponent comp, java.awt.datatransfer.DataFlavor[] flavors)- Overrides:
canImportin classjavax.swing.TransferHandler
-
createTransferable
public java.awt.datatransfer.Transferable createTransferable(javax.swing.JComponent c)
(non-Javadoc)- Overrides:
createTransferablein classjavax.swing.TransferHandler- See Also:
TransferHandler.createTransferable(javax.swing.JComponent)
-
createGraphTransferable
public mxGraphTransferable createGraphTransferable(mxGraphComponent graphComponent, java.lang.Object[] cells, javax.swing.ImageIcon icon)
-
createGraphTransferable
public mxGraphTransferable createGraphTransferable(mxGraphComponent graphComponent, java.lang.Object[] cells, mxRectangle bounds, javax.swing.ImageIcon icon)
-
createTransferableImage
public javax.swing.ImageIcon createTransferableImage(mxGraphComponent graphComponent, java.lang.Object[] cells)
-
exportDone
public void exportDone(javax.swing.JComponent c, java.awt.datatransfer.Transferable data, int action)- Overrides:
exportDonein classjavax.swing.TransferHandler
-
removeCells
protected void removeCells(mxGraphComponent graphComponent, java.lang.Object[] cells)
-
getSourceActions
public int getSourceActions(javax.swing.JComponent c)
- Overrides:
getSourceActionsin classjavax.swing.TransferHandler
-
importData
public boolean importData(javax.swing.JComponent c, java.awt.datatransfer.Transferable t)Checks if the mxGraphTransferable data flavour is supported and calls importGraphTransferable if possible.- Overrides:
importDatain classjavax.swing.TransferHandler
-
updateImportCount
protected void updateImportCount(java.awt.datatransfer.Transferable t)
Counts the number of times that the given transferable has been imported.
-
importGraphTransferable
protected boolean importGraphTransferable(mxGraphComponent graphComponent, mxGraphTransferable gt)
Returns true if the cells have been imported using importCells.
-
getDropTarget
protected java.lang.Object getDropTarget(mxGraphComponent graphComponent, mxGraphTransferable gt)
Returns the drop target for the given transferable and location.
-
importCells
protected java.lang.Object[] importCells(mxGraphComponent graphComponent, mxGraphTransferable gt, double dx, double dy)
Gets a drop target using getDropTarget and imports the cells using mxGraph.splitEdge or mxGraphComponent.importCells depending on the drop target and the return values of mxGraph.isSplitEnabled and mxGraph.isSplitTarget. Selects and returns the cells that have been imported.
-
-