MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / save

Method save

ij/src/main/java/ij/plugin/filter/Calibrator.java:414–448  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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...", "");

Callers 1

actionPerformedMethod · 0.95

Calls 13

getDataMethod · 0.95
getFileNameMethod · 0.95
getDirectoryMethod · 0.95
errorMethod · 0.95
waitMethod · 0.95
getTextArea1Method · 0.80
getTextArea2Method · 0.80
printlnMethod · 0.80
closeMethod · 0.65
selectAllMethod · 0.45
getTextMethod · 0.45
selectMethod · 0.45

Tested by

no test coverage detected