Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const resolveAnimatedLayoutAlgorithm = (
edgeStiffness:
config?.edgeStiffness ?? forceDirectedDefaults.edgeStiffness,
stopVelocity:
config?.stopVelocity ?? forceDirectedDefaults.convergenceVelocity,
config?.stopVelocity ?? forceDirectedDefaults.stopVelocity,
maxForce: config?.maxForce ?? forceDirectedDefaults.maxForce,
nodeForceCoefficient:
config?.nodeForceCoefficient ??
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const resolveLayoutAlgorithm = (
edgeStiffness:
config?.edgeStiffness ?? forceDirectedDefaults.edgeStiffness,
stopVelocity:
config?.stopVelocity ?? forceDirectedDefaults.convergenceVelocity,
config?.stopVelocity ?? forceDirectedDefaults.stopVelocity,
maxForce: config?.maxForce ?? forceDirectedDefaults.maxForce,
nodeForceCoefficient:
config?.nodeForceCoefficient ??
Expand Down
2 changes: 1 addition & 1 deletion src/canvas-builder/shared/force-directed-defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const forceDirectedDefaults = Object.freeze({
edgeStiffness: 1e3,
dtSec: 1e-2,
maxIterations: 1000,
convergenceVelocity: 10,
stopVelocity: 10,
maxForce: 1e7,
nodeForceCoefficient: 1,
barnesHutAreaRadiusThreshold: 1e-2,
Expand Down
3 changes: 2 additions & 1 deletion src/edges/edge-shape.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { EdgeElement } from "@/element";
import { EdgeRenderParams } from "./edge-render-params";

export interface EdgeShape {
readonly element: SVGSVGElement;
readonly element: EdgeElement;

render(params: EdgeRenderParams): void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import { edgeConstants } from "../../edge-constants";
import { InteractiveEdgeError } from "./interactive-edge-error";
import { EventHandler } from "@/event-subject";
import { StructuredEdgeRenderModel } from "../../structure-render-model";
import { EdgeElement } from "@/element";

export class InteractiveEdgeShape implements StructuredEdgeShape {
public readonly element: SVGSVGElement;
public readonly element: EdgeElement;

public readonly group: SVGGElement;

Expand Down
3 changes: 2 additions & 1 deletion src/edges/shapes/midpoint-edge-shape/midpoint-edge-shape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { EventHandler } from "@/event-subject";
import { EdgeRenderParams } from "../../edge-render-params";
import { StructuredEdgeRenderModel } from "../../structure-render-model";
import { StructuredEdgeShape } from "../../structured-edge-shape";
import { EdgeElement } from "@/element";

export class MidpointEdgeShape implements StructuredEdgeShape {
public readonly group: SVGGElement;
Expand All @@ -14,7 +15,7 @@ export class MidpointEdgeShape implements StructuredEdgeShape {

public readonly onAfterRender: EventHandler<StructuredEdgeRenderModel>;

public readonly element: SVGSVGElement;
public readonly element: EdgeElement;

public constructor(
private readonly baseShape: StructuredEdgeShape,
Expand Down
1 change: 1 addition & 0 deletions src/element/edge-element.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type EdgeElement = HTMLElement | SVGSVGElement;
1 change: 1 addition & 0 deletions src/element/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export type { NodeElement } from "./node-element";
export type { PortElement } from "./port-element";
export type { EdgeElement } from "./edge-element";
3 changes: 2 additions & 1 deletion src/html-view/core-html-view/core-html-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import { createContainer } from "./create-container";
import { prepareNodeElement } from "./prepare-node-element";
import { Identifier } from "@/identifier";
import { restoreNodeElement } from "./restore-node-element";
import { EdgeElement } from "@/element";

export class CoreHtmlView implements HtmlView {
private readonly host = createHost();

private readonly container = createContainer();

private readonly edgeIdToElementMap = new Map<Identifier, SVGSVGElement>();
private readonly edgeIdToElementMap = new Map<Identifier, EdgeElement>();

private readonly attachedNodeIds = new Set<Identifier>();

Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,4 @@ export type {

export { EventSubject } from "./event-subject";

export type { NodeElement, PortElement } from "./element";
export type { NodeElement, PortElement, EdgeElement } from "./element";
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class ForceDirectedAnimatedLayoutAlgorithm

private readonly nodeForcesApplicationStrategy: NodeForcesApplicationStrategy;

private readonly convergenceVelocity: number;
private readonly stopVelocity: number;

private readonly maxTimeDeltaSec: number;

Expand All @@ -34,7 +34,7 @@ export class ForceDirectedAnimatedLayoutAlgorithm
private readonly fillerLayoutAlgorithm: LayoutAlgorithm;

public constructor(params: ForceDirectedAnimatedLayoutAlgorithmParams) {
this.convergenceVelocity = params.stopVelocity;
this.stopVelocity = params.stopVelocity;
this.maxTimeDeltaSec = params.maxTimeDeltaSec;
this.nodeMass = params.nodeMass;
this.edgeEquilibriumLength = params.edgeEquilibriumLength;
Expand Down Expand Up @@ -83,7 +83,7 @@ export class ForceDirectedAnimatedLayoutAlgorithm

const maxVelocity = iteration.apply();

if (maxVelocity < this.convergenceVelocity) {
if (maxVelocity < this.stopVelocity) {
const hasUnsetCoords = graph.getAllNodeIds().some((nodeId) => {
const node = graph.getNode(nodeId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ export class ForceDirectedLayoutAlgorithm implements LayoutAlgorithm {

private readonly edgeStiffness: number;

private readonly convergenceVelocity: number;
private readonly stopVelocity: number;

public constructor(params: ForceDirectedLayoutAlgorithmParams) {
this.maxIterations = params.maxIterations;
this.dtSec = params.dtSec;
this.nodeMass = params.nodeMass;
this.edgeEquilibriumLength = params.edgeEquilibriumLength;
this.edgeStiffness = params.edgeStiffness;
this.convergenceVelocity = params.stopVelocity;
this.stopVelocity = params.stopVelocity;

this.distanceVectorGenerator = new DistanceVectorGenerator(params.rand);

Expand Down Expand Up @@ -82,7 +82,7 @@ export class ForceDirectedLayoutAlgorithm implements LayoutAlgorithm {

const maxVelocity = iteration.apply();

if (maxVelocity < this.convergenceVelocity) {
if (maxVelocity < this.stopVelocity) {
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/viewport-controller/viewport-controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ describe("ViewportController", () => {
element,
});

viewportController.center({ x: 200, y: 200 });
viewportController.center({ x: 200, y: 200 }, undefined);

expect(viewportStore.getContentMatrix()).toEqual({
scale: 1,
Expand Down
2 changes: 1 addition & 1 deletion src/viewport-controller/viewport-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class ViewportController {
this.viewportStore.patchContentMatrix(request);
}

public center(target: Point, config?: CenterConfig | undefined): void {
public center(target: Point, config: CenterConfig | undefined): void {
const { width, height } = this.viewportStore.getDimensions();
const viewportCenter: Point = { x: width / 2, y: height / 2 };

Expand Down
Loading