Search in sources :

Example 16 with MultiPath

use of com.ait.lienzo.client.core.shape.MultiPath in project kie-wb-common by kiegroup.

the class PolyLineConnectorViewTest method testCreateLine.

@Test
public void testCreateLine() {
    double[] points = new double[] { 0, 0, 10, 10 };
    PolyLineConnectorFactory factory = new PolyLineConnectorFactory();
    Object[] line = PolylineConnectorView.createLine(factory, ConnectorShapeDef.Direction.ONE, points);
    MultiPathDecorator head = (MultiPathDecorator) line[1];
    MultiPath headPath = head.getPath();
    BoundingBox headBoundingBox = headPath.getBoundingBox();
    MultiPathDecorator tail = (MultiPathDecorator) line[2];
    MultiPath tailPath = tail.getPath();
    BoundingBox tailBoundingBox = tailPath.getBoundingBox();
    assertEquals(0, headBoundingBox.getWidth(), 0);
    assertEquals(0, headBoundingBox.getHeight(), 0);
    assertNotEquals(0, tailBoundingBox.getWidth(), 0);
    assertNotEquals(0, tailBoundingBox.getHeight(), 0);
}
Also used : MultiPath(com.ait.lienzo.client.core.shape.MultiPath) BoundingBox(com.ait.lienzo.client.core.types.BoundingBox) PolyLineConnectorFactory(org.kie.workbench.common.stunner.shapes.client.factory.PolyLineConnectorFactory) MultiPathDecorator(com.ait.lienzo.client.core.shape.MultiPathDecorator) Test(org.junit.Test)

Example 17 with MultiPath

use of com.ait.lienzo.client.core.shape.MultiPath 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());
}
Also used : Group(com.ait.lienzo.client.core.shape.Group) CompositeCommand(org.kie.workbench.common.stunner.core.command.impl.CompositeCommand) Point2D(org.kie.workbench.common.stunner.core.graph.content.view.Point2D) MagnetManager(com.ait.lienzo.client.core.shape.wires.MagnetManager) NFastArrayList(com.ait.tooling.nativetools.client.collection.NFastArrayList) BoundingBox(com.ait.lienzo.client.core.types.BoundingBox) CanvasCommand(org.kie.workbench.common.stunner.core.client.command.CanvasCommand) WiresUtils(org.kie.workbench.common.stunner.client.lienzo.canvas.wires.WiresUtils) MultiPath(com.ait.lienzo.client.core.shape.MultiPath) WiresConnector(com.ait.lienzo.client.core.shape.wires.WiresConnector) ViewConnector(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector) WiresConnection(com.ait.lienzo.client.core.shape.wires.WiresConnection) Point2DArray(com.ait.lienzo.client.core.types.Point2DArray) WiresShape(com.ait.lienzo.client.core.shape.wires.WiresShape) ShapeLocationsChangedEvent(org.kie.workbench.common.stunner.core.client.canvas.event.ShapeLocationsChangedEvent) WiresShapeView(org.kie.workbench.common.stunner.client.lienzo.shape.view.wires.WiresShapeView) WiresMagnet(com.ait.lienzo.client.core.shape.wires.WiresMagnet) UpdateElementPositionCommand(org.kie.workbench.common.stunner.core.client.canvas.command.UpdateElementPositionCommand) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Test(org.junit.Test)

Example 18 with MultiPath

use of com.ait.lienzo.client.core.shape.MultiPath in project kie-wb-common by kiegroup.

the class LienzoCanvasExportTest method testWiresLayerBoundsProvider.

