()
| 144 | double sqr(double x) {return x*x;} |
| 145 | |
| 146 | boolean getData() { |
| 147 | textArea.selectAll(); |
| 148 | String text = textArea.getText(); |
| 149 | text = zapGremlins(text); |
| 150 | textArea.select(0,0); |
| 151 | StringTokenizer st = new StringTokenizer(text, " \t\n\r,"); |
| 152 | int nTokens = st.countTokens(); |
| 153 | if (nTokens<4 || (nTokens%2)!=0) { |
| 154 | IJ.showStatus("Data error: min. two (x,y) pairs needed"); |
| 155 | return false; |
| 156 | } |
| 157 | int n = nTokens/2; |
| 158 | x = new double[n]; |
| 159 | y = new double[n]; |
| 160 | for (int i=0; i<n; i++) { |
| 161 | String xString = st.nextToken(); |
| 162 | String yString = st.nextToken(); |
| 163 | x[i] = Tools.parseDouble(xString); |
| 164 | y[i] = Tools.parseDouble(yString); |
| 165 | if (Double.isNaN(x[i]) || Double.isNaN(y[i])) { |
| 166 | IJ.showStatus("Data error: Bad number at "+i+": "+xString+" "+yString); |
| 167 | return false; |
| 168 | } |
| 169 | } |
| 170 | return true; |
| 171 | } |
| 172 | |
| 173 | /** create a duplicate of an image where the fit function is applied to the pixel values */ |
| 174 | void applyFunction() { |
no test coverage detected