double theMaxX = 0;
double theMinY = java.lang.Double.MAX_VALUE;
double theMaxY = 0;
for (Pool pool : bpmnModel.getPools()) {
GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(pool.getId());
theMinX = graphicInfo.getX();
theMaxX = graphicInfo.getX() + graphicInfo.getWidth();
theMinY = graphicInfo.getY();
theMaxY = graphicInfo.getY() + graphicInfo.getHeight();
}
List<FlowNode> flowNodes = gatherAllFlowNodes(bpmnModel);
for (FlowNode flowNode : flowNodes) {
GraphicInfo flowNodeGraphicInfo = bpmnModel.getGraphicInfo(flowNode
.getId());
// width
if ((flowNodeGraphicInfo.getX() + flowNodeGraphicInfo.getWidth()) > theMaxX) {
theMaxX = flowNodeGraphicInfo.getX()
+ flowNodeGraphicInfo.getWidth();
}
if (flowNodeGraphicInfo.getX() < theMinX) {
theMinX = flowNodeGraphicInfo.getX();
}
// height
if ((flowNodeGraphicInfo.getY() + flowNodeGraphicInfo.getHeight()) > theMaxY) {
theMaxY = flowNodeGraphicInfo.getY()
+ flowNodeGraphicInfo.getHeight();
}
if (flowNodeGraphicInfo.getY() < theMinY) {
theMinY = flowNodeGraphicInfo.getY();
}
for (SequenceFlow sequenceFlow : flowNode.getOutgoingFlows()) {
List<GraphicInfo> graphicInfoList = bpmnModel
.getFlowLocationGraphicInfo(sequenceFlow.getId());
for (GraphicInfo graphicInfo : graphicInfoList) {
// width
if (graphicInfo.getX() > theMaxX) {
theMaxX = graphicInfo.getX();
}
if (graphicInfo.getX() < theMinX) {
theMinX = graphicInfo.getX();
}
// height
if (graphicInfo.getY() > theMaxY) {
theMaxY = graphicInfo.getY();
}
if (graphicInfo.getY() < theMinY) {
theMinY = 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()) > theMaxX) {
theMaxX = artifactGraphicInfo.getX()
+ artifactGraphicInfo.getWidth();
}
if (artifactGraphicInfo.getX() < theMinX) {
theMinX = artifactGraphicInfo.getX();
}
// height
if ((artifactGraphicInfo.getY() + artifactGraphicInfo
.getHeight()) > theMaxY) {
theMaxY = artifactGraphicInfo.getY()
+ artifactGraphicInfo.getHeight();
}
if (artifactGraphicInfo.getY() < theMinY) {
theMinY = artifactGraphicInfo.getY();
}
}
List<GraphicInfo> graphicInfoList = bpmnModel
.getFlowLocationGraphicInfo(artifact.getId());
if (graphicInfoList != null) {
for (GraphicInfo graphicInfo : graphicInfoList) {
// width
if (graphicInfo.getX() > theMaxX) {
theMaxX = graphicInfo.getX();
}
if (graphicInfo.getX() < theMinX) {
theMinX = graphicInfo.getX();
}
// height
if (graphicInfo.getY() > theMaxY) {
theMaxY = graphicInfo.getY();
}
if (graphicInfo.getY() < theMinY) {
theMinY = graphicInfo.getY();
}
}
}
}
int nrOfLanes = 0;
for (org.activiti.bpmn.model.Process process : bpmnModel.getProcesses()) {
for (Lane l : process.getLanes()) {
nrOfLanes++;
GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(l.getId());
// // width
if ((graphicInfo.getX() + graphicInfo.getWidth()) > theMaxX) {
theMaxX = graphicInfo.getX() + graphicInfo.getWidth();
}
if (graphicInfo.getX() < theMinX) {
theMinX = graphicInfo.getX();
}
// height
if ((graphicInfo.getY() + graphicInfo.getHeight()) > theMaxY) {
theMaxY = graphicInfo.getY() + graphicInfo.getHeight();
}
if (graphicInfo.getY() < theMinY) {
theMinY = graphicInfo.getY();
}
}
}
// Special case, see http://jira.codehaus.org/browse/ACT-1431