Пример #1
0
  public static void writeParam(String xNameFile) {
    //
    // write to file xpar all parameters.....
    //
    IOseq xFile;

    xFile = new IOseq(xNameFile);
    xFile.IOseqOpenW(false);

    try {

      Class c = Class.forName("jneat.Neat");
      Field[] fieldlist = c.getDeclaredFields();

      for (int i = 0; i < fieldlist.length; i++) {
        Field f1 = fieldlist[i];
        String x1 = f1.getName();

        if (x1.startsWith("p_")) {
          Field f2 = c.getField("d_" + Neat.normalizeName(x1));
          Object s1 = f1.get(c);
          Object s2 = f2.get(c);
          //	   String riga = s1 + "  " + s2;
          String riga = x1 + "  " + s1;
          xFile.IOseqWrite(riga);
        }
      }

    } catch (Throwable e) {
      System.err.println(e);
    }

    xFile.IOseqCloseW();
  }
Пример #2
0
 public static String getDescription(String xkey) {
   try {
     Class c = Class.forName("jneat.Neat");
     Field f = c.getField("d_" + xkey);
     return (String) f.get(c);
   } catch (Throwable e) {
     return null;
   }
 }
Пример #3
0
  public static boolean readParam(String xNomeFile) {

    boolean ret = true;
    String xline;
    IOseq xFile;
    StringTokenizer st;
    String s1;
    String s2;
    Object m1;

    xFile = new IOseq("parameters.ne");
    ret = xFile.IOseqOpenR();
    if (ret) {
      try {
        Class c = Class.forName("jneat.Neat");
        Field[] fieldlist = c.getDeclaredFields();

        int number_params = fieldlist.length / 2;

        for (int i = 0; i < number_params; i++) {
          Field f1 = fieldlist[i];
          String x1 = f1.getName();
          Object x2 = f1.getType();
          xline = xFile.IOseqRead();

          st = new StringTokenizer(xline);
          // skip comment

          s1 = st.nextToken();
          // real value
          s1 = st.nextToken();

          if (x1.startsWith("p_")) {
            if (x2.toString().equals("double")) {
              double n1 = Double.parseDouble(s1);
              f1.set(c, (new Double(n1)));
            }
            if (x2.toString().equals("int")) {
              int n1 = Integer.parseInt(s1);
              f1.set(c, (new Integer(n1)));
            }
          }
        }

      } catch (Throwable e) {
        System.err.println(e);
      }

      xFile.IOseqCloseR();

    } else System.err.print("\n : error during open " + xNomeFile);

    return ret;
  }
Пример #4
0
  public static void getParam(vectTableModel _model) {

    String xline;
    StringTokenizer st = null;
    String s1 = null;
    String s2 = null;
    Object m1 = null;
    Field fx = null;
    int j = 0;

    try {
      Class c = Class.forName("jneat.Neat");
      Field[] fieldlist = c.getDeclaredFields();

      int number_params = fieldlist.length / 2;

      j = 0;
      for (int i = 0; i < number_params; i++) {
        Field f1 = fieldlist[i];
        String nomeF = f1.getName();
        String nomeF1 = nomeF.substring(2);
        if (nomeF.substring(0, 2).equalsIgnoreCase("p_")) {
          Object o1 = nomeF1;
          fx = c.getField("p_" + nomeF1);
          Object o2 = fx.get(c);

          _model.setValueAt(o1, j, 0);
          _model.setValueAt(o2, j, 1);

          j++;
        }
      }

    } catch (Throwable e) {
      System.err.println(e);
    }

    _model.rows = j;
    return;
  }
Пример #5
0
  public static void updateParam(vectTableModel _model) {
    //
    // write to file xpar all parameters.....
    //

    for (int j = 0; j < _model.data.size(); j++) {
      try {
        Class c = Class.forName("jneat.Neat");
        ParamValue ox = (ParamValue) _model.data.elementAt(j);

        Object k = _model.getValueAt(j, 0);
        Object kv = _model.getValueAt(j, 1);

        String xkey = k.toString();
        String xval = kv.toString();
        /*
        System.out.print("\n j = "+j+" xkey = "+xkey);
        System.out.print(" xval = "+xval);
        */
        Field f1 = c.getField("p_" + xkey);
        Object fty = f1.getType();

        if (fty.toString().equals("double")) {
          double n1 = Double.parseDouble(xval);
          f1.set(c, (new Double(n1)));
        }
        if (fty.toString().equals("int")) {
          int n1 = Integer.parseInt(xval);
          f1.set(c, (new Integer(n1)));
        }

      } catch (Throwable e) {
        System.out.print("\n errore su jneat.updateParam = " + e);
      }
    }
  }