Java Code Examples for javax.imageio.metadata.IIOMetadataNode#getFirstChild()

The following examples show how to use javax.imageio.metadata.IIOMetadataNode#getFirstChild() . 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: ITXtTest.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static ITXtTest getFromNode(IIOMetadataNode n) {
    ITXtTest t = new ITXtTest();

    if (!"iTXt".equals(n.getNodeName())) {
        throw new RuntimeException("Invalid node");
    }
    IIOMetadataNode e = (IIOMetadataNode)n.getFirstChild();
    if (!"iTXtEntry".equals(e.getNodeName())) {
        throw new RuntimeException("Invalid entry node");
    }
    t.keyword = e.getAttribute("keyword");
    t.isCompressed =
        Boolean.valueOf(e.getAttribute("compressionFlag")).booleanValue();
    t.compression =
        Integer.valueOf(e.getAttribute("compressionMethod")).intValue();
    t.language = e.getAttribute("languageTag");
    t.trasKeyword = e.getAttribute("translatedKeyword");
    t.text = e.getAttribute("text");

    return t;
}
 
Example 2
Source File: ITXtTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static ITXtTest getFromNode(IIOMetadataNode n) {
    ITXtTest t = new ITXtTest();

    if (!"iTXt".equals(n.getNodeName())) {
        throw new RuntimeException("Invalid node");
    }
    IIOMetadataNode e = (IIOMetadataNode)n.getFirstChild();
    if (!"iTXtEntry".equals(e.getNodeName())) {
        throw new RuntimeException("Invalid entry node");
    }
    t.keyword = e.getAttribute("keyword");
    t.isCompressed =
        Boolean.valueOf(e.getAttribute("compressionFlag")).booleanValue();
    t.compression =
        Integer.valueOf(e.getAttribute("compressionMethod")).intValue();
    t.language = e.getAttribute("languageTag");
    t.trasKeyword = e.getAttribute("translatedKeyword");
    t.text = e.getAttribute("text");

    return t;
}
 
Example 3
Source File: ITXtTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public static ITXtTest getFromNode(IIOMetadataNode n) {
    ITXtTest t = new ITXtTest();

    if (!"iTXt".equals(n.getNodeName())) {
        throw new RuntimeException("Invalid node");
    }
    IIOMetadataNode e = (IIOMetadataNode)n.getFirstChild();
    if (!"iTXtEntry".equals(e.getNodeName())) {
        throw new RuntimeException("Invalid entry node");
    }
    t.keyword = e.getAttribute("keyword");
    t.isCompressed =
        Boolean.valueOf(e.getAttribute("compressionFlag")).booleanValue();
    t.compression =
        Integer.valueOf(e.getAttribute("compressionMethod")).intValue();
    t.language = e.getAttribute("languageTag");
    t.trasKeyword = e.getAttribute("translatedKeyword");
    t.text = e.getAttribute("text");

    return t;
}
 
Example 4
Source File: ITXtTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static ITXtTest getFromNode(IIOMetadataNode n) {
    ITXtTest t = new ITXtTest();

    if (!"iTXt".equals(n.getNodeName())) {
        throw new RuntimeException("Invalid node");
    }
    IIOMetadataNode e = (IIOMetadataNode)n.getFirstChild();
    if (!"iTXtEntry".equals(e.getNodeName())) {
        throw new RuntimeException("Invalid entry node");
    }
    t.keyword = e.getAttribute("keyword");
    t.isCompressed =
        Boolean.valueOf(e.getAttribute("compressionFlag")).booleanValue();
    t.compression =
        Integer.valueOf(e.getAttribute("compressionMethod")).intValue();
    t.language = e.getAttribute("languageTag");
    t.trasKeyword = e.getAttribute("translatedKeyword");
    t.text = e.getAttribute("text");

    return t;
}
 
Example 5
Source File: ITXtTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static ITXtTest getFromNode(IIOMetadataNode n) {
    ITXtTest t = new ITXtTest();

    if (!"iTXt".equals(n.getNodeName())) {
        throw new RuntimeException("Invalid node");
    }
    IIOMetadataNode e = (IIOMetadataNode)n.getFirstChild();
    if (!"iTXtEntry".equals(e.getNodeName())) {
        throw new RuntimeException("Invalid entry node");
    }
    t.keyword = e.getAttribute("keyword");
    t.isCompressed =
        Boolean.valueOf(e.getAttribute("compressionFlag")).booleanValue();
    t.compression =
        Integer.valueOf(e.getAttribute("compressionMethod")).intValue();
    t.language = e.getAttribute("languageTag");
    t.trasKeyword = e.getAttribute("translatedKeyword");
    t.text = e.getAttribute("text");

    return t;
}
 
