use of org.kie.workbench.common.stunner.core.client.shape.factory.ShapeFactory 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 = LienzoUtils.getScaleFactor(bb.getWidth(), bb.getHeight(), width, height);
group.setScale(scale[0], scale[1]);
return group;
}
use of org.kie.workbench.common.stunner.core.client.shape.factory.ShapeFactory in project kie-wb-common by kiegroup.
the class SessionPreviewCanvasHandlerProxyTest method checkRegisterDelegatesToWrapped.
@Test
@SuppressWarnings("unchecked")
public void checkRegisterDelegatesToWrapped() {
final Shape shape = mock(Shape.class);
final Element candidate = mock(Element.class);
final boolean fireEvents = true;
proxy.register(shape, candidate, fireEvents);
verify(wrapped).register(eq(shape), eq(candidate), eq(fireEvents));
final String shapeSetId = "ShapeSetId";
proxy.register(shapeSetId, candidate);
verify(wrapped).register(eq(shapeSetId), eq(candidate));
final ShapeFactory factory = mock(ShapeFactory.class);
proxy.register(factory, candidate, fireEvents);
verify(wrapped).register(eq(factory), eq(candidate), eq(fireEvents));
}
Aggregations