replacement.getSelectors().addAll(x.getSelectors());
List<CssProperty> properties = replacement.getProperties();
if (repeatStyle == RepeatStyle.None
|| repeatStyle == RepeatStyle.Horizontal) {
properties.add(new CssProperty("height", new ExpressionValue(instance
+ ".getHeight() + \"px\""), false));
}
if (repeatStyle == RepeatStyle.None || repeatStyle == RepeatStyle.Vertical) {
properties.add(new CssProperty("width", new ExpressionValue(instance
+ ".getWidth() + \"px\""), false));
}
properties.add(new CssProperty("overflow", new IdentValue("hidden"), false));
String repeatText;
switch (repeatStyle) {
case None:
repeatText = " no-repeat";
break;
case Horizontal:
repeatText = " repeat-x";
break;
case Vertical:
repeatText = " repeat-y";
break;
case Both:
repeatText = " repeat";
break;
default:
throw new RuntimeException("Unknown repeatStyle " + repeatStyle);
}
String backgroundExpression = "\"url(\\\"\" + " + instance
+ ".getSafeUri().asString() + \"\\\") -\" + " + instance + ".getLeft() + \"px -\" + "
+ instance + ".getTop() + \"px " + repeatText + "\"";
properties.add(new CssProperty("background", new ExpressionValue(
backgroundExpression), false));
// Retain any user-specified properties
properties.addAll(x.getProperties());