package org.newdawn.slick; import java.util.HashMap; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.newdawn.slick.util.ResourceLoader; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; /** * A sprite sheet based on an XML descriptor generated from the simple slick tool * * @author kevin */ public class XMLPackedSheet { /** The full sheet image */ private Image image; /** The sprites stored on the image */ private HashMap sprites = new HashMap(); /** * Create a new XML packed sheet from the XML output by the slick tool * * @param imageRef The reference to the image * @param xmlRef The reference to the XML * @throws SlickException Indicates a failure to parse the XML or read the image */ public XMLPackedSheet(String imageRef, String xmlRef) throws SlickException { image = new Image(imageRef, false, Image.FILTER_NEAREST); try { DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document doc = builder.parse(ResourceLoader.getResourceAsStream(xmlRef)); NodeList list = doc.getElementsByTagName("sprite"); for (int i=0;i