definitions = processDefinitionBehavior.getDefinitions();
List<BPMNDiagram> BPMNDiagramList = definitions.getDiagrams();
SvgBench svg = new SvgBench();
float maxX=0;
float maxY=0;
float minY=0;
float minX=0;
for (BPMNDiagram bpmnDiagram : BPMNDiagramList) {
//for (int i = bpmnDiagram.getPlane().getPlaneElement().size()-1; i >= 0; i--) {
// DiagramElement diagramElement = bpmnDiagram.getPlane().getPlaneElement().get(i);
//}
for (DiagramElement diagramElement : bpmnDiagram.getPlane().getPlaneElement()) {
if (diagramElement instanceof BPMNShape) {
BPMNShape bpmnShape = (BPMNShape) diagramElement;
if(bpmnShape.getBounds().getX()+bpmnShape.getBounds().getWidth()>maxX)
{
maxX=bpmnShape.getBounds().getX()+bpmnShape.getBounds().getWidth();
}
if(bpmnShape.getBounds().getY()+bpmnShape.getBounds().getHeight()>maxY)
{
maxY=bpmnShape.getBounds().getY()+bpmnShape.getBounds().getHeight();
}
if(minY==0){
minY=bpmnShape.getBounds().getY();
}else{
if(bpmnShape.getBounds().getY()<minY)
{
minY=bpmnShape.getBounds().getY();
}
}
if(minX==0){
minX=bpmnShape.getBounds().getX();
}else{
if(bpmnShape.getBounds().getX()<minX)
{
minX=bpmnShape.getBounds().getX();
}
}
BaseElement bpmnElement=getBaseElement(bpmnShape.getBpmnElement());
if(bpmnElement==null){
continue;
}
if (bpmnElement instanceof StartEvent) {
String startEventSVG = startEventToSVG(bpmnShape);
svg.addChildren(startEventSVG);
}
if (bpmnElement instanceof EndEvent) {
String endEventSVG = endEventToSVG(bpmnShape);
svg.addChildren(endEventSVG);
}
if (bpmnElement instanceof IntermediateCatchEventBehavior) {
String intermediateTimerEventSVG = intermediateTimerEventToSVG(bpmnShape);
svg.addChildren(intermediateTimerEventSVG);
}
if (bpmnElement instanceof Task) {
String taskSVG = taskToSVG(bpmnShape);
svg.addChildren(taskSVG);
}
if (bpmnElement instanceof CallActivity) {
String taskSVG = callActivityToSVG(bpmnShape);
svg.addChildren(taskSVG);
}
if (bpmnElement instanceof Gateway) {
String gatewaySVG = gatewayToSVG(bpmnShape);
svg.addChildren(gatewaySVG);
}
if(bpmnElement instanceof Lane)
{
String laneSVG = laneToSVG(bpmnShape);
svg.addChildren(laneSVG);
}
if(bpmnElement instanceof Participant)
{
String laneSVG = participantToSVG(bpmnShape);
svg.addChildren(laneSVG);
}
if(bpmnElement instanceof SubProcess)
{
String subProcessSVG = subProcessToSVG(bpmnShape);
svg.addChildren(subProcessSVG);
}
if(bpmnElement instanceof Group)
{
String subProcessSVG = groupToSVG(bpmnShape,bpmnElement);
svg.addChildren(subProcessSVG);
}
if(bpmnElement instanceof DataObject)
{
String dataObjectSVG= dataObjectToSVG(bpmnShape,bpmnElement);
svg.addChildren(dataObjectSVG);
}
//DataStoreReference //DataInput //DataOutput //Message
if(bpmnElement instanceof DataStoreReference)
{
String dataStoreReferenceSVG= dataStoreReferenceToSVG(bpmnShape,bpmnElement);
svg.addChildren(dataStoreReferenceSVG);
}
if(bpmnElement instanceof DataInput)
{
String dataInputSVG= dataInputToSVG(bpmnShape,bpmnElement);
svg.addChildren(dataInputSVG);
}
if(bpmnElement instanceof DataOutput)
{
String dataOutputSVG= dataOutputToSVG(bpmnShape,bpmnElement);
svg.addChildren(dataOutputSVG);
}
if(bpmnElement instanceof Message)
{
String messageSVG= messageToSVG(bpmnShape,bpmnElement);
svg.addChildren(messageSVG);
}
if(bpmnElement instanceof TextAnnotation)
{
String messageSVG= textAnnotationToSVG(bpmnShape,bpmnElement);
svg.addChildren(messageSVG);
}
if(bpmnElement instanceof BoundaryEvent)
{
String messageSVG= boundaryEventToSVG(bpmnShape,bpmnElement);
svg.addChildren(messageSVG);
}
}
if (diagramElement instanceof BPMNEdge) {
BPMNEdge bpmnEdge = (BPMNEdge) diagramElement;
List<Point> pointList = bpmnEdge.getWaypoint();
for (Point point : pointList) {
if(point.getX()>maxX)
{
maxX=point.getX();
}
if(point.getY()>maxY)
{
maxY=point.getY();
}
}
BaseElement bpmnElement=getBaseElement(bpmnEdge.getBpmnElement());
if (bpmnElement instanceof SequenceFlow) {
String sequenceFlowSVG = sequenceFlowToSVG(bpmnEdge);
svg.addEdge(sequenceFlowSVG);
}
if (bpmnElement instanceof Association) {
String associationSVG = associationToSVG(bpmnEdge);
svg.addEdge(associationSVG);
}
if (bpmnElement instanceof MessageFlow) {
String messageFlowSVG = messageFlowToSVG(bpmnEdge);
svg.addChildren(messageFlowSVG);
}
}
}
}
svg.setWidth(maxX+30);
svg.setHight(maxY+70);
svg.setMhight(minY);
svg.setMwidth(minX);
return svg.release();
}