Package sim.display

Class Prefs

java.lang.Object
sim.display.Prefs

public class Prefs extends Object
A simple cover class for Java's preferences system. MASON has both global and application-specific preferences. Each Preferences object is associated with a unique namespace hung under the global Preferences or under an application-specific preferences. You are responsible for defining the namespace for your particular object. Typically it's a single unique word like "Display2D" or "Bugaboo". Do not include periods, whitespace, or begin or end with a slash.

Once you have retrieved the Preferences object and modified it, you must save it before MASON is terminated.

How this works with Java's Preferences: All preferences start with a certain path and then add a namespace onto it. Global preferences have a path which starts with "edu/gmu/mason/global/" -- Display2D's namespace is "Display2D", so for example, Display2D's global preferences are "edu/gmu/mason/global/Display2D". App-specific preferences also have unique paths. For example, HeatBugs's preferences path is "edu/gmu/mason/app/sim/app/heatbugs/", so Display2D's app preferences, when used with Heatbugs, is "edu/gmu/mason/app/sim/app/heatbugs/Display2D". You don't need to be concerned with this if you just want to retrieve and/or delete preferences objects.

  • Field Details

  • Constructor Details

    • Prefs

      public Prefs()
  • Method Details

    • getGlobalPreferences

      public static Preferences getGlobalPreferences(String namespace)
      Returns the global preferences for MASON, with the given additional prefix as a namespace.
    • getAppPreferences

      public static Preferences getAppPreferences(GUIState simulation, String namespace)
      Returns app-specific preferences for MASON, with the given additional prefix as a namespace.
    • removeGlobalPreferences

      public static boolean removeGlobalPreferences(String namespace)
      Deletes certain global preferences for MASON, with the given additional prefix as a namespace.
    • removeAppPreferences

      public static boolean removeAppPreferences(GUIState simulation, String namespace)
      Deletes certain app-specific preferences for MASON, with the given additional prefix as a namespace.
    • save

      public static boolean save(Preferences prefs)
      Saves a given Preferences.