Esempio n. 1
0
  public Rectangle2D getBounds2D() {
    StringTokenizer tokens = new StringTokenizer(getRenderString(), "\n");

    int noLines = tokens.countTokens();

    double height = (theFont.getSize2D() * noLines) + 5;
    double width = 0;

    while (tokens.hasMoreTokens()) {
      double l = theFont.getSize2D() * tokens.nextToken().length() * (5.0 / 8.0);
      if (l > width) width = l;
    }

    double parX;
    double parY;
    if (parent instanceof State) {
      parX = ((State) parent).getX();
      parY = ((State) parent).getY();
    } else if (parent instanceof Transition) {
      parX = ((Transition) parent).getMiddle().getX(); // dummy
      parY = ((Transition) parent).getMiddle().getY(); // dummy
    } else {
      parX = 0;
      parY = 0;
    }

    double mx = parX + offsetX;
    double my = parY + offsetY - 10;

    double tx = parX + width + offsetX;
    double ty = parY + height + offsetY - 10;

    return new Rectangle2D.Double(mx, my, tx - mx, ty - my);
  }
Esempio n. 2
0
  public void workOutMinsAndMaxs() {
    StringTokenizer tokens = new StringTokenizer(getRenderString(), "\n");

    int noLines = tokens.countTokens();

    double height = (theFont.getSize2D() * noLines) + 5;
    double width = 0;

    while (tokens.hasMoreTokens()) {
      double l = theFont.getSize2D() * tokens.nextToken().length() * (5.0 / 8.0);
      if (l > width) width = l;
    }

    double parX;
    double parY;
    if (parent instanceof State) {
      parX = ((State) parent).getX();
      parY = ((State) parent).getY();
    } else if (parent instanceof Transition) {
      parX = ((Transition) parent).getMiddle().getX(); // dummy
      parY = ((Transition) parent).getMiddle().getY(); // dummy
    } else {
      parX = 0;
      parY = 0;
    }

    minX = parX + offsetX - 5;
    minY = parY + offsetY - 25;

    maxX = parX + width + offsetX + 5;
    maxY = parY + height + offsetY - 5;
  }
Esempio n. 3
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. 4
0
  // See comment in createericlist regarding HandleViewParams
  private /*synchronized*/ String HandleViewParams(
      String tempString, LinkedList tempList, StringTokenizer st) throws VisualizerLoadException {
    while (tempString.toUpperCase().startsWith("VIEW")) {
      StringTokenizer t = new StringTokenizer(tempString, " \t");
      String s1 = t.nextToken().toUpperCase();
      String s2 = t.nextToken().toUpperCase();
      String s3 = t.nextToken();

      // HERE PROCESS URL's AS YOU DID QUESTIONS

      if (s2.compareTo("ALGO") == 0) {
        add_a_pseudocode_URL(s3);
        // System.out.println("Adding to urls: "+Snaps+":"+s3);
        //                 urlList.append(Snaps+1 +":"+s3);
      } else if (s2.compareTo("DOCS") == 0) {
        add_a_documentation_URL(s3);
        // System.out.println("Adding to urls: "+Snaps+":"+s3);
        //                 if (debug) System.out.println("Adding to urlList: "+Snaps+1+":"+s3);
        //                 urlList.append(Snaps+1 +":"+s3);
      } else if (s2.compareTo("SCALE") == 0) {
        GKS.scale(Format.atof(s3.toUpperCase()), tempList, this);
      } else if (s2.compareTo("WINDOWS") == 0) {
        GKS.windows(Format.atoi(s3.toUpperCase()), tempList, this);
      } else if (s2.compareTo("JUMP") == 0) {
        GKS.jump(Format.atoi(s3.toUpperCase()), tempList, this);
      } else throw (new VisualizerLoadException(s2 + " is invalid VIEW parameter"));
      tempString = st.nextToken();
    }
    //         if (urlList.size() == 0)
    //             urlList.append("**");
    return (tempString);
  }
