Search in sources :

Example 21 with BPMNPlane

use of org.eclipse.bpmn2.di.BPMNPlane in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method createBpmnEdgeForAssociation.

private void createBpmnEdgeForAssociation(BpmnDiFactory factory, BPMNPlane plane, Association association) {
    BPMNEdge edge = factory.createBPMNEdge();
    edge.setBpmnElement(association);
    DcFactory dcFactory = DcFactory.eINSTANCE;
    Point point = dcFactory.createPoint();
    Bounds sourceBounds = _bounds.get(association.getSourceRef().getId());
    point.setX(sourceBounds.getX() + (sourceBounds.getWidth() / 2));
    point.setY(sourceBounds.getY() + (sourceBounds.getHeight() / 2));
    edge.getWaypoint().add(point);
    List<Point> dockers = _dockers.get(association.getId());
    for (int i = 1; i < dockers.size() - 1; i++) {
        edge.getWaypoint().add(dockers.get(i));
    }
    point = dcFactory.createPoint();
    Bounds targetBounds = _bounds.get(association.getTargetRef().getId());
    point.setX(targetBounds.getX() + (targetBounds.getWidth() / 2));
    point.setY(targetBounds.getY() + (targetBounds.getHeight() / 2));
    edge.getWaypoint().add(point);
    plane.getPlaneElement().add(edge);
}
Also used : Bounds(org.eclipse.dd.dc.Bounds) Point(org.eclipse.dd.dc.Point) BPMNEdge(org.eclipse.bpmn2.di.BPMNEdge) DcFactory(org.eclipse.dd.dc.DcFactory) Point(org.eclipse.dd.dc.Point)

Example 22 with BPMNPlane

use of org.eclipse.bpmn2.di.BPMNPlane in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method revisitEdgeBoundsInContainers.

public void revisitEdgeBoundsInContainers(Definitions def) {
    BPMNPlane plane = def.getDiagrams().get(0).getPlane();
    List<DiagramElement> diagramElements = plane.getPlaneElement();
    for (DiagramElement dia : diagramElements) {
        if (dia instanceof BPMNEdge) {
            BPMNEdge edge = (BPMNEdge) dia;
            if (edge.getBpmnElement() instanceof SequenceFlow) {
                SequenceFlow sq = (SequenceFlow) edge.getBpmnElement();
                List<RootElement> rootElements = def.getRootElements();
                for (RootElement root : rootElements) {
                    if (root instanceof Process) {
                        Process process = (Process) root;
                        updateEdgeBoundsInContainers(process, sq, plane, edge);
                    }
                }
                // update the source and target on BPMNEdge
                if (sq.getSourceRef() != null) {
                    edge.setSourceElement(getBPMNShapeForElement(sq.getSourceRef(), plane));
                }
                if (sq.getTargetRef() != null) {
                    edge.setTargetElement(getBPMNShapeForElement(sq.getTargetRef(), plane));
                }
            }
        }
    }
}
Also used : DiagramElement(org.eclipse.dd.di.DiagramElement) RootElement(org.eclipse.bpmn2.RootElement) SequenceFlow(org.eclipse.bpmn2.SequenceFlow) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) Process(org.eclipse.bpmn2.Process) BPMNPlane(org.eclipse.bpmn2.di.BPMNPlane) BPMNEdge(org.eclipse.bpmn2.di.BPMNEdge)

Example 23 with BPMNPlane

use of org.eclipse.bpmn2.di.BPMNPlane in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method updateShapeBoundsInLanes.

public void updateShapeBoundsInLanes(BPMNPlane plane, BaseElement ele, Lane lane, float parentX, float parentY) {
    for (FlowNode fn : lane.getFlowNodeRefs()) {
        Bounds fnBounds = getBoundsForElement(fn, plane);
        if (fnBounds != null) {
            fnBounds.setX(fnBounds.getX() + parentX);
            fnBounds.setY(fnBounds.getY() + parentY);
            // if flownode is a subprocess update it too
            if (fn instanceof SubProcess) {
                updateShapeBoundsInSubprocessInLanes(plane, ele, (SubProcess) fn, fnBounds.getX(), fnBounds.getY());
            } else if (fn instanceof Lane) {
                updateShapeBoundsInLanes(plane, ele, (Lane) fn, fnBounds.getX(), fnBounds.getY());
            }
        }
    }
}
Also used : AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) Bounds(org.eclipse.dd.dc.Bounds) Lane(org.eclipse.bpmn2.Lane) FlowNode(org.eclipse.bpmn2.FlowNode)

Example 24 with BPMNPlane

use of org.eclipse.bpmn2.di.BPMNPlane in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method createDiagram.

