Java Code Examples for javax.imageio.metadata.IIOMetadata#getMetadataFormat()

The following examples show how to use javax.imageio.metadata.IIOMetadata#getMetadataFormat() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestSIMPPlugin.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
    Iterator<ImageReader> readers = ImageIO.getImageReadersBySuffix("simp");
    ImageReader simpReader = null;
    if (readers.hasNext()) {
        simpReader = readers.next();
        System.out.println("reader="+simpReader);
    }
    if (simpReader == null) {
        throw new RuntimeException("Reader not found.");
    }

    ImageReaderSpi spi = simpReader.getOriginatingProvider();
    IIOMetadataFormat spiFmt =
        spi.getImageMetadataFormat("simp_metadata_1.0");
    System.out.println("fmt from SPI=" + spiFmt);

    ByteArrayInputStream bais = new ByteArrayInputStream(simpData);
    ImageInputStream iis = new MemoryCacheImageInputStream(bais);
    simpReader.setInput(iis);
    BufferedImage bi = simpReader.read(0);
    System.out.println(bi);
    IIOMetadata metadata = simpReader.getImageMetadata(0);
    System.out.println("Image metadata="+metadata);
    IIOMetadataFormat format =
        metadata.getMetadataFormat("simp_metadata_1.0");
    System.out.println("Image metadata format="+format);
    if (format == null) {
        throw new RuntimeException("MetadataFormat not found.");
    }
}
 
Example 2
Source File: UserPluginMetadataFormatTest.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public void doTest() throws IOException {

        DummyImageReaderImpl reader;

        reader = new DummyImageReaderImpl(new DummyImageReaderSpiImpl());

        byte[] data = new byte[1024];
        ByteArrayInputStream bais =
            new ByteArrayInputStream(data);

        reader.setInput(ImageIO.createImageInputStream(bais));
        IIOMetadata metadata = reader.getImageMetadata(1);
        if(metadata == null) {
            throw new RuntimeException("IIOMetada is NULL");
        }

        String[] formatNames = metadata.getMetadataFormatNames();

        for(int j=0; j<formatNames.length; j++) {

            String formatName = formatNames[j];
            System.out.println("\nFormat Names : " + formatName);

            try {
                IIOMetadataFormat metadataFormat =
                    metadata.getMetadataFormat(formatName);
                System.out.println("  Class Name " +
                                   metadataFormat.getClass());
            } catch(IllegalStateException ise) {
                Throwable t = ise;
                t.printStackTrace();
                while(t.getCause() != null) {
                    t = t.getCause();
                    t.printStackTrace();
                }
                // test failed!
                // stop applet!
                System.out.println("Test faied.");
                throw new RuntimeException("Test failed.", ise);
            }
        }
    }
 
Example 3
Source File: UserPluginMetadataFormatTest.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public void doTest() throws IOException {

        DummyImageReaderImpl reader;

        reader = new DummyImageReaderImpl(new DummyImageReaderSpiImpl());

        byte[] data = new byte[1024];
        ByteArrayInputStream bais =
            new ByteArrayInputStream(data);

        reader.setInput(ImageIO.createImageInputStream(bais));
        IIOMetadata metadata = reader.getImageMetadata(1);
        if(metadata == null) {
            throw new RuntimeException("IIOMetada is NULL");
        }

        String[] formatNames = metadata.getMetadataFormatNames();

        for(int j=0; j<formatNames.length; j++) {

            String formatName = formatNames[j];
            System.out.println("\nFormat Names : " + formatName);

            try {
                IIOMetadataFormat metadataFormat =
                    metadata.getMetadataFormat(formatName);
                System.out.println("  Class Name " +
                                   metadataFormat.getClass());
            } catch(IllegalStateException ise) {
                Throwable t = ise;
                t.printStackTrace();
                while(t.getCause() != null) {
                    t = t.getCause();
                    t.printStackTrace();
                }
                // test failed!
                // stop applet!
                System.out.println("Test faied.");
                throw new RuntimeException("Test failed.", ise);
            }
        }
    }
 
