public class Preferences
extends Object
This class does not use the Properties class because .properties files use ISO 8859-1 encoding, which is highly likely to be a problem when trying to save sketch folders and locations. Like the rest of Processing, we use UTF8.
We don't use the Java Preferences API because it would entail writing to the registry (on Windows), or an obscure file location (on Mac OS X) and make it far more difficult (impossible) to remove the preferences.txt to reset them (when they become corrupt), or to find the the file to make edits for numerous obscure preferences that are not part of the preferences window. If we added a generic editor (e.g. about:config in Mozilla) for such things, we could start using the Java Preferences API. But wow, that sounds like a lot of work. Not unlike writing this paragraph.
Constructor and Description |
---|
Preferences() |
Modifier and Type | Method and Description |
---|---|
static String |
get(String attribute) |
static boolean |
getBoolean(String attribute) |
static Color |
getColor(String name) |
static String |
getDefault(String attribute) |
static Font |
getFont(String attr) |
static int |
getInteger(String attribute) |
static String |
getOldSketchbookPath() |
static String |
getPreferencesPath() |
static String |
getSketchbookPath() |
static void |
init() |
static void |
load(InputStream input)
Load a set of key/value pairs from a UTF-8 encoded file into 'table'.
|
static void |
save() |
static void |
set(String attribute,
String value) |
static void |
setBoolean(String attribute,
boolean value) |
static void |
setColor(String attr,
Color what) |
static void |
setInteger(String key,
int value) |
static void |
unset(String attribute) |
public static void init()
public static String getPreferencesPath()
public static void load(InputStream input) throws IOException
IOException
public static void save()
public static String get(String attribute)
public static String getDefault(String attribute)
public static void set(String attribute, String value)
public static void unset(String attribute)
public static boolean getBoolean(String attribute)
public static void setBoolean(String attribute, boolean value)
public static int getInteger(String attribute)
public static void setInteger(String key, int value)
public static Color getColor(String name)
public static void setColor(String attr, Color what)
public static Font getFont(String attr)
public static String getOldSketchbookPath()
public static String getSketchbookPath()