Class TransferableImage

java.lang.Object
net.thevpc.common.swing.TransferableImage
All Implemented Interfaces:
Transferable, Serializable

public class TransferableImage extends Object implements Serializable, Transferable
A container for images.
Version:
$Revision: 4584 $ https://github.com/fracpete/jclipboardhelper/blob/master/src/main/java/com/github/fracpete/jclipboardhelper/TransferableImage.java
Author:
fracpete (fracpete at waikato dot ac dot nz)
See Also:
  • Field Details

  • Constructor Details

    • TransferableImage

      public TransferableImage(BufferedImage data)
      Initializes the container.
      Parameters:
      data - the string to transfer
  • Method Details

    • getTransferDataFlavors

      public DataFlavor[] getTransferDataFlavors()
      Returns an array of DataFlavor objects indicating the flavors the data can be provided in. The array should be ordered according to preference for providing the data (from most richly descriptive to least descriptive).
      Specified by:
      getTransferDataFlavors in interface Transferable
      Returns:
      an array of data flavors in which this data can be transferred
    • isDataFlavorSupported

      public boolean isDataFlavorSupported(DataFlavor flavor)
      Returns whether or not the specified data flavor is supported for this object.
      Specified by:
      isDataFlavorSupported in interface Transferable
      Parameters:
      flavor - the requested flavor for the data
      Returns:
      boolean indicating whether or not the data flavor is supported
    • getTransferData

      public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, 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 interface Transferable
      Parameters:
      flavor - the requested flavor for the data
      Returns:
      the transferred string
      Throws:
      IOException - if the data is no longer available in the requested flavor.
      UnsupportedFlavorException - if the requested data flavor is not supported.
      See Also:
    • getData

      public BufferedImage getData()
      Returns the underlying image.
      Returns:
      the image
    • toString

      public String toString()
      Returns a string representation of the underlying image.
      Overrides:
      toString in class Object
      Returns:
      the string representation