@Override
public String createAssignment(TreeLogger logger, ResourceContext context, JMethod method)
throws UnableToCompleteException {
String name = method.getName();
SourceWriter sw = new StringSourceWriter();
sw.println("new " + ImageResourcePrototype.class.getName() + "(");
sw.indent();
sw.println('"' + name + "\",");
ImageResourceDeclaration image = new ImageResourceDeclaration(method);
DisplayedImage bundle = getImage(image);
ImageRect rect = bundle.getImageRect(image);
assert rect != null : "No ImageRect ever computed for " + name;
String[] urlExpressions =
new String[] {bundle.getNormalContentsFieldName(), bundle.getRtlContentsFieldName()};
assert urlExpressions[0] != null : "No primary URL expression for " + name;
if (urlExpressions[1] == null) {
sw.println(UriUtils.class.getName() + ".fromTrustedString(" + urlExpressions[0] + "),");
} else {
sw.println(UriUtils.class.getName() + ".fromTrustedString("
+ "com.google.gwt.i18n.client.LocaleInfo.getCurrentLocale().isRTL() ?"
+ urlExpressions[1] + " : " + urlExpressions[0] + "),");
}
sw.println(rect.getLeft() + ", " + rect.getTop() + ", " + rect.getWidth() + ", "
+ rect.getHeight() + ", " + rect.isAnimated() + ", " + rect.isLossy());
sw.outdent();
sw.print(")");
return sw.toString();
}