Example usage for java.awt.datatransfer UnsupportedFlavorException UnsupportedFlavorException

List of usage examples for java.awt.datatransfer UnsupportedFlavorException UnsupportedFlavorException

Introduction

In this page you can find the example usage for java.awt.datatransfer UnsupportedFlavorException UnsupportedFlavorException.

Prototype

public UnsupportedFlavorException(DataFlavor flavor) 

Source Link

Document

Constructs an UnsupportedFlavorException.

Usage

From source file:Main.java

public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
    if (!DataFlavor.imageFlavor.equals(flavor)) {
        throw new UnsupportedFlavorException(flavor);
    }/* ww w.j ava2  s.c  om*/
    return image;
}

From source file:org.jfree.chart.demo.PDFChartTransferable.java

public Object getTransferData(DataFlavor dataflavor) throws UnsupportedFlavorException, IOException {
    if (pdfFlavor.equals(dataflavor)) {
        ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
        writeChartAsPDF(bytearrayoutputstream, chart, width, height, new DefaultFontMapper());
        return new ByteArrayInputStream(bytearrayoutputstream.toByteArray());
    } else {//w w  w  .  jav  a 2  s.c om
        throw new UnsupportedFlavorException(dataflavor);
    }
}

From source file:net.sf.jabref.exporter.RtfSelection.java

@Override
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {

    if (flavor.equals(DataFlavor.stringFlavor)) {
        return content;
    } else if (flavor.equals(rtfFlavor)) {
        byte[] byteArray = content.getBytes();
        return new ByteArrayInputStream(byteArray);
    }//from w  w w  .j av a  2  s .  com
    throw new UnsupportedFlavorException(flavor);
}

From source file:TransferableColor.java

/** 
 * Transfer the data.  Given a specified DataFlavor, return an Object
 * appropriate for that flavor.  Throw UnsupportedFlavorException if we
 * don't support the requested flavor.//from   w ww .j  av  a  2  s. co m
 */
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
    if (flavor.equals(colorFlavor))
        return color;
    else if (flavor.equals(DataFlavor.stringFlavor))
        return color.toString();
    else if (flavor.equals(DataFlavor.plainTextFlavor))
        return new ByteArrayInputStream(color.toString().getBytes("Unicode"));
    else
        throw new UnsupportedFlavorException(flavor);
}

From source file:net.sf.keystore_explorer.gui.dnd.KeyStoreEntryTransferable.java

/**
 * Get transfer data./* w w w .ja  v a  2 s.  co m*/
 *
 * @param dataFlavor
 *            Data flavor
 * @return Transfer data
 * @throws UnsupportedFlavorException
 *             If the requested data flavor is not supported
 * @throws IOException
 *             If an I/O problem occurred
 */
@Override
public Object getTransferData(DataFlavor dataFlavor) throws UnsupportedFlavorException, IOException {
    if (!isDataFlavorSupported(dataFlavor)) {
        throw new UnsupportedFlavorException(dataFlavor);
    }

    if (dataFlavor == DataFlavor.javaFileListFlavor) {
        String tempDir = System.getProperty("java.io.tmpdir");

        File tmpFile = new File(tempDir, dragEntry.getFileName());
        tmpFile.deleteOnExit();

        FileOutputStream fos = null;
        try {
            fos = new FileOutputStream(tmpFile);
            fos.write(dragEntry.getContent());
        } finally {
            IOUtils.closeQuietly(fos);
        }

        List<File> list = new ArrayList<File>();
        list.add(tmpFile);
        return list;
    } else {
        return dragEntry.getContentString();
    }
}

From source file:ComplexExample.java

public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException {
    if (flavor.equals(colorFlavor))
        return color;
    else if (flavor.equals(DataFlavor.stringFlavor))
        return color.toString();
    else/*  w w  w .jav a  2  s  . c o m*/
        throw new UnsupportedFlavorException(flavor);
}

From source file:DnDDemo2.java

public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
    if (flavor.equals(flavors[0])) {
        return text;
    } else if (flavor.equals(flavors[1])) {
        return color;
    } else {// w ww. jav a  2  s.  c o  m
        throw new UnsupportedFlavorException(flavor);
    }
}

From source file:org.gumtree.vis.mask.ChartTransferableWithMask.java

@Override
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
    BufferedImage image;/*from  ww w .j a va  2 s  .  c  o m*/
    if (this.imageFlavor.equals(flavor)) {
        image = chart.createBufferedImage(width, height);
    } else {
        throw new UnsupportedFlavorException(flavor);
    }
    Graphics2D g2 = image.createGraphics();
    drawMasksInDataArea(g2, dataArea != null ? dataArea : new Rectangle2D.Double(0, 0, width, height), masks,
            chart);
    ChartMaskingUtilities.drawShapes(g2, dataArea, shapeMap, chart);
    ChartMaskingUtilities.drawText(g2, dataArea, textContentMap, chart);
    g2.dispose();
    return image;
}

From source file:SerialTransferTest.java

public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException {
    if (!isDataFlavorSupported(flavor))
        throw new UnsupportedFlavorException(flavor);

    if (DataFlavor.stringFlavor.equals(flavor))
        return obj.toString();

    return obj;//from w w w  .  j av a 2 s  .  c  o m
}

From source file:ImageTransferTest.java

public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException {
    if (flavor.equals(DataFlavor.imageFlavor)) {
        return theImage;
    } else {//from  w w  w  . j  a v  a  2 s . c  o m
        throw new UnsupportedFlavorException(flavor);
    }
}