本文整理汇总了Java中java.awt.datatransfer.DataFlavor.imageFlavor方法的典型用法代码示例。如果您正苦于以下问题:Java DataFlavor.imageFlavor方法的具体用法?Java DataFlavor.imageFlavor怎么用?Java DataFlavor.imageFlavor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.datatransfer.DataFlavor
的用法示例。
在下文中一共展示了DataFlavor.imageFlavor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCanDrop
import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
public void testCanDrop() throws ClassNotFoundException {
DefaultExternalDropHandler handler = new DefaultExternalDropHandler();
DataFlavor[] flavors = new DataFlavor[] { DataFlavor.imageFlavor };
assertFalse( handler.canDrop( flavors ) );
flavors = new DataFlavor[] { DataFlavor.imageFlavor, DataFlavor.stringFlavor };
assertFalse( handler.canDrop( flavors ) );
flavors = new DataFlavor[] { DataFlavor.javaFileListFlavor };
assertTrue( handler.canDrop( flavors ) );
flavors = new DataFlavor[] { DataFlavor.javaFileListFlavor, DataFlavor.imageFlavor };
assertTrue( handler.canDrop( flavors ) );
DataFlavor uriListFlavor = new DataFlavor("text/uri-list;class=java.lang.String");
flavors = new DataFlavor[] { uriListFlavor };
assertTrue( handler.canDrop( flavors ) );
flavors = new DataFlavor[] { uriListFlavor, DataFlavor.imageFlavor };
assertTrue( handler.canDrop( flavors ) );
flavors = new DataFlavor[] { uriListFlavor, DataFlavor.javaFileListFlavor, DataFlavor.imageFlavor };
assertTrue( handler.canDrop( flavors ) );
}
示例2: setDataFlavor
import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
/**
* Sets and returns the type of the Transferable object of the clipboard
*
* @param t - Transferable object in clipboard
*
* @return t'type - Type of DataFlavor
*/
public static DataFlavor setDataFlavor(Transferable t) {
DataFlavor[] flavors = t.getTransferDataFlavors();
for (int i = 0; i < flavors.length; i++) {
if (flavors[i].equals(DataFlavor.stringFlavor)) {
type = Contents.TYPE_STRING;
return DataFlavor.stringFlavor;
} else if (flavors[i].equals(DataFlavor.imageFlavor)) {
type = Contents.TYPE_IMAGE;
return DataFlavor.imageFlavor;
} else if (flavors[i].equals(DataFlavor.javaFileListFlavor)) {
type = Contents.TYPE_FILE;
return DataFlavor.javaFileListFlavor;
} else {
}
}
return null;
}
示例3: testGetFileList
import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
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") ) ) );
}
示例4: getTransferData
import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
if (flavor == DataFlavor.imageFlavor) {
return image;
}
throw new UnsupportedFlavorException(flavor);
}
示例5: main
import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
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");
}
}
示例6: main
import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
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");
}
}
示例7: getTransferDataFlavors
import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
public DataFlavor[] getTransferDataFlavors() {
return new DataFlavor[]{
DataFlavor.imageFlavor
};
}
示例8: getTransferDataFlavors
import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
@Override
public DataFlavor[] getTransferDataFlavors() {
DataFlavor[] flavors = new DataFlavor[1];
flavors[0] = DataFlavor.imageFlavor;
return flavors;
}
示例9: getTransferDataFlavors
import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
public DataFlavor[] getTransferDataFlavors() {
return new DataFlavor[]{DataFlavor.imageFlavor};
}
示例10: getTransferDataFlavors
import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public DataFlavor[] getTransferDataFlavors() {
return new DataFlavor[]{DataFlavor.imageFlavor};
}
示例11: isDataFlavorSupported
import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public boolean isDataFlavorSupported(DataFlavor flavor) {
return flavor == DataFlavor.imageFlavor;
}
示例12: getTransferDataFlavors
import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
@Override
public DataFlavor[] getTransferDataFlavors() {
return new DataFlavor[] { DataFlavor.imageFlavor };
}
示例13: getTransferDataFlavors
import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
public DataFlavor[] getTransferDataFlavors() {
DataFlavor[] flavors = new DataFlavor[ 1 ];
flavors[ 0 ] = DataFlavor.imageFlavor;
return flavors;
}
示例14: getTransferDataFlavors
import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
@Override
public DataFlavor[] getTransferDataFlavors() {
DataFlavor[] flavors = new DataFlavor[1];
flavors[ 0] = DataFlavor.imageFlavor;
return flavors;
}
示例15: getTransferDataFlavors
import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
/**
* Gets the transferDataFlavors attribute of the ImageSelection object
*
* @return The transferDataFlavors value
*/
public DataFlavor[] getTransferDataFlavors() {
return new DataFlavor[]{DataFlavor.imageFlavor};
}