MCPcopy
hub / github.com/opentrace/opentrace / setData

Method setData

ui/src/components/pixi/PixiRenderer.ts:575–696  ·  view source on GitHub ↗
(
    graphNodes: GraphNode[],
    graphLinks: GraphLink[],
    positions: Map<string, { x: number; y: number }>,
    nodeColors: Map<string, string>,
    nodeSizes: Map<string, number>,
    linkColors: Map<string, string>,
  )

Source from the content-addressed store, hash-verified

573 // ─── Data ─────────────────────────────────────────────────────────
574
575 async setData(
576 graphNodes: GraphNode[],
577 graphLinks: GraphLink[],
578 positions: Map<string, { x: number; y: number }>,
579 nodeColors: Map<string, string>,
580 nodeSizes: Map<string, number>,
581 linkColors: Map<string, string>,
582 ): Promise<void> {
583 // Wait for init to complete before touching the scene graph
584 if (this.initPromise) await this.initPromise;
585 if (
586 this.destroyed ||
587 !this.app ||
588 !this.nodeContainer ||
589 !this.labelContainer
590 )
591 return;
592
593 // Clear previous
594 this.nodeContainer.removeChildren();
595 this.labelContainer.removeChildren();
596 this.nodes.clear();
597 this.nodeArray = [];
598 this.nodeIdToIndex.clear();
599 this.edges = [];
600 this.edgeIndex.clear();
601
602 // A fresh graph starts a new auto-fit session — forget any prior pan/zoom.
603 this.hasUserMovedCamera = false;
604
605 // Build nodes
606 for (const gn of graphNodes) {
607 const pos = positions.get(gn.id) ?? { x: 0, y: 0 };
608 const color = nodeColors.get(gn.id) ?? '#888888';
609 const size = nodeSizes.get(gn.id) ?? 4;
610 const tex = getCircleTexture(this.app, color, this.textureCache);
611
612 const sprite = new Sprite(tex);
613 sprite.anchor.set(0.5);
614 sprite.scale.set(size / CIRCLE_RADIUS); // applyCounterScale() adjusts after zoomToFit
615 sprite.alpha = 0.9;
616 sprite.position.set(pos.x, pos.y);
617 this.nodeContainer.addChild(sprite);
618
619 const node: PixiNode = {
620 id: gn.id,
621 graphNode: gn,
622 x: pos.x,
623 y: pos.y,
624 size,
625 color,
626 sprite,
627 visible: true,
628 };
629 this.nodeIdToIndex.set(gn.id, this.nodeArray.length);
630 this.nodeArray.push(node);
631 this.nodes.set(gn.id, node);
632 }

Callers 1

Calls 9

redrawAllEdgesMethod · 0.95
rebuildQuadtreeMethod · 0.95
zoomToFitMethod · 0.95
applyCounterScaleMethod · 0.95
getCircleTextureFunction · 0.90
selectBreakpointFunction · 0.90
pushMethod · 0.80
getMethod · 0.65
addMethod · 0.45

Tested by

no test coverage detected