Example 4
Source File: UserPluginMetadataFormatTest.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public void doTest() throws IOException {

        DummyImageReaderImpl reader;

        reader = new DummyImageReaderImpl(new DummyImageReaderSpiImpl());

        byte[] data = new byte[1024];
        ByteArrayInputStream bais =
            new ByteArrayInputStream(data);

        reader.setInput(ImageIO.createImageInputStream(bais));
        IIOMetadata metadata = reader.getImageMetadata(1);
        if(metadata == null) {
            throw new RuntimeException("IIOMetada is NULL");
        }

        String[] formatNames = metadata.getMetadataFormatNames();

        for(int j=0; j<formatNames.length; j++) {

            String formatName = formatNames[j];
            System.out.println("\nFormat Names : " + formatName);

            try {
                IIOMetadataFormat metadataFormat =
                    metadata.getMetadataFormat(formatName);
                System.out.println("  Class Name " +
                                   metadataFormat.getClass());
            } catch(IllegalStateException ise) {
                Throwable t = ise;
                t.printStackTrace();
                while(t.getCause() != null) {
                    t = t.getCause();
                    t.printStackTrace();
                }
                // test failed!
                // stop applet!
                System.out.println("Test faied.");
                throw new RuntimeException("Test failed.", ise);
            }
        }
    }
 
Example 5
Source File: UserPluginMetadataFormatTest.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public void doTest() throws IOException {

        DummyImageReaderImpl reader;

        reader = new DummyImageReaderImpl(new DummyImageReaderSpiImpl());

        byte[] data = new byte[1024];
        ByteArrayInputStream bais =
            new ByteArrayInputStream(data);

        reader.setInput(ImageIO.createImageInputStream(bais));
        IIOMetadata metadata = reader.getImageMetadata(1);
        if(metadata == null) {
            throw new RuntimeException("IIOMetada is NULL");
        }

        String[] formatNames = metadata.getMetadataFormatNames();

        for(int j=0; j<formatNames.length; j++) {

            String formatName = formatNames[j];
            System.out.println("\nFormat Names : " + formatName);

            try {
                IIOMetadataFormat metadataFormat =
                    metadata.getMetadataFormat(formatName);
                System.out.println("  Class Name " +
                                   metadataFormat.getClass());
            } catch(IllegalStateException ise) {
                Throwable t = ise;
                t.printStackTrace();
                while(t.getCause() != null) {
                    t = t.getCause();
                    t.printStackTrace();
                }
                // test failed!
                // stop applet!
                System.out.println("Test faied.");
                throw new RuntimeException("Test failed.", ise);
            }
        }
    }
 
Example 6
Source File: UserPluginMetadataFormatTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public void doTest() throws IOException {

        DummyImageReaderImpl reader;

        reader = new DummyImageReaderImpl(new DummyImageReaderSpiImpl());

        byte[] data = new byte[1024];
        ByteArrayInputStream bais =
            new ByteArrayInputStream(data);

        reader.setInput(ImageIO.createImageInputStream(bais));
        IIOMetadata metadata = reader.getImageMetadata(1);
        if(metadata == null) {
            throw new RuntimeException("IIOMetada is NULL");
        }

        String[] formatNames = metadata.getMetadataFormatNames();

        for(int j=0; j<formatNames.length; j++) {

            String formatName = formatNames[j];
            System.out.println("\nFormat Names : " + formatName);

            try {
                IIOMetadataFormat metadataFormat =
                    metadata.getMetadataFormat(formatName);
                System.out.println("  Class Name " +
                                   metadataFormat.getClass());
            } catch(IllegalStateException ise) {
                Throwable t = ise;
                t.printStackTrace();
                while(t.getCause() != null) {
                    t = t.getCause();
                    t.printStackTrace();
                }
                // test failed!
                // stop applet!
                System.out.println("Test faied.");
                throw new RuntimeException("Test failed.", ise);
            }
        }
    }
 
Example 7
Source File: UserPluginMetadataFormatTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public void doTest() throws IOException {

        DummyImageReaderImpl reader;

        reader = new DummyImageReaderImpl(new DummyImageReaderSpiImpl());

        byte[] data = new byte[1024];
        ByteArrayInputStream bais =
            new ByteArrayInputStream(data);

        reader.setInput(ImageIO.createImageInputStream(bais));
        IIOMetadata metadata = reader.getImageMetadata(1);
        if(metadata == null) {
            throw new RuntimeException("IIOMetada is NULL");
        }

        String[] formatNames = metadata.getMetadataFormatNames();

        for(int j=0; j<formatNames.length; j++) {

            String formatName = formatNames[j];
            System.out.println("\nFormat Names : " + formatName);

            try {
                IIOMetadataFormat metadataFormat =
                    metadata.getMetadataFormat(formatName);
                System.out.println("  Class Name " +
                                   metadataFormat.getClass());
            } catch(IllegalStateException ise) {
                Throwable t = ise;
                t.printStackTrace();
                while(t.getCause() != null) {
                    t = t.getCause();
                    t.printStackTrace();
                }
                // test failed!
                // stop applet!
                System.out.println("Test faied.");
                throw new RuntimeException("Test failed.", ise);
            }
        }
    }
 
