Class ImageSelection

  • All Implemented Interfaces:
    java.awt.datatransfer.ClipboardOwner, java.awt.datatransfer.Transferable

    public class ImageSelection
    extends java.lang.Object
    implements java.awt.datatransfer.Transferable, java.awt.datatransfer.ClipboardOwner
    A Transferable which implements the capability required to transfer an Image. This Transferable properly supports DataFlavor.imageFlavor and all equivalent flavors. No other DataFlavors are supported.

    Modified by: Joseph A. Huwaldt

    Version:
    March 5, 2009
    Author:
    Joseph A. Huwaldt Date: March 5, 2009
    • Constructor Summary

      Constructors 
      Constructor Description
      ImageSelection​(java.awt.Image image)
      Creates a Transferable capable of transferring the specified Image.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object getTransferData​(java.awt.datatransfer.DataFlavor flavor)
      Returns the Transferable's data in the requested DataFlavor if possible.
      java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
      Returns an array of flavors in which this Transferable can provide the data.
      boolean isDataFlavorSupported​(java.awt.datatransfer.DataFlavor flavor)
      Returns whether the requested flavor is supported by this Transferable.
      void lostOwnership​(java.awt.datatransfer.Clipboard clipboard, java.awt.datatransfer.Transferable contents)
      Notifies this object that it is no longer the clipboard owner.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ImageSelection

        public ImageSelection​(java.awt.Image image)
        Creates a Transferable capable of transferring the specified Image.
    • Method Detail

      • getTransferDataFlavors

        public java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
        Returns an array of flavors in which this Transferable can provide the data. DataFlavor.imageFlavor is properly supported.
        Specified by:
        getTransferDataFlavors in interface java.awt.datatransfer.Transferable
        Returns:
        an array of length one, whose only element is DataFlavor.imageFlavor
      • isDataFlavorSupported

        public boolean isDataFlavorSupported​(java.awt.datatransfer.DataFlavor flavor)
        Returns whether the requested flavor is supported by this Transferable.
        Specified by:
        isDataFlavorSupported in interface java.awt.datatransfer.Transferable
        Parameters:
        flavor - the requested flavor for the data
        Returns:
        true if flavor is equal to DataFlavor.imageFlavor; false if flavor is any other flavor.
      • getTransferData

        public java.lang.Object getTransferData​(java.awt.datatransfer.DataFlavor flavor)
                                         throws java.awt.datatransfer.UnsupportedFlavorException,
                                                java.io.IOException
        Returns the Transferable's data in the requested DataFlavor if possible. If the desired flavor is DataFlavor.imageFlavor, or an equivalent flavor, the Image representing the selection is returned.
        Specified by:
        getTransferData in interface java.awt.datatransfer.Transferable
        Parameters:
        flavor - the requested flavor for the data
        Returns:
        the data in the requested flavor, as outlined above
        Throws:
        java.awt.datatransfer.UnsupportedFlavorException - if the requested data flavor is not equivalent to DataFlavor.imageFlavor
        java.io.IOException - if the data is no longer available in the requested flavor.
        java.lang.NullPointerException - if flavor is null
      • lostOwnership

        public void lostOwnership​(java.awt.datatransfer.Clipboard clipboard,
                                  java.awt.datatransfer.Transferable contents)
        Notifies this object that it is no longer the clipboard owner. This method will be called when another application or another object within this application asserts ownership of the clipboard.
        Specified by:
        lostOwnership in interface java.awt.datatransfer.ClipboardOwner