当前位置: 首页>>代码示例>>Java>>正文


Java BufferedImage.getPropertyNames方法代码示例

本文整理汇总了Java中java.awt.image.BufferedImage.getPropertyNames方法的典型用法代码示例。如果您正苦于以下问题:Java BufferedImage.getPropertyNames方法的具体用法?Java BufferedImage.getPropertyNames怎么用?Java BufferedImage.getPropertyNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.image.BufferedImage的用法示例。


在下文中一共展示了BufferedImage.getPropertyNames方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validate

import java.awt.image.BufferedImage; //导入方法依赖的package包/类
private static void validate(final BufferedImage bi, final int expected) {
    final String[] names = bi.getPropertyNames();
    if (names.length != expected) {
        throw new RuntimeException("Wrong number of names");
    }
    for (final String name : names) {
        final Object property = bi.getProperty(name);
        if (property == Image.UndefinedProperty || property == null) {
            throw new RuntimeException("Unexpected property");
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:13,代码来源:GetPropertyNames.java

示例2: main

import java.awt.image.BufferedImage; //导入方法依赖的package包/类
public static void main(final String[] args) {
    // default result is null
    if (defaultProps.getPropertyNames() != null) {
        throw new RuntimeException("PropertyNames should be null");
    }
    // for null properties result is null
    final BufferedImage emptyProps = getBufferedImage(null);
    if (emptyProps.getPropertyNames() != null) {
        throw new RuntimeException("PropertyNames should be null");
    }
    // for empty properties result is null
    final BufferedImage nullProps = getBufferedImage(new Properties());
    if (nullProps.getPropertyNames() != null) {
        throw new RuntimeException("PropertyNames should be null");
    }
    // for non-string keys result is null
    final Properties properties = new Properties();
    properties.put(1, 1);
    properties.put(2, 2);
    properties.put(3, 3);
    final BufferedImage nonStringProps = getBufferedImage(properties);
    if (nonStringProps.getPropertyNames() != null) {
        throw new RuntimeException("PropertyNames should be null");
    }
    // for string keys result is not null
    properties.clear();
    properties.setProperty("1", "1");
    properties.setProperty("2", "2");
    validate(getBufferedImage(properties), 2);
    // for the mix of strings and objects result is not null
    properties.clear();
    properties.put(1, 1);
    properties.put(2, 2);
    properties.put(3, 3);
    properties.setProperty("key1", "value1");
    properties.setProperty("key2", "value2");
    final BufferedImage mixProps = getBufferedImage(properties);
    validate(mixProps, 2);
    if (!"value1".equals(mixProps.getProperty("key1"))
        || !"value2".equals(mixProps.getProperty("key2"))) {
        throw new RuntimeException("Wrong key-value pair");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:44,代码来源:GetPropertyNames.java


注:本文中的java.awt.image.BufferedImage.getPropertyNames方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。