*/
public static Skin loadThemePackDefinition(java.net.URL url)
throws Exception {
Skin skin = null;
XMLElement element = new XMLElement();
element.parseFromReader(new java.io.InputStreamReader(getInputStream(url)));
checkRequiredVersion(element.getProperty("REQUIRE"));
// reset any custom properties that may be set in the skin
UIManager.put("JDesktopPane.backgroundEnabled", Boolean.FALSE);
UIManager.put("PopupMenu.animation", Boolean.FALSE);
UIManager.put("ScrollBar.alternateLayout", Boolean.FALSE);
UIManager.put("JSplitPane.alternateUI", Boolean.FALSE);
Enumeration enumeration = element.enumerateChildren();
while (enumeration.hasMoreElements()) {
element = (XMLElement)enumeration.nextElement();
String tagName = element.getTagName().toLowerCase();
if ("skin".equals(tagName)) {
skin = buildSkin(url, element);
} else if ("property".equals(tagName)) {
String type = element.getProperty("TYPE");
// Take the boolean class if the typeclass is not specified for
// backward compatibility.
if (type == null
|| "".equals(type)
|| "boolean".equalsIgnoreCase(type)
|| "java.lang.Boolean".equalsIgnoreCase(type)) {
UIManager.put(
element.getProperty("NAME"),
Boolean.valueOf(element.getProperty("VALUE")));
} else if (
"int".equalsIgnoreCase(type)
|| "java.lang.Integer".equalsIgnoreCase(type)) {
UIManager.put(
element.getProperty("NAME"),
Integer.valueOf(element.getProperty("VALUE")));
} else if (
"String".equalsIgnoreCase(type)
|| "java.lang.String".equalsIgnoreCase(type)) {
UIManager.put(
element.getProperty("NAME"),
element.getProperty("VALUE"));
} else if (
"Color".equalsIgnoreCase(type)
|| "java.awt.Color".equalsIgnoreCase(type)) {
Color color = Color.decode(element.getProperty("VALUE"));
UIManager.put(
element.getProperty("NAME"),
new ColorUIResource(color));
} else if (
"Insets".equalsIgnoreCase(type)
|| "java.awt.Insets".equalsIgnoreCase(type)) {
Insets insets = parseInsets(element.getProperty("VALUE"));
UIManager.put(
element.getProperty("NAME"),
new InsetsUIResource(
insets.top,
insets.left,
insets.bottom,
insets.right));
} else if (
"Dimension".equalsIgnoreCase(type)
|| "java.awt.Dimension".equalsIgnoreCase(type)) {
Dimension dim = parseDimension(element.getProperty("VALUE"));
UIManager.put(
element.getProperty("NAME"),
new DimensionUIResource(dim.width, dim.height));
} else if (
"LineBorder".equalsIgnoreCase(type)
|| "javax.swing.border.LineBorder".equalsIgnoreCase(type)) {
boolean rounded = false;
Color color = Color.black;
int thickness = 1;
int padding = 0;
String temp;
temp = element.getProperty("ROUNDED");
if (temp != null) {
rounded = (Boolean.getBoolean(temp));
}
temp = element.getProperty("THICKNESS");
if (temp != null) {
thickness = Integer.parseInt(temp);
}
temp = element.getProperty("PADDING");
if (temp != null) {
padding = Integer.parseInt(temp);
}
temp = element.getProperty("COLOR");
if (temp != null) {
color = Color.decode(temp);
}
Border border =
new com.l2fprod.gui.border.LineBorder(color, thickness, rounded);
if (padding > 0) {
border =
new CompoundBorder(
border,
BorderFactory.createEmptyBorder(
padding,
padding,
padding,
padding));
}
UIManager.put(
element.getProperty("NAME"),
new BorderUIResource(border));
} else if (
"EmptyBorder".equalsIgnoreCase(type)
|| "javax.swing.border.EmptyBorder".equalsIgnoreCase(type)) {
Insets insets = parseInsets(element.getProperty("VALUE"));
Border border = new javax.swing.border.EmptyBorder(insets);
UIManager.put(
element.getProperty("NAME"),
new BorderUIResource(border));
}
} else if ("font".equalsIgnoreCase(tagName)) {
String[] fontStyle =
StringUtils.splitString(element.getProperty("VALUE"), ",");
Font f =
SkinUtils.getFont(
fontStyle[0],
Integer.parseInt(fontStyle[1]),
Integer.parseInt(fontStyle[2]));
if (f != null) {
if ("Global".equalsIgnoreCase(element.getProperty("NAME"))) {
SkinUtils.setFont(new FontUIResource(f));
} else {
UIManager.put(element.getProperty("NAME"), new FontUIResource(f));
}
}
} else if ("icon".equalsIgnoreCase(tagName)) {
final URL iconURL = new URL(url, element.getProperty("VALUE"));
ImageIcon icon = new ImageIcon(SkinUtils.loadImage(iconURL));
UIManager.put(element.getProperty("NAME"), new IconUIResource(icon));
// put the default internal icon at work for JOptionPane too
if ("InternalFrame.icon".equals(element.getProperty("NAME"))) {
JOptionPane.getRootFrame().setIconImage(icon.getImage());
}
}
}
return skin;