Example usage for java.awt.datatransfer DataFlavor toString

List of usage examples for java.awt.datatransfer DataFlavor toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

String representation of this DataFlavor and its parameters.

Usage

From source file:Main.java

public static void main(String[] args) {

    DataFlavor df = DataFlavor.imageFlavor;

    System.out.println(df.toString());
}

From source file:Main.java

public static void main(String[] args) {

    DataFlavor df = DataFlavor.stringFlavor;

    System.out.println(df.toString());
}

From source file:Main.java

public static void main(String[] args) {

    DataFlavor df = DataFlavor.plainTextFlavor;

    System.out.println(df.toString());
}

From source file:Main.java

public static void main(String[] args) {

    DataFlavor df = DataFlavor.javaFileListFlavor;

    System.out.println(df.toString());
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Robot robot = new Robot();
    robot.keyPress(KeyEvent.VK_PRINTSCREEN);
    robot.delay(40);//from   ww  w .  j  a  v  a 2  s .  com
    robot.keyRelease(KeyEvent.VK_PRINTSCREEN);
    robot.delay(404);

    Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();
    DataFlavor[] flavors = cb.getAvailableDataFlavors();
    for (DataFlavor flavor : flavors) {
        if (flavor.toString().indexOf("java.awt.Image") <= 0) {
            continue;
        }
        Image i = (Image) cb.getData(flavor);
        BufferedImage bi = new BufferedImage(i.getWidth(null), i.getHeight(null), BufferedImage.TYPE_INT_RGB);
        Graphics2D g = bi.createGraphics();
        g.drawImage(i, 0, 0, null);
        g.dispose();
        ImageIO.write(bi, "png", new File("c:/Java_Dev/test.png"));
    }
}

From source file:org.feistymeow.dragdrop.ListTransferable.java

/**
 * using the set of files that we've been handed, we can do transfers using our two supported
 * flavors./*w w w.j a  v a 2 s . c om*/
 */
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, java.io.IOException {
    if (flavor == null)
        return null;
    if (size() == 0) {
        logger.debug("size was zero, so loading data just in time");
        boolean worked = loadDataJustInTime(flavor);
        if (!worked || (size() == 0)) {
            logger.warn("failed to retrieve data just in time for getTransferData.");
            return null;
        }
    }
    // help from workaround at http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4899516
    logger.debug("responding to flavor: " + flavor.toString());
    if (flavor.equals(DataFlavor.javaFileListFlavor)) {
        logger.debug("java file list flavor...");
        List<Object> data = new java.util.ArrayList<Object>();
        data.addAll(this);
        return data;
    } else if (flavor.equals(URIListFlavor) || flavor.equals(AltURIListFlavor)) {
        logger.debug("uri list flavor...");
        StringBuilder data = new StringBuilder();
        Iterator<Object> iter = iterator();
        while (iter.hasNext()) {
            Object x = iter.next();
            if (x instanceof File) {
                File elem = (File) x;
                data.append(elem.toURI() + "\r\n");
            } else if (x instanceof String) {
                data.append((String) x + "\r\n");
            } else {
                logger.debug("did not know how to handle type in transfer: " + x.toString());
            }
        }
        logger.debug("returning URI string: " + data.toString());
        return data.toString();
    } else {
        logger.debug("getTransferData: didn't know how to handle the requested flavor.");
        throw new UnsupportedFlavorException(flavor);
    }
}

From source file:org.feistymeow.dragdrop.ListTransferable.java

/**
 * reports if a particular flavor is handled here.
 *///from w  ww  . j  ava 2  s .co  m
public boolean isDataFlavorSupported(DataFlavor flavor) {
    if (flavor == null)
        return false;
    for (int i = 0; i < FLAVORS.size(); i++) {
        if (flavor.equals((DataFlavor) FLAVORS.get(i))) {
            return true;
        }
    }
    logger.debug("failed to find flavor: " + flavor.toString());
    return false;
}

From source file:org.kuali.test.ui.components.repositorytree.RepositoryTree.java

/**
 *
 * @param dataFlavor/*from w  ww. ja v a 2s. co m*/
 * @param data
 * @param dropNode
 */
public void handleDataDrop(DataFlavor dataFlavor, RepositoryTransferData data,
        DefaultMutableTreeNode dropNode) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("dataFlavor: " + dataFlavor.toString() + ", targetType: " + data.getClass().getName()
                + ", targetName: " + getDropTargetName(dropNode.getUserObject()));
    }

    if (DndHelper.getTestDataFlavor().equals(dataFlavor)) {
        addSuiteTests(dropNode, (List<String>) data.getData());
    } else if (DndHelper.getTestOrderDataFlavor().equals(dataFlavor)) {
        moveSuiteTest(dropNode, (SuiteTest) data.getData());
    }

    getMainframe().getSaveConfigurationButton().setEnabled(configuration.getModified());
    getMainframe().getSaveConfigurationMenuItem().setEnabled(configuration.getModified());
}