MCPcopy Create free account
hub / github.com/OpenSourcePhysics/osp / FitBuilder

Class FitBuilder

src/org/opensourcephysics/tools/FitBuilder.java:49–891  ·  view source on GitHub ↗

This is a FunctionTool used by DatasetCurveFitter to build, save and load custom fit functions. Some methods are tailored for use with DataTool since that is its main application. @author Doug Brown

Source from the content-addressed store, hash-verified

47 *
48 */
49@SuppressWarnings("serial")
50public class FitBuilder extends FunctionTool {
51
52 private final static java.io.FileFilter xmlFilter;
53 private final static Collection<String> initialAutoloadSearchPaths = new TreeSet<String>();
54 private final static Map<String, String[]> autoloadExclusionsMap = new TreeMap<String, String[]>();
55
56 private static String[] preferredAutoloadSearchPaths;
57 private static AsyncFileChooser chooser;
58
59 static {
60 xmlFilter = new java.io.FileFilter() {
61 // accept only *.xml files.
62 @Override
63 public boolean accept(File f) {
64 if (f == null || f.isDirectory())
65 return false;
66 String ext = XML.getExtension(f.getName());
67 if (ext != null && "xml".equals(ext.toLowerCase())) //$NON-NLS-1$
68 return true;
69 return false;
70 }
71 };
72 // load preferred autoload search paths and excluded functions from
73 // OSPRuntime.preferences
74 preferredAutoloadSearchPaths = (String[]) OSPRuntime.getPreference("autoload_search_paths"); //$NON-NLS-1$
75 String[][] autoloadData = (String[][]) OSPRuntime.getPreference("autoload_exclusions"); //$NON-NLS-1$
76 if (autoloadData != null) {
77 for (String[] next : autoloadData) {
78 String filePath = XML.forwardSlash(next[0]);
79 String[] functions = new String[next.length - 1];
80 System.arraycopy(next, 1, functions, 0, functions.length);
81 autoloadExclusionsMap.put(filePath, functions);
82 }
83 }
84 }
85
86 protected JButton newFitButton, deleteFitButton, cloneFitButton, loadButton, saveButton, autoloadButton;
87 protected Component myParent;
88 protected TreeSet<String> addedFits = new TreeSet<String>();
89 protected String defaultFitName;
90 protected AutoloadManager autoloadManager;
91
92 /**
93 * Constructor
94 *
95 * @param c a component to determine the dialog owner
96 */
97 public FitBuilder(Component c) {
98 this(c, false);
99 }
100
101 public FitBuilder(Component c, boolean lazyGUI) {
102 super(c, true, lazyGUI);
103 myParent = c;
104 if (!lazyGUI)
105 createGUI();
106 }

Callers

nothing calls this directly

Calls 3

getPreferenceMethod · 0.95
forwardSlashMethod · 0.95
putMethod · 0.45

Tested by

no test coverage detected