-
Notifications
You must be signed in to change notification settings - Fork 0
Adding an Algorithm to LineFit
darksideprogramming edited this page Apr 26, 2015
·
1 revision
In order to add an algorithm in LineFit follow these steps:
- Make a copy of the AlgorithmTemplateFactory and move the copy to the package one up, LineFit.Algorithms, by removing the .Template from the package LineFit.Algorithms.Template; line and then moving it physically to the folder above, Algorithms.
- Fill in the copyright information at the very top of the file with your name or company and the current year.
- Fill in the javadoc metadata comment section above the Factory class, inputting a description of the fit algorithm, filling in the spots with the factory classes name, filling in your name, and the current version of LineFit.
- Rename the copied template .java file's name to the desired name to describe the Fit Algorithm and end it with "Factory" and then change the class name in the file to be the same. Then change the references to this Factory class in the code to match the class name i.e: "PartialDerivativeMinimization" + "Factory" => "PartialDerivativeMinimizationFactory".
- Then Rename the private internal class AlgorithmStrategyFactory and all the references in the code to the private class to the name used to describe the algorithm but end it with "Strategy" this time. i.e:"PartialDerivativeMinimizationStrategy".
- Fill in the javadocs metadata comment above the Strategy class, inputing the strategy class name, your name, and the current LineFit version. Change the string in the toString() function to the chosen name to describe your new algorithm (just the name – not including factory or strategy).
- Now you can begin coding the algorithm itself in the fitLine() function in the AlgorithmStrategy class. This method is what is called by LineFit when fitting lines in the GraphArea so any code related to the fit must be initiated through this class. Feel free to delcare any private variables and functions that are needed or are useful but do so inside of the AlgorithmStrategy class
- The final step you must do is to add it to the array of LinearFitFactories so that it will show up in LineFit! To do this, open up the LinearFitFactory class and at the top should be an array called "fitAlgorithmFactories." Simply add a new entry at the end of the array using the dame format as the others and you should be good to start testing it!