use of org.kie.workbench.common.stunner.core.graph.content.view.ControlPoint 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.ControlPoint 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);
}
}
}
use of org.kie.workbench.common.stunner.core.graph.content.view.ControlPoint in project kie-wb-common by kiegroup.
the class EdgeParser method initialize.
@SuppressWarnings("unchecked")
@Override
public void initialize(final Context context) {
super.initialize(context);
String outNodeId = element.getTargetNode() != null ? element.getTargetNode().getUUID() : null;
// Outgoing.
if (null != outNodeId) {
ArrayParser outgoingParser = new ArrayParser("outgoing");
outgoingParser.addParser(new ObjectParser("").addParser(new StringFieldParser("resourceId", outNodeId)));
super.addParser(outgoingParser);
}
// Use dockers
ArrayParser dockersParser = new ArrayParser("dockers");
ViewConnector viewConnector = (ViewConnector) element.getContent();
// insert source
dockersParser.addParser(createDockerObjectParser(viewConnector.getSourceConnection()));
// inserting ControlPoints
viewConnector.getControlPoints().stream().sequential().map(ControlPoint::getLocation).map(this::createDockerObjectParser).forEach(dockersParser::addParser);
// insert target
dockersParser.addParser(createDockerObjectParser(viewConnector.getTargetConnection()));
super.addParser(dockersParser);
}
use of org.kie.workbench.common.stunner.core.graph.content.view.ControlPoint in project kie-wb-common by kiegroup.
the class WiresConnectorViewTest method testGetShapeControlPoints.
@Test
public void testGetShapeControlPoints() {
List<ControlPoint> controlPoints = tested.getShapeControlPoints();
for (int i = 1; i < controlPoints.size() - 1; i++) {
ControlPoint controlPoint = controlPoints.get(i);
Point2D point = point2DArray.get(i);
assertEquals(controlPoint.getLocation().getX(), point.getX(), 0);
assertEquals(controlPoint.getLocation().getY(), point.getY(), 0);
assertEquals(controlPoint.getIndex().intValue(), i);
}
}
Aggregations