()
| 412 | } |
| 413 | |
| 414 | void save() { |
| 415 | TextArea ta1 = gd.getTextArea1(); |
| 416 | TextArea ta2 = gd.getTextArea2(); |
| 417 | ta1.selectAll(); |
| 418 | String text1 = ta1.getText(); |
| 419 | ta1.select(0, 0); |
| 420 | ta2.selectAll(); |
| 421 | String text2 = ta2.getText(); |
| 422 | ta2.select(0, 0); |
| 423 | double[] x = getData(text1); |
| 424 | double[] y = getData(text2); |
| 425 | SaveDialog sd = new SaveDialog("Save as Text...", "calibration", ".txt"); |
| 426 | String name = sd.getFileName(); |
| 427 | if (name == null) |
| 428 | return; |
| 429 | String directory = sd.getDirectory(); |
| 430 | PrintWriter pw = null; |
| 431 | try { |
| 432 | FileOutputStream fos = new FileOutputStream(directory+name); |
| 433 | BufferedOutputStream bos = new BufferedOutputStream(fos); |
| 434 | pw = new PrintWriter(bos); |
| 435 | } |
| 436 | catch (IOException e) { |
| 437 | IJ.error("" + e); |
| 438 | return; |
| 439 | } |
| 440 | IJ.wait(250); // give system time to redraw ImageJ window |
| 441 | int n = Math.max(x.length, y.length); |
| 442 | for (int i=0; i<n; i++) { |
| 443 | String xs = x.length==0?"":i<x.length?""+x[i]:"0"; |
| 444 | String ys = y.length==0?"":i<y.length?""+y[i]:"0"; |
| 445 | pw.println(xs + "\t"+ ys); |
| 446 | } |
| 447 | pw.close(); |
| 448 | } |
| 449 | |
| 450 | void open() { |
| 451 | OpenDialog od = new OpenDialog("Open Calibration...", ""); |
no test coverage detected