source: tmcsimulator-scriptbuilder/src/images/Images.java @ 1

Revision 1, 2.6 KB checked in by bmcguffin, 9 years ago (diff)

2017/07/18: Uploaded entire prototype to SVN repo.

Line 
1package images;
2
3import java.net.URL;
4import java.util.HashMap;
5
6/**
7 * Takes all of the files in the package "images" (the directory containing this
8 * class) and creates a mapping of the name each file that ends with ".png" to
9 * its corresponding URL.
10 *
11 * @author Nathaniel Lehrer
12 */
13public class Images
14{
15
16    private static HashMap<String, URL> images = new HashMap<String, URL>();
17
18    static
19    {
20        images.put("ATMSEval.png", Images.class.getResource("ATMSEval.png"));
21        images.put("ActivityLogEval.png", Images.class.getResource("ActivityLogEval.png"));
22        images.put("Audio.png", Images.class.getResource("Audio.png"));
23        images.put("CAD.png", Images.class.getResource("CAD.png"));
24        images.put("CADEval.png", Images.class.getResource("CADEval.png"));
25        images.put("CCTV.png", Images.class.getResource("CCTV.png"));
26        images.put("CHPRadio.png", Images.class.getResource("CHPRadio.png"));
27        images.put("CMSEval.png", Images.class.getResource("CMSEval.png"));
28        images.put("Collapse.png", Images.class.getResource("Collapse.png"));
29        images.put("Cursor.png", Images.class.getResource("Cursor.png"));
30        images.put("Event.png", Images.class.getResource("Event.png"));
31        images.put("Expand.png", Images.class.getResource("Expand.png"));
32        images.put("FacilitatorEval.png", Images.class.getResource("FacilitatorEval.png"));
33        images.put("MaintenanceRadio.png", Images.class.getResource("MaintenanceRadio.png"));
34        images.put("Paramics.png", Images.class.getResource("Paramics.png"));
35        images.put("Radio.png", Images.class.getResource("Radio.png"));
36        images.put("RadioEval.png", Images.class.getResource("RadioEval.png"));
37        images.put("TMTRadio.png", Images.class.getResource("TMTRadio.png"));
38        images.put("Telephone.png", Images.class.getResource("Telephone.png"));
39        images.put("Tow.png", Images.class.getResource("Tow.png"));
40        images.put("Unit.png", Images.class.getResource("Unit.png"));
41        images.put("Witness.png", Images.class.getResource("Witness.png"));
42    }
43
44    /**
45     * Returns the image with the given name.
46     *
47     * @param name The name of the image to lookup.
48     * @return The URL corresponding to the given name if the name is found.
49     * @throws RuntimeException If the name was not found.
50     */
51    public static URL getImage(String name)
52    {
53        if (images.get(name) == null)
54        {
55            throw new RuntimeException("Images of name \"" + name
56                    + "\" was not found.");
57        }
58        return images.get(name);
59    }
60}
Note: See TracBrowser for help on using the repository browser.