package images;

import java.net.URL;
import java.util.HashMap;

/**
 * Takes all of the files in the package "images" (the directory containing this
 * class) and creates a mapping of the name each file that ends with ".png" to
 * its corresponding URL.
 * @author Nathaniel Lehrer
 */
public class Images
{
    private static HashMap<String, URL> images = new HashMap<String, URL>();

    static
    {
        images.put("ATMSEval.png", Images.class.getResource("ATMSEval.png"));
        images.put("ActivityLogEval.png", Images.class.getResource("ActivityLogEval.png"));
        images.put("Audio.png", Images.class.getResource("Audio.png"));
        images.put("CAD.png", Images.class.getResource("CAD.png"));
        images.put("CADEval.png", Images.class.getResource("CADEval.png"));
        images.put("CCTV.png", Images.class.getResource("CCTV.png"));
        images.put("CHPRadio.png", Images.class.getResource("CHPRadio.png"));
        images.put("CMSEval.png", Images.class.getResource("CMSEval.png"));
        images.put("Collapse.png", Images.class.getResource("Collapse.png"));
        images.put("Cursor.png", Images.class.getResource("Cursor.png"));
        images.put("Event.png", Images.class.getResource("Event.png"));
        images.put("Expand.png", Images.class.getResource("Expand.png"));
        images.put("FacilitatorEval.png", Images.class.getResource("FacilitatorEval.png"));
        images.put("MaintenanceRadio.png", Images.class.getResource("MaintenanceRadio.png"));
        images.put("Paramics.png", Images.class.getResource("Paramics.png"));
        images.put("Radio.png", Images.class.getResource("Radio.png"));
        images.put("RadioEval.png", Images.class.getResource("RadioEval.png"));
        images.put("TMTRadio.png", Images.class.getResource("TMTRadio.png"));
        images.put("Telephone.png", Images.class.getResource("Telephone.png"));
        images.put("Tow.png", Images.class.getResource("Tow.png"));
        images.put("Unit.png", Images.class.getResource("Unit.png"));
        images.put("Witness.png", Images.class.getResource("Witness.png"));
    }

    /**
     * Returns the image with the given name.
     * @param name The name of the image to lookup.
     * @return The URL corresponding to the given name if the name is found.
     * @throws RuntimeException If the name was not found.
     */
    public static URL getImage(String name)
    {
        if (images.get(name) == null)
        {
            throw new RuntimeException("Images of name \"" + name
                    + "\" was not found.");
        }
        return images.get(name);
    }
}