@Test
public void testWiresLayerBoundsProvider() {
    layer = new Layer();
    when(lienzoLayer.getLienzoLayer()).thenReturn(layer);
    WiresManager wiresManager = WiresManager.get(layer);
    com.ait.lienzo.client.core.shape.wires.WiresLayer wiresLayer = wiresManager.getLayer();
    wiresLayer.add(new WiresShape(new MultiPath().rect(0, 0, 50, 50)).setLocation(new Point2D(12, 44)));
    wiresLayer.add(new WiresShape(new MultiPath().rect(0, 0, 100, 150)).setLocation(new Point2D(1, 3)));
    LienzoCanvasExport.WiresLayerBoundsProvider provider = new LienzoCanvasExport.WiresLayerBoundsProvider();
    int[] size0 = provider.compute(lienzoLayer, CanvasExportSettings.build());
    assertEquals(0, size0[0]);
    assertEquals(0, size0[1]);
    assertEquals(151, size0[2]);
    assertEquals(203, size0[3]);
}
Also used : MultiPath(com.ait.lienzo.client.core.shape.MultiPath) Layer(com.ait.lienzo.client.core.shape.Layer) WiresLayer(org.kie.workbench.common.stunner.client.lienzo.canvas.wires.WiresLayer) WiresShape(com.ait.lienzo.client.core.shape.wires.WiresShape) Point2D(com.ait.lienzo.client.core.types.Point2D) WiresManager(com.ait.lienzo.client.core.shape.wires.WiresManager) Test(org.junit.Test)

Example 19 with MultiPath

use of com.ait.lienzo.client.core.shape.MultiPath in project kie-wb-common by kiegroup.

the class WiresCanvasViewTest method testDock.

@Test
public void testDock() {
    WiresShapeView parent = new WiresShapeView(new MultiPath().rect(0, 0, 50, 50));
    WiresShapeView child = new WiresShapeView(new MultiPath().rect(0, 0, 50, 50));
    tested.dock(parent, child);
    verify(wiresLayer, times(1)).dock(eq(parent), eq(child));
}
Also used : MultiPath(com.ait.lienzo.client.core.shape.MultiPath) WiresShapeView(org.kie.workbench.common.stunner.client.lienzo.shape.view.wires.WiresShapeView) Test(org.junit.Test)

Example 20 with MultiPath

use of com.ait.lienzo.client.core.shape.MultiPath in project kie-wb-common by kiegroup.

the class WiresCanvasViewTest method testAdd.

@Test
public void testAdd() {
    WiresShapeView shapeView = new WiresShapeView(new MultiPath().rect(0, 0, 50, 50));
    tested.add(shapeView);
    verify(wiresLayer, times(1)).add(eq(shapeView));
}
Also used : MultiPath(com.ait.lienzo.client.core.shape.MultiPath) WiresShapeView(org.kie.workbench.common.stunner.client.lienzo.shape.view.wires.WiresShapeView) Test(org.junit.Test)

Aggregations

MultiPath (com.ait.lienzo.client.core.shape.MultiPath)39 Test (org.junit.Test)16 WiresShapeView (org.kie.workbench.common.stunner.client.lienzo.shape.view.wires.WiresShapeView)10 MultiPathDecorator (com.ait.lienzo.client.core.shape.MultiPathDecorator)9 WiresShape (com.ait.lienzo.client.core.shape.wires.WiresShape)9 BoundingBox (com.ait.lienzo.client.core.types.BoundingBox)7 Point2D (com.ait.lienzo.client.core.types.Point2D)7 Point2DArray (com.ait.lienzo.client.core.types.Point2DArray)4 Before (org.junit.Before)4 Layer (com.ait.lienzo.client.core.shape.Layer)3 PickerPart (com.ait.lienzo.client.core.shape.wires.PickerPart)3 DashArray (com.ait.lienzo.client.core.types.DashArray)3 PictureShapeView (org.kie.workbench.common.stunner.shapes.client.view.PictureShapeView)3 Group (com.ait.lienzo.client.core.shape.Group)2 WiresConnection (com.ait.lienzo.client.core.shape.wires.WiresConnection)2 WiresConnector (com.ait.lienzo.client.core.shape.wires.WiresConnector)2 WiresMagnet (com.ait.lienzo.client.core.shape.wires.WiresMagnet)2 NFastArrayList (com.ait.tooling.nativetools.client.collection.NFastArrayList)2 SafeUri (com.google.gwt.safehtml.shared.SafeUri)2 Edge (org.kie.workbench.common.stunner.core.graph.Edge)2