Package org.tools.xml

Examples of org.tools.xml.Node


    /**
     * Load everything.
     */
    public static void load() {

        Node parent = IOManager.getAsXML(Places.Common, "settings.xml");

        // terrains
        Node node = parent.getFirstChild("Terrains");
        defaultTerrainID = Integer.parseInt(node.getAttributeValue("default-id"));
        terrainNames = new HashMap<>(node.getChildCount());
        for (Node child: node.getChildren()) {
            int id = child.getAttributeValueAsInt("id");
            String name = child.getAttributeValue("name");
            terrainNames.put(id, name);
        }

        // resources
        node = parent.getFirstChild("Resources");
        resourceNames = new HashMap<>(node.getChildCount());
        for (Node child: node.getChildren()) {
            int id = child.getAttributeValueAsInt("id");
            String name = child.getAttributeValue("name");
            resourceNames.put(id, name);
        }
    }
View Full Code Here


     * @param action
     * @param location
     * @return
     */
    public static Node addUnitTile(String type, String action, String location) {
        Node child = new Node("Unit");
        child.addAttribute("type", type);
        child.addAttribute("action", action);
        child.addAttribute("location", location);
        return child;
    }
View Full Code Here

    /**
     *
     * @return
     */
    public static Node createMisc() {
        Node parent = new Node("Miscellaneous-Overlays");
        parent.appendChild(addMiscTile("city", "city.png"));
        parent.appendChild(addMiscTile("garrison", "garrison.png"));
        return parent;
    }
View Full Code Here

     * @param id
     * @param location
     * @return
     */
    public static Node addMiscTile(String id, String location) {
        Node child = new Node("Overlay");
        child.addAttribute("id", id);
        child.addAttribute("location", location);
        return child;
    }
View Full Code Here

    /**
     *
     * @throws IOException
     */
    public static Node createResources() {
        Node parent = new Node("Resource-Overlays");
        parent.addAttribute("base", "resources");
        parent.appendChild(addResourceOverlay(1, "resource.grain.inner.png", "resource.grain.outer.png"));
        parent.appendChild(addResourceOverlay(2, "resource.orchard.inner.png", "resource.orchard.outer.png"));
        parent.appendChild(addResourceOverlay(3, "resource.buffalo.inner.png", "resource.buffalo.outer.png"));
        parent.appendChild(addResourceOverlay(4, "resource.cotton.inner.png", "resource.cotton.outer.png"));
        parent.appendChild(addResourceOverlay(5, "resource.sheep.inner.png", "resource.sheep.outer.png"));
        parent.appendChild(addResourceOverlay(6, "resource.forest.inner.png", "resource.forest.outer.png"));
        parent.appendChild(addResourceOverlay(7, "resource.scrubforest.inner.png", "resource.scrubforest.outer.png"));
        parent.appendChild(addResourceOverlay(8, "resource.oil.inner.png", "resource.oil.outer.png"));
        parent.appendChild(addResourceOverlay(9, "resource.coal.png", null));
        parent.appendChild(addResourceOverlay(10, "resource.ore.png", null));
        parent.appendChild(addResourceOverlay(11, "resource.horse.png", null));
        return parent;
    }
View Full Code Here

     * @param location
     * @param visible
     * @return
     */
    public static Node addResourceOverlay(int id, String inner, String outer) {
        Node child = new Node("Overlay");
        child.addAttribute("id", String.valueOf(id));
        child.addAttribute("inner", inner);
        if (outer != null) {
            child.addAttribute("outer", outer);
        }
        return child;
    }
View Full Code Here

    /**
     *
     * @throws IOException
     */
    public static Node createTerrain() {
        Node parent = new Node("Terrain-Tiles");
        parent.addAttribute("base", "terrains");
        parent.appendChild(addTerrainTile(1, "terrain.sea.png", null,  "80a0e0"));
        parent.appendChild(addTerrainTile(2, "terrain.plains.png", null, "d0f0a0"));
        parent.appendChild(addTerrainTile(3, "terrain.hills.inner.png", "terrain.hills.outer.png", "604020"));
        parent.appendChild(addTerrainTile(4, "terrain.mountains.inner.png", "terrain.mountains.outer.png", "909090"));
        parent.appendChild(addTerrainTile(5, "terrain.tundra.inner.png", "terrain.tundra.outer.png", "c0c0c0"));
        parent.appendChild(addTerrainTile(6, "terrain.swamp.inner.png", "terrain.swamp.outer.png", "309030"));
        parent.appendChild(addTerrainTile(7, "terrain.desert.inner.png", "terrain.desert.outer.png", "c0c0a0"));
        return parent;
    }
View Full Code Here

     * @param location
     * @param color
     * @return
     */
    public static Node addTerrainTile(int id, String inner, String outer, String color) {
        Node child = new Node("Tile");
        child.addAttribute("id", String.valueOf(id));
        child.addAttribute("inner", inner);
        if (outer != null) {
            child.addAttribute("outer", outer);
        }
        child.addAttribute("color", color);
        return child;
    }
View Full Code Here

    /**
     * @param args the command line arguments
     * @throws IOException
     */
    public static void main(String[] args) throws IOException {
        Node parent = new Node("Music");
        parent.appendChild(makeBackgroundMusicList());
        Resource resource = ResourceUtils.asResource("music.xml");
        XMLHelper.write(resource, parent);
    }
View Full Code Here

    /**
     *
     * @return
     */
    public static Node makeBackgroundMusicList() {
        Node parent = new Node("Background");
        parent.addAttribute("base", "background");
        parent.appendChild(addPiece("01-Imperialism.ogg"));
        parent.appendChild(addPiece("02-Silent Ashes.ogg"));
        return parent;
    }
View Full Code Here

TOP

Related Classes of org.tools.xml.Node

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.