Java 8 IIOMetadataNode - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 IIOMetadataNode class.

This code example shows how to use the following methods:setAttribute
7
CodeRank
This code example shows how to use the following methods:setAttribute
    String text;
 
 
    public IIOMetadataNode getNode() {
        IIOMetadataNode iTXt = new IIOMetadataNode("iTXt");
        IIOMetadataNode iTXtEntry = new IIOMetadataNode("iTXtEntry");
        iTXtEntry.setAttribute("keyword", keyword);
        iTXtEntry.setAttribute("compressionFlag",
                               isCompressed ? "true" : "false");
        iTXtEntry.setAttribute("compressionMethod",
                               Integer.toString(compression));
        iTXtEntry.setAttribute("languageTag", language);
        iTXtEntry.setAttribute("translatedKeyword",
                               trasKeyword);
        iTXtEntry.setAttribute("text", text);
        iTXt.appendChild(iTXtEntry);
        return iTXt;
    } 
 
    public static ITXtTest getFromNode(IIOMetadataNode n) {
6
CodeRank
This code example shows how to use the following methods:setAttribute, setUserObject
     * @throws IIOInvalidTreeException 
     */ 
    private static void setLoops(IIOMetadata metaData, int loops) throws IIOInvalidTreeException {
        Node tree = metaData.getAsTree(formatName);
        IIOMetadataNode aes = new IIOMetadataNode(aesNodeName);
        IIOMetadataNode ae = new IIOMetadataNode(aeNodeName);
        ae.setAttribute("applicationID", "NETSCAPE");
        ae.setAttribute("authenticationCode", "2.0");
        ae.setUserObject(new byte[]{0x1, (byte) (loops & 0xFF), (byte) ((loops >> 8) & 0xFF)});
        aes.appendChild(ae);
        tree.appendChild(aes);
        metaData.setFromTree(formatName, tree);
    } 
     
    /** 
     * test image generator 
     */ 
    private static RenderedImage generateTestImage(int width, int height, Random r, double angle) {
        BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        Graphics g = img.getGraphics();
6
CodeRank
This code example shows how to use the following methods:setAttribute
            throw new RuntimeException("Invalid metadata!");
        } 
 
        IIOMetadataNode adobeTransform = getChildNode(markerSequence, "app14Adobe");
        if (adobeTransform == null) {
            adobeTransform = new IIOMetadataNode("app14Adobe");
            adobeTransform.setAttribute("transform" , "1"); // convert RGB to YCbCr
            adobeTransform.setAttribute("version", "101");
            adobeTransform.setAttribute("flags0", "0");
            adobeTransform.setAttribute("flags1", "0");
 
            markerSequence.appendChild(adobeTransform);
        } else { 
            adobeTransform.setAttribute("transform" , "1");
        } 
 
        try { 
            meta.setFromTree(JPEG_NATIVE_FORMAT, root);
        } catch (IIOInvalidTreeException e) {
            throw new RuntimeException("Cannot update image metadata: "
6
CodeRank
This code example shows how to use the following methods:appendChild, getElementsByTagName
	    // set the DPI 
	    IIOMetadata destMeta = writer.getDefaultImageMetadata(
	                                                       new ImageTypeSpecifier(ri), writeParam);
	    IIOMetadataNode destNodes = (IIOMetadataNode)
	        destMeta.getAsTree("javax_imageio_1.0");
	    NodeList nl = destNodes.getElementsByTagName("Dimension");
	    IIOMetadataNode dim;
	    if ((nl != null) && (nl.getLength() > 0))
	        dim = (IIOMetadataNode) nl.item(0);
	    else { 
	        dim = new IIOMetadataNode("Dimension");
	        destNodes.appendChild(dim);
	    } 
	    nl = destNodes.getElementsByTagName("HorizontalPixelSize");
	    if ((nl == null) || (nl.getLength() == 0)) {
	        IIOMetadataNode horz = new
	            IIOMetadataNode("HorizontalPixelSize");
	        dim.appendChild(horz);
	        horz.setAttribute("value", Float.toString(xDPI/25.4f));
	    } 

6
CodeRank
This code example shows how to use the following methods:setAttribute
This code example shows how to use the following methods:appendChild
	} 
 
	private void addDpiToMetadata(IIOMetadata metadata) throws IIOInvalidTreeException {
	    int dpi = getImageResolutionDPI();
	    double dotsPerMilli = 1.0 * dpi / 10 / 2.54;
	    IIOMetadataNode root = new IIOMetadataNode("javax_imageio_1.0");
	    IIOMetadataNode horiz = new IIOMetadataNode("HorizontalPixelSize");
	    horiz.setAttribute("value", Double.toString(dotsPerMilli));
	    IIOMetadataNode vert = new IIOMetadataNode("VerticalPixelSize");
	    vert.setAttribute("value", Double.toString(dotsPerMilli));
	    IIOMetadataNode dim = new IIOMetadataNode("Dimension");
	    dim.appendChild(horiz);
	    dim.appendChild(vert);
	    root.appendChild(dim);
	    metadata.mergeTree("javax_imageio_1.0", root);
    } 
 
	public FileFilter getFileFilter() {
		return new ExampleFileFilter(imageType, imageDescripton);
    } 
5
CodeRank
This code example shows how to use the following methods:appendChild
        if (meta.isStandardMetadataFormatSupported()) {
            IIOMetadataNode root = (IIOMetadataNode)meta.getAsTree(stdmeta);
            IIOMetadataNode dim = getChildNode(root, "Dimension");
            IIOMetadataNode child;
            if (params.getResolution() != null) {
                child = getChildNode(dim, "HorizontalPixelSize");
                if (child == null) {
                    child = new IIOMetadataNode("HorizontalPixelSize");
                    dim.appendChild(child);
                } 
                child.setAttribute("value", 
                        Double.toString(params.getResolution().doubleValue() / 25.4));
                child = getChildNode(dim, "VerticalPixelSize");
                if (child == null) {
                    child = new IIOMetadataNode("VerticalPixelSize");
                    dim.appendChild(child);
                } 
                child.setAttribute("value", 
                        Double.toString(params.getResolution().doubleValue() / 25.4));
            } 
            try { 
5
CodeRank
This code example shows how to use the following methods:setAttribute
    } 
 
    @SuppressWarnings("nls") 
    protected IIOMetadataNode getStandardCompressionNode() {
        IIOMetadataNode node = new IIOMetadataNode("Compression");
        IIOMetadataNode subNode = new IIOMetadataNode("Lossless");
        subNode.setAttribute("value", "TRUE");
        node.appendChild(subNode);
        return node;
    } 
 
    /** 
     * Creates a {@linkplain Node} tree from the available metadata informations of the native 
     * raster. 
     *  
     * @return the root of the tree containing the metadata of the native raster. 
     */ 
    private Node getNativeTree() {
        final IIOMetadataNode root = new IIOMetadataNode(nativeMetadataFormatName);
 
5
CodeRank
This code example shows how to use the following methods:setNodeValue, setUserObject
        child.setUserObject(new Float(vRes));
        verticalResolution = Float.toString(vRes);
        child.setNodeValue(verticalResolution);
        appendChild(child);
 
        child = new IIOMetadataNode("HorizontalResolution");
        child.setUserObject(new Float(hRes));
        horizontalResolution = Float.toString(hRes);
        child.setNodeValue(horizontalResolution);
        appendChild(child);
    } 
 
    public String getVerticalResolutionNumerator() {
        return verticalResolutionNumerator;
    } 
 
    public String getHorizontalResolutionNumerator() {
        return horizontalResolutionNumerator;
    } 
 
5
CodeRank
See Code Examples for Java 8 IIOMetadataNode Methods: