String widgetVar = cropper.resolveWidgetVar();
String clientId = cropper.getClientId(context);
String image = clientId + "_image";
String select = null;
WidgetBuilder wb = getWidgetBuilder(context);
wb.initWithComponentLoad("ImageCropper", widgetVar, clientId, clientId + "_image", "imagecropper")
.attr("image", image);
if(cropper.getMinSize() != null)
wb.append(",minSize:[").append(cropper.getMinSize()).append("]");
if(cropper.getMaxSize() != null)
wb.append(",maxSize:[").append(cropper.getMaxSize()).append("]");
wb.attr("bgColor", cropper.getBackgroundColor(), null)
.attr("bgOpacity", cropper.getBackgroundOpacity(), 0.6)
.attr("aspectRatio", cropper.getAspectRatio(), Double.MIN_VALUE);
if(cropper.getValue() != null) {
CroppedImage croppedImage = (CroppedImage) cropper.getValue();
int x = croppedImage.getLeft();
int y = croppedImage.getTop();
int x2 = x + croppedImage.getWidth();
int y2 = y + croppedImage.getHeight();
select = "[" + x + "," + y + "," + x2 + "," + y2 + "]";
}
else if(cropper.getInitialCoords() != null) {
select = "[" + cropper.getInitialCoords() + "]";
}
wb.append(",setSelect:").append(select);
wb.finish();
}