All Downloads are FREE. Search and download functionalities are using the official Maven repository.

editor.settings.Settings Maven / Gradle / Ivy

There is a newer version: 1.18.1
Show newest version
package editor.settings;

import editor.util.Experiment;
import java.util.Map;
import java.util.TreeMap;

/**
 */
public class Settings
{
  /**
   * Reset Experiment-specific settings to defaults.
   */
  public static Map makeDefaultSettings( Experiment experiment )
  {
    Map settings = new TreeMap<>();

    CompilerSettings compilerSettings = new CompilerSettings();
    compilerSettings.resetToDefaultSettings( experiment );
    settings.put( compilerSettings.getPath(), compilerSettings );

    return settings;
  }

  /**
   * Reset Gosu Lab application-level settings to defaults.
   */
  public static Map makeDefaultSettings()
  {
    Map settings = new TreeMap<>();

    AppearanceSettings appearanceSettings = new AppearanceSettings();
    appearanceSettings.resetToDefaultSettings( null );
    settings.put( appearanceSettings.getPath(), appearanceSettings );

    return settings;
  }

  /**
   * Assumes settings map is ordered top-down in tree order
   */
  public static Map mergeSettings( Map old, Experiment experiment )
  {
    Map defaultSettings = makeDefaultSettings( experiment );
    old.keySet().forEach( key -> defaultSettings.put( key, old.get( key ) ) );
    return defaultSettings;
  }

  public static Map mergeSettings( Map old )
  {
    Map defaultSettings = makeDefaultSettings();
    old.keySet().forEach( key -> defaultSettings.put( key, old.get( key ) ) );
    return defaultSettings;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy