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;
}
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;
}
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;
}
Aggregations