Search in sources :

Example 1 with Decorator

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;
}
Also used : Decorator(org.kie.workbench.common.stunner.lienzo.Decorator) Iterator(java.util.Iterator) IPrimitive(com.ait.lienzo.client.core.shape.IPrimitive) HandlerRegistrationManager(com.ait.tooling.nativetools.client.event.HandlerRegistrationManager) ItemCallback(org.kie.workbench.common.stunner.lienzo.Decorator.ItemCallback) Group(com.ait.lienzo.client.core.shape.Group) Grid(org.kie.workbench.common.stunner.lienzo.grid.Grid) Decorator(org.kie.workbench.common.stunner.lienzo.Decorator) Grid(org.kie.workbench.common.stunner.lienzo.grid.Grid)

Aggregations

Group (com.ait.lienzo.client.core.shape.Group)1 IPrimitive (com.ait.lienzo.client.core.shape.IPrimitive)1 HandlerRegistrationManager (com.ait.tooling.nativetools.client.event.HandlerRegistrationManager)1 Iterator (java.util.Iterator)1 Decorator (org.kie.workbench.common.stunner.lienzo.Decorator)1 ItemCallback (org.kie.workbench.common.stunner.lienzo.Decorator.ItemCallback)1 Grid (org.kie.workbench.common.stunner.lienzo.grid.Grid)1