package stat; import java.awt.*; import java.io.*; import parameters.Parameter; import parameters.ParameterSet; import parameters.ParameterSetArray; /** Saves the values of the value fields stored with each parameter set to a file. Value Fields are things like the Score, NumFunctionCalls, etc. - some stoppers or iterators will store other values as well with each parameter set. If you want to save the values of the parameters themselves, use the Dump statistic. @see DumpStat @see ParameterSet */ public class DumpValueFieldsStat extends Stat { public DumpValueFieldsStat() {} public void calculateStat() { int i; if(paramSets == null) { System.out.println("No Cam loaded - DumpValueFields did nothing"); return; } FileDialog fd = new FileDialog(new Frame(), "Save into file:", FileDialog.SAVE); fd.show(); if(fd.getFile() == null) return; try { PrintWriter ps = new PrintWriter(new FileOutputStream(fd.getDirectory() + fd.getFile())); prototype = paramSets.getPrototype(); if(prototype == null) prototype = paramSets.goToBeginning(); if(prototype == null) { ps.close(); return; } // Nothing in cam file // First go through and save titles of value fields ps.print("GroupNum\tTag\t"); for(i = 0; i < prototype.getNumValueFields(); i++) { ps.print(prototype.getFieldName(i) + "\t"); } ps.println(""); // Next go through all the param sets, and print out values ParameterSet set = paramSets.goToBeginning(); while(set != null) { // The order of the fields in the prototype should be the same as the order // in all the other sets ps.print(set.getGroupNum() + "\t" + set.getTag() + "\t"); for(i = 0; i < prototype.getNumValueFields(); i++) { ps.print(set.getFieldValue(i) + "\t"); } ps.println(""); System.out.println("Dumped group " + set.getGroupNum()); set = paramSets.getNextSet(); } ps.close(); } catch(Exception e) { System.out.println("Error in DumpValueFields: " + e.toString()); } } }