예제 #1
0
  // Responsible for loading the number of lines per node
  // Receives a line delimited tokenizer.  It will only process one line of
  // that tokenizer.  It must read that line, create a space/tab delimited
  // tokenizer from it, grab the number of lines per node from that tokenizer.
  // Structures that can contain additional information following the number
  // of lines per node (such as trees) should then override this generic
  // loadLinesPerNodeInfo with their own version of the method which will call
  // on the super version to get the actual lines per node and add additional
  // code to process the other information
  public void loadLinesPerNodeInfo(StringTokenizer st, LinkedList llist, draw d)
      throws VisualizerLoadException {
    String tempString, tempString2;
    if (st.hasMoreTokens()) tempString = st.nextToken();
    else throw (new VisualizerLoadException("Expected lines per node - found end of string"));

    StringTokenizer t = new StringTokenizer(tempString, " \t");
    if (t.hasMoreTokens()) tempString2 = t.nextToken();
    else throw (new VisualizerLoadException("Expected lines per node - found " + tempString));

    linespernode = Format.atoi(tempString2);

    xspacing = 1.5;
    yspacing = 1.5;

    if (t.hasMoreTokens()) tempString2 = t.nextToken();
    else return;

    xspacing = Format.atof(tempString2);

    if (t.hasMoreTokens()) tempString2 = t.nextToken();
    else return;

    yspacing = Format.atof(tempString2);
  }
예제 #2
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);
  }
예제 #3
0
  public void loadStructure(StringTokenizer st, LinkedList llist, draw d)
      throws VisualizerLoadException {
    String s;
    GTN gtn = new GTN();
    Dne = false; // For handling EOSS in the recursive procedure *)

    s = st.nextToken();
    if (!(st.hasMoreTokens()))
      throw (new VisualizerLoadException(
          "Encountered Bad Data When Expecting number of total nodes"));
    nn = Format.atoi(s);
    numNodes = nn;

    s = st.nextToken();
    if (!(st.hasMoreTokens()))
      throw (new VisualizerLoadException(
          "Encountered Bad Data When Expecting number of total nodes"));
    path = Format.atoi(s);

    s = st.nextToken();
    if (!(st.hasMoreTokens()))
      throw (new VisualizerLoadException(
          "Encountered Bad Data When Expecting number of total nodes"));
    weight = Format.atoi(s);

    s = st.nextToken();
    if (!(st.hasMoreTokens()))
      throw (new VisualizerLoadException(
          "Encountered Bad Data When Expecting number of total nodes"));
    badCommand = Format.atoi(s);

    s = st.nextToken();
    if (!(s.equals(newTree)))
      throw (new VisualizerLoadException("Encountered Bad Data When Expecting New Tree Delimeter"));

    while (!Dne && numNodes > 0) {
      if (st.hasMoreTokens()) s = st.nextToken();
      else s = "-1";

      try {
        gtn = getGTNode(st, s, linespernode, llist, d);
        numNodes--;
      } catch (EndOfSnapException e) {
        Dne = true;
      }
      if (!Dne) {
        buildGeneralTree(st, gtn, llist, d); // Build Tree *)
        nodelist.append(gtn);
        Dne = false;
      }
    }

    // loop that gets the final info values from the file
    for (int x = 0; x < 4; x++) {
      if (st.hasMoreTokens()) s = st.nextToken();
      else throw (new VisualizerLoadException("End of data when expecting info"));

      if (x == 0) cpf = s;
      else if (x == 1) cpu = s;
      else if (x == 2) command = s;
    }
  }