Examples of XmlDocument


Examples of com.lightcrafts.utils.xml.XmlDocument

    public static boolean save(
        Document doc, ComboFrame frame, boolean saveDirectly,
        ProgressThread progress
    ) throws IOException {
        // Construct the LZN data that encode the Document's state:
        XmlDocument xml = new XmlDocument(
            Application.LznNamespace, "LightZoneTransform"
        );
        XmlNode root = xml.getRoot();
        doc.save(root);

        // Try/catch XML manipulation errors:
        try {
            // The next steps depend on the SaveOptions:
View Full Code Here

Examples of com.lightcrafts.utils.xml.XmlDocument

            LOCALE.get("RememberPresetMenuItem")
        );
        savePreset.addActionListener(
            new ActionListener() {
                public void actionPerformed(ActionEvent event) {
                    XmlDocument preset = new XmlDocument("Preset");
                    control.save(preset.getRoot());
                    writePreset(preset);
                }
            }
        );
        menu.add(savePreset, 4);

        JMenuItem applyPreset = new JMenuItem(
            LOCALE.get("ApplyPresetMenuItem")
        );
        final XmlDocument preset = readPreset();
        applyPreset.addActionListener(
            new ActionListener() {
                public void actionPerformed(ActionEvent event) {
                    try {
                        // Like control.restore(), but with undo:
                        control.restorePresets(preset.getRoot());
                    }
                    catch (XMLException e) {
                        // No way to back out of this, so leave things as
                        // they are and hope the user can recover.
                        System.err.println(
View Full Code Here

Examples of com.lightcrafts.utils.xml.XmlDocument

     * <p>
     * It is possible that LZN data exists but no image file can be found.
     * This is typical in "LZT" (template) files, for instance.
     */
    public static Interpretation read(File file) {
        XmlDocument xmlDoc = null;
        File imageFile = null;

        ImageInfo info = ImageInfo.getInstanceFor(file);
        ImageType type;
        try {
            type = info.getImageType();
        }
        catch (IOException e) {
            return null;
        }
        catch (LightCraftsException e) {
            if (file.getName().endsWith(".lzt")) {
                // This is a symptom of a template file, which does have an
                // Interpretation.  So we continue.
                type = LZNImageType.INSTANCE;
            }
            else {
                return null;
            }
        }
        if (type == LZNImageType.INSTANCE) {
            try {
                InputStream in = new FileInputStream(file);
                xmlDoc = new XmlDocument(in);
                LightweightDocument lwDoc = new LightweightDocument(file);
                imageFile = lwDoc.getImageFile();
            }
            catch (IOException e) {
                // Fall back to the embedded document test.
            }
        }
        // Second try as an image with embedded document metadata:
        if (xmlDoc == null) {
            try {
                if (type instanceof LZNDocumentProvider) {
                    final LZNDocumentProvider p = (LZNDocumentProvider)type;
                    Document lznDoc = p.getLZNDocument(info);
                    if (lznDoc != null) {
                        xmlDoc = new XmlDocument(lznDoc.getDocumentElement());
                        if (xmlDoc != null) {
                            // The original image may be in the same file,
                            // or referenced through a path pointer:
                            XmlNode root = xmlDoc.getRoot();
                            // (tag copied from ui.editor.Document)
                            XmlNode imageNode = root.getChild("Image");
                            // (tag written in export())
                            if ( imageNode.hasAttribute("self")) {
                                imageFile = file;
View Full Code Here

Examples of com.lightcrafts.utils.xml.XmlDocument

        String key = getPresetsKey();
        String text = Prefs.get(key, "");
        try {
            ByteArrayInputStream in =
                new ByteArrayInputStream(text.getBytes("UTF-8"));
            return new XmlDocument(in);
        }
        catch (Exception e) {   // IOException or XMLException
            return null;
        }
    }
View Full Code Here

Examples of com.lightcrafts.utils.xml.XmlDocument

    }

    // Get a Template that matches the original Template with unsselected tools
    // omitted.
    XmlDocument getModifiedTemplate() {
        XmlDocument clone = new XmlDocument(xml);
        try {
            TemplateJig jig = new TemplateJig(clone);
            for (int n=checks.length-1; n>=0; n--) {
                JCheckBox check = checks[n];
                if (! check.isSelected()) {
                    jig.removeTool(n);
                }
            }
        }
        catch (XMLException e) {
            // Assume no modifications
            return new XmlDocument(xml);
        }
        return clone;
    }
View Full Code Here

Examples of com.lightcrafts.utils.xml.XmlDocument

        }
        return clone;
    }

    XmlDocument getOriginalTemplate() {
        return new XmlDocument(xml);
    }
View Full Code Here

Examples of com.lightcrafts.utils.xml.XmlDocument

    XmlDocument getModifiedTemplate() {
        if (selector != null) {
            return selector.getModifiedTemplate();
        }
        else {
            return new XmlDocument(originalTemplate);
        }
    }
View Full Code Here

Examples of com.lightcrafts.utils.xml.XmlDocument

    }

    public static void main(String[] args) throws Exception {
        UIManager.setLookAndFeel(Platform.getPlatform().getLookAndFeel());

        XmlDocument doc = new XmlDocument(
            new FileInputStream(
                "/Users/anton/test/1/test.lzn"
            )
        );
        ImageInfo info = ImageInfo.getInstanceFor(
View Full Code Here

Examples of com.lightcrafts.utils.xml.XmlDocument

        if ( m_originalImageFile == null ) {
            final ImageType t = getImageType();
            if ( t instanceof LZNDocumentProvider ) {
                final Document lznDoc =
                    ((LZNDocumentProvider)t).getLZNDocument( this );
                final XmlDocument xmlDocument = new XmlDocument( lznDoc );
                final LightweightDocument lwDoc =
                    new LightweightDocument( m_imageFile, xmlDocument );
                final File originalFile = lwDoc.getImageFile();
                if ( !m_imageFile.equals( originalFile ) )
                    m_originalImageFile = originalFile;
View Full Code Here

Examples of com.lightcrafts.utils.xml.XmlDocument

        dispose();
    }

    public static void main(String[] args) throws Exception {
        InputStream in = new FileInputStream(args[0]);
        XmlDocument xml = new XmlDocument(in);
        Document doc = new Document(xml, null);
        RenderedImage image = doc.engine.getRendering(new Dimension(100, 100));
        ImageIO.write(image, "jpeg", new File("out.jpg"));
    }
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.