in kit/src/main/java/com/oracle/javafx/scenebuilder/kit/editor/panel/css/CssValueConverter.java [537:603]
private static String backgroundImageToString(String property, BackgroundImage bi) {
if (property == null) {
return bi.toString();
}
StringBuilder builder = new StringBuilder();
if (property.equals("-fx-background-image")) { //NOI18N
Image p = bi.getImage();
builder.append(p.getUrl());
} else {
if (property.equals("-fx-background-position")) { //NOI18N
double left = 0, right = 0, top = 0, bottom = 0;
if (bi.getPosition().getHorizontalSide() == Side.LEFT) {
left = bi.getPosition().getHorizontalPosition();
} else {
right = bi.getPosition().getHorizontalPosition();
}
if (bi.getPosition().getVerticalSide() == Side.TOP) {
top = bi.getPosition().getVerticalPosition();
} else {
bottom = bi.getPosition().getVerticalPosition();
}
builder.append("left:"); //NOI18N
builder.append(EditorUtils.valAsStr(left));
builder.append(" right:"); //NOI18N
builder.append(EditorUtils.valAsStr(right));
builder.append(" top:"); //NOI18N
builder.append(EditorUtils.valAsStr(top));
builder.append(" bottom:"); //NOI18N
builder.append(EditorUtils.valAsStr(bottom));
} else {
if (property.equals("-fx-background-repeat")) { //NOI18N
if (bi.getRepeatX() != null) {
builder.append(bi.getRepeatX().toString());
} else {
if (bi.getRepeatY() != null) {
builder.append(bi.getRepeatY().toString());
} else {
builder.append("unknown repeat"); //NOI18N
}
}
} else {
if (property.equals("-fx-background-size")) { //NOI18N
BackgroundSize bs = bi.getSize();
if (bs.isContain()) {
builder.append("contain"); //NOI18N
} else {
if (bs.isCover()) {
builder.append("cover"); //NOI18N
} else {
if (bs.getWidth() == BackgroundSize.AUTO) {
builder.append("width: auto"); //NOI18N
} else {
builder.append("width: ").append(EditorUtils.valAsStr(bs.getWidth())); //NOI18N
}
if (bs.getHeight() == BackgroundSize.AUTO) {
builder.append("height: auto"); //NOI18N
} else {
builder.append("height: ").append(EditorUtils.valAsStr(bs.getHeight())); //NOI18N
}
}
}
}
}
}
}
return builder.toString();
}