Esempio n. 5
0
  // createericlist with a String signature is used to process a String
  // containing a sequence of GAIGS structures
  // createericlist creates the list of graphics primitives for these snapshot(s).
  // After creating these lists, that are then appended to l, the list of snapshots,
  // Also must return the number of snapshots loaded from the string
  public /*synchronized*/ int createericlist(String structString) {
    int numsnaps = 0;
    if (debug) System.out.println("In create eric " + structString);
    StringTokenizer st = new StringTokenizer(structString, "\r\n");
    while (st.hasMoreTokens()) {
      numsnaps++; // ??
      String tempString;
      LinkedList tempList = new LinkedList();
      StructureType strct;
      tempString = st.nextToken();
      try {
        boolean headers = true;
        while (headers) {
          headers = false;
          if (tempString.toUpperCase().startsWith("VIEW")) {
            tempString = HandleViewParams(tempString, tempList, st);
            headers = true;
          }
          if (tempString.toUpperCase().startsWith("FIBQUESTION ")
              || tempString.toUpperCase().startsWith("MCQUESTION ")
              || tempString.toUpperCase().startsWith("MSQUESTION ")
              || tempString.toUpperCase().startsWith("TFQUESTION ")) {
            tempString = add_a_question(tempString, st);
            headers = true;
          }
        }

        if (tempString.toUpperCase().equals("STARTQUESTIONS")) {
          numsnaps--; // questions don't count as snapshots
          readQuestions(st);
          break;
        }
        // After returning from HandleViewParams, tempString should now contain
        // the line with the structure type and possible additional text height info
        StringTokenizer structLine = new StringTokenizer(tempString, " \t");
        String structType = structLine.nextToken();
        if (debug) System.out.println("About to assign structure" + structType);
        strct = assignStructureType(structType);
        strct.loadTextHeights(structLine, tempList, this);
        strct.loadLinesPerNodeInfo(st, tempList, this);

        strct.loadTitle(st, tempList, this);
        strct.loadStructure(st, tempList, this);
        strct.calcDimsAndStartPts(tempList, this);
        strct.drawTitle(tempList, this);
        strct.drawStructure(tempList, this);
      } catch (VisualizerLoadException e) {
        System.out.println(e.toString());
      }
      //             // You've just created a snapshot.  Need to insure that "**" is appended
      //             // to the URLList for this snapshot IF no VIEW ALGO line was parsed in the
      //             // string for the snapshot.  This could probably best be done in the
      //             // HandleViewParams method
      list_of_snapshots.append(tempList);
      Snaps++;
    }
    return (numsnaps);
  } // createericlist(string)
Esempio n. 6
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);
  }
Esempio n. 7
0
  // Method that draws all elements in each set starting with the root and then
  // calling traverse to get the rest of the tree
  void drawSets(LinkedList llist, draw d) {
    int temp;
    double stringLength = 0.0;
    String s = "";
    StringTokenizer getWeight;
    GTN gtn = new GTN();
    GTN TempChild;

    x = .0;
    y = TitleEndy - .24;

    nodelist.reset();
    while (nodelist.hasMoreElements()) {
      if (nodelist.hasMoreElements()) gtn = (GTN) (nodelist.nextElement());
      else gtn = (GTN) (nodelist.currentElement());

      // traverse down current tree
      s = traverse(gtn, s, llist, d, true);
      s += "}";

      BufferedImage buffer =
          new BufferedImage(
              GaigsAV.preferred_width, GaigsAV.preferred_height, BufferedImage.TYPE_BYTE_GRAY);

      temp = buffer.getGraphics().getFontMetrics(defaultFont).stringWidth(s);

      //		temp = d.getGraphics().getFontMetrics(defaultFont).stringWidth(s);

      stringLength = ((double) temp / (double) d.getSize().width);

      // gets the weight of the current set
      getWeight = new StringTokenizer(s, ",");
      LGKS.set_text_align(0, 2, llist, d);
      LGKS.text(gtn.Gx, (gtn.Gy + Lenx + .02), ("" + getWeight.countTokens()), llist, d);

      LGKS.set_text_align(1, 2, llist, d);
      // these checks insure that the set info will be drawn within
      // the bounds of the window
      if ((x + stringLength) >= 1.0) {
        x = 0;
        y -= .05;
        LGKS.text(x, y, s, llist, d);
        x = stringLength + .05;
      } else {
        LGKS.text(x, y, s, llist, d);
        x += stringLength + .05;
      }

      s = "";
    }
  }
