Refactor ElkSharp routing sources into partial modules

This commit is contained in:
master
2026-03-28 11:56:35 +02:00
parent 7be4e855d6
commit 7057819f4d
34 changed files with 33377 additions and 21402 deletions

View File

@@ -190,6 +190,70 @@ internal static class ElkEdgeRoutingGeometry
return "bottom";
}
internal static string ResolveBoundaryApproachSide(
ElkPoint boundaryPoint,
ElkPoint adjacentPoint,
ElkPositionedNode node)
{
if (!ElkShapeBoundaries.IsGatewayShape(node))
{
return ResolveBoundarySide(boundaryPoint, node);
}
var deltaX = boundaryPoint.X - adjacentPoint.X;
var deltaY = boundaryPoint.Y - adjacentPoint.Y;
var absDx = Math.Abs(deltaX);
var absDy = Math.Abs(deltaY);
if (absDx <= CoordinateTolerance && absDy > CoordinateTolerance)
{
return deltaY >= 0d ? "top" : "bottom";
}
if (absDy <= CoordinateTolerance && absDx > CoordinateTolerance)
{
return deltaX >= 0d ? "left" : "right";
}
if (absDx > absDy * 1.25d)
{
return deltaX >= 0d ? "left" : "right";
}
if (absDy > absDx * 1.25d)
{
return deltaY >= 0d ? "top" : "bottom";
}
return ResolveBoundarySide(boundaryPoint, node);
}
internal static double ComputeParallelOverlapLength(
ElkPoint a1,
ElkPoint a2,
ElkPoint b1,
ElkPoint b2)
{
if (IsHorizontal(a1, a2) && IsHorizontal(b1, b2))
{
return OverlapLength(
Math.Min(a1.X, a2.X),
Math.Max(a1.X, a2.X),
Math.Min(b1.X, b2.X),
Math.Max(b1.X, b2.X));
}
if (IsVertical(a1, a2) && IsVertical(b1, b2))
{
return OverlapLength(
Math.Min(a1.Y, a2.Y),
Math.Max(a1.Y, a2.Y),
Math.Min(b1.Y, b2.Y),
Math.Max(b1.Y, b2.Y));
}
return 0d;
}
internal static bool AreCollinearAndOverlapping(ElkPoint a1, ElkPoint a2, ElkPoint b1, ElkPoint b2)
{
if (IsHorizontal(a1, a2) && IsHorizontal(b1, b2) && Math.Abs(a1.Y - b1.Y) <= CoordinateTolerance)