Search in sources :

Example 6 with Bounds

use of org.eclipse.dd.dc.Bounds in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method updateShapeBoundsInSubprocess.

public void updateShapeBoundsInSubprocess(BPMNPlane plane, BaseElement ele, SubProcess sub, float parentX, float parentY) {
    boolean foundInSubprocess = false;
    for (FlowElement subEle : sub.getFlowElements()) {
        if (subEle.getId().equals(ele.getId())) {
            foundInSubprocess = true;
            Bounds subEleBounds = getBoundsForElement(subEle, plane);
            if (subEleBounds != null) {
                subEleBounds.setX(subEleBounds.getX() + parentX);
                subEleBounds.setY(subEleBounds.getY() + parentY);
            }
        }
    }
    if (!foundInSubprocess) {
        for (FlowElement subEle : sub.getFlowElements()) {
            if (subEle instanceof SubProcess) {
                Bounds subEleBounds = getBoundsForElement(subEle, plane);
                updateShapeBoundsInSubprocess(plane, ele, (SubProcess) subEle, subEleBounds.getX(), subEleBounds.getY());
            }
        }
    }
}
Also used : AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) FlowElement(org.eclipse.bpmn2.FlowElement) Bounds(org.eclipse.dd.dc.Bounds)

Example 7 with Bounds

use of org.eclipse.dd.dc.Bounds in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method updateShapeBoundsInSubprocessInLanes.

public void updateShapeBoundsInSubprocessInLanes(BPMNPlane plane, BaseElement ele, SubProcess sub, float parentX, float parentY) {
    for (FlowElement subEle : sub.getFlowElements()) {
        Bounds subEleBounds = getBoundsForElement(subEle, plane);
        if (subEleBounds != null) {
            subEleBounds.setX(subEleBounds.getX() + parentX);
            subEleBounds.setY(subEleBounds.getY() + parentY);
        }
        if (subEle instanceof SubProcess) {
            updateShapeBoundsInSubprocessInLanes(plane, ele, (SubProcess) subEle, subEleBounds.getX(), subEleBounds.getY());
        }
    }
}
Also used : AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) FlowElement(org.eclipse.bpmn2.FlowElement) Bounds(org.eclipse.dd.dc.Bounds)

Example 8 with Bounds

use of org.eclipse.dd.dc.Bounds in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method createBpmnShapeForElement.

private void createBpmnShapeForElement(BpmnDiFactory factory, BPMNPlane plane, BaseElement element) {
    Bounds bounds = _bounds.get(element.getId());
    if (bounds != null) {
        BPMNShape shape = factory.createBPMNShape();
        shape.setBpmnElement(element);
        shape.setBounds(bounds);
        plane.getPlaneElement().add(shape);
    }
}
Also used : Bounds(org.eclipse.dd.dc.Bounds) BPMNShape(org.eclipse.bpmn2.di.BPMNShape)

Example 9 with Bounds

use of org.eclipse.dd.dc.Bounds in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method createBpmnEdgeForSequenceFlow.

private void createBpmnEdgeForSequenceFlow(BpmnDiFactory factory, BPMNPlane plane, SequenceFlow sequenceFlow) {
    BPMNEdge edge = factory.createBPMNEdge();
    edge.setBpmnElement(sequenceFlow);
    DcFactory dcFactory = DcFactory.eINSTANCE;
    Point point = dcFactory.createPoint();
    List<Point> dockers = _dockers.get(sequenceFlow.getId());
    if (sequenceFlow.getSourceRef() != null) {
        Bounds sourceBounds = _bounds.get(sequenceFlow.getSourceRef().getId());
        // Test for valid docker with X and Y  > -1, created by EdgeParser
        if (dockers != null && dockers.size() > 0 && dockers.get(0).getX() > -1 && dockers.get(0).getY() > -1) {
            // First docker is connection to Source
            point.setX(sourceBounds.getX() + dockers.get(0).getX());
            point.setY(sourceBounds.getY() + dockers.get(0).getY());
        } else {
            // Default is right middle of Source
            point.setX(sourceBounds.getX() + sourceBounds.getWidth());
            point.setY(sourceBounds.getY() + (sourceBounds.getHeight() / 2));
        }
    }
    edge.getWaypoint().add(point);
    for (int i = 1; i < dockers.size() - 1; i++) {
        edge.getWaypoint().add(dockers.get(i));
    }
    point = dcFactory.createPoint();
    if (sequenceFlow.getTargetRef() != null) {
        Bounds targetBounds = _bounds.get(sequenceFlow.getTargetRef().getId());
        // Test for valid docker with X and Y  > -1, created by EdgeParser
        if (dockers != null && dockers.size() > 1 && dockers.get(dockers.size() - 1).getX() > -1 && dockers.get(dockers.size() - 1).getY() > -1) {
            // Last docker is connection to Target
            point.setX(targetBounds.getX() + dockers.get(dockers.size() - 1).getX());
            point.setY(targetBounds.getY() + dockers.get(dockers.size() - 1).getY());
        } else {
            // Default is left middle of Target
            point.setX(targetBounds.getX());
            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 10 with Bounds

use of org.eclipse.dd.dc.Bounds in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method updateShapeBounds.

public void updateShapeBounds(Definitions def, BPMNPlane plane, BaseElement ele) {
    if (ele instanceof Lane) {
        Lane nextLane = (Lane) ele;
        Bounds laneBounds = getBoundsForElement(nextLane, plane);
        updateShapeBoundsInLanes(plane, ele, nextLane, laneBounds.getX(), laneBounds.getY());
    } else {
        List<RootElement> rootElements = def.getRootElements();
        for (RootElement root : rootElements) {
            if (root instanceof Process) {
                Process process = (Process) root;
                List<FlowElement> flowElements = process.getFlowElements();
                boolean foundAsTopLevel = false;
                for (FlowElement fe : flowElements) {
                    if (fe.getId().equals(ele.getId())) {
                        foundAsTopLevel = true;
                        break;
                    }
                }
                if (!foundAsTopLevel) {
                    for (FlowElement fe : flowElements) {
                        if (fe instanceof SubProcess) {
                            SubProcess sp = (SubProcess) fe;
                            // process if this subprocess is not in a lane already. otherwise we already updated it
                            if (sp.getLanes().size() < 1) {
                                // find the subprocess bounds
                                Bounds subprocessBounds = getBoundsForElement(fe, plane);
                                if (subprocessBounds != null) {
                                    updateShapeBoundsInSubprocess(plane, ele, (SubProcess) fe, subprocessBounds.getX(), subprocessBounds.getY());
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) RootElement(org.eclipse.bpmn2.RootElement) FlowElement(org.eclipse.bpmn2.FlowElement) Bounds(org.eclipse.dd.dc.Bounds) Lane(org.eclipse.bpmn2.Lane) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) Process(org.eclipse.bpmn2.Process)

Aggregations

Bounds (org.eclipse.dd.dc.Bounds)35 Point (org.eclipse.dd.dc.Point)17 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)11 SubProcess (org.eclipse.bpmn2.SubProcess)11 BPMNShape (org.eclipse.bpmn2.di.BPMNShape)11 DataObject (org.eclipse.bpmn2.DataObject)8 Process (org.eclipse.bpmn2.Process)8 SequenceFlow (org.eclipse.bpmn2.SequenceFlow)8 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)7 FlowElement (org.eclipse.bpmn2.FlowElement)7 FlowNode (org.eclipse.bpmn2.FlowNode)7 BPMNEdge (org.eclipse.bpmn2.di.BPMNEdge)7 LinkedHashMap (java.util.LinkedHashMap)6 List (java.util.List)4 Entry (java.util.Map.Entry)4 Lane (org.eclipse.bpmn2.Lane)4 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)4 TestDefinitionsWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.TestDefinitionsWriter)4 Artifact (org.eclipse.bpmn2.Artifact)3