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

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

源代码1 项目: openjdk-jdk9   文件: AddFlavorTest.java
void compareFlavors(List<DataFlavor> flavors1, List<DataFlavor> flavors2, String key){
    for (DataFlavor flavor1 : flavors1) {
        boolean result = false;
        for (DataFlavor flavor2 : flavors2) {
            if (flavor1.equals(flavor2)) result = true;
        }
        if (!result)
            throw new RuntimeException("\n*** Error in verifyNewMappings()" +
                    "\nmethod1: addFlavorForUnencodedNative(String nat, DataFlavor flav)"  +
                    "\nmethod2: List getFlavorsForNative(String nat)" +
                    "\nString native: " + key +
                    "\nAfter adding several mappings with addFlavorForUnencodedNative," +
                    "\nthe returned list did not match the mappings that were added." +
                    "\nEither the mapping was not included in the list, or the order was incorect.");
    }

}
 
源代码2 项目: consulo   文件: TextTransferable.java
@Override
public boolean isDataFlavorSupported(DataFlavor flavor) {
  for (DataFlavor f : getFlavours()) {
    if (flavor.equals(f)) {
      return true;
    }
  }
  return false;
}
 
源代码3 项目: runelite   文件: TransferableBufferedImage.java
@Override
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException
{
	if (flavor.equals(DataFlavor.imageFlavor))
	{
		return image;
	}
	else
	{
		throw new UnsupportedFlavorException(flavor);
	}
}
 
源代码4 项目: TencentKona-8   文件: XmlDataContentHandler.java
public Object getTransferData(DataFlavor df, DataSource ds)
    throws IOException {

    for (DataFlavor aFlavor : flavors) {
        if (aFlavor.equals(df)) {
            return getContent(ds);
        }
    }
    return null;
}
 
源代码5 项目: openjdk-jdk8u   文件: ImageDataContentHandler.java
/**
 * Returns an object which represents the data to be transferred.
 * The class of the object returned is defined by the representation class
 * of the flavor.
 *
 * @param df The DataFlavor representing the requested type.
 * @param ds The DataSource representing the data to be converted.
 * @return The constructed Object.
 */
public Object getTransferData(DataFlavor df, DataSource ds)
    throws IOException {
    for (DataFlavor aFlavor : flavor) {
        if (aFlavor.equals(df)) {
            return getContent(ds);
        }
    }
    return null;
}
 
源代码6 项目: hottub   文件: ImageTransferTest.java
@Override
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException {
    if (flavor.equals(flavors[IMAGE])) {
        return data;
    } else {
        throw new UnsupportedFlavorException(flavor);
    }
}
 
源代码7 项目: dragonwell8_jdk   文件: ImageTransferTest.java
@Override
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException {
    if (flavor.equals(flavors[IMAGE])) {
        return data;
    } else {
        throw new UnsupportedFlavorException(flavor);
    }
}
 
源代码8 项目: constellation   文件: DragAction.java
@Override
public boolean isDataFlavorSupported(DataFlavor flavor) {
    return flavor.equals(DataFlavor.stringFlavor);
}
 
@Override
public boolean isDataFlavorSupported(DataFlavor flavor) {
    return flavor.equals(dataFlavor);
}
 
源代码10 项目: hottub   文件: FileListTransferable.java
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
    if (flavor.equals(DataFlavor.javaFileListFlavor)) {
        return list;
    }
    throw new UnsupportedFlavorException(flavor);
}
 
源代码11 项目: java-swing-tips   文件: MainPanel.java
@Override public boolean isDataFlavorSupported(DataFlavor flavor) {
  return flavor.equals(DataFlavor.javaFileListFlavor);
}
 
源代码12 项目: wandora   文件: DnDTools.java
@Override
public K getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
    if(flavor.equals(dataFlavor)) return wrapped;
    else throw new UnsupportedFlavorException(flavor);
}
 
