Search in sources :

Example 1 with AbstractPrimitiveItem

use of org.kie.workbench.common.stunner.lienzo.toolbox.items.AbstractPrimitiveItem 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

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