chore(modeling/BpmnLayouter): simplify manhattan layout logic
This commit is contained in:
parent
905ee6f667
commit
cdacc69a3d
|
@ -61,41 +61,8 @@ BpmnLayouter.prototype.layoutConnection = function(connection, hints) {
|
|||
|
||||
// manhattan layout sequence / message flows
|
||||
if (is(connection, 'bpmn:MessageFlow')) {
|
||||
manhattanOptions = {
|
||||
preferredLayouts: [ 'v:v' ]
|
||||
};
|
||||
manhattanOptions = getMessageFlowManhattanOptions(source, target);
|
||||
|
||||
if (is(target, 'bpmn:Participant')) {
|
||||
manhattanOptions = {
|
||||
preferredLayouts: [ 'straight', 'v:v' ]
|
||||
};
|
||||
}
|
||||
|
||||
if (isExpandedSubProcess(target)) {
|
||||
manhattanOptions = {
|
||||
preferredLayouts: [ 'straight', 'v:v' ]
|
||||
};
|
||||
}
|
||||
|
||||
if (isExpandedSubProcess(source) && is(target, 'bpmn:FlowNode')) {
|
||||
manhattanOptions = {
|
||||
preferredLayouts: [ 'straight', 'v:v' ],
|
||||
preserveDocking: isExpandedSubProcess(target) ? 'source' : 'target'
|
||||
};
|
||||
}
|
||||
|
||||
if (is(source, 'bpmn:Participant') && is(target, 'bpmn:FlowNode')) {
|
||||
manhattanOptions = {
|
||||
preferredLayouts: [ 'straight', 'v:v' ],
|
||||
preserveDocking: 'target'
|
||||
};
|
||||
}
|
||||
|
||||
if (is(target, 'bpmn:Event')) {
|
||||
manhattanOptions = {
|
||||
preferredLayouts: [ 'v:v' ]
|
||||
};
|
||||
}
|
||||
} else
|
||||
|
||||
|
||||
|
@ -174,6 +141,50 @@ function getAttachOrientation(attachedElement) {
|
|||
}
|
||||
|
||||
|
||||
function getMessageFlowManhattanOptions(source, target) {
|
||||
return {
|
||||
preferredLayouts: [ 'straight', 'v:v' ],
|
||||
preserveDocking: getMessageFlowPreserveDocking(source, target)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
function getMessageFlowPreserveDocking(source, target) {
|
||||
|
||||
// (1) docking element connected to participant has precedence
|
||||
|
||||
if (is(target, 'bpmn:Participant')) {
|
||||
return 'source';
|
||||
}
|
||||
|
||||
if (is(source, 'bpmn:Participant')) {
|
||||
return 'target';
|
||||
}
|
||||
|
||||
// (2) docking element connected to expanded sub-process has precedence
|
||||
|
||||
if (isExpandedSubProcess(target)) {
|
||||
return 'source';
|
||||
}
|
||||
|
||||
if (isExpandedSubProcess(source)) {
|
||||
return 'target';
|
||||
}
|
||||
|
||||
// (3) docking event has precedence
|
||||
|
||||
if (is(target, 'bpmn:Event')) {
|
||||
return 'target';
|
||||
}
|
||||
|
||||
if (is(source, 'bpmn:Event')) {
|
||||
return 'source';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
function getConnectionDocking(point, shape) {
|
||||
return point ? (point.original || point) : getMid(shape);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue