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(); }
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; }
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; }