
public class ResourceFactory {
	/** The single instance of this class to ever exist <singleton> */
	private static final ResourceFactory single = new ResourceFactory();
	
	/**
 	 * Retrieve the single instance of this class 
	 *
 	 * @return The single instance of this class 
	 */
	public static ResourceFactory get() {
		return single;
	}

	/** The window the game should use to render */
	private JoglGameWindow window;

	/** 
       * The default contructor has been made private to prevent construction of 
	 * this class anywhere externally. This is used to enforce the singleton 
	 * pattern that this class attempts to follow
	 */
	private ResourceFactory() {
	}

	/**
 	 * Retrieve the game window that should be used to render the game
	 *
	 * @return The game window in which the game should be rendered
	 */
	public JoglGameWindow getGameWindow() {
		// if we've yet to create the game window, create the appropriate one
		// now
		if (window == null) {
			window = new JoglGameWindow();
		}

		return window;
	}

	/**
	 * Create or get a sprite which displays the image that is pointed
	 * to in the classpath by "ref"
	 * 
	 * @param ref A reference to the image to load
	 * @return A sprite that can be drawn onto the current graphics context.
	 */
	public Sprite getSprite(String ref) {
		if (window == null) {
			throw new RuntimeException("Attempt to retrieve sprite before game window was created");
		}
		
		return new Sprite((JoglGameWindow) window, ref);
	}
}