@eclipse-glsp/client 2.8.0-next.8 → 2.9.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/css/grid.css +2 -1
- package/lib/base/action-dispatcher.js +1 -4
- package/lib/base/action-dispatcher.js.map +1 -1
- package/lib/base/auto-complete/auto-complete-widget.js +4 -8
- package/lib/base/auto-complete/auto-complete-widget.js.map +1 -1
- package/lib/base/auto-complete/base-autocomplete-palette.js +1 -2
- package/lib/base/auto-complete/base-autocomplete-palette.js.map +1 -1
- package/lib/base/editor-context-service.js +4 -7
- package/lib/base/editor-context-service.js.map +1 -1
- package/lib/base/feedback/css-feedback.js +1 -1
- package/lib/base/feedback/css-feedback.js.map +1 -1
- package/lib/base/feedback/feedback-action-dispatcher.js +4 -6
- package/lib/base/feedback/feedback-action-dispatcher.js.map +1 -1
- package/lib/base/feedback/feedback-command.js +1 -2
- package/lib/base/feedback/feedback-command.js.map +1 -1
- package/lib/base/feedback/feedback-emitter.js +1 -2
- package/lib/base/feedback/feedback-emitter.js.map +1 -1
- package/lib/base/feedback/set-model-command.js +1 -2
- package/lib/base/feedback/set-model-command.js.map +1 -1
- package/lib/base/feedback/update-model-command.js +1 -2
- package/lib/base/feedback/update-model-command.js.map +1 -1
- package/lib/base/model/diagram-loader.js +4 -6
- package/lib/base/model/diagram-loader.js.map +1 -1
- package/lib/base/model/glsp-model-source.d.ts +1 -1
- package/lib/base/model/glsp-model-source.d.ts.map +1 -1
- package/lib/base/model/glsp-model-source.js +3 -5
- package/lib/base/model/glsp-model-source.js.map +1 -1
- package/lib/base/model/model-registry.js +1 -2
- package/lib/base/model/model-registry.js.map +1 -1
- package/lib/base/selection-service.js +3 -3
- package/lib/base/selection-service.js.map +1 -1
- package/lib/base/shortcuts/available-shortcuts-extension.js +3 -2
- package/lib/base/shortcuts/available-shortcuts-extension.js.map +1 -1
- package/lib/base/shortcuts/available-shortcuts-tool.js +3 -2
- package/lib/base/shortcuts/available-shortcuts-tool.js.map +1 -1
- package/lib/base/tool-manager/tool-manager.js +1 -1
- package/lib/base/tool-manager/tool-manager.js.map +1 -1
- package/lib/base/ui-extension/ui-extension.js +4 -6
- package/lib/base/ui-extension/ui-extension.js.map +1 -1
- package/lib/features/accessibility/edge-autocomplete/edge-autocomplete-palette.js +12 -17
- package/lib/features/accessibility/edge-autocomplete/edge-autocomplete-palette.js.map +1 -1
- package/lib/features/accessibility/edge-autocomplete/edge-autocomplete-tool.js +3 -2
- package/lib/features/accessibility/edge-autocomplete/edge-autocomplete-tool.js.map +1 -1
- package/lib/features/accessibility/element-navigation/diagram-navigation-tool.js +11 -15
- package/lib/features/accessibility/element-navigation/diagram-navigation-tool.js.map +1 -1
- package/lib/features/accessibility/element-navigation/left-right-top-bottom-navigator.js +2 -3
- package/lib/features/accessibility/element-navigation/left-right-top-bottom-navigator.js.map +1 -1
- package/lib/features/accessibility/element-navigation/local-element-navigator.js +2 -3
- package/lib/features/accessibility/element-navigation/local-element-navigator.js.map +1 -1
- package/lib/features/accessibility/focus-tracker/focus-tracker-tool.js +5 -4
- package/lib/features/accessibility/focus-tracker/focus-tracker-tool.js.map +1 -1
- package/lib/features/accessibility/global-keylistener-tool.js +4 -3
- package/lib/features/accessibility/global-keylistener-tool.js.map +1 -1
- package/lib/features/accessibility/keyboard-grid/keyboard-grid-search-palette.js +3 -2
- package/lib/features/accessibility/keyboard-grid/keyboard-grid-search-palette.js.map +1 -1
- package/lib/features/accessibility/keyboard-tool-palette/keyboard-tool-palette.js +5 -7
- package/lib/features/accessibility/keyboard-tool-palette/keyboard-tool-palette.js.map +1 -1
- package/lib/features/accessibility/toast/toast-handler.js +2 -4
- package/lib/features/accessibility/toast/toast-handler.js.map +1 -1
- package/lib/features/accessibility/toast/toast-tool.js +3 -2
- package/lib/features/accessibility/toast/toast-tool.js.map +1 -1
- package/lib/features/accessibility/view-key-tools/deselect-key-tool.js +3 -2
- package/lib/features/accessibility/view-key-tools/deselect-key-tool.js.map +1 -1
- package/lib/features/accessibility/view-key-tools/grid-cell-zoom-key-tool.js +4 -3
- package/lib/features/accessibility/view-key-tools/grid-cell-zoom-key-tool.js.map +1 -1
- package/lib/features/bounds/freeform-layout.js +1 -1
- package/lib/features/bounds/freeform-layout.js.map +1 -1
- package/lib/features/bounds/glsp-hidden-bounds-updater.d.ts +31 -1
- package/lib/features/bounds/glsp-hidden-bounds-updater.d.ts.map +1 -1
- package/lib/features/bounds/glsp-hidden-bounds-updater.js +119 -58
- package/lib/features/bounds/glsp-hidden-bounds-updater.js.map +1 -1
- package/lib/features/bounds/hbox-layout.js +7 -10
- package/lib/features/bounds/hbox-layout.js.map +1 -1
- package/lib/features/bounds/layout-data.js +2 -4
- package/lib/features/bounds/layout-data.js.map +1 -1
- package/lib/features/bounds/local-bounds.js +3 -4
- package/lib/features/bounds/local-bounds.js.map +1 -1
- package/lib/features/bounds/set-bounds-feedback-command.js +2 -3
- package/lib/features/bounds/set-bounds-feedback-command.js.map +1 -1
- package/lib/features/bounds/vbox-layout.js +7 -10
- package/lib/features/bounds/vbox-layout.js.map +1 -1
- package/lib/features/change-bounds/model.js +1 -1
- package/lib/features/change-bounds/model.js.map +1 -1
- package/lib/features/change-bounds/move-element-handler.js +1 -2
- package/lib/features/change-bounds/move-element-handler.js.map +1 -1
- package/lib/features/change-bounds/movement-restrictor.js +1 -2
- package/lib/features/change-bounds/movement-restrictor.js.map +1 -1
- package/lib/features/change-bounds/point-position-updater.js +1 -1
- package/lib/features/change-bounds/point-position-updater.js.map +1 -1
- package/lib/features/change-bounds/resize/resize-default-tool.js +4 -3
- package/lib/features/change-bounds/resize/resize-default-tool.js.map +1 -1
- package/lib/features/change-bounds/resize/resize-handler.js +1 -2
- package/lib/features/change-bounds/resize/resize-handler.js.map +1 -1
- package/lib/features/change-bounds/resize/resize-tool.js +4 -3
- package/lib/features/change-bounds/resize/resize-tool.js.map +1 -1
- package/lib/features/change-bounds/tracker.js +1 -2
- package/lib/features/change-bounds/tracker.js.map +1 -1
- package/lib/features/command-palette/command-palette-tool.js +3 -2
- package/lib/features/command-palette/command-palette-tool.js.map +1 -1
- package/lib/features/command-palette/command-palette.js +2 -3
- package/lib/features/command-palette/command-palette.js.map +1 -1
- package/lib/features/context-menu/glsp-context-menu-mouse-listener.js +2 -3
- package/lib/features/context-menu/glsp-context-menu-mouse-listener.js.map +1 -1
- package/lib/features/copy-paste/copy-paste-handler.d.ts +1 -1
- package/lib/features/copy-paste/copy-paste-handler.d.ts.map +1 -1
- package/lib/features/copy-paste/copy-paste-handler.js +3 -5
- package/lib/features/copy-paste/copy-paste-handler.js.map +1 -1
- package/lib/features/copy-paste/copy-paste-standalone.js +6 -9
- package/lib/features/copy-paste/copy-paste-standalone.js.map +1 -1
- package/lib/features/debug/debug-bounds-decorator.js +9 -12
- package/lib/features/debug/debug-bounds-decorator.js.map +1 -1
- package/lib/features/debug/debug-model.js +1 -1
- package/lib/features/debug/debug-model.js.map +1 -1
- package/lib/features/decoration/decoration-placer.js +3 -2
- package/lib/features/decoration/decoration-placer.js.map +1 -1
- package/lib/features/element-template/add-template-element.d.ts +6 -1
- package/lib/features/element-template/add-template-element.d.ts.map +1 -1
- package/lib/features/element-template/add-template-element.js +17 -5
- package/lib/features/element-template/add-template-element.js.map +1 -1
- package/lib/features/element-template/mouse-tracking-element-position-listener.js +1 -1
- package/lib/features/element-template/mouse-tracking-element-position-listener.js.map +1 -1
- package/lib/features/element-template/remove-template-element.js +1 -1
- package/lib/features/element-template/remove-template-element.js.map +1 -1
- package/lib/features/export/default-png-diagram-exporter.js +4 -7
- package/lib/features/export/default-png-diagram-exporter.js.map +1 -1
- package/lib/features/export/diagram-export-postprocessor.js +1 -2
- package/lib/features/export/diagram-export-postprocessor.js.map +1 -1
- package/lib/features/export/glsp-svg-exporter.d.ts.map +1 -1
- package/lib/features/export/glsp-svg-exporter.js +5 -6
- package/lib/features/export/glsp-svg-exporter.js.map +1 -1
- package/lib/features/export/request-export-command.js +1 -1
- package/lib/features/export/request-export-command.js.map +1 -1
- package/lib/features/grid/grid-model.js +1 -1
- package/lib/features/grid/grid-model.js.map +1 -1
- package/lib/features/helper-lines/helper-line-feedback.js +7 -8
- package/lib/features/helper-lines/helper-line-feedback.js.map +1 -1
- package/lib/features/helper-lines/model.d.ts +1 -1
- package/lib/features/helper-lines/model.d.ts.map +1 -1
- package/lib/features/helper-lines/model.js +3 -4
- package/lib/features/helper-lines/model.js.map +1 -1
- package/lib/features/hints/type-hint-provider.js +3 -5
- package/lib/features/hints/type-hint-provider.js.map +1 -1
- package/lib/features/label-edit/edit-label-tool.js +3 -2
- package/lib/features/label-edit/edit-label-tool.js.map +1 -1
- package/lib/features/label-edit-ui/label-edit-ui.js +2 -3
- package/lib/features/label-edit-ui/label-edit-ui.js.map +1 -1
- package/lib/features/navigation/navigation-target-resolver.js +1 -1
- package/lib/features/navigation/navigation-target-resolver.js.map +1 -1
- package/lib/features/routing/sticky-manhattan-anchors.js +9 -6
- package/lib/features/routing/sticky-manhattan-anchors.js.map +1 -1
- package/lib/features/routing/sticky-manhattan-edge-router.js +10 -12
- package/lib/features/routing/sticky-manhattan-edge-router.js.map +1 -1
- package/lib/features/search-palette/search-palette.js +3 -2
- package/lib/features/search-palette/search-palette.js.map +1 -1
- package/lib/features/search-palette/suggestions/edge-element-suggestions.js +2 -3
- package/lib/features/search-palette/suggestions/edge-element-suggestions.js.map +1 -1
- package/lib/features/search-palette/suggestions/named-element-suggestions.js +8 -11
- package/lib/features/search-palette/suggestions/named-element-suggestions.js.map +1 -1
- package/lib/features/select/select-feedback-command.js +1 -1
- package/lib/features/select/select-feedback-command.js.map +1 -1
- package/lib/features/select/select-mouse-listener.js +1 -2
- package/lib/features/select/select-mouse-listener.js.map +1 -1
- package/lib/features/status/status-overlay.js +4 -4
- package/lib/features/status/status-overlay.js.map +1 -1
- package/lib/features/tool-palette/tool-palette.d.ts.map +1 -1
- package/lib/features/tool-palette/tool-palette.js +16 -23
- package/lib/features/tool-palette/tool-palette.js.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-manager.js +4 -6
- package/lib/features/tools/change-bounds/change-bounds-manager.js.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool-feedback.js +3 -4
- package/lib/features/tools/change-bounds/change-bounds-tool-feedback.js.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.js +4 -8
- package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.js.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool.js +6 -6
- package/lib/features/tools/change-bounds/change-bounds-tool.js.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tracker.js +7 -10
- package/lib/features/tools/change-bounds/change-bounds-tracker.js.map +1 -1
- package/lib/features/tools/deletion/delete-tool.js +6 -4
- package/lib/features/tools/deletion/delete-tool.js.map +1 -1
- package/lib/features/tools/edge-creation/dangling-edge-feedback.d.ts +1 -1
- package/lib/features/tools/edge-creation/dangling-edge-feedback.d.ts.map +1 -1
- package/lib/features/tools/edge-creation/dangling-edge-feedback.js +7 -5
- package/lib/features/tools/edge-creation/dangling-edge-feedback.js.map +1 -1
- package/lib/features/tools/edge-creation/edge-creation-tool.js +5 -6
- package/lib/features/tools/edge-creation/edge-creation-tool.js.map +1 -1
- package/lib/features/tools/edge-creation/view.js +1 -2
- package/lib/features/tools/edge-creation/view.js.map +1 -1
- package/lib/features/tools/edge-edit/edge-edit-tool-feedback.d.ts +1 -1
- package/lib/features/tools/edge-edit/edge-edit-tool-feedback.d.ts.map +1 -1
- package/lib/features/tools/edge-edit/edge-edit-tool-feedback.js +8 -5
- package/lib/features/tools/edge-edit/edge-edit-tool-feedback.js.map +1 -1
- package/lib/features/tools/edge-edit/edge-edit-tool.js +3 -2
- package/lib/features/tools/edge-edit/edge-edit-tool.js.map +1 -1
- package/lib/features/tools/marquee-selection/marquee-mouse-tool.js +3 -2
- package/lib/features/tools/marquee-selection/marquee-mouse-tool.js.map +1 -1
- package/lib/features/tools/marquee-selection/marquee-tool-feedback.js +2 -2
- package/lib/features/tools/marquee-selection/marquee-tool-feedback.js.map +1 -1
- package/lib/features/tools/marquee-selection/marquee-tool.js +3 -2
- package/lib/features/tools/marquee-selection/marquee-tool.js.map +1 -1
- package/lib/features/tools/marquee-selection/model.d.ts +1 -1
- package/lib/features/tools/marquee-selection/model.d.ts.map +1 -1
- package/lib/features/tools/marquee-selection/model.js +3 -2
- package/lib/features/tools/marquee-selection/model.js.map +1 -1
- package/lib/features/tools/node-creation/container-manager.js +3 -4
- package/lib/features/tools/node-creation/container-manager.js.map +1 -1
- package/lib/features/tools/node-creation/insert-indicator.d.ts +1 -1
- package/lib/features/tools/node-creation/insert-indicator.d.ts.map +1 -1
- package/lib/features/tools/node-creation/insert-indicator.js +5 -5
- package/lib/features/tools/node-creation/insert-indicator.js.map +1 -1
- package/lib/features/tools/node-creation/node-creation-tool.js +5 -6
- package/lib/features/tools/node-creation/node-creation-tool.js.map +1 -1
- package/lib/features/tools/node-creation/node-creation-views.js +1 -2
- package/lib/features/tools/node-creation/node-creation-views.js.map +1 -1
- package/lib/features/validation/issue-marker.d.ts +2 -2
- package/lib/features/validation/issue-marker.d.ts.map +1 -1
- package/lib/features/validation/issue-marker.js +7 -2
- package/lib/features/validation/issue-marker.js.map +1 -1
- package/lib/features/validation/marker-navigator.js +1 -1
- package/lib/features/validation/marker-navigator.js.map +1 -1
- package/lib/features/validation/validate.js +4 -6
- package/lib/features/validation/validate.js.map +1 -1
- package/lib/features/viewport/origin-viewport.js +1 -1
- package/lib/features/viewport/origin-viewport.js.map +1 -1
- package/lib/features/viewport/reposition.js +2 -3
- package/lib/features/viewport/reposition.js.map +1 -1
- package/lib/features/viewport/viewport-handler.js +2 -3
- package/lib/features/viewport/viewport-handler.js.map +1 -1
- package/lib/features/viewport/viewport-tool.js +4 -3
- package/lib/features/viewport/viewport-tool.js.map +1 -1
- package/lib/features/zorder/bring-to-front-command.js +1 -2
- package/lib/features/zorder/bring-to-front-command.js.map +1 -1
- package/lib/model.js +2 -2
- package/lib/model.js.map +1 -1
- package/lib/utils/argument-utils.js +5 -5
- package/lib/utils/argument-utils.js.map +1 -1
- package/lib/utils/gmodel-util.d.ts +13 -1
- package/lib/utils/gmodel-util.d.ts.map +1 -1
- package/lib/utils/gmodel-util.js +15 -7
- package/lib/utils/gmodel-util.js.map +1 -1
- package/lib/utils/layout-utils.js +1 -2
- package/lib/utils/layout-utils.js.map +1 -1
- package/lib/views/glsp-projection-view.js +1 -2
- package/lib/views/glsp-projection-view.js.map +1 -1
- package/package.json +18 -17
- package/src/base/feedback/feedback-command.ts +1 -1
- package/src/base/model/glsp-model-source.ts +1 -1
- package/src/features/accessibility/README.md +5 -5
- package/src/features/accessibility/keyboard-tool-palette/keyboard-tool-palette.ts +1 -1
- package/src/features/bounds/glsp-hidden-bounds-updater.ts +133 -60
- package/src/features/copy-paste/copy-paste-handler.ts +3 -3
- package/src/features/element-template/add-template-element.ts +17 -2
- package/src/features/export/glsp-svg-exporter.ts +2 -2
- package/src/features/helper-lines/model.ts +4 -5
- package/src/features/tool-palette/tool-palette.ts +2 -4
- package/src/features/tools/edge-creation/dangling-edge-feedback.ts +4 -2
- package/src/features/tools/edge-edit/edge-edit-tool-feedback.ts +5 -3
- package/src/features/tools/marquee-selection/model.ts +3 -2
- package/src/features/tools/node-creation/insert-indicator.ts +5 -5
- package/src/features/validation/issue-marker.ts +7 -2
- package/src/utils/gmodel-util.ts +23 -1
- package/src/base/action-dispatcher.spec.ts +0 -366
- package/src/base/feedback/feedback-emitter.spec.ts +0 -176
- package/src/base/model/model-initialization-constraint.spec.ts +0 -95
- package/src/base/selection-service.spec.ts +0 -318
- package/src/default-modules.spec.ts +0 -56
- package/src/features/bounds/freeform-layout.spec.ts +0 -216
- package/src/features/bounds/hbox-layout.spec.ts +0 -170
- package/src/features/bounds/layouter-test-util.spec.ts +0 -127
- package/src/features/bounds/vbox-layout.spec.ts +0 -170
- package/src/features/change-bounds/point-position-updater.spec.ts +0 -81
- package/src/features/grid/grid-snapper.spec.ts +0 -30
- package/src/features/hints/type-hint-provider.spec.ts +0 -360
- package/src/features/layout/layout-elements-action.spec.ts +0 -426
- package/src/features/navigation/navigation-target-resolver.spec.ts +0 -56
- package/src/features/routing/sticky-manhattan-edge-router.spec.ts +0 -212
- package/src/features/tools/marquee-selection/marquee-behavior.spec.ts +0 -176
- package/src/features/validation/marker-navigator.spec.ts +0 -183
- package/src/utils/gmodel-util.spec.ts +0 -221
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2021-2024 EclipseSource and others.
|
|
3
|
-
*
|
|
4
|
-
* This program and the accompanying materials are made available under the
|
|
5
|
-
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
*
|
|
8
|
-
* This Source Code may also be made available under the following Secondary
|
|
9
|
-
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
* with the GNU Classpath Exception which is available at
|
|
12
|
-
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
*
|
|
14
|
-
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
-
********************************************************************************/
|
|
16
|
-
|
|
17
|
-
import { DOMHelper } from '@eclipse-glsp/sprotty';
|
|
18
|
-
import { expect } from 'chai';
|
|
19
|
-
import { IMarqueeBehavior, MarqueeUtil } from './marquee-behavior';
|
|
20
|
-
|
|
21
|
-
describe('MarqueeUtil', () => {
|
|
22
|
-
function initUtil(marqueeBehavior?: IMarqueeBehavior): MarqueeUtil {
|
|
23
|
-
const util = new MarqueeUtil(marqueeBehavior, new DOMHelper());
|
|
24
|
-
util.updateStartPoint({ x: 0, y: 0 });
|
|
25
|
-
util.updateCurrentPoint({ x: 0, y: 0 });
|
|
26
|
-
return util;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
describe('Node marquee', () => {
|
|
30
|
-
const node = { x: 20, y: 20, width: 200, height: 50 };
|
|
31
|
-
|
|
32
|
-
it('touch element', () => {
|
|
33
|
-
const util = initUtil();
|
|
34
|
-
expect(util.isNodeMarked(node)).is.equals(false);
|
|
35
|
-
util.updateCurrentPoint({ x: 30, y: 50 });
|
|
36
|
-
expect(util.isNodeMarked(node)).is.equals(true);
|
|
37
|
-
util.updateCurrentPoint({ x: 250, y: 85 });
|
|
38
|
-
expect(util.isNodeMarked(node)).is.equals(true);
|
|
39
|
-
util.updateStartPoint({ x: 30, y: 25 });
|
|
40
|
-
expect(util.isNodeMarked(node)).is.equals(true);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('touch element (reverse)', () => {
|
|
44
|
-
const util = initUtil();
|
|
45
|
-
expect(util.isNodeMarked(node)).is.equals(false);
|
|
46
|
-
util.updateStartPoint({ x: 30, y: 50 });
|
|
47
|
-
expect(util.isNodeMarked(node)).is.equals(true);
|
|
48
|
-
util.updateStartPoint({ x: 250, y: 85 });
|
|
49
|
-
expect(util.isNodeMarked(node)).is.equals(true);
|
|
50
|
-
util.updateCurrentPoint({ x: 30, y: 25 });
|
|
51
|
-
expect(util.isNodeMarked(node)).is.equals(true);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('mark entire element', () => {
|
|
55
|
-
const util = initUtil({ entireElement: true, entireEdge: false });
|
|
56
|
-
expect(util.isNodeMarked(node)).is.equals(false);
|
|
57
|
-
util.updateCurrentPoint({ x: 30, y: 50 });
|
|
58
|
-
expect(util.isNodeMarked(node)).is.equals(false);
|
|
59
|
-
util.updateCurrentPoint({ x: 250, y: 85 });
|
|
60
|
-
expect(util.isNodeMarked(node)).is.equals(true);
|
|
61
|
-
util.updateStartPoint({ x: 30, y: 85 });
|
|
62
|
-
expect(util.isNodeMarked(node)).is.equals(false);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('mark entire element (reverse)', () => {
|
|
66
|
-
const util = initUtil({ entireElement: true, entireEdge: false });
|
|
67
|
-
expect(util.isNodeMarked(node)).is.equals(false);
|
|
68
|
-
util.updateStartPoint({ x: 30, y: 50 });
|
|
69
|
-
expect(util.isNodeMarked(node)).is.equals(false);
|
|
70
|
-
util.updateStartPoint({ x: 250, y: 85 });
|
|
71
|
-
expect(util.isNodeMarked(node)).is.equals(true);
|
|
72
|
-
util.updateCurrentPoint({ x: 30, y: 85 });
|
|
73
|
-
expect(util.isNodeMarked(node)).is.equals(false);
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
describe('Edge marquee', () => {
|
|
78
|
-
const edge = [
|
|
79
|
-
{ x: 20, y: 40 },
|
|
80
|
-
{ x: 40, y: 20 }
|
|
81
|
-
];
|
|
82
|
-
const edge2 = [
|
|
83
|
-
{ x: 20, y: 20 },
|
|
84
|
-
{ x: 40, y: 40 },
|
|
85
|
-
{ x: 50, y: 10 }
|
|
86
|
-
];
|
|
87
|
-
|
|
88
|
-
it('touch edge', () => {
|
|
89
|
-
const util = initUtil();
|
|
90
|
-
expect(util.isEdgeMarked(edge)).is.equals(false);
|
|
91
|
-
expect(util.isEdgeMarked(edge2)).is.equals(false);
|
|
92
|
-
util.updateCurrentPoint({ x: 20, y: 20 });
|
|
93
|
-
expect(util.isEdgeMarked(edge)).is.equals(false);
|
|
94
|
-
expect(util.isEdgeMarked(edge2)).is.equals(true);
|
|
95
|
-
util.updateCurrentPoint({ x: 30, y: 30 });
|
|
96
|
-
expect(util.isEdgeMarked(edge)).is.equals(true);
|
|
97
|
-
expect(util.isEdgeMarked(edge2)).is.equals(true);
|
|
98
|
-
util.updateCurrentPoint({ x: 50, y: 50 });
|
|
99
|
-
expect(util.isEdgeMarked(edge)).is.equals(true);
|
|
100
|
-
expect(util.isEdgeMarked(edge2)).is.equals(true);
|
|
101
|
-
util.updateStartPoint({ x: 25, y: 25 });
|
|
102
|
-
expect(util.isEdgeMarked(edge)).is.equals(true);
|
|
103
|
-
expect(util.isEdgeMarked(edge2)).is.equals(true);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it('touch edge (reverse)', () => {
|
|
107
|
-
const util = initUtil();
|
|
108
|
-
expect(util.isEdgeMarked(edge)).is.equals(false);
|
|
109
|
-
expect(util.isEdgeMarked(edge2)).is.equals(false);
|
|
110
|
-
util.updateStartPoint({ x: 20, y: 20 });
|
|
111
|
-
expect(util.isEdgeMarked(edge)).is.equals(false);
|
|
112
|
-
expect(util.isEdgeMarked(edge2)).is.equals(true);
|
|
113
|
-
util.updateStartPoint({ x: 30, y: 30 });
|
|
114
|
-
expect(util.isEdgeMarked(edge)).is.equals(true);
|
|
115
|
-
expect(util.isEdgeMarked(edge2)).is.equals(true);
|
|
116
|
-
util.updateStartPoint({ x: 50, y: 50 });
|
|
117
|
-
expect(util.isEdgeMarked(edge)).is.equals(true);
|
|
118
|
-
expect(util.isEdgeMarked(edge2)).is.equals(true);
|
|
119
|
-
util.updateCurrentPoint({ x: 25, y: 25 });
|
|
120
|
-
expect(util.isEdgeMarked(edge)).is.equals(true);
|
|
121
|
-
expect(util.isEdgeMarked(edge2)).is.equals(true);
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('mark entire edge', () => {
|
|
125
|
-
const util = initUtil({ entireElement: false, entireEdge: true });
|
|
126
|
-
expect(util.isEdgeMarked(edge)).is.equals(false);
|
|
127
|
-
expect(util.isEdgeMarked(edge2)).is.equals(false);
|
|
128
|
-
util.updateCurrentPoint({ x: 20, y: 20 });
|
|
129
|
-
expect(util.isEdgeMarked(edge)).is.equals(false);
|
|
130
|
-
expect(util.isEdgeMarked(edge2)).is.equals(false);
|
|
131
|
-
util.updateCurrentPoint({ x: 30, y: 30 });
|
|
132
|
-
expect(util.isEdgeMarked(edge)).is.equals(false);
|
|
133
|
-
expect(util.isEdgeMarked(edge2)).is.equals(false);
|
|
134
|
-
util.updateCurrentPoint({ x: 45, y: 50 });
|
|
135
|
-
expect(util.isEdgeMarked(edge)).is.equals(true);
|
|
136
|
-
expect(util.isEdgeMarked(edge2)).is.equals(false);
|
|
137
|
-
util.updateCurrentPoint({ x: 55, y: 50 });
|
|
138
|
-
expect(util.isEdgeMarked(edge)).is.equals(true);
|
|
139
|
-
expect(util.isEdgeMarked(edge2)).is.equals(true);
|
|
140
|
-
util.updateStartPoint({ x: 25, y: 25 });
|
|
141
|
-
expect(util.isEdgeMarked(edge)).is.equals(false);
|
|
142
|
-
expect(util.isEdgeMarked(edge2)).is.equals(false);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
it('mark entire edge (reverse)', () => {
|
|
146
|
-
const util = initUtil({ entireElement: false, entireEdge: true });
|
|
147
|
-
expect(util.isEdgeMarked(edge)).is.equals(false);
|
|
148
|
-
expect(util.isEdgeMarked(edge2)).is.equals(false);
|
|
149
|
-
util.updateStartPoint({ x: 20, y: 20 });
|
|
150
|
-
expect(util.isEdgeMarked(edge)).is.equals(false);
|
|
151
|
-
expect(util.isEdgeMarked(edge2)).is.equals(false);
|
|
152
|
-
util.updateStartPoint({ x: 30, y: 30 });
|
|
153
|
-
expect(util.isEdgeMarked(edge)).is.equals(false);
|
|
154
|
-
expect(util.isEdgeMarked(edge2)).is.equals(false);
|
|
155
|
-
util.updateStartPoint({ x: 45, y: 50 });
|
|
156
|
-
expect(util.isEdgeMarked(edge)).is.equals(true);
|
|
157
|
-
expect(util.isEdgeMarked(edge2)).is.equals(false);
|
|
158
|
-
util.updateStartPoint({ x: 55, y: 50 });
|
|
159
|
-
expect(util.isEdgeMarked(edge)).is.equals(true);
|
|
160
|
-
expect(util.isEdgeMarked(edge2)).is.equals(true);
|
|
161
|
-
util.updateCurrentPoint({ x: 25, y: 25 });
|
|
162
|
-
expect(util.isEdgeMarked(edge)).is.equals(false);
|
|
163
|
-
expect(util.isEdgeMarked(edge2)).is.equals(false);
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
it('edge path should be marked', () => {
|
|
167
|
-
const path = 'M 599.968775008469,272.3972942960205 L 677.0904664855072,232';
|
|
168
|
-
const util = initUtil({ entireElement: false, entireEdge: true });
|
|
169
|
-
expect(util.isEdgePathMarked(path)).is.equals(false);
|
|
170
|
-
util.updateCurrentPoint({ x: 600, y: 300 });
|
|
171
|
-
expect(util.isEdgePathMarked(path)).is.equals(false);
|
|
172
|
-
util.updateCurrentPoint({ x: 700, y: 300 });
|
|
173
|
-
expect(util.isEdgePathMarked(path)).is.equals(true);
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
});
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2020-2023 EclipseSource and others.
|
|
3
|
-
*
|
|
4
|
-
* This program and the accompanying materials are made available under the
|
|
5
|
-
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
*
|
|
8
|
-
* This Source Code may also be made available under the following Secondary
|
|
9
|
-
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
* with the GNU Classpath Exception which is available at
|
|
12
|
-
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
*
|
|
14
|
-
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
-
********************************************************************************/
|
|
16
|
-
import { BoundsAware, GChildElement, GIssue, GModelElement, GModelRoot, GNode, GParentElement } from '@eclipse-glsp/sprotty';
|
|
17
|
-
import { expect } from 'chai';
|
|
18
|
-
import { Container } from 'inversify';
|
|
19
|
-
import 'mocha';
|
|
20
|
-
import 'reflect-metadata';
|
|
21
|
-
import { defaultModule } from '../../base/default.module';
|
|
22
|
-
import { GGraph } from '../../model';
|
|
23
|
-
import { decorationModule } from '../decoration/decoration-module';
|
|
24
|
-
import { GIssueMarker } from './issue-marker';
|
|
25
|
-
import { MarkerNavigator } from './marker-navigator';
|
|
26
|
-
import { markerNavigatorModule } from './validation-modules';
|
|
27
|
-
|
|
28
|
-
describe('MarkerNavigator', () => {
|
|
29
|
-
const container = new Container();
|
|
30
|
-
container.load(defaultModule, decorationModule, markerNavigatorModule);
|
|
31
|
-
const markerNavigator = container.get<MarkerNavigator>(MarkerNavigator);
|
|
32
|
-
function createRoot(...nodeIds: string[]): GModelRoot {
|
|
33
|
-
const root = new GGraph();
|
|
34
|
-
root.features = new Set<symbol>(GGraph.DEFAULT_FEATURES);
|
|
35
|
-
root.id = 'root';
|
|
36
|
-
root.type = 'graph';
|
|
37
|
-
nodeIds.forEach(id => {
|
|
38
|
-
const node = new GNode();
|
|
39
|
-
node.id = id;
|
|
40
|
-
node.type = 'node';
|
|
41
|
-
node.features = new Set<symbol>(GNode.DEFAULT_FEATURES);
|
|
42
|
-
root.add(node);
|
|
43
|
-
});
|
|
44
|
-
return root;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const rootWithoutAnyMarkers = createRoot('1');
|
|
48
|
-
|
|
49
|
-
const rootWithMarkers = createRoot('bottom-right', 'top-right', 'top-left', 'bottom-left');
|
|
50
|
-
|
|
51
|
-
const elementTopLeft = rootWithMarkers.children[2] as BoundsAware & GChildElement;
|
|
52
|
-
elementTopLeft.bounds = { width: 10, height: 10, x: 100, y: 100 };
|
|
53
|
-
const elementTopRight = rootWithMarkers.children[1] as BoundsAware & GChildElement;
|
|
54
|
-
elementTopRight.bounds = { width: 10, height: 10, x: 200, y: 100 };
|
|
55
|
-
const elementBottomLeft = rootWithMarkers.children[3] as BoundsAware & GChildElement;
|
|
56
|
-
elementBottomLeft.bounds = { width: 10, height: 10, x: 100, y: 200 };
|
|
57
|
-
const elementBottomRight = rootWithMarkers.children[0] as BoundsAware & GChildElement;
|
|
58
|
-
elementBottomRight.bounds = { width: 10, height: 10, x: 200, y: 200 };
|
|
59
|
-
|
|
60
|
-
beforeEach('clear issue marker', () => {
|
|
61
|
-
[elementTopLeft, elementTopRight, elementBottomLeft, elementBottomRight].forEach(clearMarker);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('next(undefined) without any markers returns undefined', () => {
|
|
65
|
-
expect(markerNavigator.next(rootWithoutAnyMarkers)).to.be.undefined;
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('previous(undefined) without any markers returns undefined', () => {
|
|
69
|
-
expect(markerNavigator.previous(rootWithoutAnyMarkers)).to.be.undefined;
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('next(undefined) with one marker returns the one marker', () => {
|
|
73
|
-
const marker = setIssues(elementTopLeft, [{ message: 'msg', severity: 'error' }]);
|
|
74
|
-
const next = markerNavigator.next(rootWithMarkers);
|
|
75
|
-
expect(next).to.eql(marker);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it('next(firstMarker) with only one marker returns again the first marker', () => {
|
|
79
|
-
const marker = setIssues(elementTopLeft, [{ message: 'msg', severity: 'error' }]);
|
|
80
|
-
const next = markerNavigator.next(rootWithMarkers, marker);
|
|
81
|
-
expect(next).to.eql(marker);
|
|
82
|
-
// and again and again
|
|
83
|
-
const nextNext = markerNavigator.next(rootWithMarkers, next);
|
|
84
|
-
expect(nextNext).to.eql(marker);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('previous(firstMarker) with only one marker returns again the first marker', () => {
|
|
88
|
-
const marker = setIssues(elementTopLeft, [{ message: 'msg', severity: 'error' }]);
|
|
89
|
-
const previous = markerNavigator.previous(rootWithMarkers, marker);
|
|
90
|
-
expect(previous).to.eql(marker);
|
|
91
|
-
// and again and again
|
|
92
|
-
const previousPrevious = markerNavigator.previous(rootWithMarkers, previous);
|
|
93
|
-
expect(previousPrevious).to.eql(marker);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it('next(firstMarker) with two marker returns second marker then again first marker', () => {
|
|
97
|
-
const marker1 = setIssues(elementTopLeft, [{ message: 'msg', severity: 'error' }]);
|
|
98
|
-
const marker2 = setIssues(elementTopRight, [{ message: 'msg', severity: 'error' }]);
|
|
99
|
-
const next = markerNavigator.next(rootWithMarkers, marker1);
|
|
100
|
-
expect(next).to.eql(marker2);
|
|
101
|
-
// and again and again
|
|
102
|
-
const nextNext = markerNavigator.next(rootWithMarkers, next);
|
|
103
|
-
expect(nextNext).to.eql(marker1);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it('previous(firstMarker) with two marker returns second marker then again first marker', () => {
|
|
107
|
-
const marker1 = setIssues(elementTopLeft, [{ message: 'msg', severity: 'error' }]);
|
|
108
|
-
const marker2 = setIssues(elementTopRight, [{ message: 'msg', severity: 'error' }]);
|
|
109
|
-
const next = markerNavigator.previous(rootWithMarkers, marker1);
|
|
110
|
-
expect(next).to.eql(marker2);
|
|
111
|
-
// and again and again
|
|
112
|
-
const nextNext = markerNavigator.previous(rootWithMarkers, next);
|
|
113
|
-
expect(nextNext).to.eql(marker1);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it('returns markers in the order left-to-right, top-to-bottom with next()', () => {
|
|
117
|
-
const marker1 = setIssues(elementTopLeft, [{ message: 'msg', severity: 'error' }]);
|
|
118
|
-
const marker2 = setIssues(elementTopRight, [{ message: 'msg', severity: 'error' }]);
|
|
119
|
-
const marker3 = setIssues(elementBottomLeft, [{ message: 'msg', severity: 'error' }]);
|
|
120
|
-
const marker4 = setIssues(elementBottomRight, [{ message: 'msg', severity: 'error' }]);
|
|
121
|
-
const found1 = markerNavigator.next(rootWithMarkers);
|
|
122
|
-
const found2 = markerNavigator.next(rootWithMarkers, found1);
|
|
123
|
-
const found3 = markerNavigator.next(rootWithMarkers, found2);
|
|
124
|
-
const found4 = markerNavigator.next(rootWithMarkers, found3);
|
|
125
|
-
const found5 = markerNavigator.next(rootWithMarkers, found4);
|
|
126
|
-
expect(found1).to.eql(marker1);
|
|
127
|
-
expect(found2).to.eql(marker2);
|
|
128
|
-
expect(found3).to.eql(marker3);
|
|
129
|
-
expect(found4).to.eql(marker4);
|
|
130
|
-
expect(found5).to.eql(marker1);
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it('returns markers in the order left-to-right, top-to-bottom with previous()', () => {
|
|
134
|
-
const marker1 = setIssues(elementTopLeft, [{ message: 'msg', severity: 'error' }]);
|
|
135
|
-
const marker2 = setIssues(elementTopRight, [{ message: 'msg', severity: 'error' }]);
|
|
136
|
-
const marker3 = setIssues(elementBottomLeft, [{ message: 'msg', severity: 'error' }]);
|
|
137
|
-
const marker4 = setIssues(elementBottomRight, [{ message: 'msg', severity: 'error' }]);
|
|
138
|
-
const found1 = markerNavigator.previous(rootWithMarkers);
|
|
139
|
-
const found2 = markerNavigator.previous(rootWithMarkers, found1);
|
|
140
|
-
const found3 = markerNavigator.previous(rootWithMarkers, found2);
|
|
141
|
-
const found4 = markerNavigator.previous(rootWithMarkers, found3);
|
|
142
|
-
const found5 = markerNavigator.previous(rootWithMarkers, found4);
|
|
143
|
-
expect(found1).to.eql(marker1);
|
|
144
|
-
expect(found2).to.eql(marker4);
|
|
145
|
-
expect(found3).to.eql(marker3);
|
|
146
|
-
expect(found4).to.eql(marker2);
|
|
147
|
-
expect(found5).to.eql(marker1);
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
function clearMarker(elem: GParentElement): void {
|
|
152
|
-
elem.children.filter(isMarker).forEach(marker => elem.remove(marker));
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
function setIssues(elem: GParentElement, issues: GIssue[]): GIssueMarker {
|
|
156
|
-
const marker = getOrCreateMarker(elem);
|
|
157
|
-
marker.issues = issues;
|
|
158
|
-
return marker;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function getOrCreateMarker(elem: GParentElement): GIssueMarker {
|
|
162
|
-
const marker = findMarker(elem);
|
|
163
|
-
if (marker instanceof GIssueMarker) {
|
|
164
|
-
return marker;
|
|
165
|
-
}
|
|
166
|
-
return createMarker(elem as GParentElement);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
function findMarker(elem: GParentElement): GIssueMarker | undefined {
|
|
170
|
-
return elem.children.find(isMarker);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
function isMarker(element: GModelElement): element is GIssueMarker {
|
|
174
|
-
return element instanceof GIssueMarker;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
function createMarker(elem: GParentElement): GIssueMarker {
|
|
178
|
-
const newMarker = new GIssueMarker();
|
|
179
|
-
newMarker.type = 'marker';
|
|
180
|
-
newMarker.id = `${elem.id}_marker`;
|
|
181
|
-
elem.add(newMarker);
|
|
182
|
-
return newMarker;
|
|
183
|
-
}
|
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2023 EclipseSource and others.
|
|
3
|
-
*
|
|
4
|
-
* This program and the accompanying materials are made available under the
|
|
5
|
-
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
*
|
|
8
|
-
* This Source Code may also be made available under the following Secondary
|
|
9
|
-
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
* with the GNU Classpath Exception which is available at
|
|
12
|
-
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
*
|
|
14
|
-
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
-
********************************************************************************/
|
|
16
|
-
import {
|
|
17
|
-
AbstractEdgeRouter,
|
|
18
|
-
EdgeRouterRegistry,
|
|
19
|
-
GNode,
|
|
20
|
-
GRoutableElement,
|
|
21
|
-
GRoutingHandle,
|
|
22
|
-
LinearRouteOptions,
|
|
23
|
-
Point,
|
|
24
|
-
ResolvedHandleMove,
|
|
25
|
-
RoutedPoint
|
|
26
|
-
} from '@eclipse-glsp/sprotty';
|
|
27
|
-
import { expect } from 'chai';
|
|
28
|
-
import { Container } from 'inversify';
|
|
29
|
-
import { routingModule } from '../features/routing/routing-module';
|
|
30
|
-
import { ALL_ROUTING_POINTS, ROUTE_KINDS, ROUTING_POINT_KINDS, calcRoute } from './gmodel-util';
|
|
31
|
-
import { GEdge, GGraph } from '../model';
|
|
32
|
-
|
|
33
|
-
class TestRouter extends AbstractEdgeRouter {
|
|
34
|
-
kind = 'test-router';
|
|
35
|
-
|
|
36
|
-
route(edge: GRoutableElement): RoutedPoint[] {
|
|
37
|
-
const pureRoute = edge.routingPoints.map(
|
|
38
|
-
(point, idx) =>
|
|
39
|
-
<RoutedPoint>{
|
|
40
|
-
kind: 'linear',
|
|
41
|
-
...point,
|
|
42
|
-
pointIndex: idx
|
|
43
|
-
}
|
|
44
|
-
);
|
|
45
|
-
return [
|
|
46
|
-
{ kind: 'source', ...edge.source!.position },
|
|
47
|
-
...pureRoute,
|
|
48
|
-
{ kind: 'bezier-control-after', x: 999, y: 999, pointIndex: pureRoute.length },
|
|
49
|
-
{ kind: 'target', ...edge.target!.position }
|
|
50
|
-
];
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
createRoutingHandles(edge: GRoutableElement): void {
|
|
54
|
-
// do nothing
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
protected getOptions(edge: GRoutableElement): LinearRouteOptions {
|
|
58
|
-
return {
|
|
59
|
-
minimalPointDistance: 0,
|
|
60
|
-
selfEdgeOffset: 0,
|
|
61
|
-
standardDistance: 0
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
protected getInnerHandlePosition(edge: GRoutableElement, route: RoutedPoint[], handle: GRoutingHandle): Point | undefined {
|
|
66
|
-
return undefined;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
protected applyInnerHandleMoves(edge: GRoutableElement, moves: ResolvedHandleMove[]): void {
|
|
70
|
-
// do nothing
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
describe('SModel Util', () => {
|
|
75
|
-
describe('calcRoute', () => {
|
|
76
|
-
const graph = new GGraph();
|
|
77
|
-
|
|
78
|
-
const source = new GNode();
|
|
79
|
-
source.id = 'node0';
|
|
80
|
-
source.position = { x: 0, y: 0 };
|
|
81
|
-
source.size = { width: 0, height: 0 };
|
|
82
|
-
graph.add(source);
|
|
83
|
-
|
|
84
|
-
const target = new GNode();
|
|
85
|
-
target.id = 'node1';
|
|
86
|
-
target.position = { x: 100, y: 100 };
|
|
87
|
-
target.size = { width: 0, height: 0 };
|
|
88
|
-
graph.add(target);
|
|
89
|
-
|
|
90
|
-
const edge = new GEdge();
|
|
91
|
-
edge.id = 'edge0';
|
|
92
|
-
edge.sourceId = 'node0';
|
|
93
|
-
edge.targetId = 'node1';
|
|
94
|
-
graph.add(edge);
|
|
95
|
-
|
|
96
|
-
edge.routerKind = 'test-router';
|
|
97
|
-
|
|
98
|
-
const container = new Container();
|
|
99
|
-
container.load(routingModule);
|
|
100
|
-
|
|
101
|
-
const routerRegistry = container.get<EdgeRouterRegistry>(EdgeRouterRegistry);
|
|
102
|
-
routerRegistry.register('test-router', new TestRouter());
|
|
103
|
-
|
|
104
|
-
it('should return complete route', () => {
|
|
105
|
-
edge.source!.position = { x: 0, y: 0 };
|
|
106
|
-
edge.target!.position = { x: 100, y: 100 };
|
|
107
|
-
edge.routingPoints = [
|
|
108
|
-
{ x: 20, y: 20 },
|
|
109
|
-
{ x: 30, y: 30 },
|
|
110
|
-
{ x: 40, y: 40 }
|
|
111
|
-
];
|
|
112
|
-
const route = calcRoute(edge, routerRegistry);
|
|
113
|
-
expect(route).to.deep.equal(<RoutedPoint[]>[
|
|
114
|
-
{ x: 0, y: 0, kind: 'source' },
|
|
115
|
-
{ x: 20, y: 20, kind: 'linear', pointIndex: 0 },
|
|
116
|
-
{ x: 30, y: 30, kind: 'linear', pointIndex: 1 },
|
|
117
|
-
{ x: 40, y: 40, kind: 'linear', pointIndex: 2 },
|
|
118
|
-
{ x: 999, y: 999, kind: 'bezier-control-after', pointIndex: 3 },
|
|
119
|
-
{ x: 100, y: 100, kind: 'target' }
|
|
120
|
-
]);
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it('should filter duplicates with same coordinates', () => {
|
|
124
|
-
edge.source!.position = { x: 0, y: 0 };
|
|
125
|
-
edge.target!.position = { x: 100, y: 100 };
|
|
126
|
-
edge.routingPoints = [
|
|
127
|
-
{ x: 20, y: 20 },
|
|
128
|
-
{ x: 20, y: 20 },
|
|
129
|
-
{ x: 30, y: 30 },
|
|
130
|
-
{ x: 40, y: 40 }
|
|
131
|
-
];
|
|
132
|
-
|
|
133
|
-
const route = calcRoute(edge, routerRegistry);
|
|
134
|
-
expect(route).to.deep.equal(<RoutedPoint[]>[
|
|
135
|
-
{ x: 0, y: 0, kind: 'source' },
|
|
136
|
-
{ x: 20, y: 20, kind: 'linear', pointIndex: 0 },
|
|
137
|
-
{ x: 30, y: 30, kind: 'linear', pointIndex: 2 },
|
|
138
|
-
{ x: 40, y: 40, kind: 'linear', pointIndex: 3 },
|
|
139
|
-
{ x: 999, y: 999, kind: 'bezier-control-after', pointIndex: 4 },
|
|
140
|
-
{ x: 100, y: 100, kind: 'target' }
|
|
141
|
-
]);
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
it('should not filter source and target even if duplicate coordinates', () => {
|
|
145
|
-
edge.source!.position = { x: 0, y: 0 };
|
|
146
|
-
edge.target!.position = { x: 0, y: 0 };
|
|
147
|
-
edge.routingPoints = [
|
|
148
|
-
{ x: 20, y: 20 },
|
|
149
|
-
{ x: 30, y: 30 },
|
|
150
|
-
{ x: 40, y: 40 }
|
|
151
|
-
];
|
|
152
|
-
|
|
153
|
-
const route = calcRoute(edge, routerRegistry);
|
|
154
|
-
expect(route).to.deep.equal(<RoutedPoint[]>[
|
|
155
|
-
{ x: 0, y: 0, kind: 'source' },
|
|
156
|
-
{ x: 20, y: 20, kind: 'linear', pointIndex: 0 },
|
|
157
|
-
{ x: 30, y: 30, kind: 'linear', pointIndex: 1 },
|
|
158
|
-
{ x: 40, y: 40, kind: 'linear', pointIndex: 2 },
|
|
159
|
-
{ x: 999, y: 999, kind: 'bezier-control-after', pointIndex: 3 },
|
|
160
|
-
{ x: 0, y: 0, kind: 'target' }
|
|
161
|
-
]);
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
it('should filter duplicates with same coordinates but allow tolerance', () => {
|
|
165
|
-
edge.source!.position = { x: 0, y: 0 };
|
|
166
|
-
edge.target!.position = { x: 100, y: 100 };
|
|
167
|
-
edge.routingPoints = [
|
|
168
|
-
{ x: 20, y: 20 },
|
|
169
|
-
{ x: 25, y: 25 },
|
|
170
|
-
{ x: 30, y: 30 },
|
|
171
|
-
{ x: 40, y: 40 }
|
|
172
|
-
];
|
|
173
|
-
|
|
174
|
-
const route = calcRoute(edge, routerRegistry, ALL_ROUTING_POINTS, 10);
|
|
175
|
-
expect(route).to.deep.equal(<RoutedPoint[]>[
|
|
176
|
-
{ x: 0, y: 0, kind: 'source' },
|
|
177
|
-
{ x: 20, y: 20, kind: 'linear', pointIndex: 0 },
|
|
178
|
-
{ x: 30, y: 30, kind: 'linear', pointIndex: 2 },
|
|
179
|
-
{ x: 40, y: 40, kind: 'linear', pointIndex: 3 },
|
|
180
|
-
{ x: 999, y: 999, kind: 'bezier-control-after', pointIndex: 4 },
|
|
181
|
-
{ x: 100, y: 100, kind: 'target' }
|
|
182
|
-
]);
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
it('should allow filtering based on point type: ROUTE_KINDS', () => {
|
|
186
|
-
edge.source!.position = { x: 0, y: 0 };
|
|
187
|
-
edge.target!.position = { x: 100, y: 100 };
|
|
188
|
-
edge.routingPoints = [
|
|
189
|
-
{ x: 20, y: 20 },
|
|
190
|
-
{ x: 30, y: 30 },
|
|
191
|
-
{ x: 40, y: 40 }
|
|
192
|
-
];
|
|
193
|
-
|
|
194
|
-
const route = calcRoute(edge, routerRegistry, ROUTE_KINDS);
|
|
195
|
-
expect(route).to.deep.equal(<RoutedPoint[]>[
|
|
196
|
-
{ x: 0, y: 0, kind: 'source' },
|
|
197
|
-
{ x: 20, y: 20, kind: 'linear', pointIndex: 0 },
|
|
198
|
-
{ x: 30, y: 30, kind: 'linear', pointIndex: 1 },
|
|
199
|
-
{ x: 40, y: 40, kind: 'linear', pointIndex: 2 },
|
|
200
|
-
{ x: 100, y: 100, kind: 'target' }
|
|
201
|
-
]);
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
it('should allow filtering based on point type: ROUTING_POINT_KINDS', () => {
|
|
205
|
-
edge.source!.position = { x: 0, y: 0 };
|
|
206
|
-
edge.target!.position = { x: 100, y: 100 };
|
|
207
|
-
edge.routingPoints = [
|
|
208
|
-
{ x: 20, y: 20 },
|
|
209
|
-
{ x: 30, y: 30 },
|
|
210
|
-
{ x: 40, y: 40 }
|
|
211
|
-
];
|
|
212
|
-
|
|
213
|
-
const route = calcRoute(edge, routerRegistry, ROUTING_POINT_KINDS);
|
|
214
|
-
expect(route).to.deep.equal(<RoutedPoint[]>[
|
|
215
|
-
{ x: 20, y: 20, kind: 'linear', pointIndex: 0 },
|
|
216
|
-
{ x: 30, y: 30, kind: 'linear', pointIndex: 1 },
|
|
217
|
-
{ x: 40, y: 40, kind: 'linear', pointIndex: 2 }
|
|
218
|
-
]);
|
|
219
|
-
});
|
|
220
|
-
});
|
|
221
|
-
});
|