| 1 | package images; |
|---|
| 2 | |
|---|
| 3 | import java.net.URL; |
|---|
| 4 | import 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 | * @author Nathaniel Lehrer |
|---|
| 11 | */ |
|---|
| 12 | public class Images |
|---|
| 13 | { |
|---|
| 14 | private static HashMap<String, URL> images = new HashMap<String, URL>(); |
|---|
| 15 | |
|---|
| 16 | static |
|---|
| 17 | { |
|---|
| 18 | images.put("ATMSEval.png", Images.class.getResource("ATMSEval.png")); |
|---|
| 19 | images.put("ActivityLogEval.png", Images.class.getResource("ActivityLogEval.png")); |
|---|
| 20 | images.put("Audio.png", Images.class.getResource("Audio.png")); |
|---|
| 21 | images.put("CAD.png", Images.class.getResource("CAD.png")); |
|---|
| 22 | images.put("CADEval.png", Images.class.getResource("CADEval.png")); |
|---|
| 23 | images.put("CCTV.png", Images.class.getResource("CCTV.png")); |
|---|
| 24 | images.put("CHPRadio.png", Images.class.getResource("CHPRadio.png")); |
|---|
| 25 | images.put("CMSEval.png", Images.class.getResource("CMSEval.png")); |
|---|
| 26 | images.put("Collapse.png", Images.class.getResource("Collapse.png")); |
|---|
| 27 | images.put("Cursor.png", Images.class.getResource("Cursor.png")); |
|---|
| 28 | images.put("Event.png", Images.class.getResource("Event.png")); |
|---|
| 29 | images.put("Expand.png", Images.class.getResource("Expand.png")); |
|---|
| 30 | images.put("FacilitatorEval.png", Images.class.getResource("FacilitatorEval.png")); |
|---|
| 31 | images.put("MaintenanceRadio.png", Images.class.getResource("MaintenanceRadio.png")); |
|---|
| 32 | images.put("Paramics.png", Images.class.getResource("Paramics.png")); |
|---|
| 33 | images.put("Radio.png", Images.class.getResource("Radio.png")); |
|---|
| 34 | images.put("RadioEval.png", Images.class.getResource("RadioEval.png")); |
|---|
| 35 | images.put("TMTRadio.png", Images.class.getResource("TMTRadio.png")); |
|---|
| 36 | images.put("Telephone.png", Images.class.getResource("Telephone.png")); |
|---|
| 37 | images.put("Tow.png", Images.class.getResource("Tow.png")); |
|---|
| 38 | images.put("Unit.png", Images.class.getResource("Unit.png")); |
|---|
| 39 | images.put("Witness.png", Images.class.getResource("Witness.png")); |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | /** |
|---|
| 43 | * Returns the image with the given name. |
|---|
| 44 | * @param name The name of the image to lookup. |
|---|
| 45 | * @return The URL corresponding to the given name if the name is found. |
|---|
| 46 | * @throws RuntimeException If the name was not found. |
|---|
| 47 | */ |
|---|
| 48 | public static URL getImage(String name) |
|---|
| 49 | { |
|---|
| 50 | if (images.get(name) == null) |
|---|
| 51 | { |
|---|
| 52 | throw new RuntimeException("Images of name \"" + name |
|---|
| 53 | + "\" was not found."); |
|---|
| 54 | } |
|---|
| 55 | return images.get(name); |
|---|
| 56 | } |
|---|
| 57 | } |
|---|