package libjtmx; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import java.io.InputStream; import java.awt.Color; import java.util.List; @XmlRootElement(name = "map") public class Map { public enum Orientation { ORTHOGONAL, ISOMETRIC, STAGGERED, HEXAGONAL } public enum RenderOrder { RIGHT_DOWN, RIGHT_UP, LEFT_DOWN, LEFT_UP } /* attributes */ String version; String tiledVersion; Orientation orientation; RenderOrder renderOrder; int width; int height; int tileWidth; int tileHeight; // hex is not supported yet /* int hexSideLenght; Axis staggerAxis; String staggerIndex; */ Color backgroundColor; /* elements */ List tileSets; private Map() {} public static Map load(InputStream is) { Map map = null; try { JAXBContext context = JAXBContext.newInstance(Map.class); Unmarshaller unmarshaller = context.createUnmarshaller(); map = (Map) unmarshaller.unmarshal(is); } catch (JAXBException ex) { ex.printStackTrace(); } return map; } }