private void updateViewBounds() { try { this.updateGraphBounds(); if (fViewBounds == null) { fViewBounds = fGraphBounds; return; } ArborPoint vLT = fGraphBounds.LeftTop.sub(fViewBounds.LeftTop).mul(Mag); ArborPoint vRB = fGraphBounds.RightBottom.sub(fViewBounds.RightBottom).mul(Mag); double aX = vLT.magnitude() * this.fScreenWidth; double aY = vRB.magnitude() * this.fScreenHeight; if (aX > 1 || aY > 1) { ArborPoint nbLT = fViewBounds.LeftTop.add(vLT); ArborPoint nbRB = fViewBounds.RightBottom.add(vRB); fViewBounds = new PSBounds(nbLT, nbRB); } } catch (Exception ex) { Debug.WriteLine("ArborSystem.updateViewBounds(): " + ex.Message); } }
private void applySprings() { foreach (ArborEdge edge in fEdges) { ArborPoint s = edge.Target.Pt.sub(edge.Source.Pt); double sMag = s.magnitude(); ArborPoint r = ((sMag > 0) ? s : ArborPoint.newRnd(1)).normalize(); double q = edge.Stiffness * (edge.Length - sMag); edge.Source.applyForce(r.mul(q * -0.5)); edge.Target.applyForce(r.mul(q * 0.5)); } }