use of com.ait.lienzo.client.core.types.BoundingBox in project kie-wb-common by kiegroup.
the class WiresScalableContainer method scaleTo.
public void scaleTo(final double x, final double y, final double width, final double height) {
if (scaleRequired) {
if (null != transformableContainer) {
transformableContainer.setX(x).setY(y);
if (null == scaleRatio) {
final BoundingBox bb = transformableContainer.getBoundingBox();
final double sx = width / bb.getWidth();
final double sy = height / bb.getHeight();
scaleRatio = new Point2D(sx, sy);
transformableContainer.setScale(scaleRatio);
}
}
for (int i = 0; i < scalableChildren.size(); i++) {
final IPrimitive<?> child = scalableChildren.get(i);
scaleChildTo(child, x, y, width, height);
}
scaleRequired = false;
}
}
use of com.ait.lienzo.client.core.types.BoundingBox in project kie-wb-common by kiegroup.
the class LienzoShapeUtils method scale.
public static void scale(final Shape shape, final double width, final double height) {
final BoundingBox bb = shape.getBoundingBox();
final double[] scale = getScaleFactor(bb.getWidth(), bb.getHeight(), width, height);
shape.setScale(scale[0], scale[1]);
}
use of com.ait.lienzo.client.core.types.BoundingBox in project kie-wb-common by kiegroup.
the class LienzoShapeGlyphRenderer method render.
@Override
@SuppressWarnings("unchecked")
public Group render(final ShapeGlyph glyph, final double width, final double height) {
final String definitionId = glyph.getDefinitionId();
final Supplier<ShapeFactory> factorySupplier = glyph.getFactorySupplier();
final Shape shape = factorySupplier.get().newShape(factoryManager.newDefinition(definitionId));
final ShapeView<?> view = shape.getShapeView();
final BoundingBox bb = boundingBoxProvider.apply(view);
Group group = groupProvider.apply(view);
if (null == group) {
throw new RuntimeException("Shape view [" + view.toString() + "] not supported for " + "this shape glyph builder [" + this.getClass().getName());
}
if (view instanceof HasTitle) {
final HasTitle hasTitle = (HasTitle) view;
hasTitle.setTitle(null);
}
// Create a copy of this view.
group = group.copy();
// Scale, if necessary, to the given glyph size.
final double[] scale = LienzoShapeUtils.getScaleFactor(bb.getWidth(), bb.getHeight(), width, height);
group.setScale(scale[0], scale[1]);
return group;
}
use of com.ait.lienzo.client.core.types.BoundingBox in project kie-wb-common by kiegroup.
the class CustomTaskShapeViewHandlerTest method checkIconLoad.
private void checkIconLoad(final String IconData) {
when(imageProxy.isLoaded()).thenReturn(true);
when(icon.getBoundingBox()).thenReturn(new BoundingBox(0d, 0d, CustomTaskShapeViewHandler.WID_ICON_WIDTH * 2, CustomTaskShapeViewHandler.WID_ICON_HEIGHT * 2));
tested.handle(task, view);
ArgumentCaptor<ImageShapeLoadedHandler> loadedHandlerArgumentCaptor = ArgumentCaptor.forClass(ImageShapeLoadedHandler.class);
verify(imageProxy, times(1)).setImageShapeLoadedHandler(loadedHandlerArgumentCaptor.capture());
verify(imageProxy, times(1)).load(eq(IconData));
ImageShapeLoadedHandler loadedHandler = loadedHandlerArgumentCaptor.getValue();
loadedHandler.onImageShapeLoaded(icon);
verify(icon, times(1)).setScale(eq(0.5d), eq(0.5d));
verify(width, times(1)).setValue(WIDTH);
verify(height, times(1)).setValue(HEIGHT);
verify(view, never()).refresh();
}
Aggregations