Search in sources :

Example 1 with Task

use of org.activiti.bpmn.model.Task in project Activiti by Activiti.

the class BpmnAutoLayout method layout.

protected void layout(FlowElementsContainer flowElementsContainer) {
    graph = new mxGraph();
    cellParent = graph.getDefaultParent();
    graph.getModel().beginUpdate();
    // Subprocesses are handled in a new instance of BpmnAutoLayout, hence they instantiations of new maps here.
    handledFlowElements = new HashMap<String, FlowElement>();
    handledArtifacts = new HashMap<String, Artifact>();
    generatedVertices = new HashMap<String, Object>();
    generatedSequenceFlowEdges = new HashMap<String, Object>();
    generatedAssociationEdges = new HashMap<String, Object>();
    //Associations are gathered and processed afterwards, because we must be sure we alreadydiv found source and target
    associations = new HashMap<String, Association>();
    // Text Annotations are gathered and processed afterwards, because we must be sure we already found the parent.
    textAnnotations = new HashMap<String, TextAnnotation>();
    // Sequence flow are gathered and processed afterwards, because we must be sure we alreadt found source and target
    sequenceFlows = new HashMap<String, SequenceFlow>();
    // Boundary events are gathered and processed afterwards, because we must be sure we have its parent
    boundaryEvents = new ArrayList<BoundaryEvent>();
    // Process all elements
    for (FlowElement flowElement : flowElementsContainer.getFlowElements()) {
        if (flowElement instanceof SequenceFlow) {
            handleSequenceFlow((SequenceFlow) flowElement);
        } else if (flowElement instanceof Event) {
            handleEvent(flowElement);
        } else if (flowElement instanceof Gateway) {
            createGatewayVertex(flowElement);
        } else if (flowElement instanceof Task || flowElement instanceof CallActivity) {
            handleActivity(flowElement);
        } else if (flowElement instanceof SubProcess) {
            handleSubProcess(flowElement);
        }
        handledFlowElements.put(flowElement.getId(), flowElement);
    }
    // process artifacts
    for (Artifact artifact : flowElementsContainer.getArtifacts()) {
        if (artifact instanceof Association) {
            handleAssociation((Association) artifact);
        } else if (artifact instanceof TextAnnotation) {
            handleTextAnnotation((TextAnnotation) artifact);
        }
        handledArtifacts.put(artifact.getId(), artifact);
    }
    // Process gathered elements
    handleBoundaryEvents();
    handleSequenceFlow();
    handleAssociations();
    // All elements are now put in the graph. Let's layout them!
    CustomLayout layout = new CustomLayout(graph, SwingConstants.WEST);
    layout.setIntraCellSpacing(100.0);
    layout.setResizeParent(true);
    layout.setFineTuning(true);
    layout.setParentBorder(20);
    layout.setMoveParent(true);
    layout.setDisableEdgeStyle(false);
    layout.setUseBoundingBox(true);
    layout.execute(graph.getDefaultParent());
    graph.getModel().endUpdate();
    generateDiagramInterchangeElements();
}
Also used : SubProcess(org.activiti.bpmn.model.SubProcess) Task(org.activiti.bpmn.model.Task) BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) SequenceFlow(org.activiti.bpmn.model.SequenceFlow) com.mxgraph.view.mxGraph(com.mxgraph.view.mxGraph) CallActivity(org.activiti.bpmn.model.CallActivity) Artifact(org.activiti.bpmn.model.Artifact) Association(org.activiti.bpmn.model.Association) FlowElement(org.activiti.bpmn.model.FlowElement) Gateway(org.activiti.bpmn.model.Gateway) Event(org.activiti.bpmn.model.Event) BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) DataObject(org.activiti.bpmn.model.DataObject) TextAnnotation(org.activiti.bpmn.model.TextAnnotation)

Aggregations

com.mxgraph.view.mxGraph (com.mxgraph.view.mxGraph)1 Artifact (org.activiti.bpmn.model.Artifact)1 Association (org.activiti.bpmn.model.Association)1 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)1 CallActivity (org.activiti.bpmn.model.CallActivity)1 DataObject (org.activiti.bpmn.model.DataObject)1 Event (org.activiti.bpmn.model.Event)1 FlowElement (org.activiti.bpmn.model.FlowElement)1 Gateway (org.activiti.bpmn.model.Gateway)1 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)1 SubProcess (org.activiti.bpmn.model.SubProcess)1 Task (org.activiti.bpmn.model.Task)1 TextAnnotation (org.activiti.bpmn.model.TextAnnotation)1