public void run() {
DataTable data = createDailyActivities();
IntensityMap.Options options = IntensityMap.Options.create();
options.setWidth(400);
options.setHeight(240);
final IntensityMap viz = new IntensityMap(data, options);
// Add a selection handler
viz.addSelectHandler(new SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
assertNotNull(event);
JsArray<Selection> s = viz.getSelections();
assertEquals("Expected 1 element in the selection", 1,
s.length());
assertEquals("Expected column 0 to be selected", 0, s.get(0).getColumn());
finishTest();
}
});
RootPanel.get().add(viz);
JsArray<Selection> s =
ArrayHelper.toJsArray(Selection.createColumnSelection(0));
assertEquals("Expected 1 element in the selection", 1, s.length());
assertEquals("Expected column 0 to be selected", 0, s.get(0).getColumn());
viz.setSelections(s);
s = viz.getSelections();
assertEquals("Expected 1 element in the selection", 1, s.length());
assertEquals("Expected column 0 to be selected", 0, s.get(0).getColumn());
// Trigger a selection callback
triggerSelection(viz, s);
}