源代码13 项目: Quelea   文件: TransferDisplayable.java
/**
 * @inheritDoc
 */
public boolean isDataFlavorSupported(DataFlavor flavor) {
    return flavor.equals(DISPLAYABLE_FLAVOR);
}
 
源代码14 项目: jdk8u60   文件: DataTransferer.java
/**
 * Returns a Map whose keys are all of the possible formats into which data
 * in the specified DataFlavors can be translated. The value of each key
 * is the DataFlavor in which the Transferable's data should be requested
 * when converting to the format.
 * <p>
 * The map keys are sorted according to the native formats preference
 * order.
 *
 * @param flavors the data flavors
 * @param map the FlavorTable which contains mappings between
 *            DataFlavors and data formats
 * @throws NullPointerException if flavors or map is <code>null</code>
 */
public SortedMap <Long, DataFlavor> getFormatsForFlavors(
    DataFlavor[] flavors, FlavorTable map)
{
    Map <Long,DataFlavor> formatMap =
        new HashMap <> (flavors.length);
    Map <Long,DataFlavor> textPlainMap =
        new HashMap <> (flavors.length);
    // Maps formats to indices that will be used to sort the formats
    // according to the preference order.
    // Larger index value corresponds to the more preferable format.
    Map indexMap = new HashMap(flavors.length);
    Map textPlainIndexMap = new HashMap(flavors.length);

    int currentIndex = 0;

    // Iterate backwards so that preferred DataFlavors are used over
    // other DataFlavors. (See javadoc for
    // Transferable.getTransferDataFlavors.)
    for (int i = flavors.length - 1; i >= 0; i--) {
        DataFlavor flavor = flavors[i];
        if (flavor == null) continue;

        // Don't explicitly test for String, since it is just a special
        // case of Serializable
        if (flavor.isFlavorTextType() ||
            flavor.isFlavorJavaFileListType() ||
            DataFlavor.imageFlavor.equals(flavor) ||
            flavor.isRepresentationClassSerializable() ||
            flavor.isRepresentationClassInputStream() ||
            flavor.isRepresentationClassRemote())
        {
            List natives = map.getNativesForFlavor(flavor);

            currentIndex += natives.size();

            for (Iterator iter = natives.iterator(); iter.hasNext(); ) {
                Long lFormat =
                    getFormatForNativeAsLong((String)iter.next());
                Integer index = Integer.valueOf(currentIndex--);

                formatMap.put(lFormat, flavor);
                indexMap.put(lFormat, index);

                // SystemFlavorMap.getNativesForFlavor will return
                // text/plain natives for all text/*. While this is good
                // for a single text/* flavor, we would prefer that
                // text/plain native data come from a text/plain flavor.
                if (("text".equals(flavor.getPrimaryType()) &&
                     "plain".equals(flavor.getSubType())) ||
                    flavor.equals(DataFlavor.stringFlavor))
                {
                    textPlainMap.put(lFormat, flavor);
                    textPlainIndexMap.put(lFormat, index);
                }
            }

            currentIndex += natives.size();
        }
    }

    formatMap.putAll(textPlainMap);
    indexMap.putAll(textPlainIndexMap);

    // Sort the map keys according to the formats preference order.
    Comparator comparator =
        new IndexOrderComparator(indexMap, IndexedComparator.SELECT_WORST);
    SortedMap sortedMap = new TreeMap(comparator);
    sortedMap.putAll(formatMap);

    return sortedMap;
}
 
源代码15 项目: dragonwell8_jdk   文件: FileListTransferable.java
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
    if (flavor.equals(DataFlavor.javaFileListFlavor)) {
        return list;
    }
    throw new UnsupportedFlavorException(flavor);
}
 
源代码16 项目: openjdk-jdk9   文件: FileListTransferable.java
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
    if (flavor.equals(DataFlavor.javaFileListFlavor)) {
        return list;
    }
    throw new UnsupportedFlavorException(flavor);
}
 
