if (style == null)
{
throw new NullPointerException();
}
final AttributeList bandStyleAtts = new AttributeList();
if (style.isLocalKey(ElementStyleKeys.BACKGROUND_COLOR))
{
final Color value = (Color) style.getStyleProperty(ElementStyleKeys.BACKGROUND_COLOR);
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "background-color", ColorValueConverter.colorToString(
value));
}
if (style.isLocalKey(ElementStyleKeys.PADDING_TOP) &&
style.isLocalKey(ElementStyleKeys.PADDING_LEFT) &&
style.isLocalKey(ElementStyleKeys.PADDING_BOTTOM) &&
style.isLocalKey(ElementStyleKeys.PADDING_RIGHT))
{
final double paddingTop = style.getDoubleStyleProperty(ElementStyleKeys.PADDING_TOP, 0);
final double paddingLeft = style.getDoubleStyleProperty(ElementStyleKeys.PADDING_LEFT, 0);
final double paddingBottom = style.getDoubleStyleProperty(ElementStyleKeys.PADDING_BOTTOM, 0);
final double paddingRight = style.getDoubleStyleProperty(ElementStyleKeys.PADDING_RIGHT, 0);
if (paddingTop == paddingLeft &&
paddingTop == paddingRight &&
paddingTop == paddingBottom)
{
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "padding", absoluteLengthFormat.format(paddingTop));
}
else
{
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "padding-top", absoluteLengthFormat.format(paddingTop));
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "padding-left", absoluteLengthFormat.format(paddingLeft));
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "padding-bottom", absoluteLengthFormat.format(
paddingBottom));
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "padding-right", absoluteLengthFormat.format(paddingRight));
}
}
else
{
if (style.isLocalKey(ElementStyleKeys.PADDING_TOP))
{
final double value = style.getDoubleStyleProperty(ElementStyleKeys.PADDING_TOP, 0);
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "padding-top", absoluteLengthFormat.format(value));
}
if (style.isLocalKey(ElementStyleKeys.PADDING_LEFT))
{
final double value = style.getDoubleStyleProperty(ElementStyleKeys.PADDING_LEFT, 0);
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "padding-left", absoluteLengthFormat.format(value));
}
if (style.isLocalKey(ElementStyleKeys.PADDING_BOTTOM))
{
final double value = style.getDoubleStyleProperty(ElementStyleKeys.PADDING_BOTTOM, 0);
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "padding-bottom", absoluteLengthFormat.format(value));
}
if (style.isLocalKey(ElementStyleKeys.PADDING_RIGHT))
{
final double value = style.getDoubleStyleProperty(ElementStyleKeys.PADDING_RIGHT, 0);
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "padding-right", absoluteLengthFormat.format(value));
}
}
if (style.isLocalKey(ElementStyleKeys.BORDER_TOP_WIDTH) &&
style.isLocalKey(ElementStyleKeys.BORDER_LEFT_WIDTH) &&
style.isLocalKey(ElementStyleKeys.BORDER_BOTTOM_WIDTH) &&
style.isLocalKey(ElementStyleKeys.BORDER_RIGHT_WIDTH))
{
final double top = style.getDoubleStyleProperty(ElementStyleKeys.BORDER_TOP_WIDTH, 0);
final double left = style.getDoubleStyleProperty(ElementStyleKeys.BORDER_LEFT_WIDTH, 0);
final double bottom = style.getDoubleStyleProperty(ElementStyleKeys.BORDER_BOTTOM_WIDTH, 0);
final double right = style.getDoubleStyleProperty(ElementStyleKeys.BORDER_RIGHT_WIDTH, 0);
if (top == left &&
top == right &&
top == bottom)
{
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-width", absoluteLengthFormat.format(top));
}
else
{
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-top-width", absoluteLengthFormat.format(top));
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-left-width", absoluteLengthFormat.format(left));
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-bottom-width", absoluteLengthFormat.format(bottom));
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-right-width", absoluteLengthFormat.format(right));
}
}
else
{
if (style.isLocalKey(ElementStyleKeys.BORDER_TOP_WIDTH))
{
final double value = style.getDoubleStyleProperty(ElementStyleKeys.BORDER_TOP_WIDTH, 0);
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-top-width", absoluteLengthFormat.format(value));
}
if (style.isLocalKey(ElementStyleKeys.BORDER_LEFT_WIDTH))
{
final double value = style.getDoubleStyleProperty(ElementStyleKeys.BORDER_LEFT_WIDTH, 0);
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-left-width", absoluteLengthFormat.format(value));
}
if (style.isLocalKey(ElementStyleKeys.BORDER_BOTTOM_WIDTH))
{
final double value = style.getDoubleStyleProperty(ElementStyleKeys.BORDER_BOTTOM_WIDTH, 0);
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-bottom-width", absoluteLengthFormat.format(value));
}
if (style.isLocalKey(ElementStyleKeys.BORDER_RIGHT_WIDTH))
{
final double value = style.getDoubleStyleProperty(ElementStyleKeys.BORDER_RIGHT_WIDTH, 0);
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-right-width", absoluteLengthFormat.format(value));
}
}
if (style.isLocalKey(ElementStyleKeys.BORDER_BREAK_WIDTH))
{
final double value = style.getDoubleStyleProperty(ElementStyleKeys.BORDER_BREAK_WIDTH, 0);
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-break-width", absoluteLengthFormat.format(value));
}
if (style.isLocalKey(ElementStyleKeys.BORDER_TOP_COLOR) &&
style.isLocalKey(ElementStyleKeys.BORDER_LEFT_COLOR) &&
style.isLocalKey(ElementStyleKeys.BORDER_BOTTOM_COLOR) &&
style.isLocalKey(ElementStyleKeys.BORDER_RIGHT_COLOR))
{
final Color top = (Color) style.getStyleProperty(ElementStyleKeys.BORDER_TOP_COLOR);
final Color left = (Color) style.getStyleProperty(ElementStyleKeys.BORDER_LEFT_COLOR);
final Color bottom = (Color) style.getStyleProperty(ElementStyleKeys.BORDER_BOTTOM_COLOR);
final Color right = (Color) style.getStyleProperty(ElementStyleKeys.BORDER_RIGHT_COLOR);
if (ObjectUtilities.equal(top, left) &&
ObjectUtilities.equal(top, right) &&
ObjectUtilities.equal(top, bottom))
{
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-color", ColorValueConverter.colorToString(top));
}
else
{
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-top-color", ColorValueConverter.colorToString(
top));
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-left-color", ColorValueConverter.colorToString(
left));
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-bottom-color", ColorValueConverter.colorToString(
bottom));
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-right-color", ColorValueConverter.colorToString(
right));
}
}
else
{
if (style.isLocalKey(ElementStyleKeys.BORDER_TOP_COLOR))
{
final Color value = (Color) style.getStyleProperty(ElementStyleKeys.BORDER_TOP_COLOR);
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-top-color", ColorValueConverter.colorToString(
value));
}
if (style.isLocalKey(ElementStyleKeys.BORDER_LEFT_COLOR))
{
final Color value = (Color) style.getStyleProperty(ElementStyleKeys.BORDER_LEFT_COLOR);
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-left-color", ColorValueConverter.colorToString(
value));
}
if (style.isLocalKey(ElementStyleKeys.BORDER_BOTTOM_COLOR))
{
final Color value = (Color) style.getStyleProperty(ElementStyleKeys.BORDER_BOTTOM_COLOR);
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-bottom-color", ColorValueConverter.colorToString(
value));
}
if (style.isLocalKey(ElementStyleKeys.BORDER_RIGHT_COLOR))
{
final Color value = (Color) style.getStyleProperty(ElementStyleKeys.BORDER_RIGHT_COLOR);
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-right-color", ColorValueConverter.colorToString(
value));
}
}
if (style.isLocalKey(ElementStyleKeys.BORDER_BREAK_COLOR))
{
final Color value = (Color) style.getStyleProperty(ElementStyleKeys.BORDER_BREAK_COLOR);
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-break-color", ColorValueConverter.colorToString(
value));
}
if (style.isLocalKey(ElementStyleKeys.BORDER_TOP_STYLE) &&
style.isLocalKey(ElementStyleKeys.BORDER_LEFT_STYLE) &&
style.isLocalKey(ElementStyleKeys.BORDER_BOTTOM_STYLE) &&
style.isLocalKey(ElementStyleKeys.BORDER_RIGHT_STYLE))
{
final Object top = style.getStyleProperty(ElementStyleKeys.BORDER_TOP_STYLE);
final Object left = style.getStyleProperty(ElementStyleKeys.BORDER_LEFT_STYLE);
final Object bottom = style.getStyleProperty(ElementStyleKeys.BORDER_BOTTOM_STYLE);
final Object right = style.getStyleProperty(ElementStyleKeys.BORDER_RIGHT_STYLE);
if (ObjectUtilities.equal(top, left) &&
ObjectUtilities.equal(top, right) &&
ObjectUtilities.equal(top, bottom))
{
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-style", top.toString());
}
else
{
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-top-style", top.toString());
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-left-style", left.toString());
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-bottom-style", bottom.toString());
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-right-style", right.toString());
}
}
else
{
if (style.isLocalKey(ElementStyleKeys.BORDER_TOP_STYLE))
{
final Object value = style.getStyleProperty(ElementStyleKeys.BORDER_TOP_STYLE);
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-top-style", value.toString());
}
if (style.isLocalKey(ElementStyleKeys.BORDER_LEFT_STYLE))
{
final Object value = style.getStyleProperty(ElementStyleKeys.BORDER_LEFT_STYLE);
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-left-style", value.toString());
}
if (style.isLocalKey(ElementStyleKeys.BORDER_BOTTOM_STYLE))
{
final Object value = style.getStyleProperty(ElementStyleKeys.BORDER_BOTTOM_STYLE);
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-bottom-style", value.toString());
}
if (style.isLocalKey(ElementStyleKeys.BORDER_RIGHT_STYLE))
{
final Object value = style.getStyleProperty(ElementStyleKeys.BORDER_RIGHT_STYLE);
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-right-style", value.toString());
}
}
if (style.isLocalKey(ElementStyleKeys.BORDER_BREAK_STYLE))
{
final Object value = style.getStyleProperty(ElementStyleKeys.BORDER_BREAK_STYLE);
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-break-style", value.toString());
}
if (style.isLocalKey(ElementStyleKeys.BORDER_BOTTOM_LEFT_RADIUS_WIDTH) &&
style.isLocalKey(ElementStyleKeys.BORDER_BOTTOM_RIGHT_RADIUS_WIDTH) &&
style.isLocalKey(ElementStyleKeys.BORDER_TOP_LEFT_RADIUS_WIDTH) &&
style.isLocalKey(ElementStyleKeys.BORDER_TOP_RIGHT_RADIUS_WIDTH))
{
final double bottomLeft = style.getDoubleStyleProperty(ElementStyleKeys.BORDER_BOTTOM_LEFT_RADIUS_WIDTH, 0);
final double bottomRight = style.getDoubleStyleProperty(ElementStyleKeys.BORDER_BOTTOM_RIGHT_RADIUS_WIDTH, 0);
final double topLeft = style.getDoubleStyleProperty(ElementStyleKeys.BORDER_TOP_LEFT_RADIUS_WIDTH, 0);
final double topRight = style.getDoubleStyleProperty(ElementStyleKeys.BORDER_TOP_RIGHT_RADIUS_WIDTH, 0);
if (bottomLeft == bottomRight &&
bottomLeft == topRight &&
bottomLeft == topLeft)
{
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-radius-width", absoluteLengthFormat.format(
bottomLeft));
}
else
{
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-top-left-radius-width", absoluteLengthFormat.format(
topLeft));
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-top-right-radius-width", absoluteLengthFormat.format(
topRight));
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-bottom-left-radius-width",
absoluteLengthFormat.format(bottomLeft));
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-bottom-right-radius-width",
absoluteLengthFormat.format(bottomRight));
}
}
else
{
if (style.isLocalKey(ElementStyleKeys.BORDER_TOP_LEFT_RADIUS_WIDTH))
{
final double value = style.getDoubleStyleProperty(ElementStyleKeys.BORDER_TOP_LEFT_RADIUS_WIDTH, 0);
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-top-left-width", absoluteLengthFormat.format(value));
}
if (style.isLocalKey(ElementStyleKeys.BORDER_TOP_RIGHT_RADIUS_WIDTH))
{
final double value = style.getDoubleStyleProperty(ElementStyleKeys.BORDER_TOP_RIGHT_RADIUS_WIDTH, 0);
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-top-right-width", absoluteLengthFormat.format(
value));
}
if (style.isLocalKey(ElementStyleKeys.BORDER_BOTTOM_LEFT_RADIUS_WIDTH))
{
final double value = style.getDoubleStyleProperty(ElementStyleKeys.BORDER_BOTTOM_LEFT_RADIUS_WIDTH, 0);
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-bottom-left-width", absoluteLengthFormat.format(
value));
}
if (style.isLocalKey(ElementStyleKeys.BORDER_BOTTOM_RIGHT_RADIUS_WIDTH))
{
final double value = style.getDoubleStyleProperty(ElementStyleKeys.BORDER_BOTTOM_RIGHT_RADIUS_WIDTH, 0);
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-bottom-right-width", absoluteLengthFormat.format(
value));
}
}
if (style.isLocalKey(ElementStyleKeys.BORDER_BOTTOM_LEFT_RADIUS_HEIGHT) &&
style.isLocalKey(ElementStyleKeys.BORDER_BOTTOM_RIGHT_RADIUS_HEIGHT) &&
style.isLocalKey(ElementStyleKeys.BORDER_TOP_LEFT_RADIUS_HEIGHT) &&
style.isLocalKey(ElementStyleKeys.BORDER_TOP_RIGHT_RADIUS_HEIGHT))
{
final double bottomLeft = style.getDoubleStyleProperty(ElementStyleKeys.BORDER_BOTTOM_LEFT_RADIUS_HEIGHT, 0);
final double bottomRight = style.getDoubleStyleProperty(ElementStyleKeys.BORDER_BOTTOM_RIGHT_RADIUS_HEIGHT, 0);
final double topLeft = style.getDoubleStyleProperty(ElementStyleKeys.BORDER_TOP_LEFT_RADIUS_HEIGHT, 0);
final double topRight = style.getDoubleStyleProperty(ElementStyleKeys.BORDER_TOP_RIGHT_RADIUS_HEIGHT, 0);
if (bottomLeft == bottomRight &&
bottomLeft == topRight &&
bottomLeft == topLeft)
{
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-radius-height", absoluteLengthFormat.format(
bottomLeft));
}
else
{
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-top-left-radius-height", absoluteLengthFormat.format(
topLeft));
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-top-right-radius-height",
absoluteLengthFormat.format(topRight));
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-bottom-left-radius-height",
absoluteLengthFormat.format(bottomLeft));
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-bottom-right-radius-height",
absoluteLengthFormat.format(bottomRight));
}
}
else
{
if (style.isLocalKey(ElementStyleKeys.BORDER_TOP_LEFT_RADIUS_HEIGHT))
{
final double value = style.getDoubleStyleProperty(ElementStyleKeys.BORDER_TOP_LEFT_RADIUS_HEIGHT, 0);
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-top-left-height", absoluteLengthFormat.format(
value));
}
if (style.isLocalKey(ElementStyleKeys.BORDER_TOP_RIGHT_RADIUS_HEIGHT))
{
final double value = style.getDoubleStyleProperty(ElementStyleKeys.BORDER_TOP_RIGHT_RADIUS_HEIGHT, 0);
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-top-right-height", absoluteLengthFormat.format(
value));
}
if (style.isLocalKey(ElementStyleKeys.BORDER_BOTTOM_LEFT_RADIUS_HEIGHT))
{
final double value = style.getDoubleStyleProperty(ElementStyleKeys.BORDER_BOTTOM_LEFT_RADIUS_HEIGHT, 0);
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-bottom-left-height", absoluteLengthFormat.format(
value));
}
if (style.isLocalKey(ElementStyleKeys.BORDER_BOTTOM_RIGHT_RADIUS_HEIGHT))
{
final double value = style.getDoubleStyleProperty(ElementStyleKeys.BORDER_BOTTOM_RIGHT_RADIUS_HEIGHT, 0);
bandStyleAtts.setAttribute(BundleNamespaces.STYLE, "border-bottom-right-height", absoluteLengthFormat.format(
value));
}
}
if (bandStyleAtts.isEmpty() == false)
{
writer.writeTag(BundleNamespaces.STYLE, "border-styles", bandStyleAtts, XmlWriterSupport.CLOSE);
}
}