Example 8
Source File: UserPluginMetadataFormatTest.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public void doTest() throws IOException {

        DummyImageReaderImpl reader;

        reader = new DummyImageReaderImpl(new DummyImageReaderSpiImpl());

        byte[] data = new byte[1024];
        ByteArrayInputStream bais =
            new ByteArrayInputStream(data);

        reader.setInput(ImageIO.createImageInputStream(bais));
        IIOMetadata metadata = reader.getImageMetadata(1);
        if(metadata == null) {
            throw new RuntimeException("IIOMetada is NULL");
        }

        String[] formatNames = metadata.getMetadataFormatNames();

        for(int j=0; j<formatNames.length; j++) {

            String formatName = formatNames[j];
            System.out.println("\nFormat Names : " + formatName);

            try {
                IIOMetadataFormat metadataFormat =
                    metadata.getMetadataFormat(formatName);
                System.out.println("  Class Name " +
                                   metadataFormat.getClass());
            } catch(IllegalStateException ise) {
                Throwable t = ise;
                t.printStackTrace();
                while(t.getCause() != null) {
                    t = t.getCause();
                    t.printStackTrace();
                }
                // test failed!
                // stop applet!
                System.out.println("Test faied.");
                throw new RuntimeException("Test failed.", ise);
            }
        }
    }
 
Example 9
Source File: UserPluginMetadataFormatTest.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public void doTest() throws IOException {

        DummyImageReaderImpl reader;

        reader = new DummyImageReaderImpl(new DummyImageReaderSpiImpl());

        byte[] data = new byte[1024];
        ByteArrayInputStream bais =
            new ByteArrayInputStream(data);

        reader.setInput(ImageIO.createImageInputStream(bais));
        IIOMetadata metadata = reader.getImageMetadata(1);
        if(metadata == null) {
            throw new RuntimeException("IIOMetada is NULL");
        }

        String[] formatNames = metadata.getMetadataFormatNames();

        for(int j=0; j<formatNames.length; j++) {

            String formatName = formatNames[j];
            System.out.println("\nFormat Names : " + formatName);

            try {
                IIOMetadataFormat metadataFormat =
                    metadata.getMetadataFormat(formatName);
                System.out.println("  Class Name " +
                                   metadataFormat.getClass());
            } catch(IllegalStateException ise) {
                Throwable t = ise;
                t.printStackTrace();
                while(t.getCause() != null) {
                    t = t.getCause();
                    t.printStackTrace();
                }
                // test failed!
                // stop applet!
                System.out.println("Test faied.");
                throw new RuntimeException("Test failed.", ise);
            }
        }
    }
 
Example 10
Source File: UserPluginMetadataFormatTest.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public void doTest() throws IOException {

        DummyImageReaderImpl reader;

        reader = new DummyImageReaderImpl(new DummyImageReaderSpiImpl());

        byte[] data = new byte[1024];
        ByteArrayInputStream bais =
            new ByteArrayInputStream(data);

        reader.setInput(ImageIO.createImageInputStream(bais));
        IIOMetadata metadata = reader.getImageMetadata(1);
        if(metadata == null) {
            throw new RuntimeException("IIOMetada is NULL");
        }

        String[] formatNames = metadata.getMetadataFormatNames();

        for(int j=0; j<formatNames.length; j++) {

            String formatName = formatNames[j];
            System.out.println("\nFormat Names : " + formatName);

            try {
                IIOMetadataFormat metadataFormat =
                    metadata.getMetadataFormat(formatName);
                System.out.println("  Class Name " +
                                   metadataFormat.getClass());
            } catch(IllegalStateException ise) {
                Throwable t = ise;
                t.printStackTrace();
                while(t.getCause() != null) {
                    t = t.getCause();
                    t.printStackTrace();
                }
                // test failed!
                // stop applet!
                System.out.println("Test faied.");
                throw new RuntimeException("Test failed.", ise);
            }
        }
    }
 
