x++; if (x == ml.getWidth()) { x = 0; y++; } if (y == ml.getHeight()) { break; }
	private MapLayer unmarshalLayer(Node t) throws Exception {		MapLayer ml = null;		Rectangle rect = new Rectangle(0,0,map.getWidth(),map.getHeight());				boolean encodedBase64=false;		try {            ml = (MapLayer)unmarshalClass(MapLayer.class,t);        } catch (Exception e) {            e.printStackTrace();        }				ml.setBounds(rect);        NodeList children = t.getChildNodes();        for (int i = 0; i < children.getLength(); i++) {            Node child = children.item(i);            if (child.getNodeName().equalsIgnoreCase("data")) {                String encoding = getAttributeValue(child, "encoding");                if (encoding != null && encoding.equalsIgnoreCase("base64")) {                    Node cdata = child.getChildNodes().item(0);                    char[] enc = cdata.getNodeValue().trim().toCharArray();                    byte[] dec = Base64.decode(enc);                    ByteArrayInputStream bais = new ByteArrayInputStream(dec);                    InputStream is;                    String comp = getAttributeValue(child, "compression");                    if (comp != null && comp.equalsIgnoreCase("gzip")) {                        is = new GZIPInputStream(bais);                    } else {                        is = bais;                    }                    for (int y = 0; y < ml.getHeight(); y++) {                        for (int x = 0; x < ml.getWidth(); x++) {                            int tileId = 0;                            tileId |= is.read();                            tileId |= is.read() <<  8;                            tileId |= is.read() << 16;                            tileId |= is.read() << 24;                            TileSet ts = map.findTileSetForTileGID(tileId);                            if (ts != null) {                            	ml.setTileAt(x, y,                                        ts.getTile(tileId - ts.getFirstGid()));                            } else {                                ml.setTileAt(x, y, map.getNullTile());                            }                        }                    }                } else {                    NodeList tilelist = doc.getElementsByTagName("tile");                    int itr = 0;                    for (int y = 0; y < ml.getHeight(); y++) {                        for (int x = 0; x < ml.getWidth(); x++) {                            Node tileNode = tilelist.item(itr++);                            Tile tile = unmarshalTile(tileNode);                            int tileId = tile.getGid();                            TileSet ts = map.findTileSetForTileGID(tileId);                            if (ts != null) {                                ml.setTileAt(x, y,                                        ts.getTile(tileId - ts.getFirstGid()));                            } else {                                ml.setTileAt(x, y, map.getNullTile());                            }                        }                    }                }                break;            }        }        return ml;    }