@neo4j-nvl/base 1.1.0 → 1.2.0-090ec876
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/CHANGELOG.md +25 -0
- package/dist/base.mjs +1 -1
- package/dist/types/index.d.ts +20 -1
- package/dist/types/layouts/d3forcelayout/__mocks__/d3ForceLayout.d.ts +10 -0
- package/dist/types/layouts/d3forcelayout/constants.d.ts +0 -1
- package/dist/types/layouts/d3forcelayout/d3ForceLayout.d.ts +20 -20
- package/dist/types/layouts/d3forcelayout/d3ForceLayout.test.d.ts +1 -0
- package/dist/types/layouts/d3forcelayout/types.d.ts +5 -6
- package/dist/types/layouts/forcedirectedlayout/physlayout/PhysLayout.d.ts +17 -13
- package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-fragment.d.ts +1 -1
- package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-repulsive-fragment.d.ts +1 -1
- package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-update-fragment.d.ts +1 -1
- package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/sim-vertex.d.ts +1 -1
- package/dist/types/layouts/forcedirectedlayout/physlayout/solarmerger/SolarMerger.bench.d.ts +1 -0
- package/dist/types/layouts/gridLayout/GridLayout.d.ts +25 -9
- package/dist/types/modules/NvlController.d.ts +25 -4
- package/dist/types/modules/NvlController.test.d.ts +1 -0
- package/dist/types/modules/Shader.d.ts +1 -1
- package/dist/types/modules/state/types.d.ts +32 -13
- package/dist/types/renderers/domrenderer/BaseRenderer.d.ts +1 -1
- package/dist/types/renderers/domrenderer/BaseRenderer.test.d.ts +1 -0
- package/dist/types/renderers/domrenderer/canvasrenderer/CanvasRenderer.d.ts +2 -36
- package/dist/types/renderers/domrenderer/canvasrenderer/arrowDrawing.d.ts +168 -0
- package/dist/types/renderers/domrenderer/canvasrenderer/arrowDrawing.test.d.ts +1 -0
- package/dist/types/renderers/domrenderer/canvasrenderer/nodeDrawing.d.ts +109 -0
- package/dist/types/renderers/domrenderer/canvasrenderer/nodeDrawing.test.d.ts +1 -0
- package/dist/types/renderers/domrenderer/shared/ImageCache.d.ts +3 -2
- package/dist/types/renderers/domrenderer/shared/arrows/ArrowBundle.d.ts +18 -2
- package/dist/types/renderers/domrenderer/shared/arrows/ArrowBundler.d.ts +10 -0
- package/dist/types/renderers/domrenderer/shared/nodes/nodes.d.ts +53 -1
- package/dist/types/renderers/domrenderer/shared/util.d.ts +6 -1
- package/dist/types/renderers/domrenderer/shared/wordwrap.d.ts +12 -1
- package/dist/types/renderers/domrenderer/svgrenderer/SvgRenderer.d.ts +1 -3
- package/dist/types/renderers/domrenderer/svgrenderer/arrowDrawing.d.ts +59 -0
- package/dist/types/renderers/domrenderer/svgrenderer/arrowDrawing.test.d.ts +1 -0
- package/dist/types/renderers/domrenderer/svgrenderer/nodeDrawing.d.ts +16 -0
- package/dist/types/renderers/domrenderer/svgrenderer/nodeDrawing.test.d.ts +1 -0
- package/dist/types/renderers/domrenderer/svgrenderer/svgUtils.d.ts +33 -141
- package/dist/types/renderers/domrenderer/svgrenderer/svgUtils.test.d.ts +1 -0
- package/dist/types/renderers/webglrenderer/Renderer.d.ts +1 -2
- package/dist/types/renderers/webglrenderer/node-animation-fragment.d.ts +1 -1
- package/dist/types/renderers/webglrenderer/node-animation-vertex.d.ts +1 -1
- package/dist/types/renderers/webglrenderer/node-fragment-point.d.ts +1 -1
- package/dist/types/renderers/webglrenderer/node-vertex-point.d.ts +1 -1
- package/dist/types/renderers/webglrenderer/rel-fragment-line.d.ts +1 -1
- package/dist/types/renderers/webglrenderer/rel-vertex-line.d.ts +1 -1
- package/dist/types/renderers/webglrenderer/viewport-box-fragment.d.ts +1 -1
- package/dist/types/renderers/webglrenderer/viewport-box-vertex.d.ts +1 -1
- package/dist/types/utils/canvasManagement.d.ts +1 -1
- package/dist/types/utils/constants.d.ts +8 -2
- package/dist/types/utils/geometry.d.ts +4 -0
- package/dist/types/utils/layoutSeeding.d.ts +7 -0
- package/dist/types/utils/layoutSeeding.test.d.ts +1 -0
- package/dist/types/utils/segmentAnalytics.d.ts +2 -2
- package/package.json +8 -6
- package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-fragment-verlet.d.ts +0 -2
- package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-repulsive-fragment-verlet.d.ts +0 -2
- package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/workaround-fragment.d.ts +0 -2
- package/dist/types/renderers/domrenderer/canvasrenderer/canvasUtils.d.ts +0 -56
- package/dist/types/renderers/domrenderer/shared/nodes/nodeUtils.d.ts +0 -29
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import type { BorderStyle, DisabledItemStyles } from '../../../modules/state/types';
|
|
2
|
+
import type { Relationship } from '../../../types/graph-element';
|
|
3
|
+
import type { Point } from '../../../utils/geometry';
|
|
4
|
+
import type ArrowBundle from '../shared/arrows/ArrowBundle';
|
|
5
|
+
/**
|
|
6
|
+
* Calculate label dimensions including font size, font weight, and truncated text.
|
|
7
|
+
*
|
|
8
|
+
* @param fullCaption - The complete caption text
|
|
9
|
+
* @param relWidth - The relationship width (may be undefined)
|
|
10
|
+
* @param selected - Whether the relationship is selected (affects font weight and width calculation)
|
|
11
|
+
* @param captionSize - The caption size multiplier (default 1)
|
|
12
|
+
* @param defaultRelWidth - The default relationship width to use if relWidth is undefined
|
|
13
|
+
* @param measureWidth - Function to measure text width given a text string
|
|
14
|
+
* @param maxWidth - The maximum width available for the label in pixels
|
|
15
|
+
* @returns LabelDimensions with calculated font metrics and label text
|
|
16
|
+
*/
|
|
17
|
+
export declare const calculateLabelDimensions: (fullCaption: string, measureWidth: (text: string) => number, maxWidth: number) => {
|
|
18
|
+
label: string;
|
|
19
|
+
width: number;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Calculate label transform including rotation and flip adjustments.
|
|
23
|
+
*
|
|
24
|
+
* @param angle - The base rotation angle in radians
|
|
25
|
+
* @param fontSize - The font size in pixels (including pixel ratio scaling)
|
|
26
|
+
* @param flip - Whether to flip the label (applies additional rotation)
|
|
27
|
+
* @param point - The base point (used to calculate offset in flip case)
|
|
28
|
+
* @returns object with final position and angle
|
|
29
|
+
*/
|
|
30
|
+
export declare const calculateLabelTransform: (angle: number, fontSize: number, flip: boolean, point: Point) => {
|
|
31
|
+
finalX: number;
|
|
32
|
+
finalY: number;
|
|
33
|
+
finalAngle: number;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Calculate vertical alignment offset for label based on caption alignment.
|
|
37
|
+
*
|
|
38
|
+
* @param captionAlign - The caption alignment: 'top' or 'bottom'
|
|
39
|
+
* @param fontSize - The font size in pixels (including pixel ratio scaling)
|
|
40
|
+
* @param lineWidth - The relationship line width in pixels
|
|
41
|
+
* @param padding - The padding around the label in pixels
|
|
42
|
+
* @returns The vertical offset in pixels to apply when drawing the label
|
|
43
|
+
*/
|
|
44
|
+
export declare const calculateLabelHeightAlign: (captionAlign: string, fontSize: number, lineWidth: number, padding: number) => number;
|
|
45
|
+
/**
|
|
46
|
+
* Calculate final label geometry for hit detection.
|
|
47
|
+
*
|
|
48
|
+
* @param point - The original point (before transform)
|
|
49
|
+
* @param angle - The rotation angle in radians
|
|
50
|
+
* @param maxWidth - The maximum width of the label in pixels
|
|
51
|
+
* @param fontSize - The font size in pixels (including pixel ratio scaling)
|
|
52
|
+
* @param heightAlign - The vertical alignment offset in pixels
|
|
53
|
+
* @param padding - The padding around the label in pixels
|
|
54
|
+
* @param pixelRatio - The device pixel ratio
|
|
55
|
+
* @param flip - Whether the label is flipped
|
|
56
|
+
* @returns object with position, rotation, width, and height for hit detection
|
|
57
|
+
*/
|
|
58
|
+
export declare const calculateLabelGeometry: (point: Point, angle: number, maxWidth: number, fontSize: number, heightAlign: number, padding: number, pixelRatio: number, flip: boolean) => {
|
|
59
|
+
position: {
|
|
60
|
+
x: number;
|
|
61
|
+
y: number;
|
|
62
|
+
};
|
|
63
|
+
rotation: number;
|
|
64
|
+
width: number;
|
|
65
|
+
height: number;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Determines the rendering state flags for a relationship.
|
|
69
|
+
*
|
|
70
|
+
* @param rel - The relationship to analyze
|
|
71
|
+
* @param disableArrowShadow - Global flag to disable arrow shadows
|
|
72
|
+
* @param showLabel - Whether the relationship label is visible
|
|
73
|
+
* @returns Object containing rendering state flags
|
|
74
|
+
*/
|
|
75
|
+
export declare const determineArrowRenderingState: (rel: Relationship, disableArrowShadow: boolean, showLabel: boolean) => {
|
|
76
|
+
isSelected: boolean;
|
|
77
|
+
isDisabled: boolean;
|
|
78
|
+
showOverlayIcon: boolean;
|
|
79
|
+
shouldRenderShadow: boolean;
|
|
80
|
+
shouldShowHoverEffect: boolean;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Selects relationship colors based on rendering state.
|
|
84
|
+
*
|
|
85
|
+
* @param rel - The relationship to get colors for
|
|
86
|
+
* @param selectedBorderStyle - The selected border style containing ring colors
|
|
87
|
+
* @param disabledItemStyles - Styling for disabled items
|
|
88
|
+
* @param defaultColor - Default color to use if none is specified
|
|
89
|
+
* @returns Object containing colors for different rendering layers
|
|
90
|
+
*/
|
|
91
|
+
export declare const selectArrowColors: (rel: Relationship, selectedBorderStyle: BorderStyle, disabledItemStyles: DisabledItemStyles, defaultColor: string) => {
|
|
92
|
+
mainColor: string;
|
|
93
|
+
selectedColor1: string;
|
|
94
|
+
selectedColor2: string;
|
|
95
|
+
hoverColor: string;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Calculates arrowhead adjustment for last segment truncation.
|
|
99
|
+
*
|
|
100
|
+
* @param lastSegmentDistance - Distance between the last two points
|
|
101
|
+
* @param headHeight - Height of the arrowhead
|
|
102
|
+
* @param headPositionOffset - Base position offset for the arrowhead (HeadChinHeight - headSelectedAdjustment)
|
|
103
|
+
* @param headSelectedAdjustment - Additional adjustment for selected state
|
|
104
|
+
* @param headChinHeight - Height of the arrowhead's chin (base)
|
|
105
|
+
* @param isSelected - Whether the arrow is selected
|
|
106
|
+
* @returns Object containing adjusted parameters and truncation flag
|
|
107
|
+
*/
|
|
108
|
+
export declare const calculateArrowheadAdjustment: (lastSegmentDistance: number, headHeight: number, headPositionOffset: number, headSelectedAdjustment: number, headChinHeight: number, isSelected: boolean) => {
|
|
109
|
+
adjustedHeadPositionOffset: number;
|
|
110
|
+
adjustedHeadSelectedAdjustment: number;
|
|
111
|
+
shouldTruncateLastSegment: boolean;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* The parameters for drawing an arrowhead.
|
|
115
|
+
*/
|
|
116
|
+
type ArrowHeadParameters = {
|
|
117
|
+
headPosition: Point;
|
|
118
|
+
headAngle: number;
|
|
119
|
+
headHeight: number;
|
|
120
|
+
headChinHeight: number;
|
|
121
|
+
headWidth: number;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Creates an arrowhead shape using a polygon.
|
|
125
|
+
* @param ctx - The canvas context to draw on.
|
|
126
|
+
* @param headLineWidth - The width of the arrowhead's outline.
|
|
127
|
+
* @param color - The color of the arrowhead.
|
|
128
|
+
* @param arrowHeadParameters - The parameters for the arrowhead.
|
|
129
|
+
* @param fill - Whether or not to fill the triangle.
|
|
130
|
+
* @param stroke - Whether or not to stroke the triangle.
|
|
131
|
+
*/
|
|
132
|
+
export declare const drawArrowHead: (ctx: CanvasRenderingContext2D, headLineWidth: number, color: string, arrowHeadParameters: ArrowHeadParameters, fill?: boolean, stroke?: boolean) => void;
|
|
133
|
+
/**
|
|
134
|
+
* Draws line segments on canvas (straight or curved).
|
|
135
|
+
*
|
|
136
|
+
* @param ctx - The canvas rendering context
|
|
137
|
+
* @param points - The array of points defining the segments
|
|
138
|
+
* @param width - The line width
|
|
139
|
+
* @param style - The stroke style (color)
|
|
140
|
+
* @param drawCurves - Whether to draw smooth curves through points
|
|
141
|
+
*/
|
|
142
|
+
export declare const drawSegments: (ctx: CanvasRenderingContext2D, points: Point[], width: number, style: string, drawCurves: boolean) => void;
|
|
143
|
+
/**
|
|
144
|
+
* Draws a self-referencing loop on canvas using two quadratic Bézier curves.
|
|
145
|
+
*
|
|
146
|
+
* @param ctx - The canvas rendering context
|
|
147
|
+
* @param fromPoint - The start point of the loop
|
|
148
|
+
* @param toPoint - The end point of the loop
|
|
149
|
+
* @param apexPoint - The top point of the loop arc
|
|
150
|
+
* @param control1Point - Control point for the first curve segment
|
|
151
|
+
* @param control2Point - Control point for the second curve segment
|
|
152
|
+
*/
|
|
153
|
+
export declare const drawLoop: (ctx: CanvasRenderingContext2D, fromPoint: Point, toPoint: Point, apexPoint: Point, control1Point: Point, control2Point: Point) => void;
|
|
154
|
+
/**
|
|
155
|
+
* Draws a label for a relationship on canvas.
|
|
156
|
+
*
|
|
157
|
+
* @param ctx - The canvas rendering context
|
|
158
|
+
* @param point - The position to draw the label at
|
|
159
|
+
* @param angle - The rotation angle for the label
|
|
160
|
+
* @param maxWidth - The maximum width available for the label
|
|
161
|
+
* @param rel - The relationship to draw the label for
|
|
162
|
+
* @param bundle - The arrow bundle containing label info
|
|
163
|
+
* @param disabledItemStyles - Styles for disabled items
|
|
164
|
+
* @param fontColor - The font color to use
|
|
165
|
+
* @param flip - Whether to flip the label orientation (default false)
|
|
166
|
+
*/
|
|
167
|
+
export declare const drawLabel: (ctx: CanvasRenderingContext2D, point: Point, angle: number, maxWidth: number, rel: Relationship, bundle: ArrowBundle, disabledItemStyles: DisabledItemStyles, fontColor: string, flip?: boolean) => void;
|
|
168
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { BorderStyle, DisabledItemStyles, ShadowStyle } from '../../../modules/state/types';
|
|
2
|
+
import type { Node } from '../../../types/graph-element';
|
|
3
|
+
import type { TextSegment } from '../shared/types';
|
|
4
|
+
import type AnimationHandler from './AnimationHandler';
|
|
5
|
+
/**
|
|
6
|
+
* Draws borders around a node with a given array of border styles
|
|
7
|
+
* @param ctx - The canvas context.
|
|
8
|
+
* @param x - The x coordinate of the node.
|
|
9
|
+
* @param y - The y coordinate of the node.
|
|
10
|
+
* @param innerRadius - The inner radius of the node without any border.
|
|
11
|
+
* @param borderStyles - An array of border styles.
|
|
12
|
+
* @internal
|
|
13
|
+
* @hidden
|
|
14
|
+
*/
|
|
15
|
+
export declare const drawCircleBand: (ctx: CanvasRenderingContext2D, x: number, y: number, innerRadius: number, borderStyles: {
|
|
16
|
+
width: number;
|
|
17
|
+
color: string;
|
|
18
|
+
}[]) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Fill a circle band with a gradient from a certain color to transparent
|
|
21
|
+
* @param ctx - The canvas context.
|
|
22
|
+
* @param x - The x coordinate of the node.
|
|
23
|
+
* @param y - The y coordinate of the node.
|
|
24
|
+
* @param color - The color of the gradient.
|
|
25
|
+
* @param radius - The inner radius of the node without any border.
|
|
26
|
+
* @param blur - The blur radius of the gradient.
|
|
27
|
+
* @param maxOpacity - The maximum opacity of the gradient.
|
|
28
|
+
*/
|
|
29
|
+
export declare const drawGradientCircleBand: (ctx: CanvasRenderingContext2D, x: number, y: number, color: string, radius: number, blur: number, maxOpacity?: number) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Draw a circle shape with a solid color
|
|
32
|
+
*/
|
|
33
|
+
export declare const drawSolidCircle: (ctx: CanvasRenderingContext2D, x: number, y: number, color: string, size: number) => void;
|
|
34
|
+
/**
|
|
35
|
+
* Prints the caption for a node
|
|
36
|
+
*/
|
|
37
|
+
export declare const drawNodeCaption: (ctx: CanvasRenderingContext2D, lines: TextSegment[], stylesPerChar: string[][], initialYPos: number, fontSize: number, fontFace: string, lineDistance: number, x: number, y: number, ellipsisWidth: number) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Calculate pulse animation parameters based on current animation state.
|
|
40
|
+
* The pulse grows from the node center to 1.88x the node radius, then fades out.
|
|
41
|
+
* This creates an expanding circle effect.
|
|
42
|
+
*
|
|
43
|
+
* @param nodeId - The unique identifier of the node
|
|
44
|
+
* @param animationHandler - The animation handler managing animation state
|
|
45
|
+
* @param mainFaceRadius - The radius of the main node circle in pixels
|
|
46
|
+
* @returns The calculated pulse radius
|
|
47
|
+
*/
|
|
48
|
+
export declare const calculatePulseAnimation: (mainFaceRadius: number) => {
|
|
49
|
+
pulseRadius: number;
|
|
50
|
+
pulseVisibility: number;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Calculate shadow animation parameters based on node state.
|
|
54
|
+
* Animates shadow width from 0 to target based on selected/hovered state.
|
|
55
|
+
*
|
|
56
|
+
* @param nodeId - The unique identifier of the node
|
|
57
|
+
* @param animationHandler - The animation handler managing animation state
|
|
58
|
+
* @param selected - Whether the node is selected
|
|
59
|
+
* @param hovered - Whether the node is hovered
|
|
60
|
+
* @param shadowStyle - The shadow style configuration
|
|
61
|
+
* @returns Object with shadowWidth, shadowFade, and shadowColor, or null if no shadow needed
|
|
62
|
+
*/
|
|
63
|
+
export declare const calculateShadowAnimation: (nodeId: string, animationHandler: AnimationHandler, selected: boolean, hovered: boolean, shadowStyle: ShadowStyle) => {
|
|
64
|
+
shadowWidth: number;
|
|
65
|
+
shadowColor: string;
|
|
66
|
+
shadowFade: number;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Returns an array of styles for the rings of a node.
|
|
70
|
+
* If the node is selected, it uses the selected ring styles.
|
|
71
|
+
* Otherwise, it uses the default ring styles.
|
|
72
|
+
* When no rings are configured, existing ring animations are wound down.
|
|
73
|
+
*
|
|
74
|
+
* @param node - The node to get the ring styles for.
|
|
75
|
+
* @param animationHandler - The animation handler.
|
|
76
|
+
* @param nodeBorderStyles - The node border styles.
|
|
77
|
+
* @returns An array of ring styles with computed widths.
|
|
78
|
+
*/
|
|
79
|
+
export type NodeRenderParamsInput = {
|
|
80
|
+
node: Node;
|
|
81
|
+
mainFaceRadius: number;
|
|
82
|
+
disabled: boolean;
|
|
83
|
+
disabledItemStyles: DisabledItemStyles;
|
|
84
|
+
selectedBorderStyle: BorderStyle;
|
|
85
|
+
animationHandler: AnimationHandler;
|
|
86
|
+
defaultNodeColor: string;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Calculate all node render parameters at once.
|
|
90
|
+
* This is the main entry point for preparing node rendering calculations.
|
|
91
|
+
*
|
|
92
|
+
* @param input - The input parameters object
|
|
93
|
+
* @returns object with node render parameters
|
|
94
|
+
*/
|
|
95
|
+
export declare const calculateNodeRenderParams: (input: NodeRenderParamsInput) => {
|
|
96
|
+
nodeColor: string;
|
|
97
|
+
fontColor: string;
|
|
98
|
+
shouldRenderPulse: boolean;
|
|
99
|
+
pulseAnimation: {
|
|
100
|
+
pulseColor: string;
|
|
101
|
+
pulseRadius: number;
|
|
102
|
+
};
|
|
103
|
+
shouldRenderShadow: boolean;
|
|
104
|
+
shadowAnimation: {
|
|
105
|
+
shadowWidth: number;
|
|
106
|
+
shadowFade: number;
|
|
107
|
+
shadowColor: string;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { Cache } from '../shared/types';
|
|
2
2
|
declare class ImageCache {
|
|
3
|
-
cache: Cache;
|
|
4
|
-
|
|
3
|
+
readonly cache: Cache;
|
|
4
|
+
private readonly onImageLoadedCb?;
|
|
5
|
+
constructor(onImageLoaded?: () => void);
|
|
5
6
|
getImage(src: string, inverted?: boolean): HTMLCanvasElement;
|
|
6
7
|
private getOrCreateEntry;
|
|
7
8
|
private invertCanvas;
|
|
@@ -19,12 +19,28 @@ export default class ArrowBundle {
|
|
|
19
19
|
toId: string;
|
|
20
20
|
angles: number[];
|
|
21
21
|
labelInfo: Record<string, LabelGeometry>;
|
|
22
|
+
relIndexCache: Map<string, number>;
|
|
23
|
+
relDirectionCache: Map<string, boolean>;
|
|
24
|
+
private cachedMaxFontSize;
|
|
22
25
|
/**
|
|
23
26
|
* @param key - The key of the arrow bundle.
|
|
24
27
|
* @param fromId - The source node of the arrow bundle.
|
|
25
28
|
* @param toId - The target node of the arrow bundle.
|
|
26
29
|
*/
|
|
27
30
|
constructor(key: string, fromId: string, toId: string);
|
|
31
|
+
/**
|
|
32
|
+
* Recalculate and cache the maximum font size
|
|
33
|
+
*/
|
|
34
|
+
updateMaxFontSize(): void;
|
|
35
|
+
/**
|
|
36
|
+
* Updates the relationship direction cache with a given relationship
|
|
37
|
+
* @param rel - The relationship to update the direction for.
|
|
38
|
+
*/
|
|
39
|
+
updateRelDirection(rel: Relationship): void;
|
|
40
|
+
/**
|
|
41
|
+
* Regenerates index cache for rel ids in bundle
|
|
42
|
+
*/
|
|
43
|
+
updateIndexCache(): void;
|
|
28
44
|
/**
|
|
29
45
|
* Insert a new arrow to the bundle
|
|
30
46
|
* @param rel - The relationship to insert.
|
|
@@ -53,7 +69,7 @@ export default class ArrowBundle {
|
|
|
53
69
|
* @param rel - The relationship to check.
|
|
54
70
|
* @returns True if the relationship is in opposite direction to the bundle.
|
|
55
71
|
*/
|
|
56
|
-
relIsOppositeDirection({
|
|
72
|
+
relIsOppositeDirection({ id }: Relationship): boolean;
|
|
57
73
|
/**
|
|
58
74
|
* Get the index of a given arrow in the bundle
|
|
59
75
|
* @param rel - The arrow to look for.
|
|
@@ -65,7 +81,7 @@ export default class ArrowBundle {
|
|
|
65
81
|
* @param index - The index of the arrow to get.
|
|
66
82
|
* @returns The arrow at the given index.
|
|
67
83
|
*/
|
|
68
|
-
getRel(index: number): Relationship
|
|
84
|
+
getRel(index: number): Relationship;
|
|
69
85
|
/**
|
|
70
86
|
* Set the waypoints for the arrow bundle
|
|
71
87
|
* @param waypoints - The waypoints for the arrow bundle.
|
|
@@ -4,6 +4,7 @@ import ArrowBundle from './ArrowBundle';
|
|
|
4
4
|
export default class ArrowBundler {
|
|
5
5
|
bundles: Record<string, ArrowBundle>;
|
|
6
6
|
nodeToBundles: Record<string, ArrowBundle[]>;
|
|
7
|
+
relToBundleKey: Map<string, string>;
|
|
7
8
|
constructor(rels: Relationship[], waypoints: Record<string, WaypointPath>);
|
|
8
9
|
/**
|
|
9
10
|
* Get the arrow bundle for a given relation
|
|
@@ -23,6 +24,15 @@ export default class ArrowBundler {
|
|
|
23
24
|
* @param positionMap A map of node IDs to positions.
|
|
24
25
|
*/
|
|
25
26
|
updatePositions(positionMap: Record<string, Node>): void;
|
|
27
|
+
/**
|
|
28
|
+
* Remove a bundle reference from the node→bundles index for one node id.
|
|
29
|
+
*/
|
|
30
|
+
private removeNodeFromMap;
|
|
31
|
+
/**
|
|
32
|
+
* Remove a relationship from a bundle.
|
|
33
|
+
* If the bundle is now empty, remove it from `bundles` and the node index.
|
|
34
|
+
*/
|
|
35
|
+
private removeRelFromBundle;
|
|
26
36
|
/**
|
|
27
37
|
* Get a unique ID for a pair of IDs
|
|
28
38
|
* @param id1 - The first ID.
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
+
import type { BorderStyles } from '../../../../modules/state/types';
|
|
1
2
|
import type { Node } from '../../../../types/graph-element';
|
|
3
|
+
import type AnimationHandler from '../../canvasrenderer/AnimationHandler';
|
|
4
|
+
import type { TextSegment } from '../types';
|
|
5
|
+
/**
|
|
6
|
+
* Returns the effective node size, which is either the provided size
|
|
7
|
+
* if it's a positive and finite number, or the default node size otherwise.
|
|
8
|
+
* @param size
|
|
9
|
+
* @returns The effective node size.
|
|
10
|
+
*/
|
|
11
|
+
export declare const getEffectiveNodeSize: (size?: number) => number;
|
|
2
12
|
/**
|
|
3
13
|
* Returns the bounding box of a node with the given x, y, and size properties.
|
|
4
14
|
* If no size is given, the default size is used.
|
|
@@ -46,6 +56,16 @@ export declare const getNodeOverlayIconPosition: (iconSize: number, mainFaceRadi
|
|
|
46
56
|
iconXPos: number;
|
|
47
57
|
iconYPos: number;
|
|
48
58
|
};
|
|
59
|
+
/**
|
|
60
|
+
* Returns the caption font size that should be used
|
|
61
|
+
* for the given info level and node diameter.
|
|
62
|
+
* @param infoLevel {number} - The info level.
|
|
63
|
+
* @param nodeRadius {number} - The radius of the node.
|
|
64
|
+
* @param captionSize {number} - The size of the caption.
|
|
65
|
+
* @param hasIcon {boolean} - Whether the node has an icon.
|
|
66
|
+
* @returns {number} - The font size.
|
|
67
|
+
*/
|
|
68
|
+
export declare const infoLevelToFontSize: (infoLevel: number, nodeRadius?: number, captionSize?: number, hasIcon?: boolean) => number;
|
|
49
69
|
/**
|
|
50
70
|
* Calculates the rendered radius of a node including pixel ratio
|
|
51
71
|
* @param node - The node object with optional size property
|
|
@@ -55,4 +75,36 @@ export declare const getNodeOverlayIconPosition: (iconSize: number, mainFaceRadi
|
|
|
55
75
|
*/
|
|
56
76
|
export declare const getNodeRadius: (node: {
|
|
57
77
|
size?: number;
|
|
58
|
-
}
|
|
78
|
+
}) => number;
|
|
79
|
+
/**
|
|
80
|
+
* Prepares node caption data for rendering (works for both Canvas and SVG)
|
|
81
|
+
* @param node - The node to prepare caption data for
|
|
82
|
+
* @param zoomLevel - Current zoom level
|
|
83
|
+
* @param ctx - Canvas context for text measurement (optional for SVG, will create one if not provided)
|
|
84
|
+
* @returns Caption rendering data including lines, styles, positioning, and font info
|
|
85
|
+
*/
|
|
86
|
+
export declare const prepareNodeCaptionData: (node: Node, zoomLevel: number, ctx?: CanvasRenderingContext2D) => {
|
|
87
|
+
lines: TextSegment[];
|
|
88
|
+
stylesPerChar: string[][];
|
|
89
|
+
fullCaption: string;
|
|
90
|
+
fontSize: number;
|
|
91
|
+
fontFace: string;
|
|
92
|
+
fontColor: string;
|
|
93
|
+
yPos: number;
|
|
94
|
+
maxNoLines: number;
|
|
95
|
+
hasContent: boolean;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Returns an array of styles for the rings of a node.
|
|
99
|
+
* If the node is selected, it uses the selected ring styles.
|
|
100
|
+
* Otherwise, it uses the default ring styles.
|
|
101
|
+
*
|
|
102
|
+
* @param node - The node to get the ring styles for.
|
|
103
|
+
* @param nodeBorderStyles - The node border styles.
|
|
104
|
+
* @param animationHandler - Optional animation handler for animating ring width changes.
|
|
105
|
+
* @returns An array of ring styles with computed widths.
|
|
106
|
+
*/
|
|
107
|
+
export declare const getRingStyles: (node: Node, nodeBorderStyles: BorderStyles, animationHandler?: AnimationHandler) => {
|
|
108
|
+
width: number;
|
|
109
|
+
color: string;
|
|
110
|
+
}[];
|
|
@@ -4,8 +4,13 @@ export declare const fontThresholds: [number, number][];
|
|
|
4
4
|
* @param color - * @param opacity - * @returns rgba() string with the given opacity.
|
|
5
5
|
*/
|
|
6
6
|
export declare const overrideOpacity: (color: string, opacity: number) => string;
|
|
7
|
-
export declare
|
|
7
|
+
export declare const getIndividualInfoLevels: (r: number, zoomLevel: number) => {
|
|
8
8
|
nodeInfoLevel: number;
|
|
9
9
|
fontInfoLevel: number;
|
|
10
10
|
iconInfoLevel: number;
|
|
11
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* On-screen size for a node icon drawn at `iconDrawSize` in graph space
|
|
14
|
+
* under a uniform `scale(zoom)` viewport transform.
|
|
15
|
+
*/
|
|
16
|
+
export declare const getNodeIconScreenPx: (iconDrawSize: number, zoom: number) => number;
|
|
@@ -36,11 +36,22 @@ export declare const tryWithNumberOfLines: (text: string, measureWidth: (text: s
|
|
|
36
36
|
export declare const tryBreakingOnSpaces: (text: string, measureWidth: (text: string) => number, getAvailableWidth: (a: number, b: number) => number, numberOfLines: number) => TextSegment[];
|
|
37
37
|
/**
|
|
38
38
|
* @param ctx - = Canvas.2dContext
|
|
39
|
-
* @param
|
|
39
|
+
* @param text - The text to display
|
|
40
40
|
*
|
|
41
41
|
* @return array of text lines
|
|
42
42
|
*/
|
|
43
43
|
export declare const getLines: (ctx: CanvasRenderingContext2D, text: string, fontFace: string, fontSize: string | number, maxWidth: number, hasIcon: boolean, maxNoLines: number, align: string) => TextSegment[];
|
|
44
|
+
/**
|
|
45
|
+
* Groups consecutive characters with the same style into text spans.
|
|
46
|
+
* @param lineText - The text of the line to process.
|
|
47
|
+
* @param stylesPerChar - A 2D array where each entry corresponds to a character.
|
|
48
|
+
* @param startCharIndex - The index of the first character of lineText in the full caption.
|
|
49
|
+
* @returns An array of objects, each containing a text span and its associated style string.
|
|
50
|
+
*/
|
|
51
|
+
export declare const getGroupedTextSpans: (lineText: string, stylesPerChar: string[][], startCharIndex: number) => {
|
|
52
|
+
text: string;
|
|
53
|
+
style: string;
|
|
54
|
+
}[];
|
|
44
55
|
/**
|
|
45
56
|
* Returns the styles by char for a group of property values.
|
|
46
57
|
* @param captions - = array of captions
|
|
@@ -6,6 +6,7 @@ export default class SvgRenderer extends BaseRenderer {
|
|
|
6
6
|
private svg;
|
|
7
7
|
private measurementContext;
|
|
8
8
|
constructor(svg: SVGSVGElement, state: NvlState, options?: RendererOptions);
|
|
9
|
+
clear(): void;
|
|
9
10
|
render(positionArray: Node[], positionBoundaries?: {
|
|
10
11
|
centerX: number;
|
|
11
12
|
centerY: number;
|
|
@@ -16,7 +17,4 @@ export default class SvgRenderer extends BaseRenderer {
|
|
|
16
17
|
backgroundColor?: string;
|
|
17
18
|
showCaptions?: boolean;
|
|
18
19
|
}): void;
|
|
19
|
-
private renderNodes;
|
|
20
|
-
private renderRelationships;
|
|
21
|
-
private getSvgTransform;
|
|
22
20
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { BorderStyles, DisabledItemStyles } from '../../../modules/state/types';
|
|
2
|
+
import type { Point } from '../../../utils/geometry';
|
|
3
|
+
import type ImageCache from '../shared/ImageCache';
|
|
4
|
+
import type ArrowBundler from '../shared/arrows/ArrowBundler';
|
|
5
|
+
import type { RelationshipToRender } from '../shared/types';
|
|
6
|
+
/**
|
|
7
|
+
* Builds an SVG path string for a self-referencing loop using quadratic curves
|
|
8
|
+
*/
|
|
9
|
+
export declare const buildSelfLoopPath: (startPoint: Point, endPoint: Point, apexPoint: Point, control1Point: Point, control2Point: Point) => string;
|
|
10
|
+
/**
|
|
11
|
+
* Builds an SVG path string for a polyline with quadratic curves between points
|
|
12
|
+
*/
|
|
13
|
+
export declare const buildQuadraticCurvePath: (points: Point[]) => string;
|
|
14
|
+
/**
|
|
15
|
+
* Converts an array of points to an SVG polyline points attribute string
|
|
16
|
+
*/
|
|
17
|
+
export declare const pointsToPolylineString: (points: Point[]) => string;
|
|
18
|
+
/**
|
|
19
|
+
* Creates an SVG arrowhead polygon element with selection rings
|
|
20
|
+
*/
|
|
21
|
+
export declare const createArrowHeadWithRings: (arrowHead: {
|
|
22
|
+
tip: Point;
|
|
23
|
+
base1: Point;
|
|
24
|
+
base2: Point;
|
|
25
|
+
}, fillColor: string, rings: {
|
|
26
|
+
color: string;
|
|
27
|
+
width: number;
|
|
28
|
+
}[]) => SVGPolygonElement[];
|
|
29
|
+
/**
|
|
30
|
+
* Creates an SVG path element with selection rings
|
|
31
|
+
*/
|
|
32
|
+
export declare const createPathWithRings: (pathData: string, strokeColor: string, strokeWidth: number, rings: {
|
|
33
|
+
color: string;
|
|
34
|
+
width: number;
|
|
35
|
+
}[]) => SVGPathElement[];
|
|
36
|
+
/**
|
|
37
|
+
* Creates an SVG polyline element with selection rings
|
|
38
|
+
*/
|
|
39
|
+
export declare const createPolylineWithRings: (points: string, strokeColor: string, strokeWidth: number, rings: {
|
|
40
|
+
color: string;
|
|
41
|
+
width: number;
|
|
42
|
+
}[]) => SVGPolylineElement[];
|
|
43
|
+
/**
|
|
44
|
+
* Calculates the proper angle for relationship labels to prevent upside-down text (SVG-specific)
|
|
45
|
+
*/
|
|
46
|
+
export declare const getCorrectLabelAngle: (angle: number) => number;
|
|
47
|
+
/**
|
|
48
|
+
* Renders an array of relationships to an SVG element.
|
|
49
|
+
*
|
|
50
|
+
* @param relationshipsToRender - Relationships with endpoint data to render
|
|
51
|
+
* @param svg - The SVG element to append relationship elements to
|
|
52
|
+
* @param drawCurves - Whether to draw curved paths (true) or polylines (false)
|
|
53
|
+
* @param arrowBundler - The arrow bundler for resolving relationship bundles
|
|
54
|
+
* @param disabledItemStyles - Styles for disabled relationships
|
|
55
|
+
* @param defaultRelationshipColor - Default relationship color
|
|
56
|
+
* @param relationshipBorderStyles - Border/ring styles for relationships
|
|
57
|
+
* @param measurementContext - Canvas 2D context for text measurement
|
|
58
|
+
*/
|
|
59
|
+
export declare const renderSvgRelationships: (relationshipsToRender: RelationshipToRender[], svg: SVGElement, drawCurves: boolean, arrowBundler: ArrowBundler, disabledItemStyles: DisabledItemStyles, defaultRelationshipColor: string, relationshipBorderStyles: BorderStyles, measurementContext: CanvasRenderingContext2D, imageCache: ImageCache) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { BorderStyles, DisabledItemStyles } from '../../../modules/state/types';
|
|
2
|
+
import type { Node } from '../../../types/graph-element';
|
|
3
|
+
import type ImageCache from '../shared/ImageCache';
|
|
4
|
+
/**
|
|
5
|
+
* Renders an array of nodes to an SVG element.
|
|
6
|
+
*
|
|
7
|
+
* @param nodesToRender - Nodes with position data to render
|
|
8
|
+
* @param svg - The SVG element to append node groups to
|
|
9
|
+
* @param zoom - Current zoom level
|
|
10
|
+
* @param idToItem - Map from node IDs to full node data
|
|
11
|
+
* @param disabledItemStyles - Styles for disabled nodes
|
|
12
|
+
* @param defaultNodeColor - Default node color
|
|
13
|
+
* @param nodeBorderStyles - Border/ring styles for nodes
|
|
14
|
+
* @param imageCache - Image cache for node icons
|
|
15
|
+
*/
|
|
16
|
+
export declare const renderSvgNodes: (nodesToRender: Node[], svg: SVGElement, zoom: number, idToItem: Record<string, Node>, disabledItemStyles: DisabledItemStyles, defaultNodeColor: string, nodeBorderStyles: BorderStyles, imageCache: ImageCache) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|