Search in sources :

Example 1 with DiagramElement

use of org.eclipse.dd.di.DiagramElement in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method updateEdgeBoundsInLanes.

public void updateEdgeBoundsInLanes(Definitions def, BPMNPlane plane, BPMNEdge edge, BaseElement ele) {
    if (ele instanceof SequenceFlow) {
        SequenceFlow sq = (SequenceFlow) ele;
        // 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));
        }
        List<RootElement> rootElements = def.getRootElements();
        for (RootElement root : rootElements) {
            if (root instanceof Process) {
                Process process = (Process) root;
                if (sq.getSourceRef() != null && sq.getTargetRef() != null) {
                    if (process.getLaneSets() != null && process.getLaneSets().size() > 0) {
                        for (LaneSet ls : process.getLaneSets()) {
                            for (Lane newLane : ls.getLanes()) {
                                List<FlowNode> laneFlowNodes = newLane.getFlowNodeRefs();
                                Bounds laneBounds = getBoundsForElement(newLane, plane);
                                for (FlowNode newFlowNode : laneFlowNodes) {
                                    if (newFlowNode.getId().equals(sq.getSourceRef().getId())) {
                                        List<DiagramElement> diagramElements = plane.getPlaneElement();
                                        for (DiagramElement dia : diagramElements) {
                                            if (dia instanceof BPMNShape) {
                                                BPMNShape shape = (BPMNShape) dia;
                                                if (shape.getBpmnElement().getId().equals(sq.getSourceRef().getId())) {
                                                    Bounds eleBounds = shape.getBounds();
                                                    List<Point> edgePoints = edge.getWaypoint();
                                                    if (edgePoints != null && edgePoints.size() > 1) {
                                                        if (eleBounds != null) {
                                                            Point first = edgePoints.get(0);
                                                            first.setX(first.getX() + laneBounds.getX());
                                                            first.setY(first.getY() + laneBounds.getY());
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    } else if (newFlowNode.getId().equals(sq.getTargetRef().getId())) {
                                        List<DiagramElement> diagramElements = plane.getPlaneElement();
                                        for (DiagramElement dia : diagramElements) {
                                            if (dia instanceof BPMNShape) {
                                                BPMNShape shape = (BPMNShape) dia;
                                                if (shape.getBpmnElement().getId().equals(sq.getTargetRef().getId())) {
                                                    Bounds eleBounds = shape.getBounds();
                                                    List<Point> edgePoints = edge.getWaypoint();
                                                    if (edgePoints != null && edgePoints.size() > 1) {
                                                        if (eleBounds != null) {
                                                            Point last = edgePoints.get(edgePoints.size() - 1);
                                                            last.setX(last.getX() + laneBounds.getX());
                                                            last.setY(last.getY() + laneBounds.getY());
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : SequenceFlow(org.eclipse.bpmn2.SequenceFlow) 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) LaneSet(org.eclipse.bpmn2.LaneSet) Point(org.eclipse.dd.dc.Point) BPMNShape(org.eclipse.bpmn2.di.BPMNShape) DiagramElement(org.eclipse.dd.di.DiagramElement) RootElement(org.eclipse.bpmn2.RootElement) ArrayList(java.util.ArrayList) List(java.util.List) FlowNode(org.eclipse.bpmn2.FlowNode)

Example 2 with DiagramElement

use of org.eclipse.dd.di.DiagramElement in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method revisitDIColors.

public void revisitDIColors(Definitions def) {
    BPMNPlane plane = def.getDiagrams().get(0).getPlane();
    List<DiagramElement> diagramElements = plane.getPlaneElement();
    for (DiagramElement dia : diagramElements) {
        if (dia instanceof BPMNShape) {
            BPMNShape shape = (BPMNShape) dia;
            updateShapeColors(shape);
        }
        if (dia instanceof BPMNEdge) {
            BPMNEdge edge = (BPMNEdge) dia;
            updateEdgeColors(edge);
        }
    }
}
Also used : DiagramElement(org.eclipse.dd.di.DiagramElement) BPMNPlane(org.eclipse.bpmn2.di.BPMNPlane) BPMNShape(org.eclipse.bpmn2.di.BPMNShape) BPMNEdge(org.eclipse.bpmn2.di.BPMNEdge)

Example 3 with DiagramElement

use of org.eclipse.dd.di.DiagramElement in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method revisitEdgeBoundsInLanes.

public void revisitEdgeBoundsInLanes(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;
            updateEdgeBoundsInLanes(def, plane, edge, edge.getBpmnElement());
        }
    }
}
Also used : DiagramElement(org.eclipse.dd.di.DiagramElement) BPMNPlane(org.eclipse.bpmn2.di.BPMNPlane) BPMNEdge(org.eclipse.bpmn2.di.BPMNEdge)

Example 4 with DiagramElement

use of org.eclipse.dd.di.DiagramElement in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method revisitDI.

public void revisitDI(Definitions def) {
    revisitDIColors(def);
    BPMNPlane plane = def.getDiagrams().get(0).getPlane();
    List<DiagramElement> diagramElements = plane.getPlaneElement();
    for (DiagramElement dia : diagramElements) {
        if (dia instanceof BPMNShape) {
            BPMNShape shape = (BPMNShape) dia;
            updateShapeBounds(def, plane, shape.getBpmnElement());
        }
    }
    revisitEdgeBoundsInLanes(def);
    revisitEdgeBoundsInContainers(def);
}
Also used : DiagramElement(org.eclipse.dd.di.DiagramElement) BPMNPlane(org.eclipse.bpmn2.di.BPMNPlane) BPMNShape(org.eclipse.bpmn2.di.BPMNShape)

Example 5 with DiagramElement

use of org.eclipse.dd.di.DiagramElement in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method orderDiagramElements.

private void orderDiagramElements(Definitions def) {
    if (zOrderEnabled) {
        if (def.getDiagrams() != null) {
            for (BPMNDiagram diagram : def.getDiagrams()) {
                if (diagram != null) {
                    _logger.debug("Sorting diagram elements using DIZorderComparator");
                    BPMNPlane plane = diagram.getPlane();
                    List<DiagramElement> unsortedElements = new ArrayList<DiagramElement>(plane.getPlaneElement());
                    plane.getPlaneElement().clear();
                    Collections.sort(unsortedElements, new DIZorderComparator());
                    plane.getPlaneElement().addAll(unsortedElements);
                    diagram.setPlane(plane);
                }
            }
        }
    }
}
Also used : DiagramElement(org.eclipse.dd.di.DiagramElement) BPMNDiagram(org.eclipse.bpmn2.di.BPMNDiagram) ArrayList(java.util.ArrayList) BPMNPlane(org.eclipse.bpmn2.di.BPMNPlane)

Aggregations

DiagramElement (org.eclipse.dd.di.DiagramElement)9 BPMNShape (org.eclipse.bpmn2.di.BPMNShape)6 BPMNEdge (org.eclipse.bpmn2.di.BPMNEdge)5 BPMNPlane (org.eclipse.bpmn2.di.BPMNPlane)5 ArrayList (java.util.ArrayList)3 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)3 Process (org.eclipse.bpmn2.Process)3 SequenceFlow (org.eclipse.bpmn2.SequenceFlow)3 SubProcess (org.eclipse.bpmn2.SubProcess)3 List (java.util.List)2 RootElement (org.eclipse.bpmn2.RootElement)2 Bounds (org.eclipse.dd.dc.Bounds)2 Point (org.eclipse.dd.dc.Point)2 Entry (java.util.Map.Entry)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 BoundaryEvent (org.eclipse.bpmn2.BoundaryEvent)1 DataObject (org.eclipse.bpmn2.DataObject)1 Definitions (org.eclipse.bpmn2.Definitions)1 FlowNode (org.eclipse.bpmn2.FlowNode)1 Lane (org.eclipse.bpmn2.Lane)1