2007-12-23 14:28:04 -05:00
|
|
|
|
|
|
|
package net.sourceforge.filebot.resources;
|
|
|
|
|
|
|
|
|
|
|
|
import java.awt.Image;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.net.URL;
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
|
import javax.imageio.ImageIO;
|
|
|
|
import javax.swing.ImageIcon;
|
|
|
|
|
|
|
|
|
|
|
|
public class ResourceManager {
|
|
|
|
|
2008-02-09 12:53:08 -05:00
|
|
|
private static HashMap<String, String> aliasMap = new HashMap<String, String>();
|
2007-12-23 14:28:04 -05:00
|
|
|
|
|
|
|
static {
|
2008-02-09 12:53:08 -05:00
|
|
|
aliasMap.put("tab.loading", "tab.loading.gif");
|
|
|
|
aliasMap.put("tab.history", "action.find.png");
|
2007-12-23 14:28:04 -05:00
|
|
|
|
2008-02-09 12:53:08 -05:00
|
|
|
aliasMap.put("loading", "loading.gif");
|
2007-12-23 14:28:04 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static Image getImage(String name) {
|
|
|
|
try {
|
2008-02-09 12:53:08 -05:00
|
|
|
return ImageIO.read(getResource(name));
|
2007-12-23 14:28:04 -05:00
|
|
|
} catch (IOException e) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static ImageIcon getIcon(String name) {
|
2008-02-09 12:53:08 -05:00
|
|
|
return new ImageIcon(getResource(name));
|
2007-12-23 14:28:04 -05:00
|
|
|
}
|
|
|
|
|
2008-02-09 12:53:08 -05:00
|
|
|
|
|
|
|
private static URL getResource(String name) {
|
|
|
|
String resource = null;
|
|
|
|
|
|
|
|
if (aliasMap.containsKey(name))
|
|
|
|
resource = aliasMap.get(name);
|
|
|
|
else
|
|
|
|
resource = name + ".png";
|
|
|
|
|
|
|
|
return ResourceManager.class.getResource(resource);
|
|
|
|
}
|
2007-12-23 14:28:04 -05:00
|
|
|
}
|