use of com.ait.lienzo.client.core.types.BoundingBox in project kie-wb-common by kiegroup.
the class WiresShapeViewExt method setFillGradient.
@Override
@SuppressWarnings("unchecked")
public T setFillGradient(final Type type, final String startColor, final String endColor) {
this.fillGradientType = type;
this.fillGradientStartColor = startColor;
this.fillGradientEndColor = endColor;
if (null != getShape()) {
final BoundingBox bb = getShape().getBoundingBox();
final double width = bb.getWidth();
final double height = bb.getHeight();
updateFillGradient(width, height);
}
return cast();
}
use of com.ait.lienzo.client.core.types.BoundingBox in project kie-wb-common by kiegroup.
the class LocationControlImplTest method testMove.
@Test
@SuppressWarnings("unchecked")
public void testMove() throws Exception {
final WiresShapeView wiresShape = mock(WiresShapeView.class);
final WiresShapeView childWiresShape = mock(WiresShapeView.class);
final MagnetManager.Magnets magnets = mock(MagnetManager.Magnets.class);
final WiresMagnet magnet = mock(WiresMagnet.class);
final WiresConnection connection = mock(WiresConnection.class);
final NFastArrayList<WiresConnection> connections = new NFastArrayList<>(connection);
final WiresConnector connector = mock(WiresConnector.class);
final String connectorUUID = UUID.uuid();
final NFastArrayList<WiresShape> children = new NFastArrayList<>(childWiresShape);
final Group connectorGroup = mock(Group.class);
final Edge connectorEdge = mock(Edge.class);
final com.ait.lienzo.client.core.types.Point2D controlPointLienzo = new com.ait.lienzo.client.core.types.Point2D(100, 100);
final Point2DArray controlPointsLienzo = new Point2DArray(controlPointLienzo);
final ViewConnector viewConnector = mock(ViewConnector.class);
Group parentGroup = mock(Group.class);
BoundingBox parentBB = new BoundingBox(0, 0, 200, 200);
MultiPath head = mock(MultiPath.class);
MultiPath tail = mock(MultiPath.class);
when(childWiresShape.getMagnets()).thenReturn(magnets);
when(childWiresShape.getParent()).thenReturn(wiresShape);
when(wiresShape.getGroup()).thenReturn(parentGroup);
when(parentGroup.getBoundingBox()).thenReturn(parentBB);
when(wiresShape.getX()).thenReturn(0d);
when(wiresShape.getY()).thenReturn(0d);
when(magnets.size()).thenReturn(1);
when(magnets.getMagnet(0)).thenReturn(magnet);
when(magnet.getConnectionsSize()).thenReturn(connections.size());
when(magnet.getConnections()).thenReturn(connections);
when(connection.getConnector()).thenReturn(connector);
when(connector.getGroup()).thenReturn(connectorGroup);
when(connectorGroup.uuid()).thenReturn(connectorUUID);
when(connector.getControlPoints()).thenReturn(controlPointsLienzo);
when(connector.getHead()).thenReturn(head);
when(connector.getTail()).thenReturn(tail);
when(head.getLocation()).thenReturn(new com.ait.lienzo.client.core.types.Point2D(1, 1));
when(tail.getLocation()).thenReturn(new com.ait.lienzo.client.core.types.Point2D(2, 2));
when(wiresShape.getChildShapes()).thenReturn(children);
when(shape.getShapeView()).thenReturn(wiresShape);
when(graphIndex.getEdge(connectorUUID)).thenReturn(connectorEdge);
when(connectorEdge.getContent()).thenReturn(viewConnector);
when(connectorGroup.getUserData()).thenReturn(new WiresUtils.UserData(connectorUUID, ""));
tested.init(canvasHandler);
tested.register(element);
Point2D location = new Point2D(45d, 65.5d);
tested.move(new Element[] { element }, new Point2D[] { location });
ArgumentCaptor<CanvasCommand> commandArgumentCaptor = forClass(CanvasCommand.class);
verify(commandManager, times(1)).execute(eq(canvasHandler), commandArgumentCaptor.capture());
ArgumentCaptor<ShapeLocationsChangedEvent> shapeLocationsChangedEventCaptor = forClass(ShapeLocationsChangedEvent.class);
verify(shapeLocationsChangedEvent, times(1)).fire(shapeLocationsChangedEventCaptor.capture());
assertTrue(shapeLocationsChangedEventCaptor.getValue() instanceof ShapeLocationsChangedEvent);
// assert parent node move
final CompositeCommand command = (CompositeCommand) commandArgumentCaptor.getValue();
UpdateElementPositionCommand updateElementPositionCommand = (UpdateElementPositionCommand) command.getCommands().get(0);
assertEquals(element, updateElementPositionCommand.getElement());
assertEquals(location, updateElementPositionCommand.getLocation());
}
use of com.ait.lienzo.client.core.types.BoundingBox in project kie-wb-common by kiegroup.
the class WiresConnectorViewTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() throws Exception {
Node lineNode = line;
Node headPathNode = headPath;
Node tailPathNode = tailPath;
point2DArray = new Point2DArray(new Point2D(0, 10), new Point2D(10, 10), new Point2D(20, 20), new Point2D(30, 30), new Point2D(40, 40));
when(line.getPoint2DArray()).thenReturn(point2DArray);
when(line.asShape()).thenReturn(lineShape);
when(line.asNode()).thenReturn(lineNode);
when(lineShape.setFillColor(anyString())).thenReturn(lineShape);
when(lineShape.setFillColor(any(IColor.class))).thenReturn(lineShape);
when(lineShape.setFillAlpha(anyDouble())).thenReturn(lineShape);
when(lineShape.setStrokeColor(anyString())).thenReturn(lineShape);
when(lineShape.setStrokeColor(any(IColor.class))).thenReturn(lineShape);
when(lineShape.setStrokeAlpha(anyDouble())).thenReturn(lineShape);
when(lineShape.setStrokeWidth(anyDouble())).thenReturn(lineShape);
when(line.isControlPointShape()).thenReturn(true);
when(headDecorator.getPath()).thenReturn(headPath);
when(tailDecorator.getPath()).thenReturn(tailPath);
when(headPath.asNode()).thenReturn(headPathNode);
when(tailPath.asNode()).thenReturn(tailPathNode);
when(headPath.getBoundingBox()).thenReturn(new BoundingBox(0, 0, 10, 10));
this.tested = new WiresConnectorView(line, headDecorator, tailDecorator);
this.tested.setControl(wiresConnectorControl);
tested = spy(tested);
}
use of com.ait.lienzo.client.core.types.BoundingBox in project kie-wb-common by kiegroup.
the class LienzoLayerUtilsTest method testLayerToDataURL.
@Test
public void testLayerToDataURL() {
ScratchPad scratchPad = mock(ScratchPad.class);
Context2D context2D = mock(Context2D.class);
when(layer.getScratchPad()).thenReturn(scratchPad);
when(scratchPad.getContext()).thenReturn(context2D);
when(scratchPad.toDataURL(eq(DataURLType.JPG), eq(1d))).thenReturn("theResultData");
String result = LienzoLayerUtils.layerToDataURL(lienzoLayer, DataURLType.JPG, 1, 3, 111, 333, "#color1");
assertEquals("theResultData", result);
verify(scratchPad, times(1)).setPixelSize(eq(111), eq(333));
verify(scratchPad, times(1)).clear();
verify(context2D, times(1)).setFillColor(eq("#color1"));
verify(context2D, times(1)).fillRect(eq(0d), eq(0d), eq(111d), eq(333d));
verify(layer, times(1)).drawWithTransforms(eq(context2D), eq(1d), eq(new BoundingBox(1d, 3d, 111d, 333d)));
}
use of com.ait.lienzo.client.core.types.BoundingBox in project kie-wb-common by kiegroup.
the class DirectionalLineTest method testBoundingBoxGeneration.
@Test
public void testBoundingBoxGeneration() throws Exception {
final BoundingBox bb1 = tested.getBoundingBox();
assertEquals(0d, bb1.getMinX(), 0d);
assertEquals(0d, bb1.getMinY(), 0d);
assertEquals(15.5d, bb1.getMaxX(), 0d);
assertEquals(50.2d, bb1.getMaxY(), 0d);
// Assert that BB must be re-generated after refreshing as well.
tested.refresh();
final BoundingBox bb2 = tested.getBoundingBox();
assertEquals(0d, bb2.getMinX(), 0d);
assertEquals(0d, bb2.getMinY(), 0d);
assertEquals(15.5d, bb2.getMaxX(), 0d);
assertEquals(50.2d, bb2.getMaxY(), 0d);
}
Aggregations