imageFlavor ( )源码实例Demo

java.awt.datatransfer.DataFlavor#imageFlavor ( )源码实例Demo

下面列出了java.awt.datatransfer.DataFlavor#imageFlavor ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: markdown-image-kit   文件: ImageUtils.java
/**
 * Gets data from clipboard.
 *
 * @return the data from clipboard  map 中只有一对 kev-value
 */
@Nullable
public static Map<DataFlavor, Object> getDataFromClipboard() {
    Map<DataFlavor, Object> data = new HashMap<>(1);
    Transferable transferable = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
    if (transferable != null) {
        // 如果剪切板的内容是文件
        try {
            DataFlavor dataFlavor;
            if (transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
                // List<File>
                dataFlavor = DataFlavor.javaFileListFlavor;
            } else if (transferable.isDataFlavorSupported(DataFlavor.imageFlavor)) {
                // Image
                dataFlavor = DataFlavor.imageFlavor;
            } else {
                return null;
            }
            Object object = transferable.getTransferData(dataFlavor);
            data.put(dataFlavor, object);
        } catch (IOException | UnsupportedFlavorException ignored) {
            // 如果 clipboard 没有文件, 不处理
        }
    }
    return data;
}
 
源代码2 项目: MtgDesktopCompanion   文件: FileDropDecorator.java
public DataFlavor[] getTransferDataFlavors() 
{   
    if( customFlavor != null )
        return new DataFlavor[]
        {   
           customFlavor,
           DATA_FLAVOR,
           DataFlavor.imageFlavor
        }; 
    else
        return new DataFlavor[]
        {   
        	DATA_FLAVOR,
            DataFlavor.imageFlavor
        }; 
}
 
源代码3 项目: TencentKona-8   文件: DataFlavorComparatorTest.java
public static void main(String[] args) {
    DataTransferer.DataFlavorComparator comparator = new DataTransferer.DataFlavorComparator();
    DataFlavor flavor1 = DataFlavor.imageFlavor;
    DataFlavor flavor2 = DataFlavor.selectionHtmlFlavor;
    if (comparator.compare(flavor1, flavor2) == 0) {
        throw new RuntimeException(flavor1.getMimeType() + " and " + flavor2.getMimeType() +
            " should not be equal");
    }
}
 
源代码4 项目: jdk8u60   文件: DataFlavorComparatorTest.java
public static void main(String[] args) {
    DataTransferer.DataFlavorComparator comparator = new DataTransferer.DataFlavorComparator();
    DataFlavor flavor1 = DataFlavor.imageFlavor;
    DataFlavor flavor2 = DataFlavor.selectionHtmlFlavor;
    if (comparator.compare(flavor1, flavor2) == 0) {
        throw new RuntimeException(flavor1.getMimeType() + " and " + flavor2.getMimeType() +
            " should not be equal");
    }
}
 
源代码5 项目: netbeans   文件: DefaultExternalDropHandlerTest.java
public void testGetFileList() throws ClassNotFoundException, URISyntaxException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
    DefaultExternalDropHandler handler = new DefaultExternalDropHandler();
    DataFlavor uriListFlavor = new DataFlavor("text/uri-list;class=java.lang.String");

    Transferable t = new TransferableImpl( new ArrayList(), new DataFlavor[] { DataFlavor.imageFlavor, DataFlavor.stringFlavor } );
    assertNull( handler.getFileList( t ) );

    List<File> list = new ArrayList<File>( 2 );
    list.add( new File("//somedir/somefile.someext") );
    list.add( new File("c:\\somedir\\somefile.someext") );
    t = new TransferableImpl( list, new DataFlavor[] { DataFlavor.javaFileListFlavor, DataFlavor.stringFlavor } );

    List<File> extractedList = handler.getFileList( t );
    assertNotNull( extractedList );
    assertEquals( 2, extractedList.size() );
    for( Iterator i=list.iterator(); i.hasNext(); ) {
        assertTrue( extractedList.contains( i.next() ) );
    }

    String uriList = "file:///somedir/somefile.someext\r\nfile:/c:/somedir/somefile.someext";
    t = new TransferableImpl( uriList, new DataFlavor[] { uriListFlavor, DataFlavor.stringFlavor } );
    extractedList = handler.getFileList( t );
    assertNotNull( extractedList );
    assertEquals( 2, extractedList.size() );
    assertTrue( extractedList.contains( new File( new URI("file:///somedir/somefile.someext") ) ) );
    assertTrue( extractedList.contains( new File( new URI("file:/c:/somedir/somefile.someext") ) ) );
}
 
