use of org.activiti.bpmn.model.Artifact in project Activiti by Activiti.
the class DefaultProcessDiagramGenerator method generateProcessDiagram.
protected DefaultProcessDiagramCanvas generateProcessDiagram(BpmnModel bpmnModel, String imageType, List<String> highLightedActivities, List<String> highLightedFlows, String activityFontName, String labelFontName, String annotationFontName, ClassLoader customClassLoader, double scaleFactor) {
prepareBpmnModel(bpmnModel);
DefaultProcessDiagramCanvas processDiagramCanvas = initProcessDiagramCanvas(bpmnModel, imageType, activityFontName, labelFontName, annotationFontName, customClassLoader);
// Draw pool shape, if process is participant in collaboration
for (Pool pool : bpmnModel.getPools()) {
GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(pool.getId());
processDiagramCanvas.drawPoolOrLane(pool.getName(), graphicInfo);
}
// Draw lanes
for (Process process : bpmnModel.getProcesses()) {
for (Lane lane : process.getLanes()) {
GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(lane.getId());
processDiagramCanvas.drawPoolOrLane(lane.getName(), graphicInfo);
}
}
// Draw activities and their sequence-flows
for (Process process : bpmnModel.getProcesses()) {
for (FlowNode flowNode : process.findFlowElementsOfType(FlowNode.class)) {
drawActivity(processDiagramCanvas, bpmnModel, flowNode, highLightedActivities, highLightedFlows, scaleFactor);
}
}
// Draw artifacts
for (Process process : bpmnModel.getProcesses()) {
for (Artifact artifact : process.getArtifacts()) {
drawArtifact(processDiagramCanvas, bpmnModel, artifact);
}
List<SubProcess> subProcesses = process.findFlowElementsOfType(SubProcess.class, true);
if (subProcesses != null) {
for (SubProcess subProcess : subProcesses) {
for (Artifact subProcessArtifact : subProcess.getArtifacts()) {
drawArtifact(processDiagramCanvas, bpmnModel, subProcessArtifact);
}
}
}
}
return processDiagramCanvas;
}
use of org.activiti.bpmn.model.Artifact in project Activiti by Activiti.
the class BpmnXMLConverter method convertToXML.
public byte[] convertToXML(BpmnModel model, String encoding) {
try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
XMLOutputFactory xof = XMLOutputFactory.newInstance();
OutputStreamWriter out = new OutputStreamWriter(outputStream, encoding);
XMLStreamWriter writer = xof.createXMLStreamWriter(out);
XMLStreamWriter xtw = new IndentingXMLStreamWriter(writer);
DefinitionsRootExport.writeRootElement(model, xtw, encoding);
CollaborationExport.writePools(model, xtw);
DataStoreExport.writeDataStores(model, xtw);
SignalAndMessageDefinitionExport.writeSignalsAndMessages(model, xtw);
for (Process process : model.getProcesses()) {
if (process.getFlowElements().isEmpty() && process.getLanes().isEmpty()) {
// empty process, ignore it
continue;
}
ProcessExport.writeProcess(process, xtw);
for (FlowElement flowElement : process.getFlowElements()) {
createXML(flowElement, model, xtw);
}
for (Artifact artifact : process.getArtifacts()) {
createXML(artifact, model, xtw);
}
// end process element
xtw.writeEndElement();
}
ErrorExport.writeError(model, xtw);
BPMNDIExport.writeBPMNDI(model, xtw);
// end definitions root element
xtw.writeEndElement();
xtw.writeEndDocument();
xtw.flush();
outputStream.close();
xtw.close();
return outputStream.toByteArray();
} catch (Exception e) {
LOGGER.error("Error writing BPMN XML", e);
throw new XMLException("Error writing BPMN XML", e);
}
}
use of org.activiti.bpmn.model.Artifact 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 already 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 mustbe sure we already 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();
}
use of org.activiti.bpmn.model.Artifact in project Activiti by Activiti.
the class DefaultProcessDiagramGenerator method generateProcessDiagram.
protected DefaultProcessDiagramCanvas generateProcessDiagram(BpmnModel bpmnModel, List<String> highLightedActivities, List<String> highLightedFlows, String activityFontName, String labelFontName, String annotationFontName) {
prepareBpmnModel(bpmnModel);
DefaultProcessDiagramCanvas processDiagramCanvas = initProcessDiagramCanvas(bpmnModel, activityFontName, labelFontName, annotationFontName);
// Draw pool shape, if process is participant in collaboration
for (Pool pool : bpmnModel.getPools()) {
GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(pool.getId());
processDiagramCanvas.drawPoolOrLane(pool.getId(), pool.getName(), graphicInfo);
}
// Draw lanes
for (Process process : bpmnModel.getProcesses()) {
for (Lane lane : process.getLanes()) {
GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(lane.getId());
processDiagramCanvas.drawPoolOrLane(lane.getId(), lane.getName(), graphicInfo);
}
}
// Draw activities and their sequence-flows
for (Process process : bpmnModel.getProcesses()) {
for (FlowNode flowNode : process.findFlowElementsOfType(FlowNode.class)) {
drawActivity(processDiagramCanvas, bpmnModel, flowNode, highLightedActivities, highLightedFlows);
}
}
// Draw artifacts
for (Process process : bpmnModel.getProcesses()) {
for (Artifact artifact : process.getArtifacts()) {
drawArtifact(processDiagramCanvas, bpmnModel, artifact);
}
List<SubProcess> subProcesses = process.findFlowElementsOfType(SubProcess.class, true);
if (subProcesses != null) {
for (SubProcess subProcess : subProcesses) {
for (Artifact subProcessArtifact : subProcess.getArtifacts()) {
drawArtifact(processDiagramCanvas, bpmnModel, subProcessArtifact);
}
}
}
}
return processDiagramCanvas;
}
use of org.activiti.bpmn.model.Artifact in project Activiti by Activiti.
the class DefaultProcessDiagramGenerator method initProcessDiagramCanvas.
protected static DefaultProcessDiagramCanvas initProcessDiagramCanvas(BpmnModel bpmnModel, String activityFontName, String labelFontName, String annotationFontName) {
// We need to calculate maximum values to know how big the image will be in its entirety
double minX = Double.MAX_VALUE;
double maxX = 0;
double minY = Double.MAX_VALUE;
double maxY = 0;
for (Pool pool : bpmnModel.getPools()) {
GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(pool.getId());
minX = graphicInfo.getX();
maxX = graphicInfo.getX() + graphicInfo.getWidth();
minY = graphicInfo.getY();
maxY = graphicInfo.getY() + graphicInfo.getHeight();
}
List<FlowNode> flowNodes = gatherAllFlowNodes(bpmnModel);
for (FlowNode flowNode : flowNodes) {
GraphicInfo flowNodeGraphicInfo = bpmnModel.getGraphicInfo(flowNode.getId());
if (flowNodeGraphicInfo == null) {
continue;
}
// width
if (flowNodeGraphicInfo.getX() + flowNodeGraphicInfo.getWidth() > maxX) {
maxX = flowNodeGraphicInfo.getX() + flowNodeGraphicInfo.getWidth();
}
if (flowNodeGraphicInfo.getX() < minX) {
minX = flowNodeGraphicInfo.getX();
}
// height
if (flowNodeGraphicInfo.getY() + flowNodeGraphicInfo.getHeight() > maxY) {
maxY = flowNodeGraphicInfo.getY() + flowNodeGraphicInfo.getHeight();
}
if (flowNodeGraphicInfo.getY() < minY) {
minY = flowNodeGraphicInfo.getY();
}
for (SequenceFlow sequenceFlow : flowNode.getOutgoingFlows()) {
List<GraphicInfo> graphicInfoList = bpmnModel.getFlowLocationGraphicInfo(sequenceFlow.getId());
if (graphicInfoList != null) {
for (GraphicInfo graphicInfo : graphicInfoList) {
// width
if (graphicInfo.getX() > maxX) {
maxX = graphicInfo.getX();
}
if (graphicInfo.getX() < minX) {
minX = graphicInfo.getX();
}
// height
if (graphicInfo.getY() > maxY) {
maxY = graphicInfo.getY();
}
if (graphicInfo.getY() < minY) {
minY = graphicInfo.getY();
}
}
}
}
}
List<Artifact> artifacts = gatherAllArtifacts(bpmnModel);
for (Artifact artifact : artifacts) {
GraphicInfo artifactGraphicInfo = bpmnModel.getGraphicInfo(artifact.getId());
if (artifactGraphicInfo != null) {
// width
if (artifactGraphicInfo.getX() + artifactGraphicInfo.getWidth() > maxX) {
maxX = artifactGraphicInfo.getX() + artifactGraphicInfo.getWidth();
}
if (artifactGraphicInfo.getX() < minX) {
minX = artifactGraphicInfo.getX();
}
// height
if (artifactGraphicInfo.getY() + artifactGraphicInfo.getHeight() > maxY) {
maxY = artifactGraphicInfo.getY() + artifactGraphicInfo.getHeight();
}
if (artifactGraphicInfo.getY() < minY) {
minY = artifactGraphicInfo.getY();
}
}
List<GraphicInfo> graphicInfoList = bpmnModel.getFlowLocationGraphicInfo(artifact.getId());
if (graphicInfoList != null) {
for (GraphicInfo graphicInfo : graphicInfoList) {
// width
if (graphicInfo.getX() > maxX) {
maxX = graphicInfo.getX();
}
if (graphicInfo.getX() < minX) {
minX = graphicInfo.getX();
}
// height
if (graphicInfo.getY() > maxY) {
maxY = graphicInfo.getY();
}
if (graphicInfo.getY() < minY) {
minY = graphicInfo.getY();
}
}
}
}
int nrOfLanes = 0;
for (Process process : bpmnModel.getProcesses()) {
for (Lane l : process.getLanes()) {
nrOfLanes++;
GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(l.getId());
if (graphicInfo != null) {
// width
if (graphicInfo.getX() + graphicInfo.getWidth() > maxX) {
maxX = graphicInfo.getX() + graphicInfo.getWidth();
}
if (graphicInfo.getX() < minX) {
minX = graphicInfo.getX();
}
// height
if (graphicInfo.getY() + graphicInfo.getHeight() > maxY) {
maxY = graphicInfo.getY() + graphicInfo.getHeight();
}
if (graphicInfo.getY() < minY) {
minY = graphicInfo.getY();
}
}
}
}
// Special case, see https://activiti.atlassian.net/browse/ACT-1431
if (flowNodes.isEmpty() && bpmnModel.getPools().isEmpty() && nrOfLanes == 0) {
// Nothing to show
minX = 0;
minY = 0;
}
return new DefaultProcessDiagramCanvas((int) maxX + 10, (int) maxY + 10, (int) minX, (int) minY, activityFontName, labelFontName, annotationFontName);
}
Aggregations