@neo4j-nvl/base 1.0.0-ccb2e2ae → 1.0.0-d3f03590
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/dist/base.mjs +1 -1
- package/dist/types/index.d.ts +19 -4
- package/dist/types/layouts/forcedirectedlayout/ForceCytoLayout.d.ts +1 -1
- package/dist/types/layouts/forcedirectedlayout/physlayout/PhysLayout.d.ts +6 -1
- package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-fragment-verlet.d.ts +1 -1
- package/dist/types/modules/NvlController.d.ts +5 -2
- package/dist/types/modules/state/types.d.ts +12 -6
- package/dist/types/modules/state/utils.d.ts +2 -2
- package/dist/types/renderers/domrenderer/BaseRenderer.d.ts +70 -0
- package/dist/types/renderers/domrenderer/canvasrenderer/CanvasRenderer.d.ts +152 -0
- package/dist/types/renderers/{canvasrenderer/util.d.ts → domrenderer/canvasrenderer/canvasUtils.d.ts} +2 -14
- package/dist/types/renderers/{canvasrenderer → domrenderer/shared}/ImageCache.d.ts +1 -1
- package/dist/types/renderers/{canvasrenderer → domrenderer/shared}/arrows/ArrowBundle.d.ts +2 -2
- package/dist/types/renderers/{canvasrenderer → domrenderer/shared}/arrows/ArrowBundler.d.ts +1 -1
- package/dist/types/renderers/domrenderer/shared/arrows/arrows.d.ts +148 -0
- package/dist/types/renderers/domrenderer/shared/nodes/nodeUtils.d.ts +29 -0
- package/dist/types/renderers/domrenderer/shared/nodes/nodes.d.ts +58 -0
- package/dist/types/renderers/{canvasrenderer → domrenderer/shared}/types.d.ts +2 -2
- package/dist/types/renderers/domrenderer/shared/util.d.ts +11 -0
- package/dist/types/renderers/{canvasrenderer → domrenderer/shared}/vectorUtils.d.ts +1 -1
- package/dist/types/renderers/domrenderer/svgrenderer/SvgRenderer.d.ts +25 -0
- package/dist/types/renderers/domrenderer/svgrenderer/SvgRenderer.test.d.ts +1 -0
- package/dist/types/renderers/domrenderer/svgrenderer/svgUtils.d.ts +191 -0
- package/dist/types/renderers/webglrenderer/Renderer.d.ts +5 -1
- package/dist/types/renderers/webglrenderer/Renderer.test.d.ts +1 -0
- package/dist/types/types/graph-element.d.ts +1 -1
- package/dist/types/utils/canvasManagement.d.ts +1 -1
- package/dist/types/utils/constants.d.ts +4 -1
- package/dist/types/utils/graphObjectUtils.d.ts +2 -2
- package/dist/types/utils/jsDriverResultTransformer.d.ts +1 -1
- package/package.json +23 -23
- package/dist/types/renderers/canvasrenderer/CanvasRenderer.d.ts +0 -93
- package/dist/types/renderers/canvasrenderer/arrows/arrows.d.ts +0 -55
- package/dist/types/renderers/canvasrenderer/nodes/nodes.d.ts +0 -59
- /package/dist/types/renderers/{canvasrenderer → domrenderer/canvasrenderer}/Animation.d.ts +0 -0
- /package/dist/types/renderers/{canvasrenderer → domrenderer/canvasrenderer}/Animation.test.d.ts +0 -0
- /package/dist/types/renderers/{canvasrenderer → domrenderer/canvasrenderer}/AnimationHandler.d.ts +0 -0
- /package/dist/types/renderers/{canvasrenderer → domrenderer/canvasrenderer}/CanvasRenderer.test.d.ts +0 -0
- /package/dist/types/renderers/{canvasrenderer → domrenderer/shared}/ImageCache.test.d.ts +0 -0
- /package/dist/types/renderers/{canvasrenderer → domrenderer/shared}/arrows/ArrowBundle.test.d.ts +0 -0
- /package/dist/types/renderers/{canvasrenderer → domrenderer/shared}/arrows/ArrowBundler.test.d.ts +0 -0
- /package/dist/types/renderers/{canvasrenderer → domrenderer/shared}/arrows/arrows.test.d.ts +0 -0
- /package/dist/types/renderers/{canvasrenderer → domrenderer/shared}/arrows/constants.d.ts +0 -0
- /package/dist/types/renderers/{canvasrenderer → domrenderer/shared}/nodes/nodes.test.d.ts +0 -0
- /package/dist/types/renderers/{canvasrenderer → domrenderer/shared}/util.test.d.ts +0 -0
- /package/dist/types/renderers/{canvasrenderer → domrenderer/shared}/wordwrap.d.ts +0 -0
- /package/dist/types/renderers/{canvasrenderer → domrenderer/shared}/wordwrap.test.d.ts +0 -0
package/dist/types/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ExternalCallbacks } from './modules/ExternalCallbackHandler';
|
|
2
|
-
import type { CircularOptions, ForceDirectedOptions, HierarchicalOptions, Layout, LayoutOptions, NvlOptions, NvlState,
|
|
3
|
-
import { CanvasRendererType, CircularLayoutType, ForceDirectedLayoutType, FreeLayoutType, GridLayoutType, HierarchicalLayoutType, WebGLRendererType, d3ForceLayoutType } from './modules/state/types';
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
2
|
+
import type { CircularOptions, ForceDirectedOptions, HierarchicalOptions, Renderer as InternalRenderer, Layout, LayoutOptions, NvlOptions, NvlState, ZoomOptions } from './modules/state/types';
|
|
3
|
+
import { CanvasRendererType, CircularLayoutType, ForceDirectedLayoutType, FreeLayoutType, GridLayoutType, HierarchicalLayoutType, SvgRendererType, WebGLRendererType, d3ForceLayoutType } from './modules/state/types';
|
|
4
|
+
import { drawCircleBand } from './renderers/domrenderer/canvasrenderer/canvasUtils';
|
|
5
|
+
import type { StyledCaption } from './renderers/domrenderer/shared/types';
|
|
6
6
|
import type { Node, PartialNode, PartialRelationship, Relationship } from './types/graph-element';
|
|
7
7
|
import { CompatibilityError } from './utils/errors';
|
|
8
8
|
import type { Point } from './utils/geometry';
|
|
@@ -269,6 +269,17 @@ declare class NVL {
|
|
|
269
269
|
filename?: string;
|
|
270
270
|
backgroundColor?: string;
|
|
271
271
|
}): void;
|
|
272
|
+
/**
|
|
273
|
+
* Saves the entire graph visualization as an SVG file to the client.
|
|
274
|
+
* @param options - Options for the SVG export
|
|
275
|
+
* @param options.filename - The filename of the SVG file.
|
|
276
|
+
* @param options.backgroundColor - The background color of the SVG file.
|
|
277
|
+
* @experimental
|
|
278
|
+
*/
|
|
279
|
+
saveToSvg(options?: {
|
|
280
|
+
filename?: string;
|
|
281
|
+
backgroundColor?: string;
|
|
282
|
+
}): void;
|
|
272
283
|
/**
|
|
273
284
|
* Returns the current view of the graph visualization canvas as a data URL.
|
|
274
285
|
* @param options - The options for the image.
|
|
@@ -376,6 +387,10 @@ declare class NVL {
|
|
|
376
387
|
declare const colorMapperFunctions: {
|
|
377
388
|
textColorForBackground: (color: string) => string;
|
|
378
389
|
};
|
|
390
|
+
/**
|
|
391
|
+
* The different types of renderers available
|
|
392
|
+
*/
|
|
393
|
+
type Renderer = Exclude<InternalRenderer, typeof SvgRendererType>;
|
|
379
394
|
export default NVL;
|
|
380
395
|
export type { NvlOptions, Renderer, Node, Relationship, PartialNode, PartialRelationship, Layout, LayoutOptions, ForceDirectedOptions, HierarchicalOptions, CircularOptions, ExternalCallbacks, HitTargets, HitTargetNode, HitTargetRelationship, Point, NvlMouseEvent, ZoomOptions, StyledCaption, WebGLRendererType, CanvasRendererType };
|
|
381
396
|
export { NVL, colorMapperFunctions, CompatibilityError, ForceDirectedLayoutType, HierarchicalLayoutType, GridLayoutType, FreeLayoutType, d3ForceLayoutType, CircularLayoutType, drawCircleBand, nvlResultTransformer, getZoomTargetForNodePositions };
|
|
@@ -16,7 +16,7 @@ export declare class ForceCytoLayout {
|
|
|
16
16
|
getShouldUpdate(): boolean;
|
|
17
17
|
getComputing(): boolean;
|
|
18
18
|
updateNodes(positionList: any): void;
|
|
19
|
-
getNodePositions(data: any): import("
|
|
19
|
+
getNodePositions(data: any): import("../..").Node[];
|
|
20
20
|
terminateUpdate(): void;
|
|
21
21
|
destroy(): void;
|
|
22
22
|
}
|
|
@@ -52,9 +52,14 @@ export declare class PhysLayout {
|
|
|
52
52
|
private pinTexture;
|
|
53
53
|
private addedNodes;
|
|
54
54
|
private updateTexture;
|
|
55
|
+
private vaoExt;
|
|
56
|
+
private physVao;
|
|
57
|
+
private physSmallVao;
|
|
58
|
+
private updateVao;
|
|
59
|
+
private workaroundVao;
|
|
55
60
|
enableVerlet: boolean;
|
|
56
61
|
constructor(config: ForceDirectedOptions & {
|
|
57
|
-
webGLContext:
|
|
62
|
+
webGLContext: WebGLRenderingContext;
|
|
58
63
|
state: NvlState;
|
|
59
64
|
});
|
|
60
65
|
/**
|
package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-fragment-verlet.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "precision mediump float;\n\nuniform sampler2D u_physData;\nuniform sampler2D u_connections;\nuniform sampler2D u_connectionOffsets;\nuniform sampler2D u_pinnedNodes;\nuniform sampler2D u_sizeTexture;\nuniform float u_baseLength;\nuniform float u_curIteration;\nuniform float u_iterationMultiplier;\nuniform vec2 u_gravityCenter;\nuniform float u_numNodes;\nuniform float u_gravity;\n\nuniform sampler2D u_clusterData;\nuniform sampler2D u_prevForce;\nuniform float u_collisionMultiplier;\n\n\nfloat DAMP = 0.6;\nfloat COOL = 0.99998;\nfloat TEMP = max(0.02, pow(COOL, u_curIteration));\nfloat TIMESTEP = 1.0 / 30.0;\nfloat VELOCITYDECAY = 0.6;\nfloat accLimitLow = 500000.0;\nfloat accLimitHigh = 750000.0;\nfloat accLimitPosHigh = 10000000.0;\n\nconst float denseNodeThreshold = 1000.0;\nconst float MIN_DISTANCE = 0.00000001;\nconst float MAX_DISTANCE = 1000000000.0;\nconst float MAX_ACCELERATION = 50000.0;\n\nvec4 getTextureData(sampler2D texture, float index, float base) {\n float x = mod(index, base);\n float y = (index - x) / base;\n return texture2D(texture, vec2(x + 0.5, y + 0.5) / base);\n}\n\nbool isNan(float val) {\n return (val < 0.0 || 0.0 < val || val == 0.0) ? false : true;\n}\n\nconst float BIG_NUMBER = 999999999999999999.0;\nbool isInf(float val) {\n return val > BIG_NUMBER || val < -BIG_NUMBER;\n}\n\nvec2 getDelta(vec2 v1, vec2 v2) {\n vec2 delta = v1 - v2;\n float dist = length(delta);\n if (dist < MIN_DISTANCE || isNan(dist)) {\n return vec2(MIN_DISTANCE, MIN_DISTANCE);\n }\n if (dist > MAX_DISTANCE) {\n vec2 normDelta = delta / dist;\n return normDelta * MAX_DISTANCE;\n }\n return delta;\n}\n\nvec4 getOtherNodePosition(float i) {\n return getTextureData(u_physData, i, 256.0);\n}\n\nfloat getCombinedNodeSize(float i, float nodeSize) {\n float otherNodeSize = getTextureData(u_sizeTexture, i, 256.0).a;\n return nodeSize + otherNodeSize;\n}\n\nvec2 getSpringForce(float curConnection, float numConnections, float springFScale, vec4 myPosition, float i) {\n float curSpring = getTextureData(u_connections, curConnection + i, 4096.0).a;\n\n vec4 otherPosition = getTextureData(u_physData, curSpring, 256.0);\n float otherDataPosition = getTextureData(u_connectionOffsets, curSpring, 256.0).a;\n float avgDegree;\n#if INTEL_WORKAROUND\n avgDegree = max(numConnections, 4.0);\n#else\n float otherNumConnections = getTextureData(u_connections, otherDataPosition, 4096.0).a;\n avgDegree = max((otherNumConnections + numConnections * 3.0) / 4.0, 4.0);\n#endif\n\n vec2 delta = getDelta(myPosition.xy, otherPosition.xy);\n float dist = length(delta);\n\n float F = (dist * dist * springFScale) / (u_baseLength * avgDegree);\n if (u_collisionMultiplier > 0.0) {\n F *= u_collisionMultiplier;\n }\n return (-delta / dist) * F;\n}\n\nvec2 getCollisionForce(float combinedNodeSize, float dist, float fScale, vec2 delta) {\n float collisionForce = (combinedNodeSize - dist) / (dist);\n if (u_collisionMultiplier > 0.0) {\n collisionForce *= u_collisionMultiplier;\n }\n return (delta * collisionForce * fScale * combinedNodeSize) / (combinedNodeSize + 1.0);\n}\n\nvec2 getRepulsionForce(float dist, float fScale, vec2 delta) {\n float F = (u_baseLength * u_baseLength * fScale) / (dist);\n return (delta / dist) * F * 0.05;\n}\n\nvoid main(void) {\n float textureSide = 256.0; //#TEXTURE_SIDE#;\n float index = (gl_FragCoord.x - 0.5) + (gl_FragCoord.y - 0.5) * textureSide;\n\n if (index >= u_numNodes) {\n discard;\n }\n\n vec4 clusterData = getTextureData(u_clusterData, index, 256.0);\n\n float clusterIndex = clusterData.x;\n float clusterStartIndex = clusterData.y;\n float clusterSize = clusterData.z;\n float clusterWeight = clusterData.w;\n\n vec4 myPosition = getTextureData(u_physData, index, 256.0);\n vec4 previousForce = getTextureData(u_prevForce, clusterIndex, 256.0);\n\n vec2 acceleration = previousForce.xy;\n\n float isPinned = getTextureData(u_pinnedNodes, index, 256.0).a;\n float nodeSize = getTextureData(u_sizeTexture, index, 256.0).a;\n\n if (isPinned > 0.5) {\n gl_FragColor = vec4(myPosition.xy, 0.0, 0.0);\n return;\n }\n\n float curConnection = getTextureData(u_connectionOffsets, index, 256.0).a;\n float numConnections = getTextureData(u_connections, curConnection, 4096.0).a;\n\n float fScale = 1.0 + sqrt(u_iterationMultiplier);\n float springFScale = fScale;\n\n if (numConnections > denseNodeThreshold) {\n springFScale = sqrt(fScale);\n }\n\n float numOfRels = 0.0;\n\n // Springs\n for (float i = 1.0; i <= 256.0 * 256.0; i++) {\n if (numOfRels >= numConnections) {\n break;\n }\n acceleration += getSpringForce(curConnection, numConnections, springFScale, myPosition, i);\n numOfRels += 1.0;\n }\n\n // Repulsion && collision detection\n if (u_collisionMultiplier > 0.0) {\n float number_of_collisions = 0.0;\n for (float i = 0.0; i < 256.0 * 256.0; i++) {\n if (i >= u_numNodes) {\n break;\n }\n\n if (i == index) {\n continue;\n }\n\n vec4 otherPosition = getOtherNodePosition(i);\n vec2 delta = getDelta(myPosition.xy, otherPosition.xy);\n float dist = length(delta);\n float combinedNodeSize = getCombinedNodeSize(i, nodeSize) * 2.0;\n\n if (dist < combinedNodeSize && number_of_collisions < 40.0) {\n number_of_collisions++;\n acceleration += getCollisionForce(combinedNodeSize, dist, fScale, delta);\n }\n\n if (i >= clusterStartIndex && i < clusterStartIndex + clusterSize) {\n acceleration += getRepulsionForce(dist, fScale, delta);\n }\n }\n } else {\n for (float i = 0.0; i < 256.0 * 256.0; i++) {\n if (i >= clusterStartIndex + clusterSize || i >= u_numNodes) {\n break;\n }\n\n if (i < clusterStartIndex || i == index) {\n continue;\n }\n\n vec4 otherPosition = getOtherNodePosition(i);\n vec2 delta = getDelta(myPosition.xy, otherPosition.xy);\n float dist = length(delta);\n float combinedNodeSize = getCombinedNodeSize(i, nodeSize);\n\n if (dist < combinedNodeSize) {\n acceleration += getCollisionForce(combinedNodeSize, dist, fScale, delta);\n }\n\n acceleration += getRepulsionForce(dist, fScale, delta);\n }\n }\n\n // Gravity\n vec2 delta = getDelta(u_gravityCenter, myPosition.xy);\n float dist = length(delta);\n\n vec2 grav = (delta / dist) * u_gravity * fScale
|
|
1
|
+
declare const _default: "precision mediump float;\n\nuniform sampler2D u_physData;\nuniform sampler2D u_connections;\nuniform sampler2D u_connectionOffsets;\nuniform sampler2D u_pinnedNodes;\nuniform sampler2D u_sizeTexture;\nuniform float u_baseLength;\nuniform float u_curIteration;\nuniform float u_iterationMultiplier;\nuniform vec2 u_gravityCenter;\nuniform float u_numNodes;\nuniform float u_gravity;\n\nuniform sampler2D u_clusterData;\nuniform sampler2D u_prevForce;\nuniform float u_collisionMultiplier;\n\n\nfloat DAMP = 0.6;\nfloat COOL = 0.99998;\nfloat TEMP = max(0.02, pow(COOL, u_curIteration));\nfloat TIMESTEP = 1.0 / 30.0;\nfloat VELOCITYDECAY = 0.6;\nfloat accLimitLow = 500000.0;\nfloat accLimitHigh = 750000.0;\nfloat accLimitPosHigh = 10000000.0;\n\nconst float denseNodeThreshold = 1000.0;\nconst float MIN_DISTANCE = 0.00000001;\nconst float MAX_DISTANCE = 1000000000.0;\nconst float MAX_ACCELERATION = 50000.0;\n\nvec4 getTextureData(sampler2D texture, float index, float base) {\n float x = mod(index, base);\n float y = (index - x) / base;\n return texture2D(texture, vec2(x + 0.5, y + 0.5) / base);\n}\n\nbool isNan(float val) {\n return (val < 0.0 || 0.0 < val || val == 0.0) ? false : true;\n}\n\nconst float BIG_NUMBER = 999999999999999999.0;\nbool isInf(float val) {\n return val > BIG_NUMBER || val < -BIG_NUMBER;\n}\n\nvec2 getDelta(vec2 v1, vec2 v2) {\n vec2 delta = v1 - v2;\n float dist = length(delta);\n if (dist < MIN_DISTANCE || isNan(dist)) {\n return vec2(MIN_DISTANCE, MIN_DISTANCE);\n }\n if (dist > MAX_DISTANCE) {\n vec2 normDelta = delta / dist;\n return normDelta * MAX_DISTANCE;\n }\n return delta;\n}\n\nvec4 getOtherNodePosition(float i) {\n return getTextureData(u_physData, i, 256.0);\n}\n\nfloat getCombinedNodeSize(float i, float nodeSize) {\n float otherNodeSize = getTextureData(u_sizeTexture, i, 256.0).a;\n return nodeSize + otherNodeSize;\n}\n\nvec2 getSpringForce(float curConnection, float numConnections, float springFScale, vec4 myPosition, float i) {\n float curSpring = getTextureData(u_connections, curConnection + i, 4096.0).a;\n\n vec4 otherPosition = getTextureData(u_physData, curSpring, 256.0);\n float otherDataPosition = getTextureData(u_connectionOffsets, curSpring, 256.0).a;\n float avgDegree;\n#if INTEL_WORKAROUND\n avgDegree = max(numConnections, 4.0);\n#else\n float otherNumConnections = getTextureData(u_connections, otherDataPosition, 4096.0).a;\n avgDegree = max((otherNumConnections + numConnections * 3.0) / 4.0, 4.0);\n#endif\n\n vec2 delta = getDelta(myPosition.xy, otherPosition.xy);\n float dist = length(delta);\n\n float F = (dist * dist * springFScale) / (u_baseLength * avgDegree);\n if (u_collisionMultiplier > 0.0) {\n F *= u_collisionMultiplier;\n }\n return (-delta / dist) * F;\n}\n\nvec2 getCollisionForce(float combinedNodeSize, float dist, float fScale, vec2 delta) {\n float collisionForce = (combinedNodeSize - dist) / (dist);\n if (u_collisionMultiplier > 0.0) {\n collisionForce *= u_collisionMultiplier;\n }\n return (delta * collisionForce * fScale * combinedNodeSize) / (combinedNodeSize + 1.0);\n}\n\nvec2 getRepulsionForce(float dist, float fScale, vec2 delta) {\n float F = (u_baseLength * u_baseLength * fScale) / (dist);\n return (delta / dist) * F * 0.05;\n}\n\nvoid main(void) {\n float textureSide = 256.0; //#TEXTURE_SIDE#;\n float index = (gl_FragCoord.x - 0.5) + (gl_FragCoord.y - 0.5) * textureSide;\n\n if (index >= u_numNodes) {\n discard;\n }\n\n vec4 clusterData = getTextureData(u_clusterData, index, 256.0);\n\n float clusterIndex = clusterData.x;\n float clusterStartIndex = clusterData.y;\n float clusterSize = clusterData.z;\n float clusterWeight = clusterData.w;\n\n vec4 myPosition = getTextureData(u_physData, index, 256.0);\n vec4 previousForce = getTextureData(u_prevForce, clusterIndex, 256.0);\n\n vec2 acceleration = previousForce.xy;\n\n float isPinned = getTextureData(u_pinnedNodes, index, 256.0).a;\n float nodeSize = getTextureData(u_sizeTexture, index, 256.0).a;\n\n if (isPinned > 0.5) {\n gl_FragColor = vec4(myPosition.xy, 0.0, 0.0);\n return;\n }\n\n float curConnection = getTextureData(u_connectionOffsets, index, 256.0).a;\n float numConnections = getTextureData(u_connections, curConnection, 4096.0).a;\n\n float fScale = 1.0 + sqrt(u_iterationMultiplier);\n float springFScale = fScale;\n\n if (numConnections > denseNodeThreshold) {\n springFScale = sqrt(fScale);\n }\n\n float numOfRels = 0.0;\n\n // Springs\n for (float i = 1.0; i <= 256.0 * 256.0; i++) {\n if (numOfRels >= numConnections) {\n break;\n }\n acceleration += getSpringForce(curConnection, numConnections, springFScale, myPosition, i);\n numOfRels += 1.0;\n }\n\n // Repulsion && collision detection\n if (u_collisionMultiplier > 0.0) {\n float number_of_collisions = 0.0;\n for (float i = 0.0; i < 256.0 * 256.0; i++) {\n if (i >= u_numNodes) {\n break;\n }\n\n if (i == index) {\n continue;\n }\n\n vec4 otherPosition = getOtherNodePosition(i);\n vec2 delta = getDelta(myPosition.xy, otherPosition.xy);\n float dist = length(delta);\n float combinedNodeSize = getCombinedNodeSize(i, nodeSize) * 2.0;\n\n if (dist < combinedNodeSize && number_of_collisions < 40.0) {\n number_of_collisions++;\n acceleration += getCollisionForce(combinedNodeSize, dist, fScale, delta);\n }\n\n if (i >= clusterStartIndex && i < clusterStartIndex + clusterSize) {\n acceleration += getRepulsionForce(dist, fScale, delta);\n }\n }\n } else {\n for (float i = 0.0; i < 256.0 * 256.0; i++) {\n if (i >= clusterStartIndex + clusterSize || i >= u_numNodes) {\n break;\n }\n\n if (i < clusterStartIndex || i == index) {\n continue;\n }\n\n vec4 otherPosition = getOtherNodePosition(i);\n vec2 delta = getDelta(myPosition.xy, otherPosition.xy);\n float dist = length(delta);\n float combinedNodeSize = getCombinedNodeSize(i, nodeSize);\n\n if (dist < combinedNodeSize) {\n acceleration += getCollisionForce(combinedNodeSize, dist, fScale, delta);\n }\n\n acceleration += getRepulsionForce(dist, fScale, delta);\n }\n }\n\n // Gravity\n vec2 delta = getDelta(u_gravityCenter, myPosition.xy);\n float dist = length(delta);\n\n vec2 grav = (delta / dist) * u_gravity * fScale * (dist / 1000.0);\n acceleration += grav;\n\n float accMagnitude = length(acceleration);\n acceleration *= min(MAX_ACCELERATION, accMagnitude) / accMagnitude;\n\n float iterationFrictionThreshold = 1000.0;\n\n if (u_curIteration > iterationFrictionThreshold) {\n float friction = 1.0 + pow((u_curIteration - iterationFrictionThreshold), 2.0) / 100.0;\n acceleration *= 1.0 / friction;\n }\n\n if (u_curIteration == 0.0) {\n gl_FragColor = vec4(myPosition.xy, myPosition.zw);\n } else {\n vec2 prevVelocity = myPosition.zw;\n vec2 currentPos = myPosition.xy;\n vec2 prevPos = currentPos - prevVelocity;\n\n vec2 newPos = currentPos + TEMP * ( DAMP * (prevVelocity) + acceleration * TIMESTEP * TIMESTEP);\n vec2 newVelocity = newPos - currentPos;\n gl_FragColor = vec4(newPos, newVelocity);\n }\n}";
|
|
2
2
|
export default _default;
|
|
@@ -30,10 +30,12 @@ export default class NvlController {
|
|
|
30
30
|
private readonly circularLayout;
|
|
31
31
|
private readonly forceLayout;
|
|
32
32
|
private readonly canvasRenderer;
|
|
33
|
+
private readonly svgRenderer;
|
|
33
34
|
private readonly glCanvas;
|
|
34
35
|
private canvasRect;
|
|
35
36
|
private readonly glMinimapCanvas;
|
|
36
37
|
private readonly c2dCanvas;
|
|
38
|
+
private readonly svg;
|
|
37
39
|
private isInRenderSwitchAnimation;
|
|
38
40
|
private justSwitchedRenderer;
|
|
39
41
|
private justSwitchedLayout;
|
|
@@ -105,8 +107,8 @@ export default class NvlController {
|
|
|
105
107
|
isDestroyed(): boolean;
|
|
106
108
|
destroy(): void;
|
|
107
109
|
callIfRegistered(...args: any[]): void;
|
|
108
|
-
getCanvasRelsAt(point: Point): import("
|
|
109
|
-
getCanvasNodesAt(point: Point, hitNodeMarginWidth?: number): import("
|
|
110
|
+
getCanvasRelsAt(point: Point): import("..").HitTargetRelationship[];
|
|
111
|
+
getCanvasNodesAt(point: Point, hitNodeMarginWidth?: number): import("..").HitTargetNode[];
|
|
110
112
|
private getLayout;
|
|
111
113
|
setLayout(layoutType: Layout): void;
|
|
112
114
|
setLayoutOptions(options: LayoutOptions): void;
|
|
@@ -114,6 +116,7 @@ export default class NvlController {
|
|
|
114
116
|
private initiateFileDownload;
|
|
115
117
|
private updateLayoutAndPositions;
|
|
116
118
|
saveToFile(options: SaveToFileOptions): void;
|
|
119
|
+
saveToSvg(options?: SaveToFileOptions): void;
|
|
117
120
|
getImageDataURL(options: SaveToFileOptions): string;
|
|
118
121
|
private prepareLargeFileForDownload;
|
|
119
122
|
private createCanvasAndRenderImage;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LogLevelDesc } from 'loglevel';
|
|
2
|
-
import type { WaypointPath } from '../../renderers/
|
|
2
|
+
import type { WaypointPath } from '../../renderers/domrenderer/shared/types';
|
|
3
3
|
import type { Node } from '../../types/graph-element';
|
|
4
4
|
import type { ExternalCallbacks } from '../ExternalCallbackHandler';
|
|
5
5
|
import type { NodeDataSet, RelationshipDataSet } from '../dataset';
|
|
@@ -118,6 +118,14 @@ export declare const WebGLRendererType = "webgl";
|
|
|
118
118
|
* but supports captions and arrowheads.
|
|
119
119
|
*/
|
|
120
120
|
export declare const CanvasRendererType = "canvas";
|
|
121
|
+
/**
|
|
122
|
+
* A renderer using SVG.
|
|
123
|
+
*
|
|
124
|
+
* @experimental
|
|
125
|
+
* @remarks
|
|
126
|
+
* This renderer is experimental.
|
|
127
|
+
*/
|
|
128
|
+
export declare const SvgRendererType = "svg";
|
|
121
129
|
/**
|
|
122
130
|
* The different types of layouts available
|
|
123
131
|
*/
|
|
@@ -129,7 +137,7 @@ export type LayoutOptions = ForceDirectedOptions | HierarchicalOptions | Circula
|
|
|
129
137
|
/**
|
|
130
138
|
* The different types of renderers available
|
|
131
139
|
*/
|
|
132
|
-
export type Renderer = typeof WebGLRendererType | typeof CanvasRendererType;
|
|
140
|
+
export type Renderer = typeof WebGLRendererType | typeof CanvasRendererType | typeof SvgRendererType;
|
|
133
141
|
/** Configurations for a NVL instance */
|
|
134
142
|
export interface NvlOptions {
|
|
135
143
|
/**
|
|
@@ -175,10 +183,9 @@ export interface NvlOptions {
|
|
|
175
183
|
initialZoom?: number;
|
|
176
184
|
/**
|
|
177
185
|
* What renderer to use
|
|
178
|
-
*
|
|
179
|
-
* @defaultValue 'webgl'
|
|
186
|
+
* @defaultValue 'canvas'
|
|
180
187
|
* WebGL renderer uses GPU and has better performance.
|
|
181
|
-
* Captions and arrowheads are only displayed when using the canvas renderer.
|
|
188
|
+
* Captions and arrowheads are only displayed when using the canvas or svg renderer.
|
|
182
189
|
*/
|
|
183
190
|
renderer?: Renderer;
|
|
184
191
|
/**
|
|
@@ -273,7 +280,6 @@ export interface NvlState {
|
|
|
273
280
|
fitNodeIds: string[];
|
|
274
281
|
resetZoom: boolean;
|
|
275
282
|
forceWebGL: boolean;
|
|
276
|
-
webGLVisible: boolean;
|
|
277
283
|
renderer: Renderer;
|
|
278
284
|
disableWebGL: boolean;
|
|
279
285
|
disableWebWorkers: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { StyledCaption } from '../../renderers/
|
|
1
|
+
import type { StyledCaption } from '../../renderers/domrenderer/shared/types';
|
|
2
2
|
import type { Node, Relationship } from '../../types/graph-element';
|
|
3
3
|
import type { NvlOptions } from './types';
|
|
4
4
|
/**
|
|
@@ -6,7 +6,7 @@ import type { NvlOptions } from './types';
|
|
|
6
6
|
* If both caption and captions are provided, captions takes precedence.
|
|
7
7
|
*/
|
|
8
8
|
export declare const processCaptions: (item: Partial<Node | Relationship>) => StyledCaption[];
|
|
9
|
-
export declare const processColorStyles: (styling: NvlOptions[
|
|
9
|
+
export declare const processColorStyles: (styling: NvlOptions["styling"]) => {
|
|
10
10
|
nodeBorderStyles: {
|
|
11
11
|
default: {
|
|
12
12
|
rings?: {
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { Channel } from '../../modules/dataset';
|
|
2
|
+
import type { NvlState } from '../../modules/state/types';
|
|
3
|
+
import type { Node } from '../../types/graph-element';
|
|
4
|
+
import ImageCache from './shared/ImageCache';
|
|
5
|
+
import ArrowBundler from './shared/arrows/ArrowBundler';
|
|
6
|
+
import type { RelationshipToRender } from './shared/types';
|
|
7
|
+
export type RendererOptions = {
|
|
8
|
+
relationshipThreshold?: number;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Base class for renderers (Canvas and SVG) that provides common functionality
|
|
12
|
+
*/
|
|
13
|
+
export default abstract class BaseRenderer {
|
|
14
|
+
arrowBundler: ArrowBundler;
|
|
15
|
+
protected state: NvlState;
|
|
16
|
+
protected relationshipThreshold: number;
|
|
17
|
+
protected stateDisposers: NvlState['reaction'][];
|
|
18
|
+
protected needsRun: boolean;
|
|
19
|
+
protected imageCache: ImageCache;
|
|
20
|
+
protected nodeVersion: number;
|
|
21
|
+
protected relVersion: number;
|
|
22
|
+
protected waypointVersion: number;
|
|
23
|
+
protected channelId: string;
|
|
24
|
+
constructor(state: NvlState, channelId: string, options?: RendererOptions);
|
|
25
|
+
/**
|
|
26
|
+
* Gets relationships to render, sorted by their rendering order
|
|
27
|
+
* @param showCaptions - Whether to show relationship captions
|
|
28
|
+
* @param zoom - Current zoom level (optional, used for threshold checking)
|
|
29
|
+
* @param checkOffScreen - Whether to check if relationships are off screen
|
|
30
|
+
* @param clientWidth - Width of the rendering area (only needed if checkOffScreen is true)
|
|
31
|
+
* @param clientHeight - Height of the rendering area (only needed if checkOffScreen is true)
|
|
32
|
+
* @returns Array of relationships to render, sorted (disabled, normal, selected)
|
|
33
|
+
*/
|
|
34
|
+
protected getRelationshipsToRender(showCaptions: boolean, zoom?: number, clientWidth?: number, clientHeight?: number, checkOffScreen?: boolean): RelationshipToRender[];
|
|
35
|
+
/**
|
|
36
|
+
* Gets nodes to render, sorted by their rendering order
|
|
37
|
+
* @param positionArray - Array of nodes with positions
|
|
38
|
+
* @param checkOffScreen - Whether to check if nodes are off screen
|
|
39
|
+
* @param clientWidth - Width of the rendering area (only needed if checkOffScreen is true)
|
|
40
|
+
* @param clientHeight - Height of the rendering area (only needed if checkOffScreen is true)
|
|
41
|
+
* @returns Array of nodes to render, sorted (disabled, normal, selected)
|
|
42
|
+
*/
|
|
43
|
+
protected getNodesToRender(positionArray: Node[], clientWidth?: number, clientHeight?: number, checkOffScreen?: boolean): Node[];
|
|
44
|
+
/**
|
|
45
|
+
* Processes updates in nodes and relationships.
|
|
46
|
+
* Subclasses can override onNodeVersionUpdate() for custom behavior.
|
|
47
|
+
*/
|
|
48
|
+
processUpdates(): void;
|
|
49
|
+
/**
|
|
50
|
+
* Hook for subclasses to handle node version updates.
|
|
51
|
+
* Override this to add custom node update handling.
|
|
52
|
+
*/
|
|
53
|
+
protected onNodeVersionUpdate(nodeChannel: Channel<Node>): void;
|
|
54
|
+
/**
|
|
55
|
+
* Checks if a bounding box is off screen
|
|
56
|
+
* @param boundingBox - The bounding box to check
|
|
57
|
+
* @param clientWidth - Width of the rendering area
|
|
58
|
+
* @param clientHeight - Height of the rendering area
|
|
59
|
+
* @returns Whether the bounding box is off screen
|
|
60
|
+
*/
|
|
61
|
+
protected isBoundingBoxOffScreen(boundingBox: DOMRect, clientWidth: number, clientHeight: number): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Abstract method to be implemented by subclasses
|
|
64
|
+
*/
|
|
65
|
+
abstract needsToRun(): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Abstract method to be implemented by subclasses
|
|
68
|
+
*/
|
|
69
|
+
abstract destroy(): void;
|
|
70
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import type { Channel } from '../../../modules/dataset';
|
|
2
|
+
import type { NvlState } from '../../../modules/state/types';
|
|
3
|
+
import type { Node } from '../../../types/graph-element';
|
|
4
|
+
import type { Point } from '../../../utils/geometry';
|
|
5
|
+
import type { HitTargetNode, HitTargetRelationship } from '../../../utils/hittest';
|
|
6
|
+
import BaseRenderer, { RendererOptions } from '../BaseRenderer';
|
|
7
|
+
export default class CanvasRenderer extends BaseRenderer {
|
|
8
|
+
private activeNodes;
|
|
9
|
+
private canvas;
|
|
10
|
+
private context;
|
|
11
|
+
private animationHandler;
|
|
12
|
+
private ellipsisWidth;
|
|
13
|
+
private disableArrowShadow;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new CanvasRenderer.
|
|
16
|
+
* @param canvas {HTMLCanvasElement} - The canvas to render on.
|
|
17
|
+
* @param context {CanvasRenderingContext2D} - The canvas context.
|
|
18
|
+
* @param state {NvlState} - The state.
|
|
19
|
+
* @param options {RendererOptions} - The visualization options.
|
|
20
|
+
*/
|
|
21
|
+
constructor(canvas: HTMLCanvasElement, context: CanvasRenderingContext2D | null, state: NvlState, options?: RendererOptions);
|
|
22
|
+
/**
|
|
23
|
+
* Checks if the renderer needs to run.
|
|
24
|
+
* @returns Whether the renderer needs to run.
|
|
25
|
+
*/
|
|
26
|
+
needsToRun(): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Override to handle Canvas-specific node channel updates
|
|
29
|
+
*/
|
|
30
|
+
protected onNodeVersionUpdate(nodeChannel: Channel<Node>): void;
|
|
31
|
+
/**
|
|
32
|
+
* Override processUpdates to add Canvas-specific shadow logic
|
|
33
|
+
*/
|
|
34
|
+
processUpdates(): void;
|
|
35
|
+
/**
|
|
36
|
+
* Draws a single node on the canvas with all its visual elements (circle, icons, captions, etc.)
|
|
37
|
+
* @param ctx - The canvas rendering context
|
|
38
|
+
* @param node - The node to draw
|
|
39
|
+
* @param imageCache - The image cache for icons
|
|
40
|
+
* @param animationHandler - The animation handler for transitions
|
|
41
|
+
* @param nodeBorderStyles - The border styles for nodes
|
|
42
|
+
* @param disabledItemStyles - The styles for disabled items
|
|
43
|
+
* @param defaultNodeColor - The default node color
|
|
44
|
+
* @param ellipsisWidth - The width of the ellipsis character
|
|
45
|
+
* @param zoomLevel - The current zoom level
|
|
46
|
+
*/
|
|
47
|
+
private drawNode;
|
|
48
|
+
/**
|
|
49
|
+
* Helper method to enable shadow on canvas context
|
|
50
|
+
*/
|
|
51
|
+
private enableShadow;
|
|
52
|
+
/**
|
|
53
|
+
* Helper method to disable shadow on canvas context
|
|
54
|
+
*/
|
|
55
|
+
private disableShadow;
|
|
56
|
+
/**
|
|
57
|
+
* Gets the relationship width considering selection factor
|
|
58
|
+
*/
|
|
59
|
+
private getRelWidth;
|
|
60
|
+
/**
|
|
61
|
+
* Draws line segments on canvas (straight or curved)
|
|
62
|
+
*/
|
|
63
|
+
private drawSegments;
|
|
64
|
+
/**
|
|
65
|
+
* Gets the padding for selected relationships
|
|
66
|
+
*/
|
|
67
|
+
private getSelectionPadding;
|
|
68
|
+
/**
|
|
69
|
+
* Gets the overlay icon size
|
|
70
|
+
*/
|
|
71
|
+
private getOverlayIconSize;
|
|
72
|
+
/**
|
|
73
|
+
* Gets the overlay icon alignment based on position
|
|
74
|
+
*/
|
|
75
|
+
private getOverlayIconAlignment;
|
|
76
|
+
/**
|
|
77
|
+
* Draws a self-referencing loop on canvas
|
|
78
|
+
*/
|
|
79
|
+
private drawLoop;
|
|
80
|
+
/**
|
|
81
|
+
* Draws a label for a relationship
|
|
82
|
+
*/
|
|
83
|
+
private drawLabel;
|
|
84
|
+
/**
|
|
85
|
+
* Renders a waypoint arrow (relationship between two different nodes)
|
|
86
|
+
*/
|
|
87
|
+
private renderWaypointArrow;
|
|
88
|
+
/**
|
|
89
|
+
* Renders a self-referencing arrow (relationship from node to itself)
|
|
90
|
+
*/
|
|
91
|
+
private renderSelfArrow;
|
|
92
|
+
/**
|
|
93
|
+
* Main arrow rendering method that delegates to waypoint or self-arrow rendering
|
|
94
|
+
*/
|
|
95
|
+
private renderArrow;
|
|
96
|
+
/**
|
|
97
|
+
* Draws the nodes and relationships to their positions on the canvas.
|
|
98
|
+
* @param positionArray {Node[]} - The array of nodes to draw
|
|
99
|
+
* @param options {any} - The options for the render
|
|
100
|
+
*/
|
|
101
|
+
render(positionArray: Node[], options?: {
|
|
102
|
+
canvas?: HTMLCanvasElement;
|
|
103
|
+
context?: CanvasRenderingContext2D;
|
|
104
|
+
backgroundColor?: string;
|
|
105
|
+
ignoreAnimations?: boolean;
|
|
106
|
+
showCaptions?: boolean;
|
|
107
|
+
}): void;
|
|
108
|
+
private getRelationshipsToRenderCanvas;
|
|
109
|
+
private getNodesToRenderCanvas;
|
|
110
|
+
private renderNodes;
|
|
111
|
+
private renderRelationships;
|
|
112
|
+
/**
|
|
113
|
+
* Returns the nodes at the pointer position
|
|
114
|
+
* @param pointer - The position of the pointer.
|
|
115
|
+
* @returns The nodes at the pointer position.
|
|
116
|
+
* @todo Sort nodes by distance descending
|
|
117
|
+
*/
|
|
118
|
+
getNodesAt(pointer: Point, hitNodeMarginWidth?: number): HitTargetNode[];
|
|
119
|
+
/**
|
|
120
|
+
* Returns the relationships at the pointer position
|
|
121
|
+
* @param pointer - The position of the pointer.
|
|
122
|
+
* @returns The relationships at the pointer position.
|
|
123
|
+
* @todo: sort relationships by distance descending
|
|
124
|
+
*/
|
|
125
|
+
getRelsAt(pointer: Point): HitTargetRelationship[];
|
|
126
|
+
destroy(): void;
|
|
127
|
+
/**
|
|
128
|
+
* Handles the channel's additions, removals and updates and adds or removes the id from the active nodes.
|
|
129
|
+
* @param channel {Channel<Node>} - The channel to process
|
|
130
|
+
* @param fullData {DataSet<Node>} - The full data
|
|
131
|
+
* @param processUpdates {boolean} - Whether to process channel updates as well
|
|
132
|
+
*/
|
|
133
|
+
private handleChannelUpdate;
|
|
134
|
+
/**
|
|
135
|
+
* Returns an array of styles for the rings of a node.
|
|
136
|
+
* It takes the node as an argument, and an optional array of size animations.
|
|
137
|
+
* If the node is selected, it returns the selectedStyle.rings array.
|
|
138
|
+
* If the node is not selected, it returns an array containing only one object with
|
|
139
|
+
* a width of 0 and an empty color.
|
|
140
|
+
* @param node - The node to get the ring styles for.
|
|
141
|
+
* @param animationHandler - The animation handler.
|
|
142
|
+
* @param nodeBorderStyles - The node border styles.
|
|
143
|
+
* @returns An array of ring styles.
|
|
144
|
+
*/
|
|
145
|
+
private getRingStyles;
|
|
146
|
+
/**
|
|
147
|
+
* Handles zoom and pan on the canvas.
|
|
148
|
+
* @param context {CanvasRenderingContext2D} - The canvas context
|
|
149
|
+
* @param canvas {HTMLCanvasElement} - The canvas
|
|
150
|
+
*/
|
|
151
|
+
private zoomAndPan;
|
|
152
|
+
}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import type { Point } from '
|
|
2
|
-
import type { TextSegment } from '
|
|
3
|
-
export declare const fontThresholds: [number, number][];
|
|
4
|
-
/**
|
|
5
|
-
* This function takes color in hex format or rgb() or rgba() format and overrides the opacity. Returns rgba() string.
|
|
6
|
-
* @param color - * @param opacity - * @returns rgba() string with the given opacity.
|
|
7
|
-
*/
|
|
8
|
-
export declare const overrideOpacity: (color: string, opacity: number) => string;
|
|
1
|
+
import type { Point } from '../../../utils/geometry';
|
|
2
|
+
import type { TextSegment } from '../shared/types';
|
|
9
3
|
/**
|
|
10
4
|
* The parameters for drawing an arrowhead.
|
|
11
5
|
*/
|
|
@@ -40,7 +34,6 @@ export declare const drawCircleBand: (ctx: CanvasRenderingContext2D, x: number,
|
|
|
40
34
|
width: number;
|
|
41
35
|
color: string;
|
|
42
36
|
}[]) => void;
|
|
43
|
-
export declare const drawCircle: (ctx: CanvasRenderingContext2D, x: number, y: number, r: number) => void;
|
|
44
37
|
/**
|
|
45
38
|
* Fill a circle band with a gradient from a certain color to transparent
|
|
46
39
|
* @param ctx - The canvas context.
|
|
@@ -56,11 +49,6 @@ export declare const drawGradientCircleBand: (ctx: CanvasRenderingContext2D, x:
|
|
|
56
49
|
* Draw a circle shape with a solid color
|
|
57
50
|
*/
|
|
58
51
|
export declare const drawSolidCircle: (ctx: CanvasRenderingContext2D, x: number, y: number, color: string, size: number) => void;
|
|
59
|
-
export declare function getIndividualInfoLevels(r: number, zoomLevel: number): {
|
|
60
|
-
nodeInfoLevel: number;
|
|
61
|
-
fontInfoLevel: number;
|
|
62
|
-
iconInfoLevel: number;
|
|
63
|
-
};
|
|
64
52
|
/**
|
|
65
53
|
* Prints the caption for a node
|
|
66
54
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Relationship } from '
|
|
2
|
-
import type { Point } from '
|
|
1
|
+
import type { Relationship } from '../../../../types/graph-element';
|
|
2
|
+
import type { Point } from '../../../../utils/geometry';
|
|
3
3
|
import type { WaypointPath } from '../types';
|
|
4
4
|
export interface LabelGeometry {
|
|
5
5
|
position: Point;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Node, Relationship } from '
|
|
1
|
+
import type { Node, Relationship } from '../../../../types/graph-element';
|
|
2
2
|
import type { WaypointPath } from '../types';
|
|
3
3
|
import ArrowBundle from './ArrowBundle';
|
|
4
4
|
export default class ArrowBundler {
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import type { BorderStyle } from '../../../../modules/state/types';
|
|
2
|
+
import type { Node, Relationship } from '../../../../types/graph-element';
|
|
3
|
+
import type { Point } from '../../../../utils/geometry';
|
|
4
|
+
import type ArrowBundle from './ArrowBundle';
|
|
5
|
+
/**
|
|
6
|
+
* This function calculates the difference in radius between two nodes.
|
|
7
|
+
* @param toArrowGap - The gap between the node and the arrow on the to side.
|
|
8
|
+
* @param fromArrowGap - The gap between the node and the arrow on the from side.
|
|
9
|
+
* @returns The difference in radius between the two nodes.
|
|
10
|
+
* @comment can be affected for example by the label crust and selected ring
|
|
11
|
+
* as well as a gap between the node and the arrow on it's side.
|
|
12
|
+
*/
|
|
13
|
+
export declare const getRadiusDifference: (toArrowGap: number, fromArrowGap: number) => number;
|
|
14
|
+
/**
|
|
15
|
+
* Calculates control points for self-referencing relationships
|
|
16
|
+
* @param {Relationship} rel - The relationship
|
|
17
|
+
* @param {Node} node - The node the relationship refers to
|
|
18
|
+
* @param {ArrowBundle} bundle - The arrow bundle
|
|
19
|
+
* @returns Object containing angles and coordinate points for the self-loop
|
|
20
|
+
*/
|
|
21
|
+
export declare const getSelfArrowControlPoints: (rel: Relationship, node: Node, bundle: ArrowBundle) => {
|
|
22
|
+
angle: number;
|
|
23
|
+
startAngle: number;
|
|
24
|
+
endAngle: number;
|
|
25
|
+
startPoint: {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
};
|
|
29
|
+
endPoint: {
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
};
|
|
33
|
+
apexPoint: {
|
|
34
|
+
x: number;
|
|
35
|
+
y: number;
|
|
36
|
+
};
|
|
37
|
+
control1Point: {
|
|
38
|
+
x: number;
|
|
39
|
+
y: number;
|
|
40
|
+
};
|
|
41
|
+
control2Point: {
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
};
|
|
45
|
+
nodeGap: number;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Calculates the padding for selected relationships based on border style
|
|
49
|
+
* @param selectedBorderRings - Array of border rings for selected state
|
|
50
|
+
* @returns The total selection padding
|
|
51
|
+
*/
|
|
52
|
+
export declare const getSelectionPadding: (selectedBorderRings?: BorderStyle["rings"]) => number;
|
|
53
|
+
/**
|
|
54
|
+
* Calculates the position and angle for a relationship label based on the Canvas renderer's logic.
|
|
55
|
+
* This handles both straight lines and curves, with special logic for odd/even number of points.
|
|
56
|
+
*
|
|
57
|
+
* @param points - Array of points defining the relationship line
|
|
58
|
+
* @param fromNode - The source node
|
|
59
|
+
* @param toNode - The target node
|
|
60
|
+
* @param drawCurves - Whether curves are being drawn
|
|
61
|
+
* @param isSelected - Whether the relationship is selected
|
|
62
|
+
* @param captionAlign - Caption alignment ('top' or 'bottom')
|
|
63
|
+
* @param selectedBorderRings - Array of border rings for selected state
|
|
64
|
+
* @returns Object containing x, y position and angle for the label
|
|
65
|
+
*/
|
|
66
|
+
export declare const getRelationshipLabelPosition: (points: Point[], fromNode: Node, toNode: Node, drawCurves: boolean, isSelected: boolean, selectedBorderRings: BorderStyle["rings"], captionAlign?: "top" | "bottom") => {
|
|
67
|
+
x: number;
|
|
68
|
+
y: number;
|
|
69
|
+
angle: number;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* This function calculates the coordinates of the via point
|
|
73
|
+
* between two nodes. The via point is used to bend the edge
|
|
74
|
+
* between the two nodes.
|
|
75
|
+
* @param fromNode - The node the edge starts from.
|
|
76
|
+
* @param toNode - The node the edge ends at.
|
|
77
|
+
* @param fromArrowGap - The gap between the node and the arrow on the from side.
|
|
78
|
+
* @param toArrowGap - The gap between the node and the arrow on the to side.
|
|
79
|
+
* @returns The coordinates of the via point.
|
|
80
|
+
*/
|
|
81
|
+
export declare const getViaCoordinates: (fromNode: Node, toNode: Node, fromArrowGap: number, toArrowGap: number, rel: Relationship, bundle: ArrowBundle) => Point;
|
|
82
|
+
export declare const getPointsForStraight: (rel: Relationship, bundle: ArrowBundle, fromNode: Node, toNode: Node, showLabel: boolean, curved?: boolean) => Point[];
|
|
83
|
+
export declare const distanceToEdge: (pos: Point, rel: Relationship, fromNode: Node, toNode: Node, bundle: ArrowBundle, showLabel: boolean, drawCurves?: boolean) => number;
|
|
84
|
+
/**
|
|
85
|
+
* Returns the bounding box of the arrow.
|
|
86
|
+
* @param rel - The relationship to get the bounding box for.
|
|
87
|
+
* @param bundle - The arrow bundle the relationship is part of.
|
|
88
|
+
* @param fromNode - The node the relationship is coming from.
|
|
89
|
+
* @param toNode - The node the relationship is going to.
|
|
90
|
+
* @param showLabel - Whether or not a label is shown.
|
|
91
|
+
* @param drawCurves - Whether or the relationship is drawn as a curve.
|
|
92
|
+
* @returns The bounding box of the arrow.
|
|
93
|
+
*/
|
|
94
|
+
export declare const getBoundingBox: (rel: Relationship, bundle: ArrowBundle, fromNode: Node, toNode: Node, showLabel?: boolean, drawCurves?: boolean) => DOMRect | null;
|
|
95
|
+
/**
|
|
96
|
+
* Calculates the width of a relationship including selection factor and pixel ratio
|
|
97
|
+
* @param rel - The relationship
|
|
98
|
+
* @param defaultWidth - The default relationship width
|
|
99
|
+
* @returns The calculated relationship width
|
|
100
|
+
*/
|
|
101
|
+
export declare const getRelationshipWidth: (rel: Relationship, defaultWidth: number) => number;
|
|
102
|
+
/**
|
|
103
|
+
* Adjusts relationship line points to create proper gaps at start and end.
|
|
104
|
+
* The Canvas renderer uses this logic:
|
|
105
|
+
* - End gap (arrowhead): headHeight/2 + headSelectedAdjustment
|
|
106
|
+
* - Start gap (tail): Only for selected relationships, uses getSelectionPadding
|
|
107
|
+
*
|
|
108
|
+
* @param points - Array of points defining the relationship line (will be modified in place)
|
|
109
|
+
* @param isSelected - Whether the relationship is selected
|
|
110
|
+
* @param headHeight - The height of the arrowhead
|
|
111
|
+
* @param headSelectedAdjustment - Additional adjustment for selected relationships
|
|
112
|
+
* @param selectedBorderRings - Array of border rings for selected state
|
|
113
|
+
* @returns Object with adjusted points and the tail offset applied (for label positioning)
|
|
114
|
+
*/
|
|
115
|
+
export declare const adjustPointsForGaps: (points: Point[], isSelected: boolean, headHeight: number, headSelectedAdjustment: number, selectedBorderRings: BorderStyle["rings"]) => {
|
|
116
|
+
tailOffset: Point | null;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Calculates the dimensions of an arrowhead
|
|
120
|
+
* @param relWidth - The width of the relationship line
|
|
121
|
+
* @param defaultRelWidth - The default relationship width
|
|
122
|
+
* @param isSelected - Whether the relationship is selected
|
|
123
|
+
* @param selectedBorderRings - Array of border rings for selected state
|
|
124
|
+
* @returns Object containing headHeight, headChinHeight, headWidth, and headSelectedAdjustment
|
|
125
|
+
*/
|
|
126
|
+
export declare const getArrowheadDimensions: (relWidth: number, defaultRelWidth: number, isSelected: boolean, selectedBorderRings: BorderStyle["rings"]) => {
|
|
127
|
+
headHeight: number;
|
|
128
|
+
headChinHeight: number;
|
|
129
|
+
headWidth: number;
|
|
130
|
+
headSelectedAdjustment: number;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Calculates the size of an overlay icon on a relationship
|
|
134
|
+
* @param iconSizeFactor - The size factor from the overlay icon configuration
|
|
135
|
+
* @returns The calculated overlay icon size
|
|
136
|
+
*/
|
|
137
|
+
export declare const getOverlayIconSize: (iconSizeFactor: number) => number;
|
|
138
|
+
/**
|
|
139
|
+
* Calculates the alignment offsets for an overlay icon on a relationship
|
|
140
|
+
* @param position - The position array [x, y] from overlay icon configuration
|
|
141
|
+
* @param width - The available width for the icon
|
|
142
|
+
* @param height - The height of the icon
|
|
143
|
+
* @returns Object with widthAlign and heightAlign offsets
|
|
144
|
+
*/
|
|
145
|
+
export declare const getOverlayIconAlignment: (position: [number, number], width: number, height: number) => {
|
|
146
|
+
widthAlign: number;
|
|
147
|
+
heightAlign: number;
|
|
148
|
+
};
|