Ejemplo n.º 1
0
  static String replaceUrlSymbol(JopSession session, String url) {
    Gdh gdh = session.getGdh();

    CdhrObjid webConfig = gdh.getClassList(Pwrb.cClass_WebBrowserConfig);
    if (webConfig.evenSts()) return url;

    CdhrString webName = gdh.objidToName(webConfig.objid, Cdh.mName_volumeStrict);
    if (webConfig.evenSts()) return url;

    for (int i = 0; i < 10; i++) {
      String attr = webName.str + ".URL_Symbols[" + i + "]";
      CdhrString attrValue = gdh.getObjectInfoString(attr);
      if (attrValue.evenSts()) return url;

      if (attrValue.str.equals("")) continue;

      StringTokenizer token = new StringTokenizer(attrValue.str);
      String symbol = "$" + token.nextToken();
      if (!token.hasMoreTokens()) continue;

      String value = token.nextToken();

      int idx = url.lastIndexOf(symbol);
      while (idx != -1) {
        url = url.substring(0, idx) + value + url.substring(idx + symbol.length());
        idx = url.lastIndexOf(symbol);
      }
    }
    return url;
  }
Ejemplo n.º 2
0
  private int Load_Edges(DataInputStream inStream, int num) {
    String line;
    String item1, item2, item3;
    int source_node;
    int dest_node;
    int value;
    int n_nodes, edge_cnt;
    // Node nodes_array[] = new Node[num]; // Wil
    Edge edge;
    n_nodes = num;
    Node nodes_array[];
    nodes_array = new Node[n_nodes];
    nodes_array = this.Node_Array(); // Wil
    edge_cnt = 0;

    try {
      while ((line = inStream.readLine()) != null) {
        StringTokenizer Data = new StringTokenizer(line, " ");
        item1 = Data.nextToken();
        item2 = Data.nextToken();
        item3 = Data.nextToken();
        source_node = Integer.parseInt(item1);
        dest_node = Integer.parseInt(item2);
        value = Integer.parseInt(item3);
        edge = new Edge(nodes_array[source_node - 1], nodes_array[dest_node - 1], value);
        this.Add_Edge(edge);
        edge_cnt++;
      }
      // inFile.close();
    } catch (IOException e) {
      System.err.println("Error in accessing URL: " + e.toString());
      System.exit(1);
    }
    return edge_cnt;
  }
Ejemplo n.º 3
0
  public void parse() {

    System.out.println("Parsing");

    for (int i = 0; i < lineArray.size(); i++) {
      StringTokenizer str = new StringTokenizer(lineArray.elementAt(i).toString());
      if (str.hasMoreTokens()) {
        String inStr = str.nextToken();

        if (inStr.indexOf("ATOM") != -1) {
          try {
            myAtom tmpatom = new myAtom(str);
            if (findChain(tmpatom.chain) != null) {
              System.out.println("Adding to chain " + tmpatom.chain);
              findChain(tmpatom.chain).atoms.addElement(tmpatom);
            } else {
              System.out.println("Making chain " + tmpatom.chain);
              PDBChain tmpchain = new PDBChain(tmpatom.chain);
              chains.addElement(tmpchain);
              tmpchain.atoms.addElement(tmpatom);
            }
          } catch (NumberFormatException e) {
            System.out.println("Caught" + e);
            System.out.println("Atom not added");
          }
        }
      }
    }
    makeResidueList();
    makeCaBondList();
    //    for (int i=0; i < chains.size() ; i++) {
    //  String pog = ((PDBChain)chains.elementAt(i)).print();
    //  System.out.println(pog);
    // }
  }
Ejemplo n.º 4
0
 private static void parseArgs(String theStringList, String[] s) {
   int x = 0;
   StringTokenizer tokenizer = new StringTokenizer(theStringList, " ");
   while (tokenizer.hasMoreTokens()) {
     s[x++] = tokenizer.nextToken();
   }
 }
Ejemplo n.º 5
0
  private void commit() {
    String serverName = (String) server.getSelectedItem();
    if (serverName == null || serverName.equals("")) {
      vlog.error("No server name specified!");
      if (VncViewer.nViewers == 1)
        if (cc.viewer instanceof VncViewer) {
          ((VncViewer) cc.viewer).exit(1);
        }
      ret = false;
      endDialog();
    }

    // set params
    if (opts.via != null && opts.via.indexOf(':') >= 0) {
      opts.serverName = serverName;
    } else {
      opts.serverName = Hostname.getHost(serverName);
      opts.port = Hostname.getPort(serverName);
    }

    // Update the history list
    String valueStr = UserPreferences.get("ServerDialog", "history");
    String t = (valueStr == null) ? "" : valueStr;
    StringTokenizer st = new StringTokenizer(t, ",");
    StringBuffer sb = new StringBuffer().append((String) server.getSelectedItem());
    while (st.hasMoreTokens()) {
      String str = st.nextToken();
      if (!str.equals((String) server.getSelectedItem()) && !str.equals("")) {
        sb.append(',');
        sb.append(str);
      }
    }
    UserPreferences.set("ServerDialog", "history", sb.toString());
    UserPreferences.save("ServerDialog");
  }
Ejemplo n.º 6
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;
  }
Ejemplo n.º 7
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);
  }
Ejemplo n.º 8
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);
  }
Ejemplo n.º 9
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;
  }
Ejemplo n.º 10
0
  private void updateVpInfo() {

    String key;
    String vps;
    for (int j = 0; j < keys.size(); j++) {
      key = (String) keys.get(j);
      vps = (String) vpInfo.get(j);
      if (vps == null || vps.length() <= 0 || vps.equals("all")) {
        for (int i = 0; i < nviews; i++) {
          tp_paneInfo[i].put(key, "yes");
        }
      } else {
        for (int i = 0; i < nviews; i++) tp_paneInfo[i].put(key, "no");
        StringTokenizer tok = new StringTokenizer(vps, " ,\n");
        while (tok.hasMoreTokens()) {
          int vp = Integer.valueOf(tok.nextToken()).intValue();
          vp--;
          if (vp >= 0 && vp < nviews) {
            tp_paneInfo[vp].remove(key);
            tp_paneInfo[vp].put(key, "yes");
          }
        }
      }
    }
  }
Ejemplo n.º 11
0
  public void paint(Graphics g) {
    m_fm = g.getFontMetrics();

    g.setColor(getBackground());
    g.fillRect(0, 0, getWidth(), getHeight());
    getBorder().paintBorder(this, g, 0, 0, getWidth(), getHeight());

    g.setColor(getForeground());
    g.setFont(getFont());
    m_insets = getInsets();
    int x = m_insets.left;
    int y = m_insets.top + m_fm.getAscent();

    StringTokenizer st = new StringTokenizer(getText(), "\t");
    while (st.hasMoreTokens()) {
      String sNext = st.nextToken();
      g.drawString(sNext, x, y);
      x += m_fm.stringWidth(sNext);

      if (!st.hasMoreTokens()) break;
      int index = 0;
      while (x >= getTab(index)) index++;
      x = getTab(index);
    }
  }
Ejemplo n.º 12
0
    protected void buildPanel(String strPath) {
      BufferedReader reader = WFileUtil.openReadFile(strPath);
      String strLine;

      if (reader == null) return;

      try {
        while ((strLine = reader.readLine()) != null) {
          if (strLine.startsWith("#") || strLine.startsWith("%") || strLine.startsWith("@"))
            continue;

          StringTokenizer sTokLine = new StringTokenizer(strLine, ":");

          // first token is the label e.g. Password Length
          if (sTokLine.hasMoreTokens()) {
            createLabel(sTokLine.nextToken(), this);
          }

          // second token is the value
          String strValue = sTokLine.hasMoreTokens() ? sTokLine.nextToken() : "";
          if (strValue.equalsIgnoreCase("yes") || strValue.equalsIgnoreCase("no"))
            createChkBox(strValue, this);
          else createTxf(strValue, this);
        }
      } catch (Exception e) {
        Messages.writeStackTrace(e);
        // e.printStackTrace();
        Messages.postDebug(e.toString());
      }
    }
 public void createColorArray() {
   color = new Color[colorString.length];
   for (int i = 0; i < colorString.length; i++) {
     StringTokenizer st = new StringTokenizer(colorString[i], " ");
     Color c = new Color(rgb(st.nextToken()), rgb(st.nextToken()), rgb(st.nextToken()));
     color[i] = c;
   }
 }
Ejemplo n.º 14
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)
Ejemplo n.º 15
0
 private static Locale parseLocal(String localString) {
   int x = 0;
   String[] s = {"", "", ""};
   StringTokenizer tokenizer = new StringTokenizer(localString, "_");
   while (tokenizer.hasMoreTokens()) {
     s[x++] = tokenizer.nextToken();
   }
   return new Locale(s[0], s[1], s[2]);
 }
Ejemplo n.º 16
0
 String nextToken() {
   while (tokenizer == null || !tokenizer.hasMoreTokens()) {
     try {
       tokenizer = new StringTokenizer(reader.readLine());
     } catch (Exception e) {
     }
   }
   return tokenizer.nextToken();
 }
