Search in sources :

Example 1 with AbstractDecoratedItem

use of org.kie.workbench.common.stunner.lienzo.toolbox.items.AbstractDecoratedItem in project kie-wb-common by kiegroup.

the class ButtonGridItemImpl method add.

@Override
public ButtonGridItemImpl add(final DecoratedItem... items) {
    toolbox.add(items);
    for (final DecoratedItem item : items) {
        try {
            final AbstractDecoratedItem primitiveItem = (AbstractDecoratedItem) item;
            registerItemFocusHandler(primitiveItem, itemFocusCallback);
            registerItemUnFocusHandler(primitiveItem, itemUnFocusCallback);
        } catch (final ClassCastException e) {
            throw new UnsupportedOperationException("The button only supports subtypes " + "of " + AbstractDecoratedItem.class.getName());
        }
    }
    return this;
}
Also used : AbstractDecoratedItem(org.kie.workbench.common.stunner.lienzo.toolbox.items.AbstractDecoratedItem) DecoratedItem(org.kie.workbench.common.stunner.lienzo.toolbox.items.DecoratedItem) AbstractDecoratedItem(org.kie.workbench.common.stunner.lienzo.toolbox.items.AbstractDecoratedItem)

Example 2 with AbstractDecoratedItem

use of org.kie.workbench.common.stunner.lienzo.toolbox.items.AbstractDecoratedItem in project kie-wb-common by kiegroup.

the class ItemGridImpl method repositionItems.

private ItemGridImpl repositionItems() {
    final Iterator<Point2D> gridIterator = grid.iterator();
    for (final AbstractDecoratedItem button : items) {
        final Point2D point = gridIterator.next();
        button.asPrimitive().setLocation(point);
    }
    fireRefresh();
    return this;
}
Also used : AbstractDecoratedItem(org.kie.workbench.common.stunner.lienzo.toolbox.items.AbstractDecoratedItem) Point2D(com.ait.lienzo.client.core.types.Point2D)

Example 3 with AbstractDecoratedItem

use of org.kie.workbench.common.stunner.lienzo.toolbox.items.AbstractDecoratedItem in project kie-wb-common by kiegroup.

the class ItemGridImpl method itemsUpdated.

private ItemGridImpl itemsUpdated() {
    // Reposition items as for the given grid.
    repositionItems();
    // Calculate BB.
    double maxw = 0;
    double maxh = 0;
    for (final AbstractDecoratedItem item : items) {
        final Point2D location = item.asPrimitive().getLocation();
        final BoundingBox itemBB = (BoundingBox) item.getBoundingBox().get();
        final double itemw = itemBB.getWidth() + location.getX();
        final double itemh = itemBB.getHeight() + location.getY();
        if (itemw > maxw) {
            maxw = itemw;
        }
        if (itemh > maxh) {
            maxh = itemh;
        }
    }
    boundingBox = new BoundingBox(0, 0, maxw, maxh);
    // Update decorator.
    if (null != getWrapped().getDecorator()) {
        getWrapped().getDecorator().setBoundingBox(getBoundingBox().get());
        if (getWrapped().getDecorator() instanceof AbstractPrimitiveItem) {
            ((AbstractPrimitiveItem) getWrapped().getDecorator()).asPrimitive().moveToBottom();
        }
    }
    return this;
}
Also used : AbstractPrimitiveItem(org.kie.workbench.common.stunner.lienzo.toolbox.items.AbstractPrimitiveItem) AbstractDecoratedItem(org.kie.workbench.common.stunner.lienzo.toolbox.items.AbstractDecoratedItem) Point2D(com.ait.lienzo.client.core.types.Point2D) BoundingBox(com.ait.lienzo.client.core.types.BoundingBox)

Aggregations

AbstractDecoratedItem (org.kie.workbench.common.stunner.lienzo.toolbox.items.AbstractDecoratedItem)3 Point2D (com.ait.lienzo.client.core.types.Point2D)2 BoundingBox (com.ait.lienzo.client.core.types.BoundingBox)1 AbstractPrimitiveItem (org.kie.workbench.common.stunner.lienzo.toolbox.items.AbstractPrimitiveItem)1 DecoratedItem (org.kie.workbench.common.stunner.lienzo.toolbox.items.DecoratedItem)1