Methods Summary |
---|
private void | abandonXP()
if (AccessController.doPrivileged(new GetPropertyAction("swing.debug")) != null) {
System.err.println("An error occured in XPStyle while reading resource "+themeFile + " in " + styleFile);
new Exception().printStackTrace();
}
xp = null;
|
private java.awt.image.BufferedImage | convertToOpaque(java.awt.image.BufferedImage src)
GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().
getDefaultScreenDevice().getDefaultConfiguration();
BufferedImage dest = (BufferedImage)gc.
createCompatibleImage(src.getWidth(), src.getHeight(), Transparency.OPAQUE);
ColorConvertOp op = new ColorConvertOp(src.getColorModel().getColorSpace(),
dest.getColorModel().getColorSpace(), null);
op.filter(src, dest);
return dest;
|
private java.awt.image.BufferedImage | convertToTransparent(java.awt.image.BufferedImage src, java.awt.Color transparentColor)
int w = src.getWidth();
int h = src.getHeight();
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsConfiguration gc = ge.getDefaultScreenDevice().getDefaultConfiguration();
BufferedImage dest = gc.createCompatibleImage(w, h, Transparency.BITMASK);
int trgb;
if (transparentColor != null) {
trgb = transparentColor.getRGB() | 0xff000000;
} else {
trgb = 0xffff00ff;
}
// Copy pixels a scan line at a time
int buf[] = new int[w];
for (int y = 0; y < h; y++) {
src.getRGB(0, y, w, 1, buf, 0, w);
for (int x = 0; x < w; x++) {
if (buf[x] == trgb) {
buf[x] = 0;
}
}
dest.setRGB(0, y, w, 1, buf, 0, w);
}
return dest;
|
static java.awt.image.BufferedImage | getBitmapResource(java.lang.String key)
Toolkit toolkit = Toolkit.getDefaultToolkit();
Map resources = (Map)toolkit.getDesktopProperty("win.xpstyle.resources.images");
return (BufferedImage)resources.get(key);
|
private java.lang.Boolean | getBoolean(java.lang.String key)
String value = getString(key);
return (value != null) ? Boolean.valueOf("true".equalsIgnoreCase(value)) : null;
|
synchronized javax.swing.border.Border | getBorder(java.lang.String category)Get a named Border value from the current style
if (category == "menu") {
// Special case because XP has no skin for menus
if (getBoolean("sysmetrics.flatmenus") == Boolean.TRUE) {
// TODO: The classic border uses this color, but we should create
// a new UI property called "PopupMenu.borderColor" instead.
return new XPFillBorder(UIManager.getColor("InternalFrame.borderShadow"), 1);
} else {
return null; // Will cause L&F to use classic border
}
}
Border border = (Border)map.get("Border "+category);
if (border == null) {
String bgType = getString(category + ".bgtype");
if ("borderfill".equalsIgnoreCase(bgType)) {
int thickness = getInt(category + ".bordersize", 1);
Color color = getColor(category + ".bordercolor", Color.black);
border = new XPFillBorder(color, thickness);
} else if ("imagefile".equalsIgnoreCase(bgType)) {
Insets m = getMargin(category + ".sizingmargins");
if (m != null) {
if (getBoolean(category + ".borderonly") == Boolean.TRUE) {
border = new XPImageBorder(category);
} else {
border = new XPEmptyBorder(m);
}
}
}
if (border != null) {
map.put("Border "+category, border);
}
}
return border;
|
synchronized java.awt.Color | getColor(java.lang.String key, java.awt.Color fallback)Get a named Color value from the current style
Color color = (Color)map.get("Color "+key);
if (color == null) {
String str = getString(key);
if (str != null) {
StringTokenizer tok = new StringTokenizer(str, " \t,");
int r = parseInt(tok.nextToken(), 0);
int g = parseInt(tok.nextToken(), 0);
int b = parseInt(tok.nextToken(), 0);
if (r >= 0 && g >=0 && b >= 0) {
color = new ColorUIResource(r, g, b);
map.put("Color "+key, color);
}
}
}
return (color != null) ? color : fallback;
|
synchronized java.awt.Dimension | getDimension(java.lang.String key)Get a named Dimension value from the current style
Dimension d = (Dimension)map.get("Dimension "+key);
if (d == null) {
String str = getString(key);
if (str != null) {
StringTokenizer tok = new StringTokenizer(str, " \t,");
d = new Dimension(parseInt(tok.nextToken(), 0),
parseInt(tok.nextToken(), 0));
map.put("Dimension "+key, d);
}
}
return d;
|
private synchronized java.awt.Image | getImage(java.lang.String key, java.lang.Boolean useTransparency, java.awt.Color transparentColor)
String imageName = getString(key);
if (imageName == null) {
return null;
}
String imageKey = "Image " + imageName;
BufferedImage image = (BufferedImage)map.get(imageKey);
if (image != null) {
return image;
}
image = getBitmapResource(imageName);
if (image == null) {
return null;
}
int oldTransparency = image.getColorModel().getTransparency();
// Transparency can be forced to false for 32-bit images and forced
// to true for 8/24-bit images. Do nothing if useTransparency is null.
if (useTransparency == Boolean.FALSE && oldTransparency != Transparency.OPAQUE) {
image = convertToOpaque(image);
} else if (useTransparency == Boolean.TRUE && oldTransparency == Transparency.OPAQUE) {
// Assume we only use images from 8/24-bit bitmaps here
image = convertToTransparent(image, transparentColor);
}
// We cache images separately because multiple keys/skins
// can point to the same image
map.put(imageKey, image);
return image;
|
int | getInt(java.lang.String key, int fallback)Get a named int value from the current style
return parseInt(getString(key), fallback);
|
synchronized java.awt.Insets | getMargin(java.lang.String key)Get a named Insets value from the current style
Insets insets = (Insets)map.get("Margin "+key);
if (insets == null) {
String str = getString(key);
if (str != null) {
StringTokenizer tok = new StringTokenizer(str, " \t,");
insets = new Insets(0, 0, 0, 0);
insets.left = parseInt(tok.nextToken(), 0);
insets.right = parseInt(tok.nextToken(), 0);
insets.top = parseInt(tok.nextToken(), 0);
insets.bottom = parseInt(tok.nextToken(), 0);
map.put("Margin "+key, insets);
}
}
return insets;
|
synchronized java.awt.Point | getPoint(java.lang.String key)Get a named Point (e.g. a location or an offset) value
from the current style
Point p = (Point)map.get("Point "+key);
if (p == null) {
String str = getString(key);
if (str != null) {
StringTokenizer tok = new StringTokenizer(str, " \t,");
p = new Point(parseInt(tok.nextToken(), 0),
parseInt(tok.nextToken(), 0));
map.put("Point "+key, p);
}
}
return p;
|
synchronized com.sun.java.swing.plaf.windows.XPStyle$Skin | getSkin(java.lang.String category)Get an XPStyle.Skin object from the current style
for a named category (component type)
Skin skin = (Skin)map.get("Skin "+category);
if (skin == null) {
skin = new Skin(category);
map.put("Skin "+category, skin);
}
return skin;
|
private static java.lang.String | getString(java.lang.String key)Get a named String value from the current style
// Example: getString("a.b(c).d") => return getString("a.b", "c", "d");
String category = "";
String state = "";
String attributeKey = key;
int i = key.lastIndexOf('.");
if (i > 0 && key.length() > i+1) {
category = key.substring(0, i);
attributeKey = key.substring(i+1);
i = category.lastIndexOf('(");
if (i > 0) {
int i2 = category.indexOf(')", i);
if (i2 == category.length() - 1) {
state = category.substring(i+1, i2);
category = category.substring(0, i);
}
}
}
return getString(category, state, attributeKey);
|
static java.lang.String | getString(java.lang.String category, java.lang.String state, java.lang.String attributeKey)Get a named String value from the current style
Toolkit toolkit = Toolkit.getDefaultToolkit();
Map resources = (Map)toolkit.getDesktopProperty("win.xpstyle.resources.strings");
String value;
if (category == null || category.length() == 0) {
value = (String)resources.get(attributeKey);
} else {
if (state == null || state.length() == 0) {
value = (String)resources.get(category + "." + attributeKey);
} else {
value = (String)resources.get(category + "(" + state + ")." + attributeKey);
}
}
if (value == null) {
// Look for inheritance. For example, the attributeKey "transparent" in
// category "window.closebutton" can be inherited from category "window".
int i = category.lastIndexOf('.");
if (i > 0) {
value = getString(category.substring(0, i), state, attributeKey);
}
}
if (value == null && state != null && state.length() > 0) {
// Try again without a state specified
value = getString(category, "", attributeKey);
}
return value;
|
static synchronized com.sun.java.swing.plaf.windows.XPStyle | getXP()Get the singleton instance of this class
if (themeActive == null) {
Toolkit toolkit = Toolkit.getDefaultToolkit();
themeActive = (Boolean)toolkit.getDesktopProperty("win.xpstyle.themeActive");
if (themeActive == null) {
themeActive = Boolean.FALSE;
}
if (themeActive.booleanValue() &&
AccessController.doPrivileged(new GetPropertyAction("swing.noxp")) == null &&
!(UIManager.getLookAndFeel() instanceof WindowsClassicLookAndFeel)) {
xp = new XPStyle();
}
}
return xp;
|
static synchronized void | invalidateStyle()Static method for clearing the hashmap and loading the
current XP style and theme
invalidateStyle();
xp = null;
themeActive = null;
|
private int | parseInt(java.lang.String str, int fallback)
if (str != null) {
try {
return Integer.parseInt(str);
} catch (NumberFormatException nfe) {
abandonXP();
}
}
return fallback;
|