Skip to content

Commit

Permalink
feat(drd): add padding when getting orientation
Browse files Browse the repository at this point in the history
* padding helps prevent ugly connections
  • Loading branch information
philippfromme committed Apr 2, 2020
1 parent 0bd1dc9 commit d232ec8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
4 changes: 3 additions & 1 deletion packages/dmn-js-drd/src/features/modeling/DrdLayouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {

import { is } from 'dmn-js-shared/lib/util/ModelUtil';

export var ORIENTATION_PADDING = 25;

var ADDITIONAL_WAYPOINT_DISTANCE = 20;


Expand All @@ -33,7 +35,7 @@ DrdLayouter.prototype.layoutConnection = function(connection, hints) {
waypoints = hints.waypoints || connection.waypoints || [],
connectionStart = hints.connectionStart,
connectionEnd = hints.connectionEnd,
orientation = getOrientation(source, target);
orientation = getOrientation(source, target, ORIENTATION_PADDING);

if (!connectionStart) {
connectionStart = getConnectionDocking(waypoints[ 0 ], source);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {
getOrientation
} from 'diagram-js/lib/layout/LayoutUtil';

import { ORIENTATION_PADDING } from '../DrdLayouter';

import {
assign,
forEach
Expand Down Expand Up @@ -47,7 +49,7 @@ export default function LayoutConnectionBehavior(injector, layouter, modeling, r
return;
}

var orientation = getOrientation(source, target);
var orientation = getOrientation(source, target, ORIENTATION_PADDING);

if (!context.hints) {
context.hints = {};
Expand Down Expand Up @@ -128,11 +130,11 @@ export default function LayoutConnectionBehavior(injector, layouter, modeling, r
return;
}

var orientation = getOrientation(source, target);
var orientation = getOrientation(source, target, ORIENTATION_PADDING);

// update all information requirements with same orientation
var informationRequirements = target.incoming.filter(incoming => {
var incomingOrientation = getOrientation(incoming.source, incoming.target);
var incomingOrientation = getOrientation(incoming.source, incoming.target, ORIENTATION_PADDING);

return is(incoming, 'dmn:InformationRequirement')
&& isSameOrientation(incomingOrientation, orientation);
Expand All @@ -155,11 +157,11 @@ export default function LayoutConnectionBehavior(injector, layouter, modeling, r
return;
}

var orientation = getOrientation(source, target);
var orientation = getOrientation(source, target, ORIENTATION_PADDING);

// update all information requirements with same orientation except reconnected
var informationRequirements = target.incoming.filter(incoming => {
var incomingOrientation = getOrientation(incoming.source, incoming.target);
var incomingOrientation = getOrientation(incoming.source, incoming.target, ORIENTATION_PADDING);

return incoming !== connection
&& is(incoming, 'dmn:InformationRequirement')
Expand Down Expand Up @@ -323,7 +325,8 @@ function getInformationRequirementsByOrientation(target, informationRequirements
var incomingInformationRequirementsByOrientation = {};

informationRequirements.forEach(function(incoming) {
var orientation = getOrientation(incoming.source, target).split('-').shift();
var orientation =
getOrientation(incoming.source, target, ORIENTATION_PADDING).split('-').shift();

if (!incomingInformationRequirementsByOrientation[ orientation ]) {
incomingInformationRequirementsByOrientation[ orientation ] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {
getOrientation
} from 'diagram-js/lib/layout/LayoutUtil';

import { ORIENTATION_PADDING } from '../modeling/DrdLayouter';

import {
isAny
} from 'dmn-js-shared/lib/util/ModelUtil';
Expand Down Expand Up @@ -47,7 +49,7 @@ export default function DrdBendpointSnapping(eventBus) {

var reconnect = type === RECONNECT_START || type === RECONNECT_END;

var orientation = getOrientation(source, target);
var orientation = getOrientation(source, target, ORIENTATION_PADDING);

if (reconnect && hover === source) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {
getOrientation
} from 'diagram-js/lib/layout/LayoutUtil';

import { ORIENTATION_PADDING } from '../modeling/DrdLayouter';

var LOW_PRIORITY = 250;


Expand All @@ -20,7 +22,7 @@ export default function DrdConnectSnapping(eventBus) {
target = context.target;

if (canExecute && canExecute.type === 'dmn:InformationRequirement') {
var orientation = getOrientation(source, target);
var orientation = getOrientation(source, target, ORIENTATION_PADDING);

// snap source
context.connectionStart = getMid(source);
Expand Down

0 comments on commit d232ec8

Please sign in to comment.