Properties props = tile.getProperties(); for (Enumeration keys = props.keys(); keys.hasMoreElements();) { String key = (String)keys.nextElement(); w.startElement("property"); w.writeAttribute("name", key); w.writeAttribute("value", props.getProperty(key)); w.endElement(); }
writeProperties(tile.getProperties(), w);
    private static void writeTile(Tile tile, XMLWriter w) throws IOException {        try {            w.startElement("tile");            int tileId = tile.getId();            w.writeAttribute("id", tileId);            //if (groundHeight != getHeight()) {            //    w.writeAttribute("groundheight", "" + groundHeight);            //}            Properties props = tile.getProperties();            for (Enumeration keys = props.keys(); keys.hasMoreElements();) {                String key = (String)keys.nextElement();                w.startElement("property");                w.writeAttribute("name", key);                w.writeAttribute("value", props.getProperty(key));                w.endElement();            }            Image tileImage = tile.getImage();            Preferences prefs = TiledConfiguration.node("saving");            boolean embedImages = prefs.getBoolean("embedImages", true);            boolean tileSetImages = prefs.getBoolean("tileSetImages", false);            // Write encoded data            if (tileImage != null && !tileSetImages) {                if (embedImages && !tileSetImages) {                    w.startElement("image");                    w.writeAttribute("format", "png");                    w.startElement("data");                    w.writeAttribute("encoding", "base64");                    w.writeCDATA(new String(Base64.encode(                                    ImageHelper.imageToPNG(tileImage))));                    w.endElement();                    w.endElement();                } else if (tileSetImages) {                    w.startElement("image");                    w.writeAttribute("id", tile.getImageId());                    w.endElement();                } else {                    String prefix = prefs.get("tileImagePrefix", "tile");                    String filename = prefs.get("maplocation", "") +                        prefix + tileId + ".png";                    w.startElement("image");                    w.writeAttribute("source", prefix + tileId + ".png");                    FileOutputStream fw = new FileOutputStream(                            new File(filename));                    byte[] data = ImageHelper.imageToPNG(tileImage);                    fw.write(data, 0, data.length);                    fw.close();                    w.endElement();                }            }            if (tile instanceof AnimatedTile) {                writeAnimation(((AnimatedTile)tile).getSprite(), w);            }            w.endElement();        } catch (XMLWriterException e) {            e.printStackTrace();        }    }