Search in sources :

Example 1 with ControlPointImpl

use of org.kie.workbench.common.stunner.core.graph.content.view.ControlPointImpl in project kie-wb-common by kiegroup.

the class AbstractCanvasControlPointCommandTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    Point2D location1 = new Point2D(0, 0);
    controlPoint1 = new ControlPointImpl(location1);
    ControlPoint controlPoint2 = new ControlPointImpl(location1, 1);
    controlPointList = Arrays.asList(controlPoint1);
    when(shape.getShapeView()).thenReturn(shapeView);
    when(shape.addControlPoints(controlPoint1)).thenReturn(Arrays.asList(controlPoint2));
    when(edge.getUUID()).thenReturn(EDGE_UUID);
    when(edge.getContent()).thenReturn(viewConnector);
    when(canvasHandler.getCanvas().getShape(EDGE_UUID)).thenReturn(shape);
}
Also used : Point2D(org.kie.workbench.common.stunner.core.graph.content.view.Point2D) ControlPointImpl(org.kie.workbench.common.stunner.core.graph.content.view.ControlPointImpl) ControlPoint(org.kie.workbench.common.stunner.core.graph.content.view.ControlPoint) Before(org.junit.Before)

Example 2 with ControlPointImpl

use of org.kie.workbench.common.stunner.core.graph.content.view.ControlPointImpl in project kie-wb-common by kiegroup.

the class AbstractControlPointCommandTest method setUp.

public void setUp() {
    super.init(0, 0);
    newLocation = new Point2D(0, 0);
    controlPoint1 = new ControlPointImpl(new Point2D(1, 1), 1);
    controlPoint2 = new ControlPointImpl(new Point2D(2, 2), 2);
    controlPoint3 = new ControlPointImpl(new Point2D(3, 3), 3);
    controlPointList = new ArrayList<ControlPoint>() {

        {
            add(controlPoint1);
            add(controlPoint2);
            add(controlPoint3);
        }
    };
    when(edge.getContent()).thenReturn(viewConnector);
    when(viewConnector.getControlPoints()).thenReturn(controlPointList);
}
Also used : Point2D(org.kie.workbench.common.stunner.core.graph.content.view.Point2D) ControlPointImpl(org.kie.workbench.common.stunner.core.graph.content.view.ControlPointImpl) ControlPoint(org.kie.workbench.common.stunner.core.graph.content.view.ControlPoint)

Example 3 with ControlPointImpl

use of org.kie.workbench.common.stunner.core.graph.content.view.ControlPointImpl in project kie-wb-common by kiegroup.

the class AddControlPointCommandTest method setUp.

@Before
public void setUp() {
    super.setUp();
    controlPointNew = new ControlPointImpl(newLocation, 2);
    controlPointEmptyIndex = new ControlPointImpl(newLocation);
    addControlPointCommand = spy(new AddControlPointCommand(edge, controlPointNew));
}
Also used : ControlPointImpl(org.kie.workbench.common.stunner.core.graph.content.view.ControlPointImpl) Before(org.junit.Before)

Example 4 with ControlPointImpl

use of org.kie.workbench.common.stunner.core.graph.content.view.ControlPointImpl in project kie-wb-common by kiegroup.

the class WiresConnectorViewTest method testAddControlPoint.

@Test
public void testAddControlPoint() {
    Point2D point1 = point2DArray.get(1);
    Point2D point2 = point2DArray.get(2);
    Point2D point3 = point2DArray.get(3);
    when(wiresConnectorControl.addControlPoint(point1.getX(), point1.getY())).thenReturn(1);
    when(wiresConnectorControl.addControlPoint(point2.getX(), point2.getY())).thenReturn(2);
    when(wiresConnectorControl.addControlPoint(point3.getX(), point3.getY())).thenReturn(3);
    ControlPoint controlPoint1 = new ControlPointImpl(point1.getX(), point1.getY());
    ControlPoint controlPoint2 = new ControlPointImpl(point2.getX(), point2.getY());
    ControlPoint controlPoint3 = new ControlPointImpl(point3.getX(), point3.getY());
    // without index
    List<ControlPoint> addedControlPoint = tested.addControlPoint(controlPoint1, controlPoint2);
    addedControlPoint.addAll(tested.addControlPoint(controlPoint3));
    InOrder addControlPointOrder = inOrder(wiresConnectorControl);
    addControlPointOrder.verify(wiresConnectorControl).addControlPoint(point1.getX(), point1.getY());
    addControlPointOrder.verify(wiresConnectorControl).addControlPoint(point2.getX(), point2.getY());
    addControlPointOrder.verify(wiresConnectorControl).addControlPoint(point3.getX(), point3.getY());
    assertEquals(addedControlPoint.get(0).getIndex(), 1, 0);
    assertEquals(addedControlPoint.get(1).getIndex(), 2, 0);
    assertEquals(addedControlPoint.get(2).getIndex(), 3, 0);
    // now with index
    addedControlPoint = tested.addControlPoint(controlPoint1, controlPoint2, controlPoint3);
    addControlPointOrder = inOrder(wiresConnectorControl);
    addControlPointOrder.verify(wiresConnectorControl).addControlPointToLine(controlPoint1.getLocation().getX(), controlPoint1.getLocation().getY(), controlPoint1.getIndex());
    addControlPointOrder.verify(wiresConnectorControl).addControlPointToLine(controlPoint2.getLocation().getX(), controlPoint2.getLocation().getY(), controlPoint2.getIndex());
    addControlPointOrder.verify(wiresConnectorControl).addControlPointToLine(controlPoint3.getLocation().getX(), controlPoint3.getLocation().getY(), controlPoint3.getIndex());
    assertEquals(addedControlPoint.get(0).getIndex(), 1, 0);
    assertEquals(addedControlPoint.get(1).getIndex(), 2, 0);
    assertEquals(addedControlPoint.get(2).getIndex(), 3, 0);
}
Also used : InOrder(org.mockito.InOrder) Point2D(com.ait.lienzo.client.core.types.Point2D) ControlPointImpl(org.kie.workbench.common.stunner.core.graph.content.view.ControlPointImpl) ControlPoint(org.kie.workbench.common.stunner.core.graph.content.view.ControlPoint) Test(org.junit.Test)

