Ejemplo n.º 1
0
  private void ApplyModifier(GTN Root) {

    /*
    GIVEN  : The node to which to apply the accumulated modifier.
    TASK   : Make recursive calls to accumulate the modifier sum up the tree,
                   filling in each individual node's modifier along the way. */

    GTN TempChild;

    if (Root != null) {
      Root.Gx = Root.Gx + ModifierSum;
      if (minXCord > Root.Gx) {
        minXCord = Root.Gx;
      } else if (maxXCord < Root.Gx) {
        maxXCord = Root.Gx;
      }
      ModifierSum = ModifierSum + Root.GModifier;
      TempChild = Root.Children;
      while (TempChild != null) {
        ApplyModifier(TempChild);
        TempChild = TempChild.Siblings;
      }
      ModifierSum = ModifierSum - Root.GModifier;
      Root.GModifier = 0.0;
    }
  }
Ejemplo n.º 2
0
  double xCoord(GTN Root) {
    /*
    GIVEN  : The pointer to the node whose coordinates we're currently
                   trying to find.
    TASK   : Find the xCoord of this node, using the principles used in
                   Algorithm 3 of "Tidy Drawings of Trees", by Charles Wetherell
                   and Alfred Shannon.  Note that this is a recursive procedure,
                   which calls on itself at a given level to find the position of
                   the children at the level below.
    RETURN: Ultimately, the xCoord of the Root node of the tree. */

    double AccumXCoords, ChildAvgPos, Tempx, Holder8087;
    int ChildCount;
    GTN TempChild;

    if (Root == null) {
      return (0.0);
    } else {
      CurrLevel = CurrLevel + 1;
      TempChild = Root.Children;
      ChildCount = 0;
      AccumXCoords = 0;
      while (TempChild != null) {
        ChildCount = ChildCount + 1;
        Holder8087 = xCoord(TempChild);
        AccumXCoords = AccumXCoords + Holder8087;
        TempChild = TempChild.Siblings;
      }
      CurrLevel = CurrLevel - 1;
      if (ChildCount == 0) ChildAvgPos = 0.0;
      else ChildAvgPos = AccumXCoords / ((double) ChildCount);
      if (NextPos[CurrLevel] > ChildAvgPos) Tempx = NextPos[CurrLevel];
      else Tempx = ChildAvgPos; // The average of node's children's positions *)
      if (Root.Children == null) {
        Root.GModifier = 0.0;
        Root.Gx = Tempx;
      } else {
        Modifier[CurrLevel] = Math.max(Modifier[CurrLevel], Tempx - ChildAvgPos);
        Root.GModifier = Modifier[CurrLevel];
        Root.Gx = Modifier[CurrLevel] + ChildAvgPos;
      }
      Root.Gy = Starty - (Root.Glevel * (yspacing * Lenx));
      NextPos[CurrLevel] = Root.Gx + (xspacing * Lenx);

      return (Root.Gx);
    }
  }