Esempio n. 8
0
 private /*synchronized*/ String add_a_question(String tmpStr, StringTokenizer st)
     throws VisualizerLoadException {
   try {
     StringTokenizer tokzer = new StringTokenizer(tmpStr);
     String idTok = tokzer.nextToken();
     idTok = tokzer.nextToken(); // what we really want is the id
     //             FIBQuestion q = new FIBQuestion(idTok);
     //             qTable.put(idTok, q);                   //add map id -> q
     GaigsAV.qCtlTable.put(new Integer(Snaps), idTok); // add map snap -> q (assumes <= 1 q/snap)
     if (debug) System.out.println("Adding question for snap " + Snaps);
     return st.nextToken();
   } catch (Exception e) {
     throw new VisualizerLoadException("Aieee... bad SHO file");
   }
 }
Esempio n. 9
0
  /**
   * A rendering method to draw this label to the given Graphics2D object, with the additional
   * option of allowing the "long" lines to be drawn. Due to the fact that the relative drawing
   * point of a state is its x and y co-ordinates and for a Transition there is a workOutMiddle()
   * method, the relative x and y values must be supplied to this method. Usually this method will
   * be called from inside a Transition render method or a State render method.
   *
   * @param g2 the Graphics2D component upon which to draw this label.
   * @param x the x position upon which to make relative co-ordinates exact.
   * @param y the y position upon which to make relative co-ordinates exact.
   * @param longLines flag to determine whether the long version of this label should be drawn.
   */
  public void render(Graphics2D g2, double x, double y, boolean longLines) {
    intersects(new Rectangle2D.Double(0, 0, 1, 1));
    StringTokenizer tokens = new StringTokenizer(getRenderString(), "\n");
    if (selected) {
      g2.setColor(Color.green);
    } else {
      g2.setColor(theColour);
    }
    g2.setFont(theFont);
    int i = 0;
    boolean doneLong = false;
    while (tokens.hasMoreTokens()) {
      if (doneLong)
        g2.drawString(
            tokens.nextToken(),
            (float) (x + offsetX),
            (float) (y + offsetY + ((i * (theFont.getSize() + 2)))));
      else {
        if (!longLines)
          g2.drawString(
              tokens.nextToken().trim(),
              (float) (x + offsetX),
              (float) (y + offsetY + ((i * (theFont.getSize()))) + 2));
        else
          g2.drawString(
              getName() + ": " + tokens.nextToken().trim(),
              (float) (x + offsetX),
              (float) (y + offsetY + ((i * (theFont.getSize()))) + 2));
      }
      i++;
      doneLong = true;
    }

    /*if(intersects != null)
    {
        g2.setColor(Color.magenta);
        for(int j = 0; j < intersects.size(); j++)
        {
            Rectangle2D rect = (Rectangle2D)intersects.get(j);
            g2.draw(rect);
        }
    }*/

  }
