Example usage for com.badlogic.gdx.utils XmlWriter pop

List of usage examples for com.badlogic.gdx.utils XmlWriter pop

Introduction

In this page you can find the example usage for com.badlogic.gdx.utils XmlWriter pop.

Prototype

public XmlWriter pop() throws IOException 

Source Link

Usage

From source file:com.steelkiwi.patheditor.proj.ProjectDataConverter.java

License:Apache License

private static void saveProjectData(ProjectData projData) throws Exception {
    String path = projData.getPath() + PATH_SEPARATOR + projData.getName() + PROJECT_EXT;
    File projectFile = new File(path);

    if (projectFile.exists()) {
        projectFile.delete();// w  w  w.jav a 2  s.  co m
    }
    projectFile.createNewFile();

    StringWriter strWriter = new StringWriter();
    XmlWriter xmlWriter = new XmlWriter(strWriter);

    xmlWriter.element("project");

    xmlWriter.element("name", projData.getName());
    //xmlWriter.element("path", projData.getPath()); //TODO

    if (projData.getScreens() != null) {
        for (int i = 0; i < projData.getScreens().size(); i++) {
            xmlWriter.element("screen").element("xml", projData.getScreens().get(i).getXmlPath())
                    .element("json", projData.getScreens().get(i).getJsonPath()).pop();
        }
    }

    xmlWriter.pop();
    xmlWriter.close();

    FileWriter writer = new FileWriter(new File(path));
    writer.write(strWriter.toString());
    writer.close();

    if (projData.getScreens() != null) {
        saveScreens(projData);
    }
}

From source file:com.mangecailloux.pebble.directory.DirectoryElement.java

License:Apache License

/**
 * Convert the directoryElement to XML.//from  w w w.ja v a  2 s. c  om
* @param _xml XmlWriter to convert the directoryElement into XML.
* @throws IOException 
*/
protected void toXML(XmlWriter _xml) throws IOException {
    _xml.element("element");
    _xml.attribute("type", getClass().getName());
    _xml.attribute("name", name);
    internalToXML(_xml);
    _xml.pop();
}

From source file:com.nebula2d.editor.framework.components.PhysicsMaterial.java

License:Open Source License

@Override
public void build(XmlWriter sceneXml, XmlWriter assetsXml, String sceneName) throws IOException {
    sceneXml.element("physicsMaterial").attribute("density", density).attribute("friction", friction)
            .attribute("restitution", restitution);
    sceneXml.pop();
}

From source file:mobi.shad.s3lib.gfx.node.core.FxEffect.java

License:Apache License

/**
 * @param writer/*from  w ww.  j  ava 2s .  c  om*/
 * @return
 */
@Override
public XmlWriter savePrefs(XmlWriter writer) {
    try {
        writer.element("effect").attribute("class", this.getClass().getName());
        formData.save(writer);
        writer.pop();
        return writer;
    } catch (IOException ex) {
        S3Log.log("savePrefsToJson", ex.toString() + " Exception in " + this.getClass().getName());
        return writer;
    }
}

From source file:com.nebula2d.editor.framework.components.Circle.java

License:Open Source License

@Override
public void build(XmlWriter sceneXml, XmlWriter assetsXml, String sceneName) throws IOException {
    super.build(sceneXml, assetsXml, sceneName);
    sceneXml.attribute("r", r);
    sceneXml.pop();
}

From source file:com.github.fauu.helix.editor.MapRegionWriter.java

License:Open Source License

public static void saveMapRegion(MapRegion mapRegion, FileHandle hmrFile) {
    final StringWriter stringWriter = new StringWriter();
    final XmlWriter xmlWriter = new XmlWriter(stringWriter);
    Writer outputWriter = null;/*from w  ww  .j a v  a2 s  . c  om*/

    stringWriter.write("<?xml version=\"1.0\"?>\n");

    try {
        xmlWriter.element("mapregion");
        xmlWriter.attribute("width", (int) mapRegion.getSize().x);
        xmlWriter.attribute("height", (int) mapRegion.getSize().y);
        xmlWriter.attribute("texturesetid", 0); // FIXME: TextureAtlas needs a wrapper after all I guess
        xmlWriter.attribute("geometrysetid", mapRegion.getGeometrySet().getId());

        xmlWriter.element("tiles");
        for (Tile tile : mapRegion.getTiles()) {
            xmlWriter.element("tile");
            xmlWriter.attribute("x", (int) tile.getPosition().x);
            xmlWriter.attribute("y", (int) tile.getPosition().y);
            xmlWriter.attribute("elevation", tile.getElevation());
            xmlWriter.attribute("textureid", tile.getTextureId());
            xmlWriter.attribute("geometryid", tile.getGeometryId());
            xmlWriter.attribute("facing", tile.getFacing().toString().toLowerCase());
            xmlWriter.attribute("type", tile.getType().toString().toLowerCase());
            xmlWriter.pop();
        }
        xmlWriter.pop();

        xmlWriter.element("objects");
        for (com.github.fauu.helix.core.Object object : mapRegion.getObjects()) {
            xmlWriter.element("object");
            xmlWriter.attribute("x", (int) object.getPosition().x);
            xmlWriter.attribute("y", (int) object.getPosition().y);
            xmlWriter.attribute("model", object.getModelName());
            xmlWriter.attribute("elevation", object.getElevation());
            xmlWriter.attribute("facing", object.getFacing().toString().toLowerCase());
            xmlWriter.pop();
        }
        xmlWriter.pop();

        xmlWriter.pop();

        outputWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(hmrFile.path())));

        outputWriter.write(stringWriter.toString());
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        try {
            outputWriter.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

From source file:com.nebula2d.editor.framework.components.BoundingBox.java

License:Open Source License

@Override
public void build(XmlWriter sceneXml, XmlWriter assetsXml, String sceneName) throws IOException {
    super.build(sceneXml, assetsXml, sceneName);
    sceneXml.attribute("w", w).attribute("h", h);
    sceneXml.pop();
}

From source file:com.nebula2d.editor.framework.Layer.java

License:Open Source License

@Override
public void build(XmlWriter sceneXml, XmlWriter assetsXml, String sceneName) throws IOException {
    sceneXml.element("layer").attribute("name", name);
    Enumeration children = children();
    while (children.hasMoreElements()) {
        GameObject child = (GameObject) children.nextElement();
        child.build(sceneXml, assetsXml, sceneName);
        sceneXml.pop();
    }/*from w w  w .j a va  2 s.  c o m*/
}

From source file:com.nebula2d.editor.framework.Scene.java

License:Open Source License

@Override
public void build(XmlWriter sceneXml, XmlWriter assetsXml, String sceneName) throws IOException {
    sceneXml.element("scene").attribute("name", name);

    Enumeration children = children();
    while (children.hasMoreElements()) {
        Layer child = (Layer) children.nextElement();
        child.build(sceneXml, assetsXml, sceneName);
        sceneXml.pop();
    }/*  w w w  .j  a v a2  s . c o m*/
}

From source file:at.highstreeto.xnllayoutparser.element.TextFieldParser.java

License:Apache License

@Override
public void save(XmlWriter writer, Actor actor, LayoutParserContext context) throws LayoutParseException {
    try {//from   w w  w  . ja va  2s  .c  o  m
        TextField textField = (TextField) actor;
        writer.element(getElementName());
        ElementParserHelper.writeDefaultAttributes(writer, actor);

        if (!textField.getText().isEmpty()) {
            writer.text(textField.getText());
        }

        writer.pop();
    } catch (IOException e) {
        throw new LayoutParseException(e);
    }
}