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);
}
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);
}
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));
}
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);
}
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);
}
}
}
Aggregations