@visuallyjs/browser-ui 1.2.2 → 1.2.4
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/css/visuallyjs.css +4 -0
- package/js/visuallyjs.browser-ui.cjs.js +56 -56
- package/js/visuallyjs.browser-ui.esm.js +56 -56
- package/package.json +1 -1
- package/types/browser-ui/pan-zoom-options.d.ts +1 -2
- package/types/browser-ui/pan-zoom.d.ts +2 -1
- package/types/browser-ui/plugins/browser-ui-plugin.d.ts +1 -0
- package/types/browser-ui/surface-renderer/diagrams/definitions.d.ts +5 -1
- package/types/browser-ui/surface-renderer/plugins/index.d.ts +1 -0
- package/types/browser-ui/surface-renderer/plugins/lasso/lasso-plugin.d.ts +8 -0
- package/types/browser-ui/surface-renderer/plugins/lasso/lasso.d.ts +18 -0
- package/types/browser-ui/surface-renderer/plugins/line-crossings/arch-bridge.d.ts +7 -0
- package/types/browser-ui/surface-renderer/plugins/line-crossings/definitions.d.ts +116 -0
- package/types/browser-ui/surface-renderer/plugins/line-crossings/dot-bridge.d.ts +7 -0
- package/types/browser-ui/surface-renderer/plugins/line-crossings/gap-bridge.d.ts +7 -0
- package/types/browser-ui/surface-renderer/plugins/line-crossings/index.d.ts +5 -0
- package/types/browser-ui/surface-renderer/plugins/line-crossings/line-crossings-plugin.d.ts +74 -0
- package/types/core/io.d.ts +6 -0
- package/types/core/layout/bowtie/bowtie-layout.d.ts +69 -0
- package/types/core/layout/bowtie/index.d.ts +1 -0
- package/types/core/layout/hierarchy/definitions.d.ts +2 -2
- package/types/core/layout/hierarchy/parent-relative-placement.d.ts +2 -2
- package/types/core/layout/index.d.ts +1 -0
- package/types/core/model/graph.d.ts +9 -0
- package/types/test-support/test-support.d.ts +2 -0
- package/types/ui/core/connector/connectors.d.ts +1 -1
- package/types/ui/core/core.d.ts +1 -0
- package/types/ui/core/viewport.d.ts +14 -0
- package/types/ui/plugins/definitions.d.ts +9 -0
- package/types/version.d.ts +1 -1
package/package.json
CHANGED
|
@@ -236,8 +236,7 @@ export interface PanZoomOptions {
|
|
|
236
236
|
*/
|
|
237
237
|
enabled?: boolean;
|
|
238
238
|
/**
|
|
239
|
-
* Optional filter that will be called on down event, with the event target and the event. Returning true
|
|
240
|
-
* from this function means the widget should respond to the event.
|
|
239
|
+
* Optional filter that will be called on down event, with the event target and the event. Returning true from this function means the widget should respond to the event.
|
|
241
240
|
*/
|
|
242
241
|
filter?: Function;
|
|
243
242
|
/**
|
|
@@ -183,6 +183,7 @@ export declare class PanZoom {
|
|
|
183
183
|
private _apparentOffset;
|
|
184
184
|
private _canStartPanning;
|
|
185
185
|
private handlers;
|
|
186
|
+
private _endPan;
|
|
186
187
|
private _call;
|
|
187
188
|
/**
|
|
188
189
|
* Programmatically report a down event in order to kick the widget into action.
|
|
@@ -499,7 +500,7 @@ export declare class PanZoom {
|
|
|
499
500
|
*/
|
|
500
501
|
mapEventLocation(event: MouseEvent): PointXY;
|
|
501
502
|
/**
|
|
502
|
-
* Sets whether or not the component should respond to mouse events.
|
|
503
|
+
* Sets whether or not the component should respond to mouse events. Resets any active pan operation - this can be invoked via the lasso arming itself after a long press.
|
|
503
504
|
* @param state Whether or not to respond to mouse events.
|
|
504
505
|
*/
|
|
505
506
|
setEnabled(state: boolean): void;
|
|
@@ -6,7 +6,7 @@ import { SurfaceSaveData } from "../definitions";
|
|
|
6
6
|
import { BrowserElement } from "../../util";
|
|
7
7
|
import { PaletteMode } from "../../components/palette/palette-options";
|
|
8
8
|
import { PanOptions, WheelOptions, ZoomOptions } from "../../pan-zoom-options";
|
|
9
|
-
import { MiniviewPluginOptions, LassoPluginOptions, ResizingToolsModelUpdater, ResizingToolsHandlerFactory, DragGroupsPluginOptions, ResizingToolsResizeMethod, SnaplinesPluginOptions, PanButtonsPluginOptions } from "../plugins";
|
|
9
|
+
import { MiniviewPluginOptions, LassoPluginOptions, ResizingToolsModelUpdater, ResizingToolsHandlerFactory, DragGroupsPluginOptions, ResizingToolsResizeMethod, SnaplinesPluginOptions, PanButtonsPluginOptions, LineCrossingsPluginOptions } from "../plugins";
|
|
10
10
|
import { EdgeSnapOptions } from "../../edge-handler-base";
|
|
11
11
|
import { DiagramActionMediator } from "./mediator";
|
|
12
12
|
import { OnVertexAddedCallback, FontSpec } from "../../definitions";
|
|
@@ -435,6 +435,10 @@ export interface DiagramOptions {
|
|
|
435
435
|
* Controls whether pan buttons are displayed at the edges of the canvas, defaults to false. You can either supply a boolean and have the panbuttons plugin initialize with its default settings, or supply your own settings.
|
|
436
436
|
*/
|
|
437
437
|
panButtons?: boolean | PanButtonsPluginOptions;
|
|
438
|
+
/**
|
|
439
|
+
* Controls whether line crossings are shown by a visual cue. Defaults to false. You can either supply a boolean and have the panbuttons plugin initialize with its default settings, or supply your own settings.
|
|
440
|
+
*/
|
|
441
|
+
lineCrossings?: boolean | LineCrossingsPluginOptions;
|
|
438
442
|
}
|
|
439
443
|
/**
|
|
440
444
|
* Options for a palette for a diagram.
|
|
@@ -59,6 +59,14 @@ export interface LassoPluginOptions extends BrowserUIPluginOptions {
|
|
|
59
59
|
* Optional setting for whether lasso inside groups is enabled - it is by default. Setting this to `false` will mean that the user cannot lasso items inside a group. Setting to `"metaKey"` will mean that lasso is supported inside groups if the user is holding the meta key down (ie the Window key, or Cmd on macs).
|
|
60
60
|
*/
|
|
61
61
|
enableInGroups?: false | true | "metaKey";
|
|
62
|
+
/**
|
|
63
|
+
* Defaults to false. If true, the lasso will arm itself after a long press.
|
|
64
|
+
*/
|
|
65
|
+
autoArm?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Timeout in ms for autoArm long press. Defaults to 500ms.
|
|
68
|
+
*/
|
|
69
|
+
armTimeout?: number;
|
|
62
70
|
}
|
|
63
71
|
/**
|
|
64
72
|
* A Surface plugin that allows the user to select multiple elements with the mouse.
|
|
@@ -3,6 +3,9 @@ import { ViewportElement } from "../../../../ui";
|
|
|
3
3
|
import { BrowserElement } from "../../../util";
|
|
4
4
|
import { PointXY, Size } from "../../../../core";
|
|
5
5
|
import { AutoPanHandler } from "../../../auto-pan-handler";
|
|
6
|
+
/**
|
|
7
|
+
* Options for a lasso
|
|
8
|
+
*/
|
|
6
9
|
export interface LassoOptions {
|
|
7
10
|
canvas: Element;
|
|
8
11
|
onStart?: (pagePosition: PointXY, canvasPosition: PointXY, shiftKey: boolean, e: MouseEvent, viewportElement: ViewportElement<BrowserElement> | null) => any;
|
|
@@ -14,6 +17,9 @@ export interface LassoOptions {
|
|
|
14
17
|
* @param e
|
|
15
18
|
*/
|
|
16
19
|
onClick?: (p: PointXY, e: MouseEvent) => any;
|
|
20
|
+
/**
|
|
21
|
+
* Set this to true to have the lasso drawn as set of overlays which mask the whole browser window except for the lassoed area.
|
|
22
|
+
*/
|
|
17
23
|
invert?: boolean;
|
|
18
24
|
surface: Surface;
|
|
19
25
|
filter?: ((e: MouseEvent) => boolean) | string;
|
|
@@ -34,6 +40,14 @@ export interface LassoOptions {
|
|
|
34
40
|
* Defaults to true, meaning the canvas will pan automatically to track the lasso
|
|
35
41
|
*/
|
|
36
42
|
autoPan?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Defaults to false. If true, the lasso will arm itself after a long press.
|
|
45
|
+
*/
|
|
46
|
+
autoArm?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Timeout in ms for autoArm long press. Defaults to 500ms.
|
|
49
|
+
*/
|
|
50
|
+
armTimeout?: number;
|
|
37
51
|
}
|
|
38
52
|
export declare class Lasso {
|
|
39
53
|
visibleOrigin: PointXY;
|
|
@@ -69,6 +83,10 @@ export declare class Lasso {
|
|
|
69
83
|
_enableInGroups: false | true | "metaKey";
|
|
70
84
|
_generatedLassoContent: BrowserElement;
|
|
71
85
|
_lastPageLocation: PointXY;
|
|
86
|
+
_autoArm: boolean;
|
|
87
|
+
_armTimeout: number;
|
|
88
|
+
_armTimer: any;
|
|
89
|
+
_armClickTriggered: boolean;
|
|
72
90
|
constructor(options: LassoOptions);
|
|
73
91
|
/**
|
|
74
92
|
* list of selectors that should be filtered regardless of user preference
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { Edge, LineXY, PointXY } from "../../../../core";
|
|
2
|
+
import { Connection, Connector } from "../../../../ui";
|
|
3
|
+
import { BrowserElement } from "../../../util";
|
|
4
|
+
/**
|
|
5
|
+
* Options for the line crossings plugin.
|
|
6
|
+
*/
|
|
7
|
+
export interface LineCrossingsPluginOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Whether to apply the bridge to the horizontal or the vertical segment in a crossing. Defaults to horizontal.
|
|
10
|
+
*/
|
|
11
|
+
orientation: 'h' | 'v';
|
|
12
|
+
/**
|
|
13
|
+
* Type of bridge to use. Defaults to 'arch'.
|
|
14
|
+
*/
|
|
15
|
+
bridgeType: "dot" | "arch" | "gap";
|
|
16
|
+
/**
|
|
17
|
+
* Radius to use for dot bridges. Defaults to 5.
|
|
18
|
+
*/
|
|
19
|
+
dotRadius?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Color to use for dot bridges. Defaults to null, and the dot is painted with the stroke color of the dominant segment. You can also control this via the CSS class defined by the constant CLASS_LINE_CROSSING_BRIDGE_DOT, but using CSS will be lost in an SVG export.
|
|
22
|
+
*/
|
|
23
|
+
dotColor?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Optional function to invoke when the user taps on a bridge. This will only fire for bridge types that draw extra components - arch and dot - but the gap bridge just masks
|
|
26
|
+
* @param edge1 First edge in the intersection
|
|
27
|
+
* @param edge2 Second edge in the intersection.
|
|
28
|
+
* @param canvasLocation The location on the canvas that the intersection is located at.
|
|
29
|
+
* @param e The mouse event associated with the tap.
|
|
30
|
+
*/
|
|
31
|
+
onTap?: (edge1: Edge, edge2: Edge, canvasLocation: PointXY, e: MouseEvent) => any;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Line crossings plugin type
|
|
35
|
+
*/
|
|
36
|
+
export declare const PLUGIN_TYPE_LINE_CROSSINGS = "lineCrossings";
|
|
37
|
+
/**
|
|
38
|
+
* Assigned to all bridges (of any type) that mark a line crossing.
|
|
39
|
+
* @cssClass
|
|
40
|
+
* @context Line crossings plugin
|
|
41
|
+
*/
|
|
42
|
+
export declare const CLASS_LINE_CROSSING_BRIDGE = "vjs-bridge";
|
|
43
|
+
/**
|
|
44
|
+
* Assigned to all bridges (of any type) that mark a line crossing when the bridge is on the vertical axis
|
|
45
|
+
* @cssClass
|
|
46
|
+
* @context Line crossings plugin
|
|
47
|
+
*/
|
|
48
|
+
export declare const CLASS_LINE_CROSSING_BRIDGE_VERTICAL = "vjs-bridge-vertical";
|
|
49
|
+
/**
|
|
50
|
+
* Assigned to all bridges (of any type) that mark a line crossing when the bridge is on the horizontal axis
|
|
51
|
+
* @cssClass
|
|
52
|
+
* @context Line crossings plugin
|
|
53
|
+
*/
|
|
54
|
+
export declare const CLASS_LINE_CROSSING_BRIDGE_HORIZONTAL = "vjs-bridge-horizontal";
|
|
55
|
+
/**
|
|
56
|
+
* Assigned to all dot bridges that mark a line crossing.
|
|
57
|
+
* @cssClass
|
|
58
|
+
* @context Line crossings plugin
|
|
59
|
+
*/
|
|
60
|
+
export declare const CLASS_LINE_CROSSING_BRIDGE_DOT = "vjs-bridge-dot";
|
|
61
|
+
/**
|
|
62
|
+
* Assigned to all arch bridges that mark a line crossing.
|
|
63
|
+
* @cssClass
|
|
64
|
+
* @context Line crossings plugin
|
|
65
|
+
*/
|
|
66
|
+
export declare const CLASS_LINE_CROSSING_BRIDGE_ARCH = "vjs-bridge-arch";
|
|
67
|
+
/**
|
|
68
|
+
* Assigned to all gap bridges that mark a line crossing.
|
|
69
|
+
* @cssClass
|
|
70
|
+
* @context Line crossings plugin
|
|
71
|
+
*/
|
|
72
|
+
export declare const CLASS_LINE_CROSSING_BRIDGE_GAP = "vjs-bridge-gap";
|
|
73
|
+
type SegmentOrientation = "h" | "v";
|
|
74
|
+
export type SegmentInfo = {
|
|
75
|
+
o: SegmentOrientation;
|
|
76
|
+
index: 0 | 1;
|
|
77
|
+
line: LineXY;
|
|
78
|
+
strokeWidth: number;
|
|
79
|
+
};
|
|
80
|
+
export type ConnectionInfo = {
|
|
81
|
+
segments: Array<SegmentInfo>;
|
|
82
|
+
connection: Connection<BrowserElement>;
|
|
83
|
+
connector: Connector;
|
|
84
|
+
intersectingPoints: Array<IntersectingPoint>;
|
|
85
|
+
pathElement: BrowserElement;
|
|
86
|
+
canvasElement: BrowserElement;
|
|
87
|
+
stroke: string;
|
|
88
|
+
strokeWidth: number;
|
|
89
|
+
id: string;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* @internal
|
|
93
|
+
*/
|
|
94
|
+
export interface IntersectingPoint {
|
|
95
|
+
index: 0 | 1;
|
|
96
|
+
point: PointXY;
|
|
97
|
+
o: {
|
|
98
|
+
ref: SegmentOrientation;
|
|
99
|
+
other: SegmentOrientation;
|
|
100
|
+
};
|
|
101
|
+
strokeWidth: {
|
|
102
|
+
ref: number;
|
|
103
|
+
other: number;
|
|
104
|
+
};
|
|
105
|
+
stroke: {
|
|
106
|
+
ref: string;
|
|
107
|
+
other: string;
|
|
108
|
+
};
|
|
109
|
+
refConnector: ConnectionInfo;
|
|
110
|
+
otherConnector: ConnectionInfo;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* @internal
|
|
114
|
+
*/
|
|
115
|
+
export type BridgeDefinition = [Array<BrowserElement>, number, Array<BrowserElement>];
|
|
116
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BridgeDefinition, IntersectingPoint } from "./definitions";
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
* @param ip
|
|
5
|
+
* @param _orientation
|
|
6
|
+
*/
|
|
7
|
+
export declare function $dotBridge(ip: IntersectingPoint, _orientation: "h" | "v", dotRadius: number, dotColor: string): BridgeDefinition;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Connection, ConnectionEstablishedParams } from "../../../../ui";
|
|
2
|
+
import { BaseBrowserUIPlugin } from "../../../plugins";
|
|
3
|
+
import { Edge, PointXY } from "../../../../core";
|
|
4
|
+
import { ConnectionInfo, LineCrossingsPluginOptions } from "./definitions";
|
|
5
|
+
import { Surface } from "../../surface";
|
|
6
|
+
import { BrowserElement } from "../../../util";
|
|
7
|
+
interface InternalBridgeDefinition {
|
|
8
|
+
canvasElements: Array<BrowserElement>;
|
|
9
|
+
bgSize: number;
|
|
10
|
+
masks: Array<BrowserElement>;
|
|
11
|
+
edge: Edge;
|
|
12
|
+
otherEdge: Edge;
|
|
13
|
+
id: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Adds visual artifacts ("bridges") to the canvas at the locations where two orthogonal segments intersect. As of the first release, this plugin will only work with Orthogonal connectors (or Straight connectors with 'orthogonal' constrain set).
|
|
17
|
+
*
|
|
18
|
+
* Three bridge types are supported: "arch" (the default), "gap" and "dot". For dot bridges you can supply a dot radius and fill colour to use, or VisuallyJs will just use the stroke from the dominant connector at the intersection.
|
|
19
|
+
*
|
|
20
|
+
* The plugin has the concept of "orientation": which axis to apply updates to segments in. "h" - horizontal - is the default, and in this orientation VisuallyJs will add bridges to the horizontal segment at an intersection. You can set orientation to "v" to switch to vertical.
|
|
21
|
+
*/
|
|
22
|
+
export declare class LineCrossingsPlugin extends BaseBrowserUIPlugin {
|
|
23
|
+
_surface: Surface;
|
|
24
|
+
_orientation: "h" | "v";
|
|
25
|
+
_otherAxisOrientation: "h" | "v";
|
|
26
|
+
_orientationClass: string;
|
|
27
|
+
_dotRadius: number;
|
|
28
|
+
_dotColor: string;
|
|
29
|
+
_onTap: (edge1: Edge, edge2: Edge, canvasLocation: PointXY, e: MouseEvent) => any;
|
|
30
|
+
_edgeCache: Map<string, ConnectionInfo>;
|
|
31
|
+
_bridgeType: "arch" | "dot" | "gap";
|
|
32
|
+
_key: string;
|
|
33
|
+
tracksEdgeRedraws: boolean;
|
|
34
|
+
_bridgesByEdgeId: Map<string, Array<InternalBridgeDefinition>>;
|
|
35
|
+
_bridgesById: Map<string, InternalBridgeDefinition>;
|
|
36
|
+
initialise(surface: Surface, options: LineCrossingsPluginOptions): boolean;
|
|
37
|
+
$edgeRedraw(c: Connection<BrowserElement>): void;
|
|
38
|
+
private _getConnectorInfo;
|
|
39
|
+
private _resetCache;
|
|
40
|
+
private _trackOneEdge;
|
|
41
|
+
private _getEdgeInfo;
|
|
42
|
+
/**
|
|
43
|
+
* Gets the list of segments for the reference orientation. This is a stub; it isnt entirely necessary if we are going to be locked to orthogonal always. But if we decided to support arbitrary angles, we could update this method to have it ignore orientation.
|
|
44
|
+
* @param s
|
|
45
|
+
*/
|
|
46
|
+
private _getRefConnectorSegments;
|
|
47
|
+
/**
|
|
48
|
+
* Gets the list of segments for the other orientation. This is a stub; it isnt entirely necessary if we are going to be locked to orthogonal always. But if we decided to support arbitrary angles, we could update this method to have it ignore orientation.
|
|
49
|
+
* @param s
|
|
50
|
+
*/
|
|
51
|
+
private _getOtherConnectorSegments;
|
|
52
|
+
private _getBridgeSize;
|
|
53
|
+
private _cleanupBridgesForEdge;
|
|
54
|
+
private _cleanupBridges;
|
|
55
|
+
/**
|
|
56
|
+
* Place bridges for a single edge, either looking for segment's in the current orientation in that edge only (testAllCombinations:false), or by also testing segments in any overlapping connectors. The first case is for when we're painting the whole dataset, and we know that every segment will be reached. The second case is when we're just repainting a single edge.
|
|
57
|
+
* @param edge
|
|
58
|
+
* @param testAllCombinations
|
|
59
|
+
*/
|
|
60
|
+
private _placeBridgesForEdge;
|
|
61
|
+
/**
|
|
62
|
+
* Clears the edge cache and recomputes bridges for every edge in the dataset
|
|
63
|
+
*/
|
|
64
|
+
private _placeAllBridges;
|
|
65
|
+
private _drawBridge;
|
|
66
|
+
destroy(): void;
|
|
67
|
+
reset(): void;
|
|
68
|
+
private _createMaskId;
|
|
69
|
+
private _ensureMaskDef;
|
|
70
|
+
private _removeMaskDef;
|
|
71
|
+
$edgeRemoved(edge: Edge): void;
|
|
72
|
+
$edgeRendered(p: ConnectionEstablishedParams): void;
|
|
73
|
+
}
|
|
74
|
+
export {};
|
package/types/core/io.d.ts
CHANGED
|
@@ -94,7 +94,13 @@ export interface VisuallyJsDefaultJSON {
|
|
|
94
94
|
*/
|
|
95
95
|
groups?: Array<GroupData>;
|
|
96
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Defines the default JSON datatype
|
|
99
|
+
*/
|
|
97
100
|
export declare const JSON_DATATYPE = "json";
|
|
101
|
+
/**
|
|
102
|
+
* Defines the hierarchical json datatype
|
|
103
|
+
*/
|
|
98
104
|
export declare const HIERARCHICAL_JSON_DATATYPE = "hierarchical-json";
|
|
99
105
|
/**
|
|
100
106
|
* Register a parser for some given datatype
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { AbstractLayout, InternalLayoutOptions, LayoutParameters } from "../abstract-layout";
|
|
2
|
+
import { HasIdAndType, Vertex } from "../../model/graph";
|
|
3
|
+
import { PointXY, Size } from "../../util";
|
|
4
|
+
import { DataSource } from "../../datasource";
|
|
5
|
+
import { CircularLayoutParameters } from "../circular";
|
|
6
|
+
/**
|
|
7
|
+
* Bowtie layout type.
|
|
8
|
+
* @group Layouts
|
|
9
|
+
* @category Bowtie
|
|
10
|
+
*/
|
|
11
|
+
export declare const LAYOUT_TYPE_BOWTIE = "Bowtie";
|
|
12
|
+
/**
|
|
13
|
+
* Options for the Bowtie layout
|
|
14
|
+
* @group Layouts
|
|
15
|
+
* @category Hierarchy
|
|
16
|
+
*/
|
|
17
|
+
export interface BowtieLayoutParameters extends LayoutParameters {
|
|
18
|
+
/**
|
|
19
|
+
* Whether to draw the layout horizontally or vertically. Defaults to "horizontal".
|
|
20
|
+
*/
|
|
21
|
+
axis?: "horizontal" | "vertical";
|
|
22
|
+
/**
|
|
23
|
+
* Optional node to use as the root. You must provide this or `getRootNode`.
|
|
24
|
+
*/
|
|
25
|
+
rootNode?: Vertex | string;
|
|
26
|
+
/**
|
|
27
|
+
* Optional function you can provide that will dynamically be invoked to get the root node to use. You must provide this or `rootNode`.
|
|
28
|
+
*/
|
|
29
|
+
getRootNode?: (dataSource: DataSource) => Vertex | string;
|
|
30
|
+
/**
|
|
31
|
+
* Gets immediate upstream nodes for the focus vertex. Only invoked with the focus vertex.
|
|
32
|
+
* @param dataSource
|
|
33
|
+
* @param vertex
|
|
34
|
+
*/
|
|
35
|
+
getUpstream: (dataSource: DataSource, vertex: HasIdAndType) => Array<HasIdAndType>;
|
|
36
|
+
/**
|
|
37
|
+
* Gets immediate downstream nodes for the focus vertex. Only invoked with the focus vertex.
|
|
38
|
+
* @param dataSource
|
|
39
|
+
* @param vertex
|
|
40
|
+
*/
|
|
41
|
+
getDownstream: (dataSource: DataSource, vertex: HasIdAndType) => Array<HasIdAndType>;
|
|
42
|
+
/**
|
|
43
|
+
* Optional function to invoke on any non-focus vertex, to get the vertex's children. Will not be invoked with the focus vertex. If this function returns the focus vertex in its set it will be filtered out. When you do not provide this function, VisuallyJs will find all vertices that are targets of edges for which this vertex is a source.
|
|
44
|
+
*/
|
|
45
|
+
childVerticesFunction?: (node: HasIdAndType, dataSource: DataSource) => Array<HasIdAndType>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Places the focus vertex in the center of the canvas and then branches out to the left and right - or top and bottom - with children of the focus. You are expected to supply a `getUpstream` and `getDownstream` function for this layout, as well as either `getRootNode` or `rootNode`. `getUpstream` is used to get the immediate children of the focus vertex that will be painted to the left or above, depending on axis. `getDownstream` is used to get the immediate children of the focus vertex that will be painted to the right or below. By default this layout will draw horizontally, which you can change by setting `axis:"vertical"`.
|
|
49
|
+
* @group Layouts
|
|
50
|
+
* @category Bowtie
|
|
51
|
+
*/
|
|
52
|
+
export declare class BowtieLayout extends AbstractLayout<BowtieLayoutParameters> {
|
|
53
|
+
focusVertex: Vertex;
|
|
54
|
+
static type: string;
|
|
55
|
+
readonly type = "Bowtie";
|
|
56
|
+
private readonly _getRootNode;
|
|
57
|
+
private readonly _rootNode;
|
|
58
|
+
private _axis;
|
|
59
|
+
private _getUpstreamVertices;
|
|
60
|
+
private _getDownstreamVertices;
|
|
61
|
+
private _childVerticesFunction;
|
|
62
|
+
private _defaultGetDownstream;
|
|
63
|
+
constructor(params: InternalLayoutOptions<BowtieLayoutParameters>);
|
|
64
|
+
begin(dataSource: DataSource, positionGetter: (id: string) => PointXY, positionSetter: (id: string, x: number, y: number) => void, sizes: Record<string, Size>, parameters: CircularLayoutParameters): void;
|
|
65
|
+
end(dataSource: DataSource, getPosition: (id: string) => PointXY, setPosition: (id: string, x: number, y: number) => void, sizes: Record<string, Size>, parameters: BowtieLayoutParameters): void;
|
|
66
|
+
getDefaultParameters(): BowtieLayoutParameters;
|
|
67
|
+
reset(): void;
|
|
68
|
+
step(dataSource: DataSource, getPosition: (id: string) => PointXY, setPosition: (id: string, x: number, y: number) => void, sizes: Record<string, Size>, parameters: BowtieLayoutParameters): void;
|
|
69
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./bowtie-layout";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AbstractEdgeTerminus, Edge, Group, HasId, HasIdAndType, Node } from "../../model/graph";
|
|
2
|
-
import { VisuallyJsModel } from "../../toolkit";
|
|
3
2
|
import { AbsoluteBackedLayoutParameters } from "../absolute-layout";
|
|
4
3
|
import { PlacementStageStrategy } from "./placement-stage";
|
|
5
4
|
import { HierarchyLayout } from "./hierarchy-layout";
|
|
@@ -7,6 +6,7 @@ import { VertexSet } from "./vertex-set";
|
|
|
7
6
|
import { LayoutLayerEntry, LayoutLayerOrdering } from "../abstract-layout";
|
|
8
7
|
import { GatedPath } from "../../router";
|
|
9
8
|
import { PointXY, Size } from "../../util";
|
|
9
|
+
import { DataSource } from "../../datasource";
|
|
10
10
|
/**
|
|
11
11
|
* @internal
|
|
12
12
|
*/
|
|
@@ -21,7 +21,7 @@ export declare const VERTEX = "vertex";
|
|
|
21
21
|
* @category Hierarchy
|
|
22
22
|
* @typeParam T Defines the type of the object from which child vertices will be retrieved, and the type of the child vertices.
|
|
23
23
|
*/
|
|
24
|
-
export type ChildVerticesFunction<T extends HasId> = (node: T, layer: number, instance:
|
|
24
|
+
export type ChildVerticesFunction<T extends HasId> = (node: T, layer: number, instance: DataSource) => Array<T>;
|
|
25
25
|
/**
|
|
26
26
|
* Axis types for a {@link HierarchyLayout}
|
|
27
27
|
* @group Layouts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ParentRelativePlacementStrategyOptions } from "./definitions";
|
|
2
2
|
import { HasIdAndType } from "../../model/graph";
|
|
3
3
|
import { PointXY } from "../../util";
|
|
4
|
-
import {
|
|
4
|
+
import { DataSource } from "../../datasource";
|
|
5
5
|
/**
|
|
6
6
|
* Places elements with respect to their parents, aligning them at parent start/end/center depending on the value of `alignment`.
|
|
7
7
|
* @internal
|
|
@@ -34,7 +34,7 @@ export declare class ParentRelativePlacementStrategy<T extends HasIdAndType> {
|
|
|
34
34
|
private readonly _getSize;
|
|
35
35
|
private readonly _getChildVertices;
|
|
36
36
|
private readonly _absolutePositionFunction;
|
|
37
|
-
constructor(model:
|
|
37
|
+
constructor(model: DataSource, parameters: ParentRelativePlacementStrategyOptions<T>);
|
|
38
38
|
execute(): Map<string, {
|
|
39
39
|
position: PointXY;
|
|
40
40
|
layer: number;
|
|
@@ -183,6 +183,13 @@ export declare function isNodeVertex(v: Vertex): v is Node;
|
|
|
183
183
|
* @category Utils
|
|
184
184
|
*/
|
|
185
185
|
export declare function isVertex(o: any): o is Vertex;
|
|
186
|
+
/**
|
|
187
|
+
* Checks if an edge is connected to the given vertex or any of its ports.
|
|
188
|
+
* @param edge The edge to check.
|
|
189
|
+
* @param vertex The vertex (Node or Group) to check against.
|
|
190
|
+
* @returns True if the edge's source or target (or their parent Node/Group if a Port) matches the vertex.
|
|
191
|
+
*/
|
|
192
|
+
export declare function isEdgeConnectedTo(edge: Edge, ...vertex: Array<Vertex>): boolean;
|
|
186
193
|
/**
|
|
187
194
|
* @internal
|
|
188
195
|
*/
|
|
@@ -829,6 +836,8 @@ export declare abstract class Vertex extends Base implements AbstractEdgeTerminu
|
|
|
829
836
|
* Gets all Edges where this Vertex is the target.
|
|
830
837
|
*/
|
|
831
838
|
getTargetEdges(): Array<Edge>;
|
|
839
|
+
getAllSourceEdges(): Edge[];
|
|
840
|
+
getAllTargetEdges(): Edge[];
|
|
832
841
|
/**
|
|
833
842
|
* Adds an Edge to the vertex.
|
|
834
843
|
* @param edge The Edge to add.
|
|
@@ -41,6 +41,7 @@ export interface SynthesizedEvent {
|
|
|
41
41
|
pageX: number;
|
|
42
42
|
pageY: number;
|
|
43
43
|
}
|
|
44
|
+
declare function _createMouseEventWithPageLoc(el: Element, evt: string, pageLoc: PointXY, metaKeys?: Record<string, boolean>, button?: number): void;
|
|
44
45
|
/**
|
|
45
46
|
* Callbacks you can provide to connection drag methods in the TestHarness to interrupt the process
|
|
46
47
|
* and inspect what's going on.
|
|
@@ -97,6 +98,7 @@ export declare const VisuallyJsTestSupport: {
|
|
|
97
98
|
nudgeEvent: typeof _nudgeEvent;
|
|
98
99
|
getEdgeCanvas: typeof getEdgeCanvas;
|
|
99
100
|
defaultEventManager: EventManager;
|
|
101
|
+
createMouseEventWithPageLoc: typeof _createMouseEventWithPageLoc;
|
|
100
102
|
/**
|
|
101
103
|
* Drag any DOM element around, not just elements managed by the surface.
|
|
102
104
|
* @param el
|
|
@@ -26,7 +26,6 @@ export declare const Connectors: {
|
|
|
26
26
|
register: (name: string, handler: ConnectorHandler) => void;
|
|
27
27
|
compute: (c: Connection<any>, geometry: PaintGeometry, params: ConnectorComputeParams) => Geometry;
|
|
28
28
|
update: (c: Connection<any>, geometry: PaintGeometry, params: ConnectorComputeParams, sourceMoved: boolean, targetMoved: boolean) => Geometry;
|
|
29
|
-
markEdited(connection: Connection<any>, g?: Geometry): void;
|
|
30
29
|
/**
|
|
31
30
|
* Import the given geometry, setting it on the connector, marking the connector persistToModel, and setting
|
|
32
31
|
* anchor locations to the values from the geometry, then locking them. This method does not write the
|
|
@@ -71,6 +70,7 @@ export declare function defaultImportGeometry(ac: Connector, g: Geometry): boole
|
|
|
71
70
|
*/
|
|
72
71
|
export declare function _updateConnectorBounds(ac: Connector, segment: Segment): void;
|
|
73
72
|
export declare function _clearConnectorSegments(c: Connector): void;
|
|
73
|
+
export declare function clampToHalfPixel(value: number): number;
|
|
74
74
|
export declare function _addConnectorSegment(c: Connector, type: string, params: any): void;
|
|
75
75
|
/**
|
|
76
76
|
* This abstraction exists to support using the various pointOnPath, pointAlongPath etc methods, without needing a Connector. The initial use case is to support ad-hoc drawing of edges, for such things as the edge type picker, but also this is really a step on the way to refactoring the paint code to make it less complex and more of a rubber-stamp operation.
|
package/types/ui/core/core.d.ts
CHANGED
|
@@ -97,6 +97,7 @@ export declare abstract class UICore<EL, EVT = CoreUIEvent> extends OptimisticEv
|
|
|
97
97
|
zoomToFitOnLoad: boolean;
|
|
98
98
|
plugins: Array<UIPlugin<EL, any, any>>;
|
|
99
99
|
pluginMap: Map<string, UIPlugin<EL, any, any>>;
|
|
100
|
+
_edgeRedrawPlugins: Array<UIPlugin<EL, any, any>>;
|
|
100
101
|
connectorClass: string;
|
|
101
102
|
connectorOutlineClass: string;
|
|
102
103
|
connectorPathClass: string;
|
|
@@ -37,6 +37,12 @@ export interface ViewportElement<E> extends ElementBase {
|
|
|
37
37
|
export interface ViewportNodeElement<E> extends ViewportElement<E> {
|
|
38
38
|
modelObject: Node;
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
export interface ConnectorBounds extends RectangleXY {
|
|
44
|
+
id: string;
|
|
45
|
+
}
|
|
40
46
|
/**
|
|
41
47
|
* An element that tracks a Group
|
|
42
48
|
* @internal
|
|
@@ -81,6 +87,7 @@ export declare class Viewport<EL> {
|
|
|
81
87
|
private getRenderedElement;
|
|
82
88
|
private _currentTransaction;
|
|
83
89
|
private rtree;
|
|
90
|
+
private edgertree;
|
|
84
91
|
private _suspended;
|
|
85
92
|
private _boundsDirty;
|
|
86
93
|
constructor(instance: UICore<EL, any>, getRenderedElement: (id: string) => EL);
|
|
@@ -116,6 +123,7 @@ export declare class Viewport<EL> {
|
|
|
116
123
|
* @internal
|
|
117
124
|
*/
|
|
118
125
|
findVerticesIntersectingWithRect(rect: RectangleXY, margin: number, greedy: boolean, ignoreIds: Array<string>, ignoreBoundaryMatch: boolean): Array<ViewportElement<any>>;
|
|
126
|
+
findConnectorBoundsIntersectingWithRect(rect: RectangleXY, margin: number, greedy: boolean, ignoreIds: Array<string>, ignoreBoundaryMatch: boolean): Array<ConnectorBounds>;
|
|
119
127
|
/**
|
|
120
128
|
* Returns vertices that are enclosed by the given rectangle, optionally ignoring a set of vertex IDs when performing the calculation.
|
|
121
129
|
* @param rect Rectangle to test
|
|
@@ -155,6 +163,12 @@ export declare class Viewport<EL> {
|
|
|
155
163
|
* @param doNotRecalculateBounds Defaults to false. For internal use. If true, does not update viewport bounds after updating the element.
|
|
156
164
|
*/
|
|
157
165
|
updateElement(id: string, x: number, y: number, width: number, height: number, rotation: number, modelObject: Vertex, doNotRecalculateBounds: boolean): ViewportElement<EL>;
|
|
166
|
+
/**
|
|
167
|
+
* @internal
|
|
168
|
+
* @param c
|
|
169
|
+
*/
|
|
170
|
+
$updateEdge(c: ConnectorBounds): void;
|
|
171
|
+
$removeEdge(id: string): void;
|
|
158
172
|
$forEachElement(cb: (e: ViewportElement<any>) => any): void;
|
|
159
173
|
$refreshEveryElement(): void;
|
|
160
174
|
$refreshElement(elId: string, doNotRecalculateBounds?: boolean, pos?: PointXY, size?: Size, rotation?: number): ViewportElement<EL>;
|
|
@@ -17,6 +17,15 @@ export interface UIPlugin<EL, O extends UIPluginOptions, U extends UICore<EL, an
|
|
|
17
17
|
initialise(ui: U, options: O): boolean;
|
|
18
18
|
destroy(): void;
|
|
19
19
|
reset(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Set this to true to inform the UI that the plugin wishes to be informed at the end of an edge paint.
|
|
22
|
+
*/
|
|
23
|
+
tracksEdgeRedraws: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Optional method you can implement if you set `tracksEdgeRedraws:true`; the UI will invoke this method at the end of each edge's paint cycle. You can access the underlying edge via `c.edge`.
|
|
26
|
+
* @param c
|
|
27
|
+
*/
|
|
28
|
+
$edgeRedraw?: (c: Connection<EL>) => any;
|
|
20
29
|
/**
|
|
21
30
|
* Invoked when a group member has been removed
|
|
22
31
|
* @param element
|
package/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "1.2.
|
|
1
|
+
export declare const VERSION = "1.2.4";
|