package xyz.svgdemo.client;
import org.vectomatic.dom.svg.ui.SVGImage;
import org.vectomatic.dom.svg.ui.SVGResource;
import com.google.gwt.cell.client.AbstractCell;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.cellview.client.Column;
import com.google.gwt.user.cellview.client.DataGrid;
import com.google.gwt.view.client.ListDataProvider;
public class SVGDatagrid extends DataGrid<String> {
private SVGResource svgResource;
private class SVGCell extends AbstractCell<String> {
@Override
public void render(Context context, String value, SafeHtmlBuilder sb) {
SVGImage svgImage = new SVGImage(svgResource);
sb.appendHtmlConstant(svgImage.toString());
}
}
public SVGDatagrid(SVGResource svgResource) {
this.svgResource = svgResource;
setWidth("400px");
setHeight("300px");
Column<String, String> columnSVG = new Column<String, String>(
new SVGCell()) {
@Override
public String getValue(String object) {
return object;
}
};
addColumn(columnSVG, "svg");
ListDataProvider<String> dataProvider = new ListDataProvider<String>();
dataProvider.getList().add("dummy");
dataProvider.addDataDisplay(this);
}
}