use of org.kie.workbench.common.stunner.core.graph.content.view.ControlPoint 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.ControlPoint in project kie-wb-common by kiegroup.
the class DeleteControlPointCommand method execute.
@Override
public CommandResult<RuleViolation> execute(GraphCommandExecutionContext context) {
HasControlPoints edgeContent = getEdgeContent();
List<ControlPoint> connectorControlPoints = edgeContent.getControlPoints();
connectorControlPoints.removeAll(getControlPointList());
// update index
updateControlPointsIndex(connectorControlPoints);
return GraphCommandResultBuilder.SUCCESS;
}
use of org.kie.workbench.common.stunner.core.graph.content.view.ControlPoint 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.ControlPoint in project kie-wb-common by kiegroup.
the class AddCanvasConnectorCommand method execute.
@Override
@SuppressWarnings("unchecked")
public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context) {
context.register(shapeSetId, candidate);
context.applyElementMutation(candidate, MutationContext.STATIC);
if (candidate.getContent() instanceof ViewConnector) {
ControlPoint[] controlPoints = ((ViewConnector) candidate.getContent()).getControlPoints().stream().toArray(ControlPoint[]::new);
CommandResult<CanvasViolation> addControlPointsResult = new AddCanvasControlPointCommand(candidate, controlPoints).execute(context);
ShapeUtils.hideControlPoints(candidate, context);
if (CommandUtils.isError(addControlPointsResult)) {
return addControlPointsResult;
}
}
ShapeUtils.updateEdgeConnections(candidate, context);
ShapeUtils.applyConnections(candidate, context, MutationContext.STATIC);
final Node source = candidate.getSourceNode();
if (null != source) {
context.notifyCanvasElementUpdated(source);
}
return buildResult();
}
use of org.kie.workbench.common.stunner.core.graph.content.view.ControlPoint in project kie-wb-common by kiegroup.
the class AddCanvasControlPointCommand method allow.
@Override
public CommandResult<CanvasViolation> allow(AbstractCanvasHandler context) {
if (checkExistingControlPoints(ShapeUtils.getControlPoints(candidate, context))) {
return buildResult();
}
ShapeUtils.hideControlPoints(candidate, context);
List<ControlPoint> addedControlPoints = ShapeUtils.addControlPoints(candidate, context, this.controlPoints);
if (addedControlPoints.stream().map(ControlPoint::getIndex).anyMatch(Objects::isNull)) {
return new CanvasCommandResultBuilder().setType(CommandResult.Type.ERROR).addViolation(new CanvasViolationImpl.Builder().build(new RuleViolationImpl("Control Point out of connector"))).build();
}
ShapeUtils.showControlPoints(candidate, context);
allowed = Boolean.TRUE;
return buildResult();
}
Aggregations