Example usage for java.awt.datatransfer DataFlavor getRepresentationClass

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

Introduction

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

Prototype

public Class<?> getRepresentationClass() 

Source Link

Document

Returns the Class which objects supporting this DataFlavor will return when this DataFlavor is requested.

Usage

From source file:Main.java

public static void main(String[] args) {

    DataFlavor df = DataFlavor.stringFlavor;

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

From source file:MainClass.java

public static void main(String[] args) {

    DataFlavor df = DataFlavor.stringFlavor;

    System.out.println("Mime type: " + df.getMimeType());
    System.out.println("Primary type: " + df.getPrimaryType());
    System.out.println("Subtype: " + df.getSubType());
    System.out.println("Name: " + df.getHumanPresentableName());
    String s = df.getRepresentationClass().toString();
    System.out.println("Representation class: " + s + "\n");

    df = DataFlavor.javaFileListFlavor;

    System.out.println("Mime type: " + df.getMimeType());
    System.out.println("Primary type: " + df.getPrimaryType());
    System.out.println("Subtype: " + df.getSubType());
    System.out.println("Name: " + df.getHumanPresentableName());
    s = df.getRepresentationClass().toString();
    System.out.println("Representation class: " + s);
}

From source file:MainClass.java

public static void main(String[] args) {

    DataFlavor df1 = new DataFlavor("text/plain; charset=ASCII", "Plain ASCII text");

    DataFlavor df2 = new DataFlavor(java.awt.Button.class, "AWT Button");

    System.out.println("Mime type: " + df2.getMimeType());
    System.out.println("Primary type: " + df2.getPrimaryType());
    System.out.println("Subtype: " + df2.getSubType());
    System.out.println("Name: " + df2.getHumanPresentableName());
    String s = df2.getRepresentationClass().toString();
    System.out.println("Representation class: " + s + "\n");

    System.out.println("df1 equals df2: " + df1.isMimeTypeEqual(df2));
}

From source file:MainClass.java

public static void main(String[] args) {

    DataFlavor df = new DataFlavor("text/plain; charset=ASCII", "Plain ASCII text");

    System.out.println("Mime type: " + df.getMimeType());
    System.out.println("Primary type: " + df.getPrimaryType());
    System.out.println("Subtype: " + df.getSubType());
    System.out.println("Parameter: " + df.getParameter("charset"));
    System.out.println("Name: " + df.getHumanPresentableName());
    String s = df.getRepresentationClass().toString();
    System.out.println("Representation class: " + s + "\n");

}

From source file:com.igormaznitsa.sciareto.ui.editors.MMDEditor.java

protected static boolean checkDragType(@Nonnull final DropTargetDragEvent dtde) {
    boolean result = false;
    for (final DataFlavor flavor : dtde.getCurrentDataFlavors()) {
        final Class dataClass = flavor.getRepresentationClass();
        if (FileTransferable.class.isAssignableFrom(dataClass) || flavor.isFlavorJavaFileListType()) {
            result = true;/*ww  w.  ja  v  a 2s .  co  m*/
            break;
        }
    }
    return result;
}

From source file:edu.ku.brc.specify.tasks.subpane.wb.ImageTransferable.java

@Override
public boolean canImport(TransferSupport support) {
    Transferable trans = support.getTransferable();
    DataFlavor[] flavors = trans.getTransferDataFlavors();
    for (DataFlavor df : flavors) {
        if (df.getHumanPresentableName().equals(MIME_TYPE) && df.getRepresentationClass() == String.class) {
            return true;
            /*try//from  ww  w  .j ava 2s.  c o  m
            {
            String uris = (String)trans.getTransferData(df);
                    
            String[] filePaths = StringUtils.split(uris, "\r\n");
            for (String path : filePaths)
            {
                System.out.println("canImport2: "+filter.isImageFile(path));
                return filter.isImageFile(path);
            }
            } catch (UnsupportedFlavorException e)
            {
            e.printStackTrace();
            } catch (IOException e)
            {
            e.printStackTrace();
            }*/
        }
    }
    return false;
}

From source file:edu.ku.brc.specify.tasks.subpane.wb.ImageTransferable.java

@Override
public boolean canImport(JComponent comp, DataFlavor[] transferFlavors) {
    for (DataFlavor df : transferFlavors) {
        if (df.getHumanPresentableName().equals(MIME_TYPE) && df.getRepresentationClass() == String.class) {
            return true;
            /*try//w w w . j  a v  a2s .  co  m
            {
                       
            String uris = (String)trans.getTransferData(df);
            String[] filePaths = StringUtils.split(uris, "\r\n");
            for (String path : filePaths)
            {
                return filter.isImageFile(path);
            }
            } catch (UnsupportedFlavorException e)
            {
            e.printStackTrace();
            } catch (IOException e)
            {
            e.printStackTrace();
            }*/
        }
    }
    System.out.println("canImport1: false");
    return false;
}

From source file:TreeDragTest.java

public boolean isDataFlavorSupported(DataFlavor flavor) {
    return (flavor.getRepresentationClass() == TreePath.class);
}

From source file:edu.ku.brc.specify.tasks.subpane.wb.ImageTransferable.java

@Override
public boolean importData(TransferSupport support) {
    Vector<File> fileList = new Vector<File>();

    try {/* w  w  w.j a va 2  s .  c  om*/
        Transferable trans = support.getTransferable();
        DataFlavor[] flavors = trans.getTransferDataFlavors();
        for (DataFlavor df : flavors) {
            if (df.getHumanPresentableName().equals("text/uri-list")
                    && df.getRepresentationClass() == String.class) {
                String uris = (String) trans.getTransferData(df);
                String[] filePaths = StringUtils.split(uris, "\r\n");
                for (String path : filePaths) {
                    URI uri = URI.create(path);
                    File f = new File(uri);
                    if (filter.isImageFile(path)) {
                        fileList.add(f);
                    }
                }
                break;
            }
        }

    } catch (UnsupportedFlavorException e) {
        e.printStackTrace();

    } catch (IOException e) {
        e.printStackTrace();
    }

    if (fileList.size() > 0) {
        processImages(fileList);
        return true;
    }

    return false;
}

From source file:SerialTransferTest.java

public boolean isDataFlavorSupported(DataFlavor flavor) {
    return DataFlavor.stringFlavor.equals(flavor) || "application".equals(flavor.getPrimaryType())
            && "x-java-serialized-object".equals(flavor.getSubType())
            && flavor.getRepresentationClass().isAssignableFrom(obj.getClass());
}