Esempio 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;
    }
  }
Esempio n. 2
0
  public void buildGeneralTree(StringTokenizer st, GTN PresentNode, LinkedList llist, draw d)
      throws VisualizerLoadException {
    String s;
    GTN LastChild;

    if (st.hasMoreTokens() && numNodes > 0) {
      s = st.nextToken();

      if (!(s.equals(newTree)) && !(s.equals(EndSnapShot))) {
        try {
          NextNode = getGTNode(st, s, linespernode, llist, d);
          numNodes--;
        } catch (EndOfSnapException e) {
          Dne = true;
        }
        LastChild = NextNode;
        while (!Dne && (NextNode.Glevel > PresentNode.Glevel)) {
          // We must insert NextNode as the LastChild of the PresentNode...*)
          if (PresentNode.Children == null) // Special case *)
          PresentNode.Children = NextNode;
          else LastChild.Siblings = NextNode;
          LastChild = NextNode;
          buildGeneralTree(st, NextNode, llist, d);
        }
      } else {
        Dne = true;
      }
    } else Dne = true;
  }
Esempio n. 3
0
  public GTN getGTNode(StringTokenizer st, String s, int linesPerNode, LinkedList llist, draw d)
      throws EndOfSnapException, VisualizerLoadException {
    GTN gtn = new GTN();

    if (s.equals("-1")) throw (new EndOfSnapException("End of Snap Shot Reached"));

    gtn.Glevel = Format.atoi(s);
    gtn.textInNode = getTextNode(st, linesPerNode, llist, d);

    return (gtn);
  }
Esempio n. 4
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);
    }
  }