Examples of XMLNode

  • org.sf.bee.commons.xml.XmlNode
  • org.vietspider.parser.xml.XMLNode
    Created by VietSpider Studio Author : Nhu Dinh Thuan nhudinhthuan@yahoo.com Mar 13, 2006
  • org.webharvest.definition.XmlNode
  • org.zachtaylor.jnodalxml.XmlNode

  • Examples of com.lightcrafts.utils.xml.XmlNode

                   UnknownImageTypeException,
                   UserCanceledException,
                   MissingImageFileException,
                   ImagingException
        {
            XmlNode root = doc.getRoot();
            int version = root.getVersion();
            if (version > SavedDocVersion) {
                throw new XMLException(LOCALE.get("FutureLznError"));
            }
            if (version < 0) {
                throw new XMLException(LOCALE.get("MissingLznVersionError"));
            }
            if (meta == null) {

                // Find the original image:
                XmlNode node = root.getChild(ImageTag);
                String path = node.getAttribute(ImagePathTag);
                File file = new File(path);
                if (! file.isFile()) {
                    throw new MissingImageFileException(file);
                }
                // Override with a relative path, if one was defined:
                if (node.hasAttribute(ImageRelativePathTag)) {
                    path = node.getAttribute(ImageRelativePathTag);
                    File relativeFile = new File(path);
                    if (relativeFile.isFile()) {
                        file = relativeFile;
                    }
                }
                ImageInfo info = ImageInfo.getInstanceFor(file);
                try {
                    meta = info.getMetadata();
                }
                catch (FileNotFoundException e) {
                    throw new MissingImageFileException(file);
                }
            }
            this.meta = meta;

            // Enforce the saved original image orientation, which defines the
            // coordinate system used for regions and crop bounds:
            XmlNode imageNode = root.getChild(ImageTag);
            if (imageNode.hasAttribute(ImageOrientationTag)) {
                String value = imageNode.getAttribute(ImageOrientationTag);
                try {
                    ImageOrientation oldOrientation =
                        ImageOrientation.getOrientationFor(Short.parseShort(value));
                    ImageOrientation newOrientation = meta.getOrientation();
                    if (oldOrientation != newOrientation) {
                        meta.setOrientation(oldOrientation);
                    }
                }
                catch (NumberFormatException e) {
                    throw new XMLException(
                        "Image orientation \"" + value + "\" is not a number", e
                    );
                }
            }
            // Backwards compatibility: before XMP support, the convention in LZN
            // files was that the image orientation was its original orientation,
            // before any browser rotations.
            else {
                // Make sure this pre-XMP LZN structure is not a Template.
                // (See Application.saveTemplate().)
                if (! root.getName().equals("Template")) {
                    ImageOrientation origOrient = meta.getOriginalOrientation();
                    meta.setOrientation(origOrient);
                }
            }
            engine = EngineFactory.createEngine(meta, versionInfo, thread);

            xform = new XFormModel(engine);

            regions = new RegionManager();
            crop = new CropRotateManager(engine, xform);

            scale = new ScaleModel(engine);
            XmlNode scaleNode = root.getChild(ScaleTag);
            Scale s = new Scale(scaleNode);
            scale.setScale(s);

            editor = new Editor(engine, scale, xform, regions, crop, this);
            editor.showWait(LOCALE.get("EditorWaitText"));
            crop.setEditor( editor );

            XmlNode controlNode = root.getChild(ControlTag);

            // this does the inverse of save(XmlNode):
            try {
                editor.restore(controlNode);
            } catch (XMLException e) {
                dispose();
                throw e;
            }

            commonInitialization();

            if (root.hasChild(SaveTag)) {
                XmlNode saveNode = root.getChild(SaveTag);
                save = SaveOptions.restore(saveNode);
            }
            if (root.hasChild(PrintTag)) {
                XmlNode printNode = root.getChild(PrintTag);
                Dimension size = engine.getNaturalSize();
                print = new PrintLayoutModel(size.width, size.height);
                print.restore(printNode);
            }
            if (root.hasChild(ExportTag)) {
                XmlNode exportNode = root.getChild(ExportTag);
                export = ImageExportOptions.read(exportNode);
            }
        }
    View Full Code Here

    Examples of com.lightcrafts.utils.xml.XmlNode

        private final static String ExportTag = "Export";

        public void save(XmlNode node) {
            node.setVersion(SavedDocVersion);

            XmlNode scaleNode = node.addChild(ScaleTag);
            scale.getCurrentScale().save(scaleNode);

            XmlNode imageNode = node.addChild(ImageTag);
            imageNode.setAttribute(
                ImagePathTag, meta.getFile().getAbsolutePath()
            );
            imageNode.setAttribute(
                ImageOrientationTag,
                Integer.toString(meta.getOrientation().getTIFFConstant())
            );
            if (save != null) {
                String path;
                try {
                    path = RelativePathUtility.getRelativePath(
                        save.getFile(), meta.getFile()
                    );
                }
                catch (IOException e) {
                    path = meta.getFile().getName();
                }
                imageNode.setAttribute(ImageRelativePathTag, path);
            }
            XmlNode controlNode = node.addChild(ControlTag);
            editor.save(controlNode);

            if (save != null) {
                XmlNode saveNode = node.addChild(SaveTag);
                save.save(saveNode);
            }
            if (print != null) {
                XmlNode printNode = node.addChild(PrintTag);
                print.save(printNode);
            }
            if (export != null) {
                XmlNode exportNode = node.addChild(ExportTag);
                export.write(exportNode);
            }
        }
    View Full Code Here

    Examples of com.lightcrafts.utils.xml.XmlNode

        // empty image pointer, and no image relative path.  The result may
        // be used either in a Document constructor or in applyTemplate().
        public void saveTemplate(XmlNode node) {
            node.setVersion(SavedDocVersion);

            XmlNode scaleNode = node.addChild(ScaleTag);
            scale.getCurrentScale().save(scaleNode);

            XmlNode imageNode = node.addChild(ImageTag);
            imageNode.setAttribute(ImagePathTag, "");
            XmlNode controlNode = node.addChild(ControlTag);
            editor.save(controlNode);
        }
    View Full Code Here

    Examples of com.lightcrafts.utils.xml.XmlNode

            if (version < 0) {
                throw new XMLException(LOCALE.get("MissingTemplateVersionError"));
            }
            // Ignore the scale factor under ScaleTag.

            XmlNode controlNode = node.getChild(ControlTag);
            editor.addControls(controlNode);
        }
    View Full Code Here

    Examples of com.lightcrafts.utils.xml.XmlNode

            printer.println("batch name: " + name);
            printer.println("output folder: " + directory.getAbsolutePath());
            printer.println("export options:");
            printer.flush();
            XmlDocument doc = new XmlDocument("Export");
            XmlNode root = doc.getRoot();
            export.write(root);
            try {
                doc.write(out);
            }
            catch (IOException e) {
    View Full Code Here

    Examples of com.lightcrafts.utils.xml.XmlNode

                try {
                    InputStream in = new ByteArrayInputStream(
                        text.getBytes("UTF-8")
                    );
                    XmlDocument doc = new XmlDocument(in);
                    XmlNode root = doc.getRoot();
                    export = (ImageFileExportOptions) ImageExportOptions.read(root);
                }
                catch (IOException e) {
                    System.err.print(
                        "Error reading BatchConfig preferences: "
    View Full Code Here

    Examples of com.lightcrafts.utils.xml.XmlNode

        /**
         * Construct a LightweightDocument from the XML content already extracted.
         */
        public LightweightDocument(File file, XmlDocument doc) throws XMLException {
            XmlNode root = doc.getRoot();
            XmlNode imageNode = root.getChild("Image");
            String path = imageNode.getAttribute("path");
            imageFile = new File(path);
            if (! imageFile.isFile()) {
                if (imageNode.hasAttribute("relativePath")) {
                    String relativepath = imageNode.getAttribute("relativePath");
                    File relativeFile =
                        RelativePathUtility.getRelativeFile(file, relativepath);
                    if (relativeFile.isFile()) {
                        imageFile = relativeFile;
                    }
    View Full Code Here

    Examples of com.lightcrafts.utils.xml.XmlNode

                    // iteration.
                    export.resizeWidth.setValue(exportWidth);
                    export.resizeHeight.setValue(exportHeight);

                    if (template != null) {
                        XmlNode root = template.getRoot();

                        doc.applyTemplate(root);

                        SaveOptions save = doc.getSaveOptions();
                        if (save == null) {
    View Full Code Here

    Examples of com.lightcrafts.utils.xml.XmlNode

        private final static String ColorTag = "Color";

        public void save(XmlNode node) {
            super.save(node);
            Color color = getColor();
            XmlNode colorNode = node.addChild(ColorTag);
            colorNode.setAttribute("r", Integer.toString(color.getRed()));
            colorNode.setAttribute("g", Integer.toString(color.getGreen()));
            colorNode.setAttribute("b", Integer.toString(color.getBlue()));
        }
    View Full Code Here

    Examples of com.lightcrafts.utils.xml.XmlNode

            colorNode.setAttribute("b", Integer.toString(color.getBlue()));
        }

        public void restore(XmlNode node) throws XMLException {
            super.restore(node);
            XmlNode whiteNode = node.getChild(ColorTag);
            int r = Integer.parseInt(whiteNode.getAttribute("r"));
            int g = Integer.parseInt(whiteNode.getAttribute("g"));
            int b = Integer.parseInt(whiteNode.getAttribute("b"));
            Color color = new Color(r, g, b);
            undoSupport.restoreStart();
            setColor(color, false);
            undoSupport.restoreEnd();
        }
    View Full Code Here
    TOP
    Copyright © 2018 www.massapi.com. 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.