Example 5 with ControlPointImpl

use of org.kie.workbench.common.stunner.core.graph.content.view.ControlPointImpl in project kie-wb-common by kiegroup.

the class AbstractEdgeBuilder method buildControlPoints.

private void buildControlPoints(BuilderContext context, T edge, GraphCommandFactory commandFactory) {
    if (dockers.size() > 2) {
        Counter indexCounter = new Counter(0);
        ControlPoint[] controlPoints = dockers.subList(1, dockers.size() - 1).stream().sequential().map(docker -> (docker.length == 2 ? new Point2D(docker[0], docker[1]) : null)).filter(Objects::nonNull).map(point -> new ControlPointImpl(point, indexCounter.increment())).toArray(ControlPoint[]::new);
        CommandResult<RuleViolation> addControlPointsResult = context.execute(commandFactory.addControlPoint(edge, controlPoints));
        if (hasErrors(addControlPointsResult)) {
            throw new RuntimeException("Error building BPMN graph. Command 'AddControlPointCommand' execution failed." + addControlPointsResult);
        }
    }
}
Also used : AddControlPointCommand(org.kie.workbench.common.stunner.core.graph.command.impl.AddControlPointCommand) Point2D(org.kie.workbench.common.stunner.core.graph.content.view.Point2D) Connection(org.kie.workbench.common.stunner.core.graph.content.view.Connection) ControlPoint(org.kie.workbench.common.stunner.core.graph.content.view.ControlPoint) BPMNDefinition(org.kie.workbench.common.stunner.bpmn.definition.BPMNDefinition) Edge(org.kie.workbench.common.stunner.core.graph.Edge) MutableIndex(org.kie.workbench.common.stunner.core.graph.processing.index.MutableIndex) Collectors(java.util.stream.Collectors) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Objects(java.util.Objects) GraphCommandFactory(org.kie.workbench.common.stunner.core.graph.command.impl.GraphCommandFactory) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) CommandUtils(org.kie.workbench.common.stunner.core.command.util.CommandUtils) Bpmn2OryxManager(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.Bpmn2OryxManager) Counter(org.kie.workbench.common.stunner.core.util.Counter) ControlPointImpl(org.kie.workbench.common.stunner.core.graph.content.view.ControlPointImpl) AddNodeCommand(org.kie.workbench.common.stunner.core.graph.command.impl.AddNodeCommand) SetConnectionTargetNodeCommand(org.kie.workbench.common.stunner.core.graph.command.impl.SetConnectionTargetNodeCommand) MagnetConnection(org.kie.workbench.common.stunner.core.graph.content.view.MagnetConnection) FactoryManager(org.kie.workbench.common.stunner.core.api.FactoryManager) CommandResult(org.kie.workbench.common.stunner.core.command.CommandResult) Node(org.kie.workbench.common.stunner.core.graph.Node) Counter(org.kie.workbench.common.stunner.core.util.Counter) Point2D(org.kie.workbench.common.stunner.core.graph.content.view.Point2D) Objects(java.util.Objects) ControlPointImpl(org.kie.workbench.common.stunner.core.graph.content.view.ControlPointImpl) ControlPoint(org.kie.workbench.common.stunner.core.graph.content.view.ControlPoint) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation)

Aggregations

ControlPointImpl (org.kie.workbench.common.stunner.core.graph.content.view.ControlPointImpl)8 Before (org.junit.Before)4 ControlPoint (org.kie.workbench.common.stunner.core.graph.content.view.ControlPoint)4 Point2D (org.kie.workbench.common.stunner.core.graph.content.view.Point2D)4 Edge (org.kie.workbench.common.stunner.core.graph.Edge)2 Point2D (com.ait.lienzo.client.core.types.Point2D)1 Objects (java.util.Objects)1 Collectors (java.util.stream.Collectors)1 Test (org.junit.Test)1 Bpmn2OryxManager (org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.Bpmn2OryxManager)1 BPMNDefinition (org.kie.workbench.common.stunner.bpmn.definition.BPMNDefinition)1 TestingGraphMockHandler (org.kie.workbench.common.stunner.core.TestingGraphMockHandler)1 FactoryManager (org.kie.workbench.common.stunner.core.api.FactoryManager)1 CanvasControlPointDoubleClickEvent (org.kie.workbench.common.stunner.core.client.canvas.event.controlpoint.CanvasControlPointDoubleClickEvent)1 CanvasControlPointDragEndEvent (org.kie.workbench.common.stunner.core.client.canvas.event.controlpoint.CanvasControlPointDragEndEvent)1 CanvasControlPointDragStartEvent (org.kie.workbench.common.stunner.core.client.canvas.event.controlpoint.CanvasControlPointDragStartEvent)1 CanvasSelectionEvent (org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasSelectionEvent)1 HasEventHandlers (org.kie.workbench.common.stunner.core.client.shape.view.HasEventHandlers)1 MouseDoubleClickEvent (org.kie.workbench.common.stunner.core.client.shape.view.event.MouseDoubleClickEvent)1 MouseDoubleClickHandler (org.kie.workbench.common.stunner.core.client.shape.view.event.MouseDoubleClickHandler)1