/** * Find the path to a given icon and return it as a URL. * * @param name base name of the icon to search for * @param loader class loader to use or null to use the default class loader * @return the URL where the icon was found */ public static URL lookupIconUrl(String name, ClassLoader loader) { return ResourceLoader.lookupIconUrl(name, loader); }
/** * This public operation is needed to allow modules to add their own images. * * @param location the path were the images are */ public static void addResourceLocation(String location) { ResourceLoader.addResourceLocation(location); }
/** * Find the correct icon for a key. * * @param resource The name of the resource to look up. * @param desc The description for the icon. * @return The ImageIcon. */ public static ImageIcon lookupIconResource(String resource, String desc) { return ResourceLoader.lookupIconResource(resource, desc); }
/** * Initializes the resourceloader. * * <p>LookupIconResource checks if there are locations and extensions known. If there are none, * this method is called to initialize the resource loader. Originally, this method was placed * within Main but this coupled Main and the resourceLoader too much. */ private static void initResourceLoader() { String lookAndFeelClassName; if ("true".equals(System.getProperty("force.nativelaf", "false"))) { lookAndFeelClassName = UIManager.getSystemLookAndFeelClassName(); } else { lookAndFeelClassName = "javax.swing.plaf.metal.MetalLookAndFeel"; } String lookAndFeelGeneralImagePath = lookAndFeelPath(lookAndFeelClassName, "general"); String lookAndFeelNavigationImagePath = lookAndFeelPath(lookAndFeelClassName, "navigation"); String lookAndFeelDiagramImagePath = lookAndFeelPath(lookAndFeelClassName, "argouml/diagrams"); String lookAndFeelElementImagePath = lookAndFeelPath(lookAndFeelClassName, "argouml/elements"); String lookAndFeelArgoUmlImagePath = lookAndFeelPath(lookAndFeelClassName, "argouml"); ResourceLoader.addResourceExtension("gif"); ResourceLoader.addResourceExtension("png"); ResourceLoader.addResourceLocation(lookAndFeelGeneralImagePath); ResourceLoader.addResourceLocation(lookAndFeelNavigationImagePath); ResourceLoader.addResourceLocation(lookAndFeelDiagramImagePath); ResourceLoader.addResourceLocation(lookAndFeelElementImagePath); ResourceLoader.addResourceLocation(lookAndFeelArgoUmlImagePath); ResourceLoader.addResourceLocation("/org/argouml/Images"); ResourceLoader.addResourceLocation("/org/tigris/gef/Images"); // Initialze GEF's version of the loader too // TODO: We should probably be passing icons that we loaded ourselves // but there doesn't seem to be a way to do that with GEF - tfm org.tigris.gef.util.ResourceLoader.addResourceExtension("gif"); org.tigris.gef.util.ResourceLoader.addResourceExtension("png"); org.tigris.gef.util.ResourceLoader.addResourceLocation(lookAndFeelGeneralImagePath); org.tigris.gef.util.ResourceLoader.addResourceLocation(lookAndFeelNavigationImagePath); org.tigris.gef.util.ResourceLoader.addResourceLocation(lookAndFeelDiagramImagePath); org.tigris.gef.util.ResourceLoader.addResourceLocation(lookAndFeelElementImagePath); org.tigris.gef.util.ResourceLoader.addResourceLocation(lookAndFeelArgoUmlImagePath); org.tigris.gef.util.ResourceLoader.addResourceLocation("/org/argouml/Images"); org.tigris.gef.util.ResourceLoader.addResourceLocation("/org/tigris/gef/Images"); initialStateIcon = ResourceLoader.lookupIconResource("Initial"); deepIcon = ResourceLoader.lookupIconResource("DeepHistory"); shallowIcon = ResourceLoader.lookupIconResource("ShallowHistory"); forkIcon = ResourceLoader.lookupIconResource("Fork"); joinIcon = ResourceLoader.lookupIconResource("Join"); branchIcon = ResourceLoader.lookupIconResource("Choice"); junctionIcon = ResourceLoader.lookupIconResource("Junction"); realizeIcon = ResourceLoader.lookupIconResource("Realization"); signalIcon = ResourceLoader.lookupIconResource("SignalSending"); exceptionIcon = ResourceLoader.lookupIconResource("Exception"); commentIcon = ResourceLoader.lookupIconResource("Note"); }