Пример #1
0
  /* The following routine loads Iterated Function System codes.  Note
   * that loadifs() only reads the very first set of IFS codes in the
   * file and ignores the name label in the file entirely.
   */
  void loadifs() {
    BufferedReader in = null;
    try {
      in =
          new BufferedReader(
              new InputStreamReader(
                  Thread.currentThread().getContextClassLoader().getResourceAsStream(ifsfile)));
    } catch (Exception e) {
      System.out.println(e.toString());
    }
    ;

    transitions = 0;

    String line = null;

    // throw away first line
    try {
      line = in.readLine();
    } catch (IOException e) {
      System.out.println(e.toString());
    }

    try {
      while ((line = in.readLine()) != null) {
        String[] tokens = line.trim().split("\\s+"); // Tokens separated by "whitespace"
        if (tokens[0].equals("}")) return;
        try {
          rotate_scale_xx[transitions] = Double.parseDouble(tokens[0]);
          rotate_scale_xy[transitions] = Double.parseDouble(tokens[1]);
          rotate_scale_yx[transitions] = Double.parseDouble(tokens[2]);
          rotate_scale_yy[transitions] = Double.parseDouble(tokens[3]);
          trans_x[transitions] = Double.parseDouble(tokens[4]);
          trans_y[transitions] = Double.parseDouble(tokens[5]);
          prob[transitions] = Double.parseDouble(tokens[6]);
        } catch (NumberFormatException ex) {
          System.out.println("Not a double ");
          System.out.println(ex);
        }
        transitions++;
      }
    } catch (IOException e) {
      System.out.println(e.toString());
    }
  }