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

Method savePreferences

ij/src/main/java/ij/Prefs.java:541–595  ·  view source on GitHub ↗

Saves user preferences in the IJ_Prefs.txt properties file.

()

Source from the content-addressed store, hash-verified

539
540 /** Saves user preferences in the IJ_Prefs.txt properties file. */
541 @AstroImageJ(reason = "Rename for AIJ", modified = true)
542 public static void savePreferences() {
543 String path = null;
544 commandLineMacro = false;
545 try {
546 Properties prefs = new Properties();
547 String dir = OpenDialog.getDefaultDirectory();
548 if (dir!=null)
549 prefs.put(DIR_IMAGE, dir);
550 prefs.put(ROICOLOR, Tools.c2hex(Roi.getColor()));
551 prefs.put(SHOW_ALL_COLOR, Tools.c2hex(ImageCanvas.getShowAllColor()));
552 prefs.put(FCOLOR, Tools.c2hex(Toolbar.getForegroundColor()));
553 prefs.put(BCOLOR, Tools.c2hex(Toolbar.getBackgroundColor()));
554 prefs.put(JPEG, Integer.toString(FileSaver.getJpegQuality()));
555 prefs.put(FPS, Double.toString(Animator.getFrameRate()));
556 prefs.put(DIV_BY_ZERO_VALUE, Double.toString(FloatBlitter.divideByZeroValue));
557 prefs.put(NOISE_SD, Double.toString(Filters.getSD()));
558 if (threads>1) prefs.put(THREADS, Integer.toString(threads));
559 if (IJ.isMacOSX()) useJFileChooser = false;
560 if (!IJ.isLinux()) dialogCancelButtonOnRight = false;
561 saveOptions(prefs);
562 savePluginPrefs(prefs);
563 ImageJ ij = IJ.getInstance();
564 if (ij!=null)
565 ij.savePreferences(prefs);
566 Menus.savePreferences(prefs);
567 ParticleAnalyzer.savePreferences(prefs);
568 Analyzer.savePreferences(prefs);
569 ImportDialog.savePreferences(prefs);
570 PlotWindow.savePreferences(prefs);
571 NewImage.savePreferences(prefs);
572 String prefsDir = getPrefsDir();
573 path = prefsDir+separator+PREFS_NAME;
574 if (prefsDir.endsWith(".astroimagej")) {
575 File f = new File(prefsDir);
576 if (!f.exists()) f.mkdir(); // create .imagej directory
577 }
578 if (resetPreferences) {
579 File f = new File(path);
580 if (!f.exists())
581 IJ.error("Edit>Options>Reset", "Unable to reset preferences. File not found at\n"+path);
582 boolean rtn = f.delete();
583 resetPreferences = false;
584 } else
585 savePrefs(prefs, path);
586 } catch (Throwable t) {
587 String msg = t.getMessage();
588 if (msg==null) msg = ""+t;
589 int delay = 4000;
590 try {
591 new TextWindow("Error Saving Preferences:\n"+path, msg, 500, 200);
592 IJ.wait(delay);
593 } catch (Throwable t2) {}
594 }
595 }
596
597 /** Delete the preferences file when ImageJ quits. */
598 public static void resetPreferences() {

Callers 10

runMethod · 0.95
runMethod · 0.95
savePreferencesMethod · 0.95
disposeMethod · 0.95
finishFancyDialogMethod · 0.95
savePrefsMethod · 0.95
backupAllAIJSettingsMethod · 0.95
restoreAllAIJSettingsMethod · 0.95

Calls 15

getDefaultDirectoryMethod · 0.95
c2hexMethod · 0.95
getColorMethod · 0.95
getShowAllColorMethod · 0.95
getForegroundColorMethod · 0.95
getBackgroundColorMethod · 0.95
getJpegQualityMethod · 0.95
getFrameRateMethod · 0.95
getSDMethod · 0.95
isMacOSXMethod · 0.95
isLinuxMethod · 0.95
saveOptionsMethod · 0.95

Tested by

no test coverage detected