Search in sources :

Example 6 with BPMNEdge

use of org.eclipse.bpmn2.di.BPMNEdge 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 7 with BPMNEdge

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

the class Bpmn2JsonUnmarshaller method updateEdgeBoundsInContainers.

public void updateEdgeBoundsInContainers(FlowElementsContainer container, SequenceFlow sq, BPMNPlane plane, BPMNEdge edge) {
    for (FlowElement fele : container.getFlowElements()) {
        // dont do this if its on process level
        if (!(container instanceof Process)) {
            if (fele.getId().equals(sq.getSourceRef().getId())) {
                Bounds sourceBounds = getBoundsForElement(sq.getSourceRef(), plane);
                List<Point> edgePoints = edge.getWaypoint();
                if (edgePoints != null && edgePoints.size() > 1) {
                    if (sourceBounds != null) {
                        Point first = edgePoints.get(0);
                        first.setX(first.getX() + getBoundsForElement(container, plane).getX() + (sourceBounds.getWidth() / 2));
                        first.setY(first.getY() + getBoundsForElement(container, plane).getY());
                    }
                }
            } else if (fele.getId().equals(sq.getTargetRef().getId())) {
                Bounds targetBounds = getBoundsForElement(sq.getTargetRef(), plane);
                List<Point> edgePoints = edge.getWaypoint();
                if (edgePoints != null && edgePoints.size() > 1) {
                    if (targetBounds != null) {
                        Point last = edgePoints.get(edgePoints.size() - 1);
                        last.setX(last.getX() + getBoundsForElement(container, plane).getX() - (targetBounds.getWidth() / 2));
                        last.setY(last.getY() + getBoundsForElement(container, plane).getY());
                    }
                }
            }
        }
        if (fele instanceof FlowElementsContainer) {
            updateEdgeBoundsInContainers((FlowElementsContainer) fele, sq, plane, edge);
        }
    }
}
Also used : FlowElement(org.eclipse.bpmn2.FlowElement) Bounds(org.eclipse.dd.dc.Bounds) FlowElementsContainer(org.eclipse.bpmn2.FlowElementsContainer) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) Process(org.eclipse.bpmn2.Process) ArrayList(java.util.ArrayList) List(java.util.List) Point(org.eclipse.dd.dc.Point)

Example 8 with BPMNEdge

use of org.eclipse.bpmn2.di.BPMNEdge 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 9 with BPMNEdge

use of org.eclipse.bpmn2.di.BPMNEdge 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 10 with BPMNEdge

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

the class SequenceFlowPropertyReader method getSourcePosition.

private Point2D getSourcePosition(String edgeId, String sourceId) {
    BPMNEdge bpmnEdge = definitionResolver.getEdge(edgeId).get();
    Bounds sourceBounds = definitionResolver.getShape(sourceId).getBounds();
    List<Point> waypoint = bpmnEdge.getWaypoint();
    return waypoint.isEmpty() ? sourcePosition(sourceBounds) : offsetPosition(sourceBounds, waypoint.get(0));
}
Also used : Bounds(org.eclipse.dd.dc.Bounds) Point(org.eclipse.dd.dc.Point) BPMNEdge(org.eclipse.bpmn2.di.BPMNEdge)

Aggregations

BPMNEdge (org.eclipse.bpmn2.di.BPMNEdge)12 Bounds (org.eclipse.dd.dc.Bounds)9 Point (org.eclipse.dd.dc.Point)9 BPMNShape (org.eclipse.bpmn2.di.BPMNShape)6 DiagramElement (org.eclipse.dd.di.DiagramElement)6 ArrayList (java.util.ArrayList)4 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)4 Process (org.eclipse.bpmn2.Process)4 SubProcess (org.eclipse.bpmn2.SubProcess)4 List (java.util.List)3 Entry (java.util.Map.Entry)3 DataObject (org.eclipse.bpmn2.DataObject)3 SequenceFlow (org.eclipse.bpmn2.SequenceFlow)3 BPMNPlane (org.eclipse.bpmn2.di.BPMNPlane)3 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)3 LinkedHashMap (java.util.LinkedHashMap)2 RootElement (org.eclipse.bpmn2.RootElement)2 TextAnnotation (org.eclipse.bpmn2.TextAnnotation)2 DcFactory (org.eclipse.dd.dc.DcFactory)2 BoundaryEvent (org.eclipse.bpmn2.BoundaryEvent)1