源代码6 项目: openjdk-jdk9   文件: DataFlavorComparatorTest.java
public static void main(String[] args) {
    Comparator<DataFlavor> comparator = DataFlavorUtil.getDataFlavorComparator();
    DataFlavor flavor1 = DataFlavor.imageFlavor;
    DataFlavor flavor2 = DataFlavor.selectionHtmlFlavor;
    if (comparator.compare(flavor1, flavor2) == 0) {
        throw new RuntimeException(flavor1.getMimeType() + " and " + flavor2.getMimeType() +
            " should not be equal");
    }
}
 
public static void main(String[] args) {
    DataTransferer.DataFlavorComparator comparator = new DataTransferer.DataFlavorComparator();
    DataFlavor flavor1 = DataFlavor.imageFlavor;
    DataFlavor flavor2 = DataFlavor.selectionHtmlFlavor;
    if (comparator.compare(flavor1, flavor2) == 0) {
        throw new RuntimeException(flavor1.getMimeType() + " and " + flavor2.getMimeType() +
            " should not be equal");
    }
}
 
源代码8 项目: jdk8u-dev-jdk   文件: DataFlavorComparatorTest.java
public static void main(String[] args) {
    DataTransferer.DataFlavorComparator comparator = new DataTransferer.DataFlavorComparator();
    DataFlavor flavor1 = DataFlavor.imageFlavor;
    DataFlavor flavor2 = DataFlavor.selectionHtmlFlavor;
    if (comparator.compare(flavor1, flavor2) == 0) {
        throw new RuntimeException(flavor1.getMimeType() + " and " + flavor2.getMimeType() +
            " should not be equal");
    }
}
 
源代码9 项目: markdown-image-kit   文件: ImageUtilsTest.java
public DataFlavor[] getTransferDataFlavors() {
    return new DataFlavor[] {DataFlavor.imageFlavor};
}
 
源代码10 项目: Spade   文件: ClipboardHandler.java
public DataFlavor[] getTransferDataFlavors()
{
	return new DataFlavor[]{DataFlavor.imageFlavor};
}
 
源代码11 项目: netbeans-mmd-plugin   文件: ImageSelection.java
@Override
@Nonnull
@MustNotContainNull
public DataFlavor[] getTransferDataFlavors() {
  return new DataFlavor[] {DataFlavor.imageFlavor};
}
 
源代码12 项目: energy2d   文件: ClipImage.java
public DataFlavor[] getTransferDataFlavors() {
	return new DataFlavor[] { DataFlavor.imageFlavor };
}
 
源代码13 项目: Spark   文件: ContactGroupTransferHandler.java
@Override
public DataFlavor[] getTransferDataFlavors() {
          return new DataFlavor[]{DataFlavor.imageFlavor};
      }
 
源代码14 项目: PyramidShader   文件: ImageTransferable.java
public DataFlavor[] getTransferDataFlavors() {
	return new DataFlavor[] {DataFlavor.imageFlavor};
}
 
源代码15 项目: jpexs-decompiler   文件: PlayerControls.java
@Override
public DataFlavor[] getTransferDataFlavors() {
    DataFlavor[] flavors = new DataFlavor[1];
    flavors[0] = DataFlavor.imageFlavor;
    return flavors;
}
 
public DataFlavor[] getTransferDataFlavors() {
    return new DataFlavor[]{
            DataFlavor.imageFlavor};
}
 
源代码17 项目: runelite   文件: TransferableBufferedImage.java
@Override
public DataFlavor[] getTransferDataFlavors()
{
	return new DataFlavor[]{DataFlavor.imageFlavor};
}
 
源代码18 项目: xnx3   文件: SystemUtil.java
public DataFlavor[] getTransferDataFlavors() { 
	return new DataFlavor[]{DataFlavor.imageFlavor}; 
}
 
源代码19 项目: osp   文件: SnapshotTool.java
public DataFlavor[] getTransferDataFlavors() {
  return new DataFlavor[] {DataFlavor.imageFlavor};
}
 
源代码20 项目: rapidminer-studio   文件: TransferableImage.java
@Override
public DataFlavor[] getTransferDataFlavors() {
	DataFlavor[] flavors = new DataFlavor[1];
	flavors[0] = DataFlavor.imageFlavor;
	return flavors;
}