Example 6
Source File: ITXtTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static ITXtTest getFromNode(IIOMetadataNode n) {
    ITXtTest t = new ITXtTest();

    if (!"iTXt".equals(n.getNodeName())) {
        throw new RuntimeException("Invalid node");
    }
    IIOMetadataNode e = (IIOMetadataNode)n.getFirstChild();
    if (!"iTXtEntry".equals(e.getNodeName())) {
        throw new RuntimeException("Invalid entry node");
    }
    t.keyword = e.getAttribute("keyword");
    t.isCompressed =
        Boolean.valueOf(e.getAttribute("compressionFlag")).booleanValue();
    t.compression =
        Integer.valueOf(e.getAttribute("compressionMethod")).intValue();
    t.language = e.getAttribute("languageTag");
    t.trasKeyword = e.getAttribute("translatedKeyword");
    t.text = e.getAttribute("text");

    return t;
}
 
Example 7
Source File: ITXtTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static ITXtTest getFromNode(IIOMetadataNode n) {
    ITXtTest t = new ITXtTest();

    if (!"iTXt".equals(n.getNodeName())) {
        throw new RuntimeException("Invalid node");
    }
    IIOMetadataNode e = (IIOMetadataNode)n.getFirstChild();
    if (!"iTXtEntry".equals(e.getNodeName())) {
        throw new RuntimeException("Invalid entry node");
    }
    t.keyword = e.getAttribute("keyword");
    t.isCompressed =
        Boolean.valueOf(e.getAttribute("compressionFlag")).booleanValue();
    t.compression =
        Integer.valueOf(e.getAttribute("compressionMethod")).intValue();
    t.language = e.getAttribute("languageTag");
    t.trasKeyword = e.getAttribute("translatedKeyword");
    t.text = e.getAttribute("text");

    return t;
}
 
Example 8
Source File: ITXtTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public static ITXtTest getFromNode(IIOMetadataNode n) {
    ITXtTest t = new ITXtTest();

    if (!"iTXt".equals(n.getNodeName())) {
        throw new RuntimeException("Invalid node");
    }
    IIOMetadataNode e = (IIOMetadataNode)n.getFirstChild();
    if (!"iTXtEntry".equals(e.getNodeName())) {
        throw new RuntimeException("Invalid entry node");
    }
    t.keyword = e.getAttribute("keyword");
    t.isCompressed =
        Boolean.valueOf(e.getAttribute("compressionFlag")).booleanValue();
    t.compression =
        Integer.valueOf(e.getAttribute("compressionMethod")).intValue();
    t.language = e.getAttribute("languageTag");
    t.trasKeyword = e.getAttribute("translatedKeyword");
    t.text = e.getAttribute("text");

    return t;
}
 
Example 9
Source File: ITXtTest.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public static ITXtTest getFromNode(IIOMetadataNode n) {
    ITXtTest t = new ITXtTest();

    if (!"iTXt".equals(n.getNodeName())) {
        throw new RuntimeException("Invalid node");
    }
    IIOMetadataNode e = (IIOMetadataNode)n.getFirstChild();
    if (!"iTXtEntry".equals(e.getNodeName())) {
        throw new RuntimeException("Invalid entry node");
    }
    t.keyword = e.getAttribute("keyword");
    t.isCompressed =
        Boolean.valueOf(e.getAttribute("compressionFlag")).booleanValue();
    t.compression =
        Integer.valueOf(e.getAttribute("compressionMethod")).intValue();
    t.language = e.getAttribute("languageTag");
    t.trasKeyword = e.getAttribute("translatedKeyword");
    t.text = e.getAttribute("text");

    return t;
}
 
Example 10
Source File: ITXtTest.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public static ITXtTest getFromNode(IIOMetadataNode n) {
    ITXtTest t = new ITXtTest();

    if (!"iTXt".equals(n.getNodeName())) {
        throw new RuntimeException("Invalid node");
    }
    IIOMetadataNode e = (IIOMetadataNode)n.getFirstChild();
    if (!"iTXtEntry".equals(e.getNodeName())) {
        throw new RuntimeException("Invalid entry node");
    }
    t.keyword = e.getAttribute("keyword");
    t.isCompressed =
        Boolean.valueOf(e.getAttribute("compressionFlag")).booleanValue();
    t.compression =
        Integer.valueOf(e.getAttribute("compressionMethod")).intValue();
    t.language = e.getAttribute("languageTag");
    t.trasKeyword = e.getAttribute("translatedKeyword");
    t.text = e.getAttribute("text");

    return t;
}
 
Example 11
Source File: ITXtTest.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static ITXtTest getFromNode(IIOMetadataNode n) {
    ITXtTest t = new ITXtTest();

    if (!"iTXt".equals(n.getNodeName())) {
        throw new RuntimeException("Invalid node");
    }
    IIOMetadataNode e = (IIOMetadataNode)n.getFirstChild();
    if (!"iTXtEntry".equals(e.getNodeName())) {
        throw new RuntimeException("Invalid entry node");
    }
    t.keyword = e.getAttribute("keyword");
    t.isCompressed =
        Boolean.valueOf(e.getAttribute("compressionFlag")).booleanValue();
    t.compression =
        Integer.valueOf(e.getAttribute("compressionMethod")).intValue();
    t.language = e.getAttribute("languageTag");
    t.trasKeyword = e.getAttribute("translatedKeyword");
    t.text = e.getAttribute("text");

    return t;
}
 
