void AddSpringForces(FiEdge e) { Point duv; if (settings.RespectEdgePorts) { var sourceLocation = e.source.Center; var targetLocation = e.target.Center; var sourceFloatingPort = e.mEdge.SourcePort as FloatingPort; if (sourceFloatingPort != null) { sourceLocation = sourceFloatingPort.Location; } var targetFloatingPort = e.mEdge.TargetPort as FloatingPort; if (targetFloatingPort != null) { targetLocation = targetFloatingPort.Location; } duv = sourceLocation - targetLocation; } else { duv = e.vector(); } if (settings.LogScaleEdgeForces) { AddLogSpringForces(e, duv, e.mEdge.Length); } else { AddSquaredSpringForces(e, duv, e.mEdge.Length); } }
void AddLogSpringForces(FiEdge e, Point duv, double d) { double l = duv.Length, f = 0.0007 * settings.AttractiveForceConstant * l * Math.Log((l + 0.1) / (d + 0.1)); e.source.force += f * duv; e.target.force -= f * duv; }
void AddSquaredSpringForces(FiEdge e, Point duv, double d) { double l = duv.Length, d2 = d * d + 0.1, f = settings.AttractiveForceConstant * (l - d) / d2; e.source.force += f * duv; e.target.force -= f * duv; }
static void CalculateMultiPorts(FiEdge e) { var sourceLocation = e.source.Center; var targetLocation = e.target.Center; var sourceMultiPort = e.mEdge.SourcePort as MultiLocationFloatingPort; if (sourceMultiPort != null) { sourceMultiPort.SetClosestLocation(targetLocation); } var targetMultiPort = e.mEdge.TargetPort as MultiLocationFloatingPort; if (targetMultiPort != null) { targetMultiPort.SetClosestLocation(sourceLocation); } }
void AddSpringForces(FiEdge e) { Point duv; if (settings.RespectEdgePorts) { var sourceLocation = e.source.Center; var targetLocation = e.target.Center; var sourceFloatingPort = e.mEdge.SourcePort as FloatingPort; if (sourceFloatingPort != null) { sourceLocation = sourceFloatingPort.Location; } var targetFloatingPort = e.mEdge.TargetPort as FloatingPort; if (targetFloatingPort != null) { targetLocation = targetFloatingPort.Location; } duv = sourceLocation - targetLocation; } else { duv = e.vector(); } if (settings.LogScaleEdgeForces) { AddLogSpringForces(e, duv, e.mEdge.Length); } else { AddSquaredSpringForces(e, duv, e.mEdge.Length); } }
static void CalculateMultiPorts(FiEdge e) { var sourceLocation = e.source.Center; var targetLocation = e.target.Center; var sourceMultiPort = e.mEdge.SourcePort as MultiLocationFloatingPort; if (sourceMultiPort != null) { sourceMultiPort.SetClosestLocation(targetLocation); } var targetMultiPort = e.mEdge.TargetPort as MultiLocationFloatingPort; if (targetMultiPort != null) { targetMultiPort.SetClosestLocation(sourceLocation); } }
void AddSquaredSpringForces(FiEdge e, Point duv, double d) { double l = duv.Length, d2 = d*d + 0.1, f = settings.AttractiveForceConstant*(l - d)/d2; e.source.force += f*duv; e.target.force -= f*duv; }
void AddLogSpringForces(FiEdge e, Point duv, double d) { double l = duv.Length, f = 0.0007*settings.AttractiveForceConstant*l*Math.Log((l + 0.1)/(d + 0.1)); e.source.force += f*duv; e.target.force -= f*duv; }