package stat; import java.awt.*; import java.io.*; import parameters.Parameter; import parameters.ParameterSet; import parameters.ParameterSetArray; import main.MoreMath; public class FilterParamsStat extends Stat implements Runnable { public FilterParamsStat() {} public void calculateStat() { int i, j, k, l; String valueField = "IteratorScore"; float targetValue = 4.0f; if(paramSets == null) { System.out.println("No Cam loaded - Stat 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())); ps.println("&Cam"); ps.println("&endHeader"); prototype = paramSets.getPrototype(); if(prototype == null) prototype = paramSets.goToBeginning(); if(prototype == null) { ps.close(); return; } // Nothing in cam file int pos = prototype.getFieldPos(valueField); ParameterSet set = paramSets.goToBeginning(); int set_num = 0; while(set != null) { float val = set.getFieldValue(pos); if(val == targetValue) { ps.println("&par" + set_num); ps.println("\t&p1"); ps.println("\t" + "&IPARS"); set.toString(ps, ("\t\t")); ps.println("\t" + "&endIPARS"); set_num++; } set = paramSets.getNextSet(); } ps.println(); ps.close(); System.out.println("Saved filtered parameters"); } catch(Exception e) { System.out.println("Error in FilterParams: " + e.toString()); } } }