Example 12
Source File: ITXtTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static ITXtTest getFromNode(IIOMetadataNode n) {
    ITXtTest t = new ITXtTest();

    if (!"iTXt".equals(n.getNodeName())) {
        throw new RuntimeException("Invalid node");
    }
    IIOMetadataNode e = (IIOMetadataNode)n.getFirstChild();
    if (!"iTXtEntry".equals(e.getNodeName())) {
        throw new RuntimeException("Invalid entry node");
    }
    t.keyword = e.getAttribute("keyword");
    t.isCompressed =
        Boolean.valueOf(e.getAttribute("compressionFlag")).booleanValue();
    t.compression =
        Integer.valueOf(e.getAttribute("compressionMethod")).intValue();
    t.language = e.getAttribute("languageTag");
    t.trasKeyword = e.getAttribute("translatedKeyword");
    t.text = e.getAttribute("text");

    return t;
}
 
Example 13
Source File: ITXtTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static ITXtTest getFromNode(IIOMetadataNode n) {
    ITXtTest t = new ITXtTest();

    if (!"iTXt".equals(n.getNodeName())) {
        throw new RuntimeException("Invalid node");
    }
    IIOMetadataNode e = (IIOMetadataNode)n.getFirstChild();
    if (!"iTXtEntry".equals(e.getNodeName())) {
        throw new RuntimeException("Invalid entry node");
    }
    t.keyword = e.getAttribute("keyword");
    t.isCompressed =
        Boolean.valueOf(e.getAttribute("compressionFlag")).booleanValue();
    t.compression =
        Integer.valueOf(e.getAttribute("compressionMethod")).intValue();
    t.language = e.getAttribute("languageTag");
    t.trasKeyword = e.getAttribute("translatedKeyword");
    t.text = e.getAttribute("text");

    return t;
}
 
Example 14
Source File: TIFFBaseJPEGCompressor.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
private static List<Node> getAllNodes(IIOMetadataNode root, List<Node> nodes) {
    if(nodes == null) nodes = new ArrayList<Node>();

    if(root.hasChildNodes()) {
        Node sibling = root.getFirstChild();
        while(sibling != null) {
            nodes.add(sibling);
            nodes = getAllNodes((IIOMetadataNode)sibling, nodes);
            sibling = sibling.getNextSibling();
        }
    }

    return nodes;
}
 
Example 15
Source File: TIFFBaseJPEGCompressor.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static List<Node> getAllNodes(IIOMetadataNode root, List<Node> nodes) {
    if(nodes == null) nodes = new ArrayList<Node>();

    if(root.hasChildNodes()) {
        Node sibling = root.getFirstChild();
        while(sibling != null) {
            nodes.add(sibling);
            nodes = getAllNodes((IIOMetadataNode)sibling, nodes);
            sibling = sibling.getNextSibling();
        }
    }

    return nodes;
}
 
Example 16
Source File: ExifReader.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("nls")
private void parseExifMeta( IIOMetadata exifMeta ) {
    outTags = new HashMap<String, ExifTag>();

    IIOMetadataNode root = (IIOMetadataNode) exifMeta.getAsTree("com_sun_media_imageio_plugins_tiff_image_1.0");

    NodeList imageDirectories = root.getElementsByTagName("TIFFIFD");
    for( int i = 0; i < imageDirectories.getLength(); i++ ) {
        IIOMetadataNode directory = (IIOMetadataNode) imageDirectories.item(i);

        NodeList tiffTags = directory.getElementsByTagName("TIFFField");
        for( int j = 0; j < tiffTags.getLength(); j++ ) {
            IIOMetadataNode tag = (IIOMetadataNode) tiffTags.item(j);

            String tagNumber = tag.getAttribute("number");
            String tagName = tag.getAttribute("name");
            String tagValue;

            StringBuilder tmp = new StringBuilder();
            IIOMetadataNode values = (IIOMetadataNode) tag.getFirstChild();

            if ("TIFFUndefined".equals(values.getNodeName())) {
                tmp.append(values.getAttribute("value"));
            } else {
                NodeList tiffNumbers = values.getChildNodes();
                for( int k = 0; k < tiffNumbers.getLength(); k++ ) {
                    tmp.append(((IIOMetadataNode) tiffNumbers.item(k)).getAttribute("value"));
                    tmp.append(",");
                }
                tmp.deleteCharAt(tmp.length() - 1);
            }

            tagValue = tmp.toString();

            ExifTag exifTag = new ExifTag(tagName, tagNumber, tagValue);
            outTags.put(tagName, exifTag);
        }
    }
}