public void addToChain(String key,
HashMap prop) {
// adjust the font size
String value = (String) prop.get(ElementTags.SIZE);
if (value != null) {
if (value.endsWith("px")) {
prop.put(ElementTags.SIZE, value.substring(0,
value.length() - 2));
} else {
int s = 0;
if (value.startsWith("+") || value.startsWith("-")) {
String old = getProperty("basefontsize");
if (old == null)
old = "12";
float f = Float.parseFloat(old);
int c = (int) f;
for (int k = fontSizes.length - 1; k >= 0; --k) {
if (c >= fontSizes[k]) {
s = k;
break;
}
}
int inc = Integer.parseInt(value.startsWith("+") ? value
.substring(1) : value);
s += inc;
} else {
try {
s = Integer.parseInt(value) - 1;
} catch (NumberFormatException nfe) {
s = 0;
}
}
if (s < 0)
s = 0;
else if (s >= fontSizes.length)
s = fontSizes.length - 1;
prop.put(ElementTags.SIZE, Integer.toString(fontSizes[s]));
}
}
chain.add(new Object[] { key, prop });
}
|