public drawCalculatedPath()

in web/src/app/pages/graph/architecture-graph/graph/base/path.ts [163:228]


  public drawCalculatedPath(calculatedPath: CalculatedPath) {
    const path = calculatedPath.path;
    let result = '';
    for (let i = 0; i < path.length; i += 2) {
      if (i == 0) {
        result += `M ${path[i]},${path[i + 1]}`;
      } else {
        result += ` L ${path[i]},${path[i + 1]}`;
      }
    }
    const pathElement = document.createElementNS(
      'http://www.w3.org/2000/svg',
      'path',
    );
    pathElement.setAttribute('stroke', 'black');
    pathElement.setAttribute('fill', 'none');
    pathElement.setAttribute('d', result);
    pathElement.setAttribute('stroke-width', '3');
    for (const styleKey in calculatedPath.definition.pathStyle) {
      pathElement.setAttribute(
        styleKey,
        calculatedPath.definition.pathStyle[styleKey] as string,
      );
    }
    this._root?.element!.appendChild(pathElement);
    for (let i = 2; i < path.length - 2; i += 2) {
      const pointIndex = i / 2 - 1;
      const prevPipe = pointIndex - 1;

      const connectedPipes = [];
      if (pointIndex < calculatedPath.pipes.length) {
        connectedPipes.push(calculatedPath.pipes[pointIndex]);
      }
      if (prevPipe >= 0) {
        connectedPipes.push(calculatedPath.pipes[prevPipe]);
      }

      let jointVisible = false;
      for (const pipe of connectedPipes) {
        jointVisible =
          jointVisible ||
          pipe.isVisibleJointForLine(calculatedPath.source, {
            x: path[i],
            y: path[i + 1],
          });
      }
      if (!jointVisible) continue;
      const jointElement = document.createElementNS(
        'http://www.w3.org/2000/svg',
        'circle',
      );
      jointElement.setAttribute('r', '5');
      jointElement.setAttribute('cx', '' + path[i]);
      jointElement.setAttribute('cy', '' + path[i + 1]);
      this._root?.element!.appendChild(jointElement);
    }
    const pathEdge = this.createHeadEdge(
      calculatedPath.definition,
      path[path.length - 2],
      path[path.length - 1],
    );
    if (pathEdge) {
      this._root?.element!.appendChild(pathEdge);
    }
    return result;
  }