private void createDiagram(Definitions def) {
    for (RootElement rootElement : def.getRootElements()) {
        if (rootElement instanceof Process) {
            Process process = (Process) rootElement;
            BpmnDiFactory factory = BpmnDiFactory.eINSTANCE;
            BPMNDiagram diagram = factory.createBPMNDiagram();
            BPMNPlane plane = factory.createBPMNPlane();
            plane.setBpmnElement(process);
            diagram.setPlane(plane);
            // first process flowNodes
            for (FlowElement flowElement : process.getFlowElements()) {
                if (flowElement instanceof FlowNode) {
                    createBpmnShapeForElement(factory, plane, flowElement);
                    if (flowElement instanceof BoundaryEvent) {
                        createDockersForBoundaryEvent((BoundaryEvent) flowElement);
                    }
                    // check if its a subprocess
                    if (flowElement instanceof SubProcess) {
                        createSubProcessDiagram(plane, flowElement, factory);
                    }
                } else if (flowElement instanceof DataObject) {
                    createBpmnShapeForElement(factory, plane, flowElement);
                } else if (flowElement instanceof SequenceFlow) {
                    createBpmnEdgeForSequenceFlow(factory, plane, (SequenceFlow) flowElement);
                }
            }
            // then process artifacts
            if (process.getArtifacts() != null) {
                List<Association> incompleteAssociations = new ArrayList<Association>();
                for (Artifact artifact : process.getArtifacts()) {
                    // if (artifact instanceof TextAnnotation || artifact instanceof Group) {
                    if (artifact instanceof Group) {
                        createBpmnShapeForElement(factory, plane, artifact);
                    }
                    if (artifact instanceof Association) {
                        Association association = (Association) artifact;
                        if (association.getSourceRef() != null && association.getTargetRef() != null) {
                            createBpmnEdgeForAssociation(factory, plane, association);
                        } else {
                            incompleteAssociations.add(association);
                        }
                    }
                }
                if (!incompleteAssociations.isEmpty()) {
                    for (Association incompleteAssociation : incompleteAssociations) {
                        process.getArtifacts().remove(incompleteAssociation);
                    }
                }
            }
            // finally process lanes
            if (process.getLaneSets() != null && process.getLaneSets().size() > 0) {
                for (LaneSet ls : process.getLaneSets()) {
                    for (Lane lane : ls.getLanes()) {
                        createBpmnShapeForElement(factory, plane, lane);
                    }
                }
            }
            def.getDiagrams().add(diagram);
        }
    }
}
Also used : AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) Group(org.eclipse.bpmn2.Group) BoundaryEvent(org.eclipse.bpmn2.BoundaryEvent) SequenceFlow(org.eclipse.bpmn2.SequenceFlow) ArrayList(java.util.ArrayList) Lane(org.eclipse.bpmn2.Lane) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) Process(org.eclipse.bpmn2.Process) LaneSet(org.eclipse.bpmn2.LaneSet) BpmnDiFactory(org.eclipse.bpmn2.di.BpmnDiFactory) Artifact(org.eclipse.bpmn2.Artifact) BPMNDiagram(org.eclipse.bpmn2.di.BPMNDiagram) RootElement(org.eclipse.bpmn2.RootElement) DataObject(org.eclipse.bpmn2.DataObject) Association(org.eclipse.bpmn2.Association) DataOutputAssociation(org.eclipse.bpmn2.DataOutputAssociation) DataInputAssociation(org.eclipse.bpmn2.DataInputAssociation) FlowElement(org.eclipse.bpmn2.FlowElement) BPMNPlane(org.eclipse.bpmn2.di.BPMNPlane) FlowNode(org.eclipse.bpmn2.FlowNode)

Example 25 with BPMNPlane

use of org.eclipse.bpmn2.di.BPMNPlane in project kie-wb-common by kiegroup.

the class Bpmn2JsonMarshaller method marshallInclusiveGateway.

protected void marshallInclusiveGateway(InclusiveGateway gateway, BPMNPlane plane, JsonGenerator generator, float xOffset, float yOffset, Map<String, Object> flowElementProperties) throws JsonGenerationException, IOException {
    if (gateway.getDefault() != null) {
        SequenceFlow defsf = gateway.getDefault();
        String defGatewayStr = defsf.getId();
        flowElementProperties.put("defaultgate", defGatewayStr);
    }
    marshallNode(gateway, flowElementProperties, "InclusiveGateway", plane, generator, xOffset, yOffset);
}
Also used : SequenceFlow(org.eclipse.bpmn2.SequenceFlow)

Aggregations

Bounds (org.eclipse.dd.dc.Bounds)16 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)15 SubProcess (org.eclipse.bpmn2.SubProcess)15 ArrayList (java.util.ArrayList)12 BPMNShape (org.eclipse.bpmn2.di.BPMNShape)12 Process (org.eclipse.bpmn2.Process)11 DataObject (org.eclipse.bpmn2.DataObject)10 FlowElement (org.eclipse.bpmn2.FlowElement)9 BPMNEdge (org.eclipse.bpmn2.di.BPMNEdge)9 LinkedHashMap (java.util.LinkedHashMap)8 DataInputAssociation (org.eclipse.bpmn2.DataInputAssociation)8 DataOutputAssociation (org.eclipse.bpmn2.DataOutputAssociation)8 SequenceFlow (org.eclipse.bpmn2.SequenceFlow)8 Point (org.eclipse.dd.dc.Point)8 DiagramElement (org.eclipse.dd.di.DiagramElement)8 Artifact (org.eclipse.bpmn2.Artifact)7 BPMNPlane (org.eclipse.bpmn2.di.BPMNPlane)7 Entry (java.util.Map.Entry)6 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)6 Association (org.eclipse.bpmn2.Association)5