Esempio n. 10
0
  /**
   * This method calculates whether a given "Hot area" rectangle intersects with this label and
   * returns the result. The aim of this method is that it can be used to detect whether the
   * position of the mouse is colliding with the label.
   *
   * @param rect A "Hot area" which we are looking for the collision to lie in.
   * @return the result of the collision.
   */
  public boolean intersects(Rectangle2D rect) {
    intersects = new ArrayList();
    if (!getString().equals("")) {
      double parX;
      double parY;
      if (parent instanceof State) {
        parX = ((State) parent).getX();
        parY = ((State) parent).getY();
      } else if (parent instanceof Transition) {
        parX = ((Transition) parent).getMiddle().getX(); // dummy
        parY = ((Transition) parent).getMiddle().getY(); // dummy
      } else {
        parX = 0;
        parY = 0;
      }

      double x = parX + offsetX;
      double y = parY + offsetY - 5;
      StringTokenizer tokens;
      String pre = "";
      if (lineLabels) {
        pre = getName() + ": ";
      }

      tokens = new StringTokenizer(pre + getRenderString(), "\n");

      int i = 0;
      boolean collides = false;
      while (tokens.hasMoreTokens() && !collides) {
        String str = tokens.nextToken().trim();
        // System.out.println("str = \""+str+"\"");
        double height = theFont.getSize2D();
        double width = theFont.getSize2D() * str.length() * (5.0 / 8.0);
        intersects.add(new Rectangle2D.Double(x, y + (i * (height + 1.75) - 2), width, height));
        collides =
            (new Rectangle2D.Double(x, y + (i * (height + 1.75) - 2), width, height))
                .intersects(rect);
        i++;
      }
      return collides;
    } else return false;
  }
Esempio n. 11
0
  public static Color getColor(String value) {
    value = value.trim().toLowerCase();

    if (value.equals("none")) {
      return null;
    } else if (value.equals("currentColor")) {
      // indicates that painting shall be done using the color specified by the 'color' property.
      return CURRENT_COLOR;
    } else if (value.equals("inherit")) {
      // Each property may also have a specified value of 'inherit', which
      // means that, for a given element, the property takes the same
      // computed value as the property for the element's parent
      return INHERIT_COLOR;
    } else if (SVG_COLORS.containsKey(value)) {
      return SVG_COLORS.get(value);
    } else if (value.startsWith("#") && value.length() == 7) {
      return new Color(Integer.decode(value));
    } else if (value.startsWith("#") && value.length() == 4) {
      // Three digits hex value
      int th = Integer.decode(value);
      return new Color(
          (th & 0xf)
              | ((th & 0xf) << 4)
              | ((th & 0xf0) << 4)
              | ((th & 0xf0) << 8)
              | ((th & 0xf00) << 8)
              | ((th & 0xf00) << 12));
    } else if (value.startsWith("rgb")) {
      StringTokenizer tt = new StringTokenizer(value, "() ,");
      tt.nextToken();
      Color c =
          new Color(
              Integer.decode(tt.nextToken()),
              Integer.decode(tt.nextToken()),
              Integer.decode(tt.nextToken()));
      return c;
    } else {
      return null;
    }
  }
Esempio n. 12
0
  public /*synchronized*/ Color colorSet(String values) {
    String temp;
    int x;
    Color c = Color.black;

    StringTokenizer st = new StringTokenizer(values);
    x = Format.atoi(st.nextToken());
    if (x == 1) c = Color.black;
    else if (x == 2) c = Color.blue;
    else if (x == 6) c = Color.cyan;
    else if (x == 13) c = Color.darkGray;
    else if (x == 11) c = Color.gray;
    else if (x == 3) c = Color.green;
    else if (x == 9) c = Color.lightGray;
    else if (x == 5) c = Color.magenta;
    else if (x == 10) c = Color.orange;
    else if (x == 12) c = Color.pink;
    else if (x == 4) c = Color.red;
    else if (x == 8) c = Color.white;
    else if (x == 7) c = Color.yellow;
    else if (x < 0) c = new Color(-x);
    return c;
  }
