/// <summary> /// /// </summary> /// <param name="edge"></param> /// <param name="cornerFitRadius"></param> public static void CreateSimpleEdgeCurveWithGivenFitRadius(Edge edge, double cornerFitRadius) { ValidateArg.IsNotNull(edge, "edge"); var a = edge.Source.Center; var b = edge.Target.Center; if (edge.Source == edge.Target) { var dx = edge.Source.BoundaryCurve.BoundingBox.Width / 2; var dy = edge.Source.BoundingBox.Height / 4; edge.UnderlyingPolyline = CreateUnderlyingPolylineForSelfEdge(a, dx, dy); for (var site = edge.UnderlyingPolyline.HeadSite.Next; site.Next != null; site = site.Next) { CalculateCoefficiensUnderSite(site, cornerFitRadius); } edge.Curve = edge.UnderlyingPolyline.CreateCurve(); } else { edge.UnderlyingPolyline = SmoothedPolyline.FromPoints(new[] { a, b }); edge.Curve = edge.UnderlyingPolyline.CreateCurve(); } if (!Arrowheads.TrimSplineAndCalculateArrowheads(edge.EdgeGeometry, edge.Source.BoundaryCurve, edge.Target.BoundaryCurve, edge.Curve, true)) { Arrowheads.CreateBigEnoughSpline(edge); } }
static void CreateCurveOnChangedPolyline(GeomEdge e) { Curve curve = e.UnderlyingPolyline.CreateCurve(); if ( !Arrowheads.TrimSplineAndCalculateArrowheads(e.EdgeGeometry, e.Source.BoundaryCurve, e.Target.BoundaryCurve, curve, false, false)) { Arrowheads.CreateBigEnoughSpline(e); } }
void CreateEdgeCurve(DrawingEdge de, LayoutEdge le) { var a = de.SourceNode.GeometryNode.Center; var b = de.TargetNode.GeometryNode.Center; Site start, end, mids; if (Source.Label == Target.Label) { start = new Site(a); end = new Site(b); var mid1 = de.SourceNode.GeometryNode.Center; mid1.X += (de.SourceNode.GeometryNode.BoundingBox.Width / 3 * 2); var mid2 = mid1; mid1.Y -= de.SourceNode.GeometryNode.BoundingBox.Height / 2; mid2.Y += de.SourceNode.GeometryNode.BoundingBox.Height / 2; Site mid1s = new Site(mid1); Site mid2s = new Site(mid2); start.Next = mid1s; mid1s.Previous = start; mid1s.Next = mid2s; mid2s.Previous = mid1s; mid2s.Next = end; end.Previous = mid2s; } else { start = new Site(a); end = new Site(b); mids = new Site(a * 0.5 + b * 0.5); start.Next = mids; mids.Previous = start; mids.Next = end; end.Previous = mids; } SmoothedPolyline polyline = new SmoothedPolyline(start); le.UnderlyingPolyline = polyline; le.Curve = polyline.CreateCurve(); if (Arrowheads.TrimSplineAndCalculateArrowheads(le, le.Curve, true, true) == false) { Arrowheads.CreateBigEnoughSpline(le); } }
/// <summary> /// creates an edge curve based only on the source and target geometry /// </summary> /// <param name="edge"></param> public static void CreateSimpleEdgeCurve(Edge edge) { ValidateArg.IsNotNull(edge, "edge"); var a = edge.Source.Center; var b = edge.Target.Center; if (edge.Source == edge.Target) { var dx = edge.Source.BoundaryCurve.BoundingBox.Width / 2; var dy = edge.Source.BoundingBox.Height / 4; edge.UnderlyingPolyline = CreateUnderlyingPolylineForSelfEdge(a, dx, dy); edge.Curve = edge.UnderlyingPolyline.CreateCurve(); } else { edge.UnderlyingPolyline = SmoothedPolyline.FromPoints(new[] { a, b }); edge.Curve = edge.UnderlyingPolyline.CreateCurve(); } if (!Arrowheads.TrimSplineAndCalculateArrowheads(edge.EdgeGeometry, edge.Source.BoundaryCurve, edge.Target.BoundaryCurve, edge.Curve, true)) { Arrowheads.CreateBigEnoughSpline(edge); } }