Example 11
Source File: UserPluginMetadataFormatTest.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public void doTest() throws IOException {

        DummyImageReaderImpl reader;

        reader = new DummyImageReaderImpl(new DummyImageReaderSpiImpl());

        byte[] data = new byte[1024];
        ByteArrayInputStream bais =
            new ByteArrayInputStream(data);

        reader.setInput(ImageIO.createImageInputStream(bais));
        IIOMetadata metadata = reader.getImageMetadata(1);
        if(metadata == null) {
            throw new RuntimeException("IIOMetada is NULL");
        }

        String[] formatNames = metadata.getMetadataFormatNames();

        for(int j=0; j<formatNames.length; j++) {

            String formatName = formatNames[j];
            System.out.println("\nFormat Names : " + formatName);

            try {
                IIOMetadataFormat metadataFormat =
                    metadata.getMetadataFormat(formatName);
                System.out.println("  Class Name " +
                                   metadataFormat.getClass());
            } catch(IllegalStateException ise) {
                Throwable t = ise;
                t.printStackTrace();
                while(t.getCause() != null) {
                    t = t.getCause();
                    t.printStackTrace();
                }
                // test failed!
                // stop applet!
                System.out.println("Test faied.");
                throw new RuntimeException("Test failed.", ise);
            }
        }
    }
 
Example 12
Source File: UserPluginMetadataFormatTest.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public void doTest() throws IOException {

        DummyImageReaderImpl reader;

        reader = new DummyImageReaderImpl(new DummyImageReaderSpiImpl());

        byte[] data = new byte[1024];
        ByteArrayInputStream bais =
            new ByteArrayInputStream(data);

        reader.setInput(ImageIO.createImageInputStream(bais));
        IIOMetadata metadata = reader.getImageMetadata(1);
        if(metadata == null) {
            throw new RuntimeException("IIOMetada is NULL");
        }

        String[] formatNames = metadata.getMetadataFormatNames();

        for(int j=0; j<formatNames.length; j++) {

            String formatName = formatNames[j];
            System.out.println("\nFormat Names : " + formatName);

            try {
                IIOMetadataFormat metadataFormat =
                    metadata.getMetadataFormat(formatName);
                System.out.println("  Class Name " +
                                   metadataFormat.getClass());
            } catch(IllegalStateException ise) {
                Throwable t = ise;
                t.printStackTrace();
                while(t.getCause() != null) {
                    t = t.getCause();
                    t.printStackTrace();
                }
                // test failed!
                // stop applet!
                System.out.println("Test faied.");
                throw new RuntimeException("Test failed.", ise);
            }
        }
    }
 
Example 13
Source File: UserPluginMetadataFormatTest.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public void doTest() throws IOException {

        DummyImageReaderImpl reader;

        reader = new DummyImageReaderImpl(new DummyImageReaderSpiImpl());

        byte[] data = new byte[1024];
        ByteArrayInputStream bais =
            new ByteArrayInputStream(data);

        reader.setInput(ImageIO.createImageInputStream(bais));
        IIOMetadata metadata = reader.getImageMetadata(1);
        if(metadata == null) {
            throw new RuntimeException("IIOMetada is NULL");
        }

        String[] formatNames = metadata.getMetadataFormatNames();

        for(int j=0; j<formatNames.length; j++) {

            String formatName = formatNames[j];
            System.out.println("\nFormat Names : " + formatName);

            try {
                IIOMetadataFormat metadataFormat =
                    metadata.getMetadataFormat(formatName);
                System.out.println("  Class Name " +
                                   metadataFormat.getClass());
            } catch(IllegalStateException ise) {
                Throwable t = ise;
                t.printStackTrace();
                while(t.getCause() != null) {
                    t = t.getCause();
                    t.printStackTrace();
                }
                // test failed!
                // stop applet!
                System.out.println("Test faied.");
                throw new RuntimeException("Test failed.", ise);
            }
        }
    }
 
Example 14
Source File: UserPluginMetadataFormatTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
public void doTest() throws IOException {

        DummyImageReaderImpl reader;

        reader = new DummyImageReaderImpl(new DummyImageReaderSpiImpl());

        byte[] data = new byte[1024];
        ByteArrayInputStream bais =
            new ByteArrayInputStream(data);

        reader.setInput(ImageIO.createImageInputStream(bais));
        IIOMetadata metadata = reader.getImageMetadata(1);
        if(metadata == null) {
            throw new RuntimeException("IIOMetada is NULL");
        }

        String[] formatNames = metadata.getMetadataFormatNames();

        for(int j=0; j<formatNames.length; j++) {

            String formatName = formatNames[j];
            System.out.println("\nFormat Names : " + formatName);

            try {
                IIOMetadataFormat metadataFormat =
                    metadata.getMetadataFormat(formatName);
                System.out.println("  Class Name " +
                                   metadataFormat.getClass());
            } catch(IllegalStateException ise) {
                Throwable t = ise;
                t.printStackTrace();
                while(t.getCause() != null) {
                    t = t.getCause();
                    t.printStackTrace();
                }
                // test failed!
                // stop applet!
                System.out.println("Test faied.");
                throw new RuntimeException("Test failed.", ise);
            }
        }
    }