Replies: 6 comments 17 replies
-
...maybe I should work with a And I found this comment mentioning feedback commands... But I did not found any code comments or docu. So maybe this is only for internal usage? |
Beta Was this translation helpful? Give feedback.
-
To give you a better example of what I did with trying to adapt my snapper. I implemented (for example for the divider problem) the following snapper : @injectable()
export class BPMNElementSnapper implements ISnapper {
constructor(public grid: { x: number; y: number } = { x: 1, y: 1 }) { }
snap(position: Point, _element: GModelElement): Point {
if (isLaneDivider(_element)) {
return this.findLaneDividerSnapPoint(_element, position);
}
return {
x: Math.round(position.x),
y: Math.round(position.y)
};
}
private findLaneDividerSnapPoint(element: GModelElement, position: Point): Point {
const x = 0;
const y = position.y;
return { x: x, y: y };
}
} Very easy code. I just set the x(delta) always to 0. And this looks at the first glance fine but if I move the mouse aggressive left/right the element suddenly changes the x position even when I set it to 0 - this is the strange thing..... This effect also happens when I move the mouse very fast. |
Beta Was this translation helpful? Give feedback.
-
Hi @martin-fleck-at, I am sorry, but at the moment I did not understand anything. Even analyzing the code you referred did not help me. To me it looks over-killed extending the From the overall concept of GLSP I expect that I should be able to
at least I understand that I can not or must not overwrite the bounds property of an element in any action as this is always readonly property - right? Or did you expect that a You can see my current code base here and here. But it is more experimental at the moment. |
Beta Was this translation helpful? Give feedback.
-
Finally I found a working solution (not perfect). My code looks like this - Note that I need to explicit check the 'graph' case at the beginning of the snap method. Found no other solution. Only returning 0,0 in the 'graph' case healed the situation (very very strange): @injectable()
export class BPMNElementSnapper extends GridSnapper {
constructor() {
super({ x: 1, y: 1 });
}
override snap(position: Point, element: GModelElement): Point {
if ('graph' === element.type) {
console.log('causing problems...!');
return { x: 0, y: 0 };
}
if (this.isElementOrSelected(element, elem => 'lane-divider' === elem.type)) {
return this.findLaneDividerSnapPoint(element, position);
}
// default move 1x1...
return {
x: Math.round(position.x),
y: Math.round(position.y)
};
}
/**
* Returns true if the given element or any of the selected elements in the indexed graph matches the given predicate.
*
*/
public isElementOrSelected(element: GModelElement, predicate: (modelElement: GModelElement) => boolean): boolean {
try {
return predicate(element) || getMatchingElements(element.index, isSelected).some(predicate);
} catch (error) {
return false;
}
}
/*
* This helper method computes the snap Position of a Lane-Divider.
* The position is based on the Bounds of the containing Pool.
* The final position is always on the x position of the Pool.
*/
public findLaneDividerSnapPoint(element: GModelElement, position: Point): Point {
let x = 0;
let y = position.y;
// test min / max position
if (hasArgs(element) && isBoundsAware(element)) {
x = 0;
const yMin = Number(element.args.ymin);
const yMax = Number(element.args.ymax);
console.log(' ---> element (' + element.type + ') position: ' + element.bounds.x + ',' + element.bounds.y + ' yMin/yMax=' + yMin + '/' + yMax
+ ' Point--> ' + position.x + ',' + position.y);
if (element.bounds.y + position.y < yMin) {
y = 0;
}
if (element.bounds.y + position.y > yMax) {
y = 0;
}
}
// return the new position;
return { x: x, y: y };
}
} |
Beta Was this translation helpful? Give feedback.
-
Isn't it the |
Beta Was this translation helpful? Give feedback.
-
Hi @martin-fleck-at , maybe we should take a step back and rethink the situation. I am afraid that we are now proceeding in a way that is far too complicated. Why don't you just send in a method like I'm doing the same thing in Jakarta EE in my workflow engine. The engine transmits life cycle events at specific points in the process. These allow implementers to change the properties of a process instance. The engine itself doesn't use these events. It is just an interceptor interface. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I have a strange behavior since I migrated from GLSP 1.x to 2.x. In our Open-BPMN project we have some special cases where elements are forced to snap in specific positions.
For example, a so called BPMN BoundaryEvent is always placed on the edge of a Task, and a Lane-Divider should not move out of its pool:
I solved this in the past with a custom
ISnapper
implementation, where I simply calculated the possible absolute new position of a snap-point. So the result of the methodsnap(position: Point, element: SModelElement): Point
was always an absolute position in the diagram plane.This is no longer true for GLSP version 2.x. I can't find any notes regarding the changed behavior in the release notes. I am very confused about this issue and I did not found a solution. This topic does not have any relation ship to the new HelperLine feature.
If I run my old code in GLSP 2.x it looks like this caused by the calculation of the absolute position:
I wonder how the
ISnapper
is working and if using aISnapper
may be the wrong approach for my feature to move some elements only aligned to a internal line... ?Beta Was this translation helpful? Give feedback.
All reactions