Survive by day and develop by night.
talk for import biz , show your perfect code,full busy,skip hardness,make a better result,wait for change,challenge Survive.
happy for hardess to solve denpendies.

org.activiti.bpmn是一个非常常见的需求。
private static final String STYLE_EVENT = "styleEvent";private static final String STYLE_GATEWAY = "styleGateway";private static final String STYLE_SEQUENCEFLOW = "styleSequenceFlow";private static final String STYLE_BOUNDARY_SEQUENCEFLOW = "styleBoundarySequenceFlow";protected BpmnModel bpmnModel;protected int eventSize = 30;protected int gatewaySize = 40;protected int taskWidth = 100;protected int taskHeight = 60;protected int subProcessMargin = 20;protected mxGraph graph;protected Object cellParent;protected Map associations;protected Map textAnnotations;protected Map sequenceFlows;protected List boundaryEvents;protected Map handledFlowElements;protected Map handledArtifacts;protected Map generatedVertices;protected Map generatedSequenceFlowEdges;protected Map generatedAssociationEdges;public BpmnAutoLayout(BpmnModel bpmnModel) {this.bpmnModel = bpmnModel;}public void execute() {// Reset any previous DI informationbpmnModel.getLocationMap().clear();bpmnModel.getFlowLocationMap().clear();// Generate DI for each processfor (Process process : bpmnModel.getProcesses()) {layout(process);// Operations that can only be done after all elements have received// DItranslateNestedSubprocesses(process);}}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();handledArtifacts = new HashMap();generatedVertices = new HashMap();generatedSequenceFlowEdges = new HashMap();generatedAssociationEdges = new HashMap();associations = new HashMap(); //Associations are gathered and processed afterwards, because we must be sure we already found source and targettextAnnotations = new HashMap(); // Text Annotations are gathered and processed afterwards, because we must be sure we already found the parent.sequenceFlows = new HashMap(); // Sequence flow are gathered and processed afterwards,because we mustbe sure we already found source and targetboundaryEvents = new ArrayList(); // Boundary events are gathered and processed afterwards, because we must be sure we have its parent// Process all elementsfor (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 artifactsfor (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 elementshandleBoundaryEvents();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();}private void handleTextAnnotation(TextAnnotation artifact) {ensureArtifactIdSet(artifact);textAnnotations.put(artifact.getId(), artifact);}// BPMN element handlingprotected void ensureSequenceFlowIdSet(SequenceFlow sequenceFlow) {// We really must have ids for sequence flow to be able to generate// stuffif (sequenceFlow.getId() == null) {sequenceFlow.setId("sequenceFlow-" + UUID.randomUUID().toString());}}protected void ensureArtifactIdSet(Artifact artifact) {// We really must have ids for sequence flow to be able to generate stuffif (artifact.getId() == null) {artifact.setId("artifact-" + UUID.randomUUID().toString());}}protected void handleAssociation(Association association) {ensureArtifactIdSet(association);associations.put(association.getId(), association);}protected void handleSequenceFlow(SequenceFlow sequenceFlow) {ensureSequenceFlowIdSet(sequenceFlow);sequenceFlows.put(sequenceFlow.getId(), sequenceFlow);}protected void handleEvent(FlowElement flowElement) {// Boundary events are an exception to the general way of drawing an// eventif (flowElement instanceof BoundaryEvent) {boundaryEvents.add((BoundaryEvent) flowElement);} else {createEventVertex(flowElement);}}protected void handleActivity(FlowElement flowElement) {Object activityVertex = graph.insertVertex(cellParent, flowElement.getId(), "", 0, 0, taskWidth, taskHeight);generatedVertices.put(flowElement.getId(), activityVertex);}protected void handleSubProcess(FlowElement flowElement) {BpmnAutoLayout bpmnAutoLayout = new BpmnAutoLayout(bpmnModel);bpmnAutoLayout.layout((SubProcess) flowElement);


public class BPMNLayout extends mxGraphLayout {// NEWprotected BpmnAutoLayout bpmnAutoLayout;public void setBpmnAutoLayout(BpmnAutoLayout bpmnAutoLayout) {this.bpmnAutoLayout = bpmnAutoLayout;}// NEW/*** Specifies the orientation of the layout. Default is true.*/protected boolean horizontal;/*** Specifies if edge directions should be inverted. Default is false.*/protected boolean invert;/*** If the parent should be resized to match the width/height of the tree. Default is true.*/protected boolean resizeParent = true;/*** Specifies if the tree should be moved to the top, left corner if it is inside a top-level layer. Default is true.*/protected boolean moveTree = true;/*** Specifies if all edge points of traversed edges should be removed. Default is true.*/protected boolean resetEdges = true;/*** Holds the levelDistance. Default is 40.*/protected int levelDistance = 40;/*** Holds the nodeDistance. Default is 20.*/protected int nodeDistance = 20;/**** @param graph*/public BPMNLayout(mxGraph graph) {this(graph, true);}/**** @param graph* @param horizontal*/public BPMNLayout(mxGraph graph, boolean horizontal) {this(graph, horizontal, false);}/**** @param graph* @param horizontal* @param invert*/public BPMNLayout(mxGraph graph, boolean horizontal, boolean invert) {super(graph);setUseBoundingBox(false);this.horizontal = horizontal;this.invert = invert;}public mxGraph getGraph() {return (mxGraph) graph;}/*** Returns a boolean indicating if the given mxCell should be ignored as a vertex. This returns true if the cell has no connections.** @param vertex* Object that represents the vertex to be tested.* @return Returns true if the vertex should be ignored.*/public boolean isVertexIgnored(Object vertex) {return super.isVertexIgnored(vertex) || graph.isSwimlane(vertex) || graph.getModel().getGeometry(vertex).isRelative() || graph.getConnections(vertex).length == 0;}/*** @return the horizontal*/public boolean isHorizontal() {return horizontal;}/*** @param horizontal* the horizontal to set*/public void setHorizontal(boolean horizontal) {this.horizontal = horizontal;}/*** @return the invert*/public boolean isInvert() {return invert;}/*** @param invert* the invert to set*/public void setInvert(boolean invert) {this.invert = invert;}/*** @return the resizeParent*/public boolean isResizeParent() {return resizeParent;}/*** @param resizeParent* the resizeParent to set*/public void setResizeParent(boolean resizeParent) {this.resizeParent = resizeParent;}/*** @return the moveTree*/public boolean isMoveTree() {return moveTree;}/*** @param moveTree* the moveTree to set*/public void setMoveTree(boolean moveTree) {this.moveTree = moveTree;}/*** @return the resetEdges*/public boolean isResetEdges() {return resetEdges;}/*** @param resetEdges* the resetEdges to set*/public void setResetEdges(boolean resetEdges) {this.resetEdges = resetEdges;}/*** @return the levelDistance*/public int getLevelDistance() {return levelDistance;}/*** @param levelDistance* the levelDistance to set*/public void setLevelDistance(int levelDistance) {this.levelDistance = levelDistance;}/*** @return the nodeDistance*/public int getNodeDistance() {return nodeDistance;}/*** @param nodeDistance* the nodeDistance to set*/public void setNodeDistance(int nodeDistance) {this.nodeDistance = nodeDistance;}public void execute(Object parent) {mxIGraphModel model = graph.getModel();List


[1]. https://www.activiti.org/
欢迎阅读,各位老铁,如果对你有帮助,点个赞加个关注呗!~
上一篇:python——数理统计,概率
下一篇:口琴简谱上的^o是什么意思