コード例 #1
0
ファイル: draw.java プロジェクト: bossiernesto/jvmbytecodes
  // 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);
  }
コード例 #2
0
ファイル: JopSpider.java プロジェクト: jordibrus/proview
  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;
  }
コード例 #3
0
 private static void parseArgs(String theStringList, String[] s) {
   int x = 0;
   StringTokenizer tokenizer = new StringTokenizer(theStringList, " ");
   while (tokenizer.hasMoreTokens()) {
     s[x++] = tokenizer.nextToken();
   }
 }
コード例 #4
0
ファイル: ServerDialog.java プロジェクト: chaddiller/turbovnc
  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");
  }
コード例 #5
0
 public void hitResponse(String response) {
   StringTokenizer st = new StringTokenizer(response);
   int k = 0;
   String side = null;
   int x = -1;
   int y = -1;
   while (st.hasMoreTokens()) {
     if (k == 0) st.nextToken();
     if (k == 1) side = st.nextToken();
     if (k == 2) x = Integer.parseInt(st.nextToken());
     if (k == 3) y = Integer.parseInt(st.nextToken());
     k++;
   }
   System.out.println(gameData.getPlayerSide());
   System.out.println(side);
   if (gameData.getPlayerSide().equals(side)) {
     System.out.println("player field hit");
     gameData.shootAtField(side, x, y, 3, false, null, null, -1, -1);
     mw.v.enqueEvent(new CustomEvent(CustomEvent.PLAYER_FIELD_HIT, x, y));
   } else {
     System.out.println("enemy field hit");
     gameData.shootAtField(side, x, y, 3, false, null, null, -1, -1);
     mw.v.enqueEvent(new CustomEvent(CustomEvent.OPPONENT_FIELD_HIT, x, y));
   }
 }
コード例 #6
0
ファイル: VTabbedToolPanel.java プロジェクト: timburrow/ovj3
  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");
          }
        }
      }
    }
  }
コード例 #7
0
ファイル: ShowSavedResults.java プロジェクト: pjotrp/EMBOSS
  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);
    }
  }
コード例 #8
0
ファイル: WPart11Dialog.java プロジェクト: timburrow/ovj3
    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());
      }
    }
コード例 #9
0
 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;
   }
 }
コード例 #10
0
ファイル: draw.java プロジェクト: bossiernesto/jvmbytecodes
  // 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)
コード例 #11
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]);
 }
コード例 #12
0
ファイル: LoginBox.java プロジェクト: timburrow/ovj3
 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();
   }
 }
コード例 #13
0
ファイル: VCaretEntry.java プロジェクト: timburrow/OpenVnmrJ
 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;
 }
コード例 #14
0
ファイル: DrawApplet.java プロジェクト: RoDaniel/featurehouse
 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();
           }
         }
       });
 }
コード例 #15
0
ファイル: LoginBox.java プロジェクト: timburrow/ovj3
 /**
  * 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;
 }
コード例 #16
0
ファイル: LoginBox.java プロジェクト: timburrow/ovj3
 /**
  * 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;
 }
コード例 #17
0
ファイル: LoginBox.java プロジェクト: timburrow/ovj3
 /**
  * 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;
 }
コード例 #18
0
ファイル: ShowSavedResults.java プロジェクト: pjotrp/EMBOSS
  /**
   * 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());
  }
コード例 #19
0
 public void allShipsDestroyed(String response) {
   StringTokenizer st = new StringTokenizer(response);
   st.nextToken();
   String result;
   if ((st.nextToken().equals(gameData.getPlayerSide()))) result = "You Lose";
   else result = "You Win!";
   mw.v.enqueEvent(new CustomEvent(CustomEvent.GAME_OVER, result));
   try {
     Thread.sleep(10000);
   } catch (InterruptedException e) {
   }
   System.exit(0);
 }
コード例 #20
0
 public String[] getServerSidePlayers() {
   if (!isServer) {
     requestToServer.println("serverSidePlayerList");
     while (!serverResponse) {}
     playersServerSide = new ArrayList<String>();
     if (spl == null) return new String[1];
   }
   if (isServer) spl = cont.getServerSidePlayerList();
   StringTokenizer st = new StringTokenizer(spl);
   while (st.hasMoreTokens()) playersServerSide.add(st.nextToken());
   String[] t = new String[playersServerSide.size()];
   for (int l = 0; l < playersServerSide.size(); l++) t[l] = playersServerSide.get(l);
   serverResponse = false;
   return t;
 }
コード例 #21
0
 public void waterResponse(String response) {
   StringTokenizer st = new StringTokenizer(response);
   String side = null;
   int k = 0;
   int x = -1;
   int y = -1;
   while (st.hasMoreTokens()) {
     if (k == 0) st.nextToken();
     if (k == 1) side = st.nextToken();
     if (k == 2) x = Integer.parseInt(st.nextToken());
     if (k == 3) y = Integer.parseInt(st.nextToken());
     k++;
   }
   gameData.shootAtField(side, x, y, 2, false, null, null, -1, -1);
 }
コード例 #22
0
ファイル: MultiLabel.java プロジェクト: philippsimon/JFritz
  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();
  }
コード例 #23
0
ファイル: draw.java プロジェクト: bossiernesto/jvmbytecodes
 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");
   }
 }
コード例 #24
0
 /** Update state from Infostat. */
 public void updateStatus(String msg) {
   // Messages.postDebug("VLcStatusChart.updateStatus(" + msg + ")");/*CMP*/
   if (msg == null) {
     return;
   }
   StringTokenizer tok = new StringTokenizer(msg);
   if (tok.hasMoreTokens()) {
     String key = tok.nextToken();
     String val = "";
     if (tok.hasMoreTokens()) {
       val = tok.nextToken("").trim(); // Get remainder of msg
     }
     if (key.equals(statkey)) {
       if (val != null && !val.equals("-")) {
         valstr = val;
         setState(state);
       }
       /*System.out.println("Chart: statkey=" + statkey
       + ", val=" + val);/*CMP*/
     }
     if (key.equals(statpar)) {
       if (val != null && !val.equals("-")) {
         /*System.out.println("Chart statpar=" + statpar
         + ", value=" + value);/*CMP*/
         setState(state);
       }
     }
     if (key.equals(statset)) {
       if (val != null && !val.equals("-")) {
         setval = val;
         try {
           String num = val.substring(0, val.indexOf(' '));
           setStatusValue(Double.parseDouble(num));
         } catch (NumberFormatException nfe) {
           Messages.postDebug("VLcStatusChart.updateStatus(): " + "Non-numeric value: " + msg);
         } catch (StringIndexOutOfBoundsException sioobe) {
           setStatusValue(0); // No value found
         }
         /*System.out.println("Chart statset=" + statset
         + ", setval=" + setval);/*CMP*/
         setState(state);
       }
     }
   }
   repaint();
 }
コード例 #25
0
      MyNode findNode(String fqn) {
        MyNode curr, n;
        StringTokenizer tok;
        String child_name;

        if (fqn == null) return null;
        curr = this;
        tok = new StringTokenizer(fqn, ReplicatedTreeView.SEP);

        while (tok.hasMoreTokens()) {
          child_name = tok.nextToken();
          n = curr.findChild(child_name);
          if (n == null) return null;
          curr = n;
        }
        return curr;
      }
コード例 #26
0
ファイル: FormatTest.java プロジェクト: hwp0710/javabread
 public Object stringToValue(String text) throws ParseException {
   StringTokenizer tokenizer = new StringTokenizer(text, ".");
   byte[] a = new byte[4];
   for (int i = 0; i < 4; i++) {
     int b = 0;
     if (!tokenizer.hasMoreTokens()) throw new ParseException("Too few bytes", 0);
     try {
       b = Integer.parseInt(tokenizer.nextToken());
     } catch (NumberFormatException e) {
       throw new ParseException("Not an integer", 0);
     }
     if (b < 0 || b >= 256) throw new ParseException("Byte out of range", 0);
     a[i] = (byte) b;
   }
   if (tokenizer.hasMoreTokens()) throw new ParseException("Too many bytes", 0);
   return a;
 }
コード例 #27
0
  public static String findUrl(PsiFile file, int offset, String uri) {
    final PsiElement currentElement = file.findElementAt(offset);
    final XmlAttribute attribute = PsiTreeUtil.getParentOfType(currentElement, XmlAttribute.class);

    if (attribute != null) {
      final XmlTag tag = PsiTreeUtil.getParentOfType(currentElement, XmlTag.class);

      if (tag != null) {
        final String prefix = tag.getPrefixByNamespace(XmlUtil.XML_SCHEMA_INSTANCE_URI);
        if (prefix != null) {
          final String attrValue =
              tag.getAttributeValue(XmlUtil.SCHEMA_LOCATION_ATT, XmlUtil.XML_SCHEMA_INSTANCE_URI);
          if (attrValue != null) {
            final StringTokenizer tokenizer = new StringTokenizer(attrValue);

            while (tokenizer.hasMoreElements()) {
              if (uri.equals(tokenizer.nextToken())) {
                if (!tokenizer.hasMoreElements()) return uri;
                final String url = tokenizer.nextToken();

                return url.startsWith(HTTP_PROTOCOL) ? url : uri;
              }

              if (!tokenizer.hasMoreElements()) return uri;
              tokenizer.nextToken(); // skip file location
            }
          }
        }
      }
    }
    return uri;
  }
コード例 #28
0
  /** Set the matching descriptors. */
  private void setMatchingFileNames() {
    StringTokenizer st = new StringTokenizer(matchingTF.getText(), ",");

    int numTokens = st.countTokens();

    if (numTokens == 0) {
      descriptors = new String[1];
      descriptors[0] = "*";
      return;
    }

    descriptors = new String[numTokens];

    int i = 0;
    while (st.hasMoreElements()) {
      descriptors[i++] = st.nextToken().trim();
    }
  }
コード例 #29
0
 public void parseChatMessage(String response) {
   int counter = 0;
   String side = null;
   String playerName = null;
   String chatMessage = null;
   response = response.substring(5);
   StringTokenizer st = new StringTokenizer(response);
   while (st.hasMoreElements()) {
     if (counter > 1) break;
     if (counter == 0) playerName = st.nextToken();
     if (counter == 1) side = st.nextToken();
     counter++;
   }
   chatMessage = response.substring(playerName.length() + side.length() + 2);
   if (playerName.equals(gameData.getPlayerName())) playerName = "Me";
   String finalString = playerName + " (" + side + ") says: " + chatMessage;
   mw.v.enqueEvent(new CustomEvent(CustomEvent.CHAT_MESSAGE, finalString));
 }
コード例 #30
0
ファイル: Bomberman.java プロジェクト: sujen29/Bomberman
  // This method loads the map from a text file. It reads the numbers from the file and assigns them
  // to the grid array.
  public void loadMap() {
    try {
      // Creates necessary objects and variables
      BufferedReader br = new BufferedReader(new FileReader(map + ".txt"));
      StringTokenizer st;
      String s;

      // Loops to go through every number in the file
      for (int i = 0; i < 11; i++) {
        // Uses the string tokenizer to get numbers that are seperated by a space
        st = new StringTokenizer(br.readLine(), " ");
        for (int j = 0; j < 11; j++) {
          // Assigns the value in the file to grid[i][j]
          grid[i][j] = Integer.parseInt(st.nextToken());
        }
      }
    } catch (Exception e) {
      System.out.println("Map not fount");
    }
  }