Package com.lightcrafts.utils.xml

Examples of com.lightcrafts.utils.xml.XmlNode


     */
    public PlanarImage getImage( ImageInfo imageInfo, ProgressThread thread )
        throws BadImageFileException, IOException, UserCanceledException
    {
        final XmlDocument xml = getDocument( imageInfo );
        final XmlNode cache = getCacheNode( xml );
        final byte[] bytes = cache.getData();
        if (bytes == null) {
            // no cache data in the file
            throw new BadImageFileException( imageInfo.getFile() );
        }
        try {
View Full Code Here


                90
            );
            writer.putImage( image );

            final XmlDocument xml = getDocument( imageInfo );
            final XmlNode cache = getCacheNode( xml );
            cache.setData( buf.toByteArray() );

            final OutputStream out =
                new FileOutputStream( imageInfo.getFile() );
            try {
                xml.write( out );
View Full Code Here

     * @return The XmlNode containing the LZN cache data, or a new cache node
     * if none was present.
     */
    private static XmlNode getCacheNode( XmlDocument xml ) {
        // Parse the LZN file and locate the cache node:
        final XmlNode root = xml.getRoot();
        try {
            return root.getChild(CacheTag);
        }
        catch (XMLException e) {
            return root.addChild(CacheTag);
        }
    }
View Full Code Here

        root.setAttribute(IntentTag, intent.toString());

        root.setAttribute(PpiTag, Integer.toString(pixelsPerInch));

        if (profile != null) {
            XmlNode profileNode = root.addChild(ProfileTag);
            profileNode.setAttribute(ProfileNameTag, profile.getName());
            profileNode.setAttribute(ProfilePathTag, profile.getPath());
        }
        XmlNode pageNode = root.addChild(PageTag);
        savePageFormat(pageNode);

        XmlNode imageRectNode = root.addChild(ImageRectTag);
        imageRectNode.setAttribute("x", Double.toString(imageRect.getX()));
        imageRectNode.setAttribute("y", Double.toString(imageRect.getY()));
        imageRectNode.setAttribute("w", Double.toString(imageRect.getWidth()));
        imageRectNode.setAttribute("h", Double.toString(imageRect.getHeight()));

    }
View Full Code Here

        else {
            // arbitrary but sensible default, mostly backwards compatible
            pixelsPerInch = 300;
        }
        profile = null;
        XmlNode profileNode = null;
        try {
            profileNode = root.getChild(ProfileTag);
        }
        catch (XMLException e) {
            // OK, color profile is optional.
        }
        if (profileNode != null) {
            String profileName = profileNode.getAttribute(ProfileNameTag);
            String profilePath = profileNode.getAttribute(ProfilePathTag);
            profile = new ColorProfileInfo(profileName, profilePath);
        }
        XmlNode pageNode = root.getChild(PageTag);
        restorePageFormat(pageNode);

        XmlNode imageRectNode = root.getChild(ImageRectTag);
        try {
            double x = Double.valueOf(imageRectNode.getAttribute("x"));
            double y = Double.valueOf(imageRectNode.getAttribute("y"));
            double w = Double.valueOf(imageRectNode.getAttribute("w"));
            double h =
                Double.valueOf(imageRectNode.getAttribute("h"));
            imageRect = new Rectangle2D.Double(x, y, w, h);

            // The restored imageRect may not make sense with the current
            // imageWidth and imageHeight.
            // If the saved aspect ratio is far off, then we scaleToFit().
View Full Code Here

    private void savePageFormat(XmlNode pageRoot) {
        int orientation = pageFormat.getOrientation();
        pageRoot.setAttribute(OrientationTag, Integer.toString(orientation));

        Paper paper = pageFormat.getPaper();
        XmlNode paperNode = pageRoot.addChild(PaperTag);

        paperNode.setAttribute(
            "width", Double.toString(paper.getWidth())
        );
        paperNode.setAttribute(
            "height", Double.toString(paper.getHeight())
        );
        paperNode.setAttribute(
            "x", Double.toString(paper.getImageableX())
        );
        paperNode.setAttribute(
            "y", Double.toString(paper.getImageableY())
        );
        paperNode.setAttribute(
            "w", Double.toString(paper.getImageableWidth())
        );
        paperNode.setAttribute(
            "h", Double.toString(paper.getImageableHeight())
        );
    }
View Full Code Here

        int orientation =
            Integer.parseInt(pageRoot.getAttribute(OrientationTag));
        pageFormat.setOrientation(orientation);

        Paper paper = pageFormat.getPaper();
        XmlNode paperNode = pageRoot.getChild(PaperTag);

        // Backwards compatibility: releases 1.0.5 and earlier omitted
        // Paper width and height.
        if (paperNode.hasAttribute("width") && paperNode.hasAttribute("height")) {
            double width = Double.parseDouble(paperNode.getAttribute("width"));
            double height = Double.parseDouble(paperNode.getAttribute("height"));
            paper.setSize(width, height);
        }
        double x = Double.parseDouble(paperNode.getAttribute("x"));
        double y = Double.parseDouble(paperNode.getAttribute("y"));
        double w = Double.parseDouble(paperNode.getAttribute("w"));
        double h = Double.parseDouble(paperNode.getAttribute("h"));
        paper.setImageableArea(x, y, w, h);

        pageFormat.setPaper(paper);
    }
View Full Code Here

        TreePath path = tree.getPathForLocation(p.x, p.y);
        if (path != null) {
            Object last = path.getLastPathComponent();
            if (last instanceof TemplateTreeNode) {
                TemplateTreeNode node = (TemplateTreeNode) last;
                XmlNode xml = node.node;
                preview.showTemplatePreview(xml);
                setPreviewNode((TemplateTreeNode) last);
            }
            else {
                preview.showNormalPreview();
View Full Code Here

    ) throws TemplateDatabase.TemplateException, XMLException {
        this.key = key;
        this.parent = parent;
        this.key = key;
        XmlDocument xml = TemplateDatabase.getTemplateDocument(key);
        XmlNode root = xml.getRoot();
        // Tag name copied from Document.ControlTag:
        node = root.getChild("Controls");
    }
View Full Code Here

                editor.removeControls(controls);
            }
        }
        if (template != null) {
            selected = template;
            XmlNode node = template.node;
            try {
                selected.opControls = editor.addControls(node);
            }
            catch (Throwable t) {
                // Let the control just do nothing.
View Full Code Here

TOP

Related Classes of com.lightcrafts.utils.xml.XmlNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.