use of org.kie.workbench.common.stunner.core.graph.content.HasControlPoints 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.HasControlPoints in project kie-wb-common by kiegroup.
the class AddControlPointCommand method execute.
@Override
public CommandResult<RuleViolation> execute(GraphCommandExecutionContext context) {
if (checkExistingControlPoints(getEdgeContent().getControlPoints())) {
// skipping in case adding already existing control points
return GraphCommandResultBuilder.SUCCESS;
}
CommandResult<RuleViolation> allowResult = allow(context);
if (CommandUtils.isError(allowResult)) {
return allowResult;
}
HasControlPoints edgeContent = getEdgeContent();
if (Objects.isNull(edgeContent.getControlPoints())) {
edgeContent.setControlPoints(new LinkedList<>());
}
// add on the right index position on the list
getControlPointList().stream().forEach(cp -> {
// the effective index should not consider the head point that is a control point on the connector
int effectiveIndex = cp.getIndex() - 1;
if (edgeContent.getControlPoints().size() > effectiveIndex) {
edgeContent.getControlPoints().add(effectiveIndex, cp);
} else {
edgeContent.getControlPoints().add(cp);
}
});
// update index control points
updateControlPointsIndex(edgeContent.getControlPoints());
return GraphCommandResultBuilder.SUCCESS;
}
Aggregations