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());
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
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);
}
}
}
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());
}
}
}
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);
}
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);
}
}
}
}
}
Aggregations