當前位置: 首頁>>代碼示例>>Java>>正文


Java DataFlavor.isFlavorTextType方法代碼示例

本文整理匯總了Java中java.awt.datatransfer.DataFlavor.isFlavorTextType方法的典型用法代碼示例。如果您正苦於以下問題:Java DataFlavor.isFlavorTextType方法的具體用法?Java DataFlavor.isFlavorTextType怎麽用?Java DataFlavor.isFlavorTextType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.datatransfer.DataFlavor的用法示例。


在下文中一共展示了DataFlavor.isFlavorTextType方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getFlavorsForFormatsAsSet

import java.awt.datatransfer.DataFlavor; //導入方法依賴的package包/類
/**
 * Returns a Set of all DataFlavors for which
 * 1) a mapping from at least one of the specified formats exists in the
 * specified map and
 * 2) the data translation for this mapping can be performed by the data
 * transfer subsystem.
 *
 * @param formats the data formats
 * @param map the FlavorTable which contains mappings between
 *            DataFlavors and data formats
 * @throws NullPointerException if formats or map is {@code null}
 */
public Set<DataFlavor> getFlavorsForFormatsAsSet(long[] formats, FlavorTable map) {
    Set<DataFlavor> flavorSet = new HashSet<>(formats.length);

    for (long format : formats) {
        List<DataFlavor> flavors = map.getFlavorsForNative(getNativeForFormat(format));
        for (DataFlavor flavor : flavors) {
            // 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()) {
                flavorSet.add(flavor);
            }
        }
    }

    return flavorSet;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:34,代碼來源:DataTransferer.java

示例2: getFlavorsForFormatsAsSet

import java.awt.datatransfer.DataFlavor; //導入方法依賴的package包/類
/**
 * Returns a Set of all DataFlavors for which
 * 1) a mapping from at least one of the specified formats exists in the
 * specified map and
 * 2) the data translation for this mapping can be performed by the data
 * transfer subsystem.
 *
 * @param formats the data formats
 * @param map the FlavorTable which contains mappings between
 *            DataFlavors and data formats
 * @throws NullPointerException if formats or map is <code>null</code>
 */
public Set getFlavorsForFormatsAsSet(long[] formats, FlavorTable map) {
    Set flavorSet = new HashSet(formats.length);

    for (int i = 0; i < formats.length; i++) {
        String nat = getNativeForFormat(formats[i]);
        List flavors = map.getFlavorsForNative(nat);

        for (Iterator iter = flavors.iterator(); iter.hasNext(); ) {
            DataFlavor flavor = (DataFlavor)iter.next();

            // 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())
            {
                flavorSet.add(flavor);
            }
        }
    }

    return flavorSet;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:39,代碼來源:DataTransferer.java

示例3: translateStream

import java.awt.datatransfer.DataFlavor; //導入方法依賴的package包/類
@Override
public Object translateStream(InputStream str,
                             DataFlavor flavor, long format,
                             Transferable localeTransferable)
    throws IOException
{
    if (format == CF_HTML && flavor.isFlavorTextType()) {
        str = new HTMLCodec(str,
                             EHTMLReadMode.getEHTMLReadMode(flavor));

    }
    return super.translateStream(str, flavor, format,
                                    localeTransferable);

}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:16,代碼來源:WDataTransferer.java

示例4: getFormatsForFlavors

import java.awt.datatransfer.DataFlavor; //導入方法依賴的package包/類
/**
 * 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}
 */
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<Long, Integer> indexMap = new HashMap<>(flavors.length);
    Map<Long, Integer> 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<String> natives = map.getNativesForFlavor(flavor);

            currentIndex += natives.size();

            for (String aNative : natives) {
                Long lFormat = getFormatForNativeAsLong(aNative);
                Integer index = 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<Long> comparator = DataFlavorUtil.getIndexOrderComparator(indexMap).reversed();
    SortedMap<Long, DataFlavor> sortedMap = new TreeMap<>(comparator);
    sortedMap.putAll(formatMap);

    return sortedMap;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:81,代碼來源:DataTransferer.java

示例5: compare

import java.awt.datatransfer.DataFlavor; //導入方法依賴的package包/類
/**
 * Compares two {@code DataFlavor} objects. Returns a negative integer,
 * zero, or a positive integer as the first {@code DataFlavor} is worse
 * than, equal to, or better than the second.
 * <p>
 * {@code DataFlavor}s are ordered according to the rules outlined for
 * {@link DataFlavor#selectBestTextFlavor selectBestTextFlavor}.
 *
 * @param  flavor1 the first {@code DataFlavor} to be compared
 * @param  flavor2 the second {@code DataFlavor} to be compared
 * @return a negative integer, zero, or a positive integer as the first
 *         argument is worse, equal to, or better than the second
 * @throws ClassCastException if either of the arguments is not an
 *         instance of {@code DataFlavor}
 * @throws NullPointerException if either of the arguments is
 *         {@code null}
 * @see DataFlavor#selectBestTextFlavor
 */
public int compare(DataFlavor flavor1, DataFlavor flavor2) {
    if (flavor1.isFlavorTextType()) {
        if (flavor2.isFlavorTextType()) {
            return super.compare(flavor1, flavor2);
        } else {
            return 1;
        }
    } else if (flavor2.isFlavorTextType()) {
        return -1;
    } else {
        return 0;
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:32,代碼來源:DataFlavorUtil.java


注:本文中的java.awt.datatransfer.DataFlavor.isFlavorTextType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。