mirror of
https://github.com/sartography/bpmn-js.git
synced 2025-02-17 11:26:42 +00:00
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
|
// manhattan layout sequence / message flows
|
||||||
if (is(connection, 'bpmn:MessageFlow')) {
|
if (is(connection, 'bpmn:MessageFlow')) {
|
||||||
manhattanOptions = {
|
manhattanOptions = getMessageFlowManhattanOptions(source, target);
|
||||||
preferredLayouts: [ 'v:v' ]
|
|
||||||
};
|
|
||||||
|
|
||||||
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
|
} 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) {
|
function getConnectionDocking(point, shape) {
|
||||||
return point ? (point.original || point) : getMid(shape);
|
return point ? (point.original || point) : getMid(shape);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user