* Initialise style handlers.
*/
protected void initialiseStyleHandlers() {
// Initialise style value handlers.
colorValueHandler = new ColorHandler();
colorHandler = new ValueHandlerToPropertyAdapter(
StylePropertyDetails.COLOR, colorValueHandler);
backgroundColorHandler = new ValueHandlerToPropertyAdapter(
StylePropertyDetails.BACKGROUND_COLOR, colorValueHandler);
backgroundComponentHandler = new BackgroundComponentHandler(
context.getPolicyReferenceResolver(), context.getAssetResolver(),
context.getTranscodableUrlResolver());
// todo The instance created here is exactly the same as the one created in the BackgroundComponentHandler so reuse it.
// This may not be sensible if there are issues with sharing code with state in it.
mcsImageHandler = new ValueHandlerToPropertyAdapter(
StylePropertyDetails.MCS_IMAGE,
new BackgroundImageHandler(context.getPolicyReferenceResolver(),
context.getAssetResolver(),
context.getTranscodableUrlResolver()));
// A border should only be rendered if the border style is not none
// and the border width is valid.
final ChoicePropertyHandler borderWidthHandler =
new ChoicePropertyHandler();
borderWidthHandler.addHandlers(PropertyGroups.BORDER_WIDTH_PROPERTIES,
new PositivePixelLengthHandler());
final ChoicePropertyHandler borderStyleHandler =
new ChoicePropertyHandler();
borderStyleHandler.addHandlers(PropertyGroups.BORDER_STYLE_PROPERTIES,
new ValueRendererChecker() {
public void visit(StyleKeyword value,
Object object) {
if (value != BorderStyleKeywords.NONE) {
string = "true";
}
}
});
borderHandler = new AbstractPropertyHandler() {
public boolean isSignificant(PropertyValues propertyValues) {
return borderStyleHandler.isSignificant(propertyValues) &&
borderWidthHandler.isSignificant(propertyValues);
}
public String getAsString(MutablePropertyValues propertyValues) {
return borderStyleHandler.isSignificant(propertyValues) ?
borderWidthHandler.getAsString(propertyValues) : null;
}
};
if (context.getDeviceName().endsWith("Netscape4")) {
borderHandler = new DefaultingPropertyHandler(borderHandler, "0");
}
borderSpacingHandler = new AverageBorderSpacingRenderer();
marginEdgeHandler = new PositivePixelLengthHandler();
marginTopHandler =
new ValueHandlerToPropertyAdapter(StylePropertyDetails.MARGIN_TOP,
marginEdgeHandler);
ChoicePropertyHandler choicePropertyHandler =
new ChoicePropertyHandler();
choicePropertyHandler.addHandlers(