Ejemplo n.º 17
0
 private void newLabel(String s) {
   StringTokenizer tkn = new StringTokenizer(s, "\n");
   num_lines = tkn.countTokens();
   lines = new String[num_lines];
   line_widths = new int[num_lines];
   for (int i = 0; i < num_lines; i++) {
     lines[i] = tkn.nextToken();
   }
 }
 {
   StringBuffer sb = new StringBuffer();
   StringTokenizer st = new StringTokenizer(cfg.REQPARAM_CONTACT_LIST_LOGIN_IDS, ",");
   while (st.hasMoreTokens()) {
     sb.append(st.nextToken());
     if (st.hasMoreTokens()) sb.append("\n");
   }
   contactList.setText(sb.toString());
 }
Ejemplo n.º 19
0
 private String subString(String s, String m, String d) {
   String r = "";
   StringTokenizer tok = new StringTokenizer(s, " \t\':+-*/\"/()=,\0", true);
   while (tok.hasMoreTokens()) {
     String t = tok.nextToken();
     if (t.equals(m)) r += d;
     else r += t;
   }
   return r;
 }
Ejemplo n.º 20
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);
  }
Ejemplo n.º 21
0
 protected void createButtons(JPanel panel) {
   panel.add(new Filler(24, 20));
   JComboBox drawingChoice = new JComboBox();
   drawingChoice.addItem(fgUntitled);
   String param = getParameter("DRAWINGS");
   if (param == null) {
     param = "";
   }
   StringTokenizer st = new StringTokenizer(param);
   while (st.hasMoreTokens()) {
     drawingChoice.addItem(st.nextToken());
   }
   if (drawingChoice.getItemCount() > 1) {
     panel.add(drawingChoice);
   } else {
     panel.add(new JLabel(fgUntitled));
   }
   drawingChoice.addItemListener(
       new ItemListener() {
         public void itemStateChanged(ItemEvent e) {
           if (e.getStateChange() == ItemEvent.SELECTED) {
             loadDrawing((String) e.getItem());
           }
         }
       });
   panel.add(new Filler(6, 20));
   JButton button;
   button = new CommandButton(new DeleteCommand("Delete", this));
   panel.add(button);
   button = new CommandButton(new DuplicateCommand("Duplicate", this));
   panel.add(button);
   button = new CommandButton(new GroupCommand("Group", this));
   panel.add(button);
   button = new CommandButton(new UngroupCommand("Ungroup", this));
   panel.add(button);
   button = new JButton("Help");
   button.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           showHelp();
         }
       });
   panel.add(button);
   fUpdateButton = new JButton("Simple Update");
   fUpdateButton.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           if (fSimpleUpdate) {
             setBufferedDisplayUpdate();
           } else {
             setSimpleDisplayUpdate();
           }
         }
       });
 }
Ejemplo n.º 22
0
 /**
  * Get the "next sample" string from the given "title".
  * The "title" is a series of tokens of the form:
  * <pre>
  * autodir h1freq traymax [help:path] [nextloc:loc] [frameBounds:keyword]
  * <pre>
  * @param title The "title" passed in.
  * @return The next available sample location, or null.
  */
 protected String getSampleName(String title) {
   String name = null;
   StringTokenizer tok = new QuotedStringTokenizer(title);
   while (tok.hasMoreTokens()) {
     String strValue = tok.nextToken();
     if (strValue.startsWith("nextloc:")) {
       name = strValue.substring(8);
     }
   }
   return name;
 }
Ejemplo n.º 23
0
 /**
  * Gets the keyword telling where to place the login frame.
  * The "title" is a series of tokens of the form:
  * <pre>
  * autodir h1freq traymax [help:path] [nextloc:loc] [frameBounds:keyword]
  * <pre>
  * @param title The "title" passed in.
  * @return The frame location keyword.
  */
 private String getFrameBounds(String title) {
   String bounds = null;
   StringTokenizer tok = new QuotedStringTokenizer(title);
   while (tok.hasMoreTokens()) {
     String strValue = tok.nextToken();
     if (strValue.startsWith("frameBounds:")) {
       bounds = strValue.substring(12);
     }
   }
   return bounds;
 }
