Skip to content

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
Issue #365
  • Loading branch information
rsoika committed Dec 7, 2024
1 parent ca88904 commit 3078cbc
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions open-bpmn.glsp-client/open-bpmn-glsp/src/bpmn-manhattan-router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@
import {
Action,
Bounds,
findParentByFeature,
GLSPManhattanEdgeRouter,
GModelElement,
GNode,
GRoutableElement,
isConnectable,
isRoutable,
ManhattanRouterOptions,
MouseListener,
Point,
RoutedPoint,
translatePoint
} from '@eclipse-glsp/client';
import { isBPMNNode } from '@open-bpmn/open-bpmn-model';
import { inject, injectable } from 'inversify';

/**
Expand Down Expand Up @@ -70,6 +71,14 @@ export class BPMNManhattanRouter extends GLSPManhattanEdgeRouter {
this.debug('├── update currentDelta = ' + delta.x + "," + delta.y + ' for elements: ' + edgeIds.join(', '));
}

protected override getOptions(edge: GRoutableElement): ManhattanRouterOptions {
return {
standardDistance: 20, // 20
minimalPointDistance: 3,
selfEdgeOffset: 0.25 // 0.25
};
}

/**
* Main routing method that calculates the path for an edge. This override handles the following cases:
* 1. Default routing when no movement is happening
Expand Down Expand Up @@ -257,28 +266,37 @@ export class BPMNRouterMoveListener extends MouseListener {
* @param event Mouse event
*/
override mouseDown(target: GModelElement, event: MouseEvent): Action[] {


if (event.button === 0) { // left mouse button
// Only track connectable elements
if (isConnectable(target)) {
let targetElement = target;
if (!isBPMNNode(targetElement)) {
const bpmnNode = findParentByFeature(targetElement, isBPMNNode);
if (bpmnNode) {
targetElement = bpmnNode;
}
}
// do we have a BPMN node?
if (isBPMNNode(targetElement)) {
this.isDragging = true;
this.elementId = target.id;
this.elementId = targetElement.id;
this.lastPosition = {
x: event.clientX,
y: event.clientY
};
}
if (target instanceof GNode) {
// Collect all affected edges
// console.log('found: ' + targetElement.id);
this.affectedEdges = [];
if (target.incomingEdges) {
target.incomingEdges.forEach(edge => {
if (targetElement.incomingEdges) {
targetElement.incomingEdges.forEach(edge => {
if (isRoutable(edge)) {
this.affectedEdges.push(edge.id);
}
});
}
if (target.outgoingEdges) {
target.outgoingEdges.forEach(edge => {
if (targetElement.outgoingEdges) {
targetElement.outgoingEdges.forEach(edge => {
if (isRoutable(edge)) {
this.affectedEdges.push(edge.id);
}
Expand Down

0 comments on commit 3078cbc

Please sign in to comment.