Search in sources :

Example 1 with AddControlPointCommand

use of org.kie.workbench.common.stunner.core.graph.command.impl.AddControlPointCommand 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

Objects (java.util.Objects)1 Collectors (java.util.stream.Collectors)1 Bpmn2OryxManager (org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.Bpmn2OryxManager)1 BPMNDefinition (org.kie.workbench.common.stunner.bpmn.definition.BPMNDefinition)1 FactoryManager (org.kie.workbench.common.stunner.core.api.FactoryManager)1 CommandResult (org.kie.workbench.common.stunner.core.command.CommandResult)1 CommandUtils (org.kie.workbench.common.stunner.core.command.util.CommandUtils)1 Edge (org.kie.workbench.common.stunner.core.graph.Edge)1 Node (org.kie.workbench.common.stunner.core.graph.Node)1 AddControlPointCommand (org.kie.workbench.common.stunner.core.graph.command.impl.AddControlPointCommand)1 AddNodeCommand (org.kie.workbench.common.stunner.core.graph.command.impl.AddNodeCommand)1 GraphCommandFactory (org.kie.workbench.common.stunner.core.graph.command.impl.GraphCommandFactory)1 SetConnectionTargetNodeCommand (org.kie.workbench.common.stunner.core.graph.command.impl.SetConnectionTargetNodeCommand)1 Connection (org.kie.workbench.common.stunner.core.graph.content.view.Connection)1 ControlPoint (org.kie.workbench.common.stunner.core.graph.content.view.ControlPoint)1 ControlPointImpl (org.kie.workbench.common.stunner.core.graph.content.view.ControlPointImpl)1 MagnetConnection (org.kie.workbench.common.stunner.core.graph.content.view.MagnetConnection)1 Point2D (org.kie.workbench.common.stunner.core.graph.content.view.Point2D)1 View (org.kie.workbench.common.stunner.core.graph.content.view.View)1 MutableIndex (org.kie.workbench.common.stunner.core.graph.processing.index.MutableIndex)1