Ejemplo n.º 24
0
  public final String readCommand(byte[] b)
      throws IOException, InterruptedException, MessagingNetworkException {
    InputStream is = getInputStream();
    synchronized (is) {
      long abortTime =
          System.currentTimeMillis() + 1000 * MSNMessagingNetwork.REQPARAM_SOCKET_TIMEOUT_SECONDS;
      int ofs = 0;
      boolean d = false;
      for (; ; ) {
        if (Thread.currentThread().isInterrupted()) throw new InterruptedIOException();
        int by = is.read();
        if (by == -1) throw new IOException("unexpected EOF");
        if (by == 10 && d) break;
        d = (by == 13);
        if (ofs < b.length) {
          b[ofs++] = (byte) by;
        }
        if (System.currentTimeMillis() > abortTime) throw new IOException("connection timed out");
        /*
        if (len >= buffer.length)
        {
          ...
          return ...;
        }
        int pos = findCRLF();
        if (pos != -1) break;
        fill(is, abortTime);
        */
      }
      if (b[ofs - 1] == 13) --ofs;

      String line = new String(b, 0, ofs, "ASCII");

      if (StringUtil.startsWith(line, "MSG")) {
        StringTokenizer st = new StringTokenizer(line);
        String len_s = null;
        while (st.hasMoreTokens()) {
          len_s = st.nextToken();
        }
        if (len_s == null) throw new AssertException("len_s is null");
        int len;
        try {
          len = Integer.parseInt(len_s);
        } catch (NumberFormatException ex) {
          ServerConnection.throwProtocolViolated("MSG length must be int");
          len = 0;
        }
        String msg = readMSG(len);
        line = line + "\r\n" + msg;
      }
      if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug("S: " + line);
      return line;
    }
  }
Ejemplo n.º 25
0
 /**
  * Set the helpfile string from the given "title".
  * The "title" is a series of tokens of the form:
  * <pre>
  * autodir h1freq traymax [help:path] [nextloc:loc]
  * <pre>
  * @param title The "title" passed in.
  * @return The path to the help file, or null.
  */
 protected String getHelpFile(String title) {
   StringTokenizer tok = new QuotedStringTokenizer(title);
   String path = null;
   while (tok.hasMoreTokens()) {
     String strValue = tok.nextToken();
     if (strValue.startsWith("help:")) {
       path = strValue.substring(5);
     }
   }
   return path;
 }
Ejemplo n.º 26
0
  /**
   * List results by date
   *
   * @param reslist result list
   * @param ldisp
   */
  private void listByDateRun(ResultList reslist, boolean ldisp) {
    StringTokenizer tokenizer = new StringTokenizer((String) reslist.get("list"), "\n");

    Vector vdata = new Vector();
    while (tokenizer.hasMoreTokens()) {
      String data = convertToPretty(tokenizer.nextToken());
      if (datasets.contains(data) || ldisp) vdata.add(data);
    }
    datasets.removeAllElements();

    Enumeration en = vdata.elements();
    while (en.hasMoreElements()) datasets.addElement(en.nextElement());
  }
Ejemplo n.º 27
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 = "";
    }
  }
Ejemplo n.º 28
0
  /* look for the rate in te account file for the time in the login string */
  public RateEntry getRate(String login) {
    int logday = 0, rateday = 0;
    //    System.out.println("getRate: login='******'");
    String day, time, rate = null;
    StringTokenizer st = new StringTokenizer(login);
    // frits     pts/21       flash            Fri Mar 18 13:46 - 14:30 (6+00:44)
    //                                        ^              ^
    day = st.nextToken();
    time = st.nextToken();
    time = st.nextToken();
    time = st.nextToken().substring(0, 5);
    // System.out.println(login+" "+day+" "+time);
    // Get the international names of the days and which day is (1,2,3...
    // Then find day of each rate entry, (1,2,3,4
    // Now we can compare, independent of the language used for the days
    // Finally use the time to compare as well
    DateFormatSymbols dfs = new DateFormatSymbols();
    String[] days = dfs.getShortWeekdays();
    for (int j = 1; j < days.length; j++) {
      if (day.compareTo(days[j]) == 0) {
        logday = j;
        break;
      }
    }
    // logday -> the day given in the gorecords.xml file (the log)

    int n = rates.size();
    // the last rate applies if before the first entry
    // Init to last rate given in the account
    RateEntry tmpRE, saveRE = rates(n - 1);
    //    System.out.println("n="+n);
    for (int i = 0; i < n; i++) {
      tmpRE = rates(i);
      for (int j = 1; j < days.length; j++) {
        if (tmpRE.day.compareTo(days[j]) == 0) {
          rateday = j;
          break;
        }
      }
      //    System.out.println("j="+jday+" k="+kday+" "+tmpRE.time+" "+tmpRE.loginhr);
      // the last rate applies if before the first entry
      if (logday > rateday) {
        saveRE = tmpRE;
      }
      if ((logday == rateday) && (time.compareTo(tmpRE.time) >= 0)) {
        saveRE = tmpRE;
      }
    }
    return saveRE;
  }
Ejemplo n.º 29
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");
   }
 }
Ejemplo n.º 30
0
  public void setText(final String text) {
    String currentText = text;
    if (currentText == null) currentText = "";

    StringTokenizer tkn = new StringTokenizer(currentText, "\n");

    numLines = tkn.countTokens();
    lines = new String[numLines];
    lineWidths = new int[numLines];

    for (int i = 0; i < numLines; i++) lines[i] = tkn.nextToken();

    recalculateDimension();
    repaint();
  }