public static void computePositions(Node node,int depth,double aoff,double awid,double radius,double radiusinc){
  node.x=Math.sin(aoff) * radius;
  node.y=Math.cos(aoff) * radius;
  double cwid=awid / node.weight;
  double div=1;
  if (node.weight > 1) {
    double s=Math.sin(awid * .5), c=Math.cos(awid * .5);
    double dx=s * (depth + 1), dy=c * (depth + 1) - depth;
    double d=Math.sqrt(dx * dx + dy * dy) / MathUtil.SQRT2;
    div=Math.max(div,d);
  }
  double cang=aoff - awid * .5 / div;
  final double adjwid=cwid / div;
  for (  Node c : node.children) {
    computePositions(c,depth + 1,cang + adjwid * c.weight * .5,adjwid * c.weight,radius + radiusinc,radiusinc);
    cang+=adjwid * c.weight;
  }
}

public static void computePositions ( Node node , int depth , double aoff , double awid , double radius , double radiusinc ) { node . x = Math . sin ( aoff ) * radius ; node . y = Math . cos ( aoff ) * radius ; double cwid = awid / node . weight ; double div = 1 ; if ( node . weight > 1 ) { double s = Math . sin ( awid * .5 ) , c = Math . cos ( awid * .5 ) ; double dx = s * ( depth + 1 ) , dy = c * ( depth + 1 ) - depth ; double d = Math . sqrt ( dx * dx + dy * dy ) / MathUtil . SQRT2 ; div = Math . max ( div , d ) ; } double cang = aoff - awid * .5 / div ; final double adjwid = cwid / div ; for ( Node c : node . children ) { computePositions ( c , depth + 1 , cang + adjwid * c . weight * .5 , adjwid * c . weight , radius + radiusinc , radiusinc ) ; cang += adjwid * c . weight ; } }
compute the layout positions