源代码17 项目: dragonwell8_jdk   文件: FileListTransferable.java
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
    if (flavor.equals(DataFlavor.javaFileListFlavor)) {
        return list;
    }
    throw new UnsupportedFlavorException(flavor);
}
 
源代码18 项目: jdk8u-jdk   文件: DataTransferer.java
/**
 * Returns a Map whose keys are all of the possible formats into which data
 * in the specified DataFlavors can be translated. The value of each key
 * is the DataFlavor in which the Transferable's data should be requested
 * when converting to the format.
 * <p>
 * The map keys are sorted according to the native formats preference
 * order.
 *
 * @param flavors the data flavors
 * @param map the FlavorTable which contains mappings between
 *            DataFlavors and data formats
 * @throws NullPointerException if flavors or map is <code>null</code>
 */
public SortedMap <Long, DataFlavor> getFormatsForFlavors(
    DataFlavor[] flavors, FlavorTable map)
{
    Map <Long,DataFlavor> formatMap =
        new HashMap <> (flavors.length);
    Map <Long,DataFlavor> textPlainMap =
        new HashMap <> (flavors.length);
    // Maps formats to indices that will be used to sort the formats
    // according to the preference order.
    // Larger index value corresponds to the more preferable format.
    Map indexMap = new HashMap(flavors.length);
    Map textPlainIndexMap = new HashMap(flavors.length);

    int currentIndex = 0;

    // Iterate backwards so that preferred DataFlavors are used over
    // other DataFlavors. (See javadoc for
    // Transferable.getTransferDataFlavors.)
    for (int i = flavors.length - 1; i >= 0; i--) {
        DataFlavor flavor = flavors[i];
        if (flavor == null) continue;

        // Don't explicitly test for String, since it is just a special
        // case of Serializable
        if (flavor.isFlavorTextType() ||
            flavor.isFlavorJavaFileListType() ||
            DataFlavor.imageFlavor.equals(flavor) ||
            flavor.isRepresentationClassSerializable() ||
            flavor.isRepresentationClassInputStream() ||
            flavor.isRepresentationClassRemote())
        {
            List natives = map.getNativesForFlavor(flavor);

            currentIndex += natives.size();

            for (Iterator iter = natives.iterator(); iter.hasNext(); ) {
                Long lFormat =
                    getFormatForNativeAsLong((String)iter.next());
                Integer index = Integer.valueOf(currentIndex--);

                formatMap.put(lFormat, flavor);
                indexMap.put(lFormat, index);

                // SystemFlavorMap.getNativesForFlavor will return
                // text/plain natives for all text/*. While this is good
                // for a single text/* flavor, we would prefer that
                // text/plain native data come from a text/plain flavor.
                if (("text".equals(flavor.getPrimaryType()) &&
                     "plain".equals(flavor.getSubType())) ||
                    flavor.equals(DataFlavor.stringFlavor))
                {
                    textPlainMap.put(lFormat, flavor);
                    textPlainIndexMap.put(lFormat, index);
                }
            }

            currentIndex += natives.size();
        }
    }

    formatMap.putAll(textPlainMap);
    indexMap.putAll(textPlainIndexMap);

    // Sort the map keys according to the formats preference order.
    Comparator comparator =
        new IndexOrderComparator(indexMap, IndexedComparator.SELECT_WORST);
    SortedMap sortedMap = new TreeMap(comparator);
    sortedMap.putAll(formatMap);

    return sortedMap;
}
 
源代码19 项目: runelite   文件: TransferableBufferedImage.java
@Override
public boolean isDataFlavorSupported(DataFlavor flavor)
{
	return flavor.equals(DataFlavor.imageFlavor);
}
 
源代码20 项目: pumpernickel   文件: ImageTransferable.java
public boolean isDataFlavorSupported(DataFlavor flavor) {
	return (flavor.equals(DataFlavor.imageFlavor));
}