Esempio n. 13
0
  private /*synchronized*/ void readQuestions(StringTokenizer st) throws VisualizerLoadException {
    String tmpStr =
        "STARTQUESTIONS\n"; // When CG's QuestionFactory parses from a string, it looks for
    // a line with STARTQUESTIONS -- hence we add it artificially here
    try { // Build the string for the QuestionFactory
      while (st.hasMoreTokens()) {
        tmpStr += st.nextToken() + "\n";
      }
    } catch (Exception e) {
      e.printStackTrace();
      throw new VisualizerLoadException("Ooof!  bad question format");
    }

    try {
      // System.out.println(tmpStr);
      // Problem -- must make this be line oriented
      GaigsAV.questionCollection = QuestionFactory.parseScript(tmpStr);
    } catch (QuestionParseException e) {
      e.printStackTrace();
      System.out.println("Error parsing questions.");
      throw new VisualizerLoadException("Ooof!  bad question format");
      // throw new IOException();
    }
  } // readQuestions(st)
Esempio n. 14
0
 String next() throws IOException {
   while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(in.readLine().trim());
   return st.nextToken();
 }
Esempio n. 15
0
  /** Reads the attributes from the specified DOMInput and assigns them to the figure. */
  public static void readAttributes(Figure f, DOMInput in) throws IOException {
    // FIXME - This method is not working, when "style" and individual attributes
    // are both used in an SVG document.
    List<Map<String, String>> styles = new ArrayList<Map<String, String>>();
    List<String> values = in.getInheritedAttribute("style");
    for (String v : values) {
      styles.add(getStyles(v));
    }
    String value;

    // Fill color
    value = getInheritedAttribute("fill", in, styles);
    if (value != null) {
      Color color = getColor(value);
      if (color != INHERIT_COLOR && color != CURRENT_COLOR) {
        FILL_COLOR.set(f, color);
      }
    }
    value = getInheritedAttribute("fill-rule", in, styles);
    if (value != null) {
      WINDING_RULE.set(
          f, value.toUpperCase().equals("NONZERO") ? WindingRule.NON_ZERO : WindingRule.EVEN_ODD);
    } else {
      WINDING_RULE.set(f, WindingRule.NON_ZERO);
    }

    // Stroke color
    value = getInheritedAttribute("stroke", in, styles);
    if (value != null) {
      Color color = getColor(value);
      if (color != INHERIT_COLOR && color != CURRENT_COLOR) {
        STROKE_COLOR.set(f, color);
      }
    }

    value = getInheritedAttribute("stroke-width", in, styles);
    if (value != null) {
      STROKE_WIDTH.set(f, Double.valueOf(value));
    }
    value = getInheritedAttribute("stroke-miterlimit", in, styles);
    if (value != null) {
      STROKE_MITER_LIMIT_FACTOR.set(f, Double.valueOf(value));
    }
    value = getInheritedAttribute("stroke-dasharray", in, styles);
    if (value != null) {
      StringTokenizer tt = new StringTokenizer(value, " ,");
      double[] dashes = new double[tt.countTokens()];
      for (int i = 0, n = dashes.length; i < n; i++) {
        dashes[i] = Double.valueOf(tt.nextToken());
      }
      STROKE_DASHES.set(f, dashes);
    }
    value = getInheritedAttribute("stroke-dashoffset", in, styles);
    if (value != null) {
      STROKE_DASH_PHASE.set(f, Math.abs(Double.valueOf(value)));
    }
    value = getInheritedAttribute("font-size", in, styles);
    if (value != null) {
      FONT_SIZE.set(f, getDimensionValue(in, value));
    }
    value = getInheritedAttribute("text-anchor", in, styles);
    if (value != null) {
      SVGText.TEXT_ANCHOR.set(f, Enum.valueOf(SVGText.TextAnchor.class, value.toUpperCase()));
    }
  }
Esempio n. 16
0
  // creates the list of snapshots
  public /*synchronized*/ obj dothis(String inputString) {
    /* Snapshot codes

    29 - rectangle draw
    2 - oval draw
    5 - fill oval
    6 - string
    7 - line & text color
    8 - fill color
    9 - text color (possible to ignore)
    10 - text height
    11 - polydraw
    4 - fill poly
    14 - arc draw
    30 - fill arc
    12 - text style, centered horizontal/vertical
    ???? 45 - url.  Note, when bring up multiple algorithms, the URL's for the most recently
    run algorithm are posted in the upper browser frame
    THE CODE BELOW WOULD INDICATE THIS IS 54, NOT 45 ????

    20 - number of windows.  For static algorithms, 1, 2, 3, 4 have the obvious meaning.
    21 - scale factor
    22 - jump factor

    For 20, 21, 22, the last factor loaded is the one that will affect all snapshots in
    the show

     */

    obj temp = new rectDraw("0 0 0 0", lineC);
    Object urlTest;
    String arrg;

    int graphic_obj_code = Format.atoi(inputString.substring(0, 3));
    StringTokenizer tmp = null;

    switch (graphic_obj_code) {
      case 29:
        temp = new rectDraw(inputString.substring(3, (inputString.length())), lineC);
        break;
      case 2:
        temp = new ovalDraw(inputString.substring(3, (inputString.length())), lineC);
        break;
      case 5:
        temp = new fillOvalDraw(inputString.substring(3, (inputString.length())), fillC);
        break;
      case 6:
        temp =
            new stringDraw(
                inputString.substring(3, (inputString.length())), textC, LineH, LineV, fontMult);
        // 		System.out.println(" printing " + inputString);
        break;
      case 7:
        lineC = colorSet(inputString.substring(3, (inputString.length())));
        textC = lineC;
        break;
      case 8:
        tmp = new StringTokenizer(inputString.substring(2, (inputString.length())));
        fillC = colorSet(tmp.nextToken());
        break;
      case 9:
        textC = colorSet(inputString.substring(3, (inputString.length())));
        break;
      case 10:
        StringTokenizer st = new StringTokenizer(inputString.substring(3, (inputString.length())));
        fontMult = Format.atof(st.nextToken());
        // 		System.out.println("setting fontMult= " + fontMult);
        break;
        // TLN changed on 10/14/97 to accomodate condensed prm files
        // temp=new textHeight(inputString.substring(3,(inputString.length())));
      case 11:
        temp = new polyDraw(inputString.substring(3, (inputString.length())), lineC);
        break;
      case 4:
        temp = new fillPolyDraw(inputString.substring(3, (inputString.length())), fillC);
        break;
      case 64:
        temp = new animated_fillPolyDraw(inputString.substring(3, (inputString.length())), fillC);
        break;
      case 14:
        temp = new arcDraw(inputString.substring(3, (inputString.length())), lineC);
        break;
      case 30:
        temp = new fillArcDraw(inputString.substring(3, (inputString.length())), fillC);
        break;
      case 12:
        tmp = new StringTokenizer(inputString.substring(3, (inputString.length())));
        LineH = Format.atoi(tmp.nextToken());
        LineV = Format.atoi(tmp.nextToken());
        break;
      case 20:
        tmp = new StringTokenizer(inputString.substring(3, (inputString.length())));
        // graphWin.setNumViews(Format.atoi(tmp.nextToken()));
        // multiTrigger=true;
        break;
      case 21:
        tmp = new StringTokenizer(inputString.substring(3, (inputString.length())));
        double tempFloat = Format.atof(tmp.nextToken());
        zoom = tempFloat;
        break;
      case 22:
        tmp = new StringTokenizer(inputString.substring(3, (inputString.length())));
        //            graphWin.setJump(Format.atoi(tmp.nextToken()));  // This is now a noop in
        // gaigs2
        break;
      case 54:
        tmp = new StringTokenizer(inputString.substring(3, (inputString.length())));
        //             if (tmp.hasMoreElements()){
        //                 urlTest=tmp.nextToken();
        //                 urlList.append(urlTest);
        //             }
        //             else{
        //                 tmp=new StringTokenizer("**");
        //                 urlTest=tmp.nextToken();
        //                 urlList.append(urlTest);
        //             }
        break;
    } // end switch

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