/*
* @(#)ImageTransferable.java
*
* $Date: 2011-05-02 16:01:45 -0500 (Mon, 02 May 2011) $
*
* Copyright (c) 2011 by Jeremy Wood.
* All rights reserved.
*
* The copyright of this software is owned by Jeremy Wood.
* You may not use, copy or modify this software, except in
* accordance with the license agreement you entered into with
* Jeremy Wood. For details see accompanying license terms.
*
* This software is probably, but not necessarily, discussed here:
* http://javagraphics.java.net/
*
* That site should also contain the most recent official version
* of this software. (See the SVN repository for more details.)
*/
package ale.util.colors.bric.swing;
import java.awt.Image;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;
class ImageTransferable implements Transferable {
Image img;
public ImageTransferable(Image i) {
this.img = i;
}
@Override
public Object getTransferData(DataFlavor f)
throws UnsupportedFlavorException, IOException {
if (f.equals(DataFlavor.imageFlavor) == false) {
throw new UnsupportedFlavorException(f);
}
return this.img;
}
@Override
public DataFlavor[] getTransferDataFlavors() {
return new DataFlavor[] { DataFlavor.imageFlavor };
}
@Override
public boolean isDataFlavorSupported(DataFlavor flavor) {
return (flavor.equals(DataFlavor.imageFlavor));
}
}