Exemplo n.º 1
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;
  }
Exemplo n.º 2
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);
      }
    }
  }