use of org.kie.workbench.common.stunner.lienzo.Decorator in project kie-wb-common by kiegroup.
the class AbstractPalette method build.
public T build(final Item... items) {
clear();
this.add(itemsGroup);
beforeBuild();
final Grid grid = createGrid(items.length);
final Iterator<Grid.Point> pointIterator = grid.iterator();
for (int c = 0; c < items.length; c++) {
final Grid.Point point = pointIterator.next();
final Item item = items[c];
final int index = c;
final double px = x + point.getX();
final double py = y + point.getY();
final Decorator itemDecorator = item.getDecorator() != null ? createDecorator(index, px, py) : null;
final IPrimitive<?> i = null != itemDecorator ? itemDecorator.build(item.getPrimitive(), toDouble(iconSize), toDouble(iconSize)) : item.getPrimitive();
i.setX(px).setY(py).moveToTop();
this.itemsGroup.add(i);
handlerRegistrationManager.register(i.addNodeMouseDownHandler(event -> onItemMouseDown(index, event.getX(), event.getY(), px, py)));
handlerRegistrationManager.register(i.addNodeMouseClickHandler(event -> onItemClick(index, event.getX(), event.getY(), px, py)));
}
afterBuild();
return (T) this;
}
Aggregations