summaryrefslogtreecommitdiff
path: root/src/main/java/prefs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/prefs')
-rw-r--r--src/main/java/prefs/VSDefaultPrefs.java275
-rw-r--r--src/main/java/prefs/VSPrefs.java1163
-rw-r--r--src/main/java/prefs/VSPrefsRestriction.java137
-rw-r--r--src/main/java/prefs/VSSerializablePrefs.java37
-rw-r--r--src/main/java/prefs/editors/VSAbstractBetterEditor.java101
-rw-r--r--src/main/java/prefs/editors/VSAbstractEditor.java1056
-rw-r--r--src/main/java/prefs/editors/VSColorChooser.java61
-rw-r--r--src/main/java/prefs/editors/VSEditorFrame.java98
-rw-r--r--src/main/java/prefs/editors/VSEditorTable.java290
-rw-r--r--src/main/java/prefs/editors/VSProcessEditor.java107
-rw-r--r--src/main/java/prefs/editors/VSSimulatorEditor.java120
11 files changed, 3445 insertions, 0 deletions
diff --git a/src/main/java/prefs/VSDefaultPrefs.java b/src/main/java/prefs/VSDefaultPrefs.java
new file mode 100644
index 0000000..f980734
--- /dev/null
+++ b/src/main/java/prefs/VSDefaultPrefs.java
@@ -0,0 +1,275 @@
+package prefs;
+
+import java.awt.Color;
+import java.awt.event.KeyEvent;
+
+/**
+ * The class VSDefaultPrefs, makes sure that the simulator has its default
+ * configuration values.
+ *
+ * @author Paul C. Buetow
+ */
+public class VSDefaultPrefs extends VSSerializablePrefs {
+ /**
+ * Inits a prefs object with default values.
+ *
+ * @return the lang.process.removeprefs
+ */
+ public static VSPrefs init() {
+ VSDefaultPrefs prefs = new VSDefaultPrefs();
+ prefs.fillWithDefaults();
+ return prefs;
+ }
+
+ /**
+ * Fill everything with ts defaults.
+ */
+ public void fillWithDefaults() {
+ super.clear();
+ addWithDefaults();
+ }
+
+ /**
+ * Adds default values if not existent.
+ */
+ public void addWithDefaults() {
+ fillDefaultBooleans();
+ fillDefaultColors();
+ fillDefaultFloats();
+ fillDefaultIntegers();
+ fillDefaultLongs();
+ fillDefaultStrings();
+ }
+
+ /**
+ * Fill with default strings.
+ */
+ public void fillDefaultStrings() {
+ initString("lang.about", "About");
+ initString("lang.about.info", "This program used to be the diploma thesis of Paul C. Buetow. Please contact vs-sim@dev.buetow.org, if you find any errors!");
+ initString("lang.activate", "activate");
+ initString("lang.activated", "activated");
+ initString("lang.actualize", "Activation");
+ initString("lang.all", "All");
+ initString("lang.antialiasing", "Anti-Aliasing");
+ initString("lang.cancel", "Abort");
+ initString("lang.client", "Client");
+ initString("lang.clientrequest.start", "Start client request");
+ initString("lang.close", "Close");
+ initString("lang.colorchooser", "Color chooser");
+ initString("lang.colorchooser2", "Please select color");
+ initString("lang.copy", "Copy");
+ initString("lang.crashed", "Crashed");
+ initString("lang.dat", "Simulation (.dat)");
+ initString("langactivate", "deactivate");
+ initString("langactivated", "deactivated");
+ initString("lang.default", "Defaults");
+ initString("lang.edit", "Edit");
+ initString("lang.editor", "Editor");
+ initString("lang.event", "Event");
+ initString("lang.event.add.global", "Insert global event");
+ initString("lang.event.add.local", "Insert local event");
+ initString("lang.event.add.time", "at");
+ initString("lang.events", "Events");
+ initString("lang.events.process", "Process events");
+ initString("lang.file", "File");
+ initString("lang.filter", "Filter");
+ initString("lang.loging.active", "Logging");
+ initString("lang.loging.clear", "Delete logs");
+ initString("lang.message", "Message");
+ initString("lang.message.recv", "Message received");
+ initString("lang.message.sent", "Message sent");
+ initString("lang.mode.expert", "Expert mode");
+ initString("lang.name", "VS-Simulator 1.2-beta");
+ initString("lang.ok", "OK");
+ initString("lang.open", "Open");
+ initString("lang.pause", "Pause");
+ initString("lang.prefs", "Preferences");
+ initString("lang.prefs.color", "Color preferences");
+ initString("lang.prefs.diverse", "Diverse preferences");
+ initString("lang.prefs.ext", "Extended preferences");
+ initString("lang.prefs.message", "Message preferences");
+ initString("lang.prefs.message.defaults", "Message prefs. for new processes");
+ initString("lang.prefs.more", "More preferences");
+ initString("lang.prefs.process", "Process preferences");
+ initString("lang.prefs.process", "Standard process preferences");
+ initString("lang.prefs.process.defaults", "Preferences for new processes");
+ initString("lang.prefs.process.ext", "Extended process preferences");
+ initString("lang.prefs.protocols", "Protocol preferences");
+ initString("lang.prefs.simulator", "Simulator preferences");
+ initString("lang.process", "Process");
+ initString("lang.process.add.new", "Insert new process");
+ initString("lang.process.crash", "Crash process");
+ initString("lang.process.edit", "Edit process");
+ initString("lang.process.id", "PID");
+ initString("lang.process.new", "New process");
+ initString("lang.process.not.selected", "No process selected");
+ initString("lang.process.recover", "Recover process");
+ initString("lang.process.remove", "Remove process");
+ initString("lang.process.selected", "Selected process");
+ initString("lang.process.time.local", "Local time");
+ initString("lang.processes.all", "All processes");
+ initString("lang.protocol", "Protocol");
+ initString("lang.protocol.client", "Client side");
+ initString("lang.protocol.editor", "Protocol editor");
+ initString("lang.protocol.server", "Server side");
+ initString("lang.protocol.tasks.activation", "Client-/Server protocol activation");
+ initString("lang.protocol.tasks.client", "Client Task-Manager (Client request)");
+ initString("lang.protocols", "Protocols");
+ initString("lang.quit", "Quit");
+ initString("lang.recovered", "Recovered");
+ initString("lang.remove", "Remove");
+ initString("lang.replay", "Repeat");
+ initString("lang.reset", "Reset");
+ initString("lang.save", "Save");
+ initString("lang.saveas", "Save as");
+ initString("lang.server", "Server");
+ initString("lang.serverrequest.start", "Start server request");
+ initString("lang.simulator", "Simulator");
+ initString("lang.simulator.close", "Close simulation");
+ initString("lang.simulator.finished", "Simulation closed");
+ initString("lang.simulator.new", "New simulation");
+ initString("lang.simulator.paused", "Simulation paused");
+ initString("lang.simulator.resetted", "Simulation resetted");
+ initString("lang.simulator.started", "Simulation started");
+ initString("lang.start", "Start");
+ initString("lang.stop", "Stop");
+ initString("lang.takeover", "Take over");
+ initString("lang.task", "Task");
+ initString("lang.task.manager", "Event editor");
+ initString("lang.tasks.fullfilled", "Fullfilled tasks");
+ initString("lang.tasks.global", "GLobal tasks");
+ initString("lang.tasks.local", "Local tasks");
+ initString("lang.time", "Time");
+ initString("lang.time.lamport", "Lamport time");
+ initString("lang.time.vector", "Vector time");
+ initString("lang.timed.global", "Global events");
+ initString("lang.timed.local", "Local events");
+ initString("lang.type", "Type");
+ initString("lang.value", "Value");
+ initString("lang.variable", "Variable");
+ initString("lang.variables", "Variables");
+ initString("lang.variables.global", "Global variables");
+ initString("lang.window.close", "Close window");
+ initString("lang.window.new", "New window");
+
+ /* Protocol names */
+ initString("lang.events.implementations.VSProcessCrashEvent", "Process Crash Event");
+ initString("lang.events.implementations.VSProcessCrashEvent.short", "Process Crash");
+ initString("lang.events.implementations.VSProcessRecoverEvent", "Process Recover Event");
+ initString("lang.events.implementations.VSProcessRecoverEvent.short", "Process Recover");
+ initString("lang.protocols.implementations.VSBasicMulticastProtocol", "Basic Multicast Protocol");
+ initString("lang.protocols.implementations.VSBasicMulticastProtocol.short", "Basic Multicast");
+ initString("lang.protocols.implementations.VSBerkelyTimeProtocol", "Berkley algorithm for internal sync.");
+ initString("lang.protocols.implementations.VSBerkelyTimeProtocol.short", "Berkley Protocol");
+ initString("lang.protocols.implementations.VSBroadcastProtocol", "Broadcast Protocol");
+ initString("lang.protocols.implementations.VSBroadcastProtocol.short", "Broadcast");
+ initString("lang.protocols.implementations.VSDummyProtocol", "Example/Dummy Protocol");
+ initString("lang.protocols.implementations.VSDummyProtocol.short", "Example/Dummy");
+ initString("lang.protocols.implementations.VSExternalTimeSyncProtocol", "Christians method for external sync.");
+ initString("lang.protocols.implementations.VSExternalTimeSyncProtocol.short", "Christians");
+ initString("lang.protocols.implementations.VSInternalTimeSyncProtocol", "Internal Synchronization Protocol");
+ initString("lang.protocols.implementations.VSInternalTimeSyncProtocol.short", "Internal sync.");
+ initString("lang.protocols.implementations.VSOnePhaseCommitProtocol", "One-Phase Commit Protocol");
+ initString("lang.protocols.implementations.VSOnePhaseCommitProtocol.short", "1-Phase Commit");
+ initString("lang.protocols.implementations.VSPingPongProtocol", "Ping-Pong Protocol");
+ initString("lang.protocols.implementations.VSPingPongProtocol.short", "Ping-Pong");
+ initString("lang.protocols.implementations.VSReliableMulticastProtocol", "Reliable Multicast Protocol");
+ initString("lang.protocols.implementations.VSReliableMulticastProtocol.short", "Reliable Multicast");
+ initString("lang.protocols.implementations.VSTwoPhaseCommitProtocol", "Two-Phase Commit");
+ initString("lang.protocols.implementations.VSTwoPhaseCommitProtocol.short", "2-Phase Commit");
+ }
+
+ /**
+ * Fill with default integers.
+ */
+ public void fillDefaultIntegers() {
+ /* Simulator prefs */
+ initInteger("sim.process.num", 3, "Number of processes", 1, 6);
+ initInteger("message.prob.outage", 0, "Message lost prob.", 0, 100, "%");
+ initInteger("process.prob.crash", 0, "Process crash prob.", 0, 100, "%");
+ initInteger("sim.seconds", 15, "Simulation duration", 5, 120, "s");
+
+ /* Internal prefs */
+ initInteger("keyevent.about", KeyEvent.VK_A, null, 0, 100);
+ initInteger("keyevent.cancel", KeyEvent.VK_A, null, 0, 100);
+ initInteger("keyevent.close", KeyEvent.VK_C, null, 0, 100);
+ initInteger("keyevent.default", KeyEvent.VK_F, null, 0, 100);
+ initInteger("keyevent.edit", KeyEvent.VK_E, null, 0, 100);
+ initInteger("keyevent.file", KeyEvent.VK_D, null, 0, 100);
+ initInteger("keyevent.new", KeyEvent.VK_N, null, 0, 100);
+ initInteger("keyevent.actualize", KeyEvent.VK_A, null, 0, 100);
+ initInteger("keyevent.takeover", KeyEvent.VK_B, null, 0, 100);
+ initInteger("keyevent.ok", KeyEvent.VK_O, null, 0, 100);
+ initInteger("keyevent.open", KeyEvent.VK_O, null, 0, 100);
+ initInteger("keyevent.pause", KeyEvent.VK_P, null, 0, 100);
+ initInteger("keyevent.prefs", KeyEvent.VK_P, null, 0, 100);
+ initInteger("keyevent.prefs.ext", KeyEvent.VK_E, null, 0, 100);
+ initInteger("keyevent.quit", KeyEvent.VK_B, null, 0, 100);
+ initInteger("keyevent.replay", KeyEvent.VK_W, null, 0, 100);
+ initInteger("keyevent.reset", KeyEvent.VK_R, null, 0, 100);
+ initInteger("keyevent.save", KeyEvent.VK_S, null, 0, 100);
+ initInteger("keyevent.saveas", KeyEvent.VK_V, null, 0, 100);
+ initInteger("keyevent.simulator", KeyEvent.VK_S, null, 0, 100);
+ initInteger("keyevent.start", KeyEvent.VK_S, null, 0, 100);
+ initInteger("keyevent.stop", KeyEvent.VK_P, null, 0, 100);
+
+ initInteger("div.window.prefs.xsize", 400, "Configuration window X-Axis", 550, 3200, "px");
+ initInteger("div.window.prefs.ysize", 400, "Configuration window Y-Axis", 640, 2400, "px");
+ initInteger("div.window.logsize", 300, "Log window Y-Axis", 100, 1000, "px");
+ initInteger("div.window.splitsize", 320, "Toolbar X-Axis", 100, 1000, "px");
+ initInteger("div.window.xsize", 1024, "Main window X-Axis", 750, 3200, "px");
+ initInteger("div.window.ysize", 768, "Main window Y-Axis", 600, 2400, "px");
+ }
+
+ /**
+ * Fill with default floats.
+ */
+ public void fillDefaultFloats() {
+ /* Simulator prefs */
+ initFloat("process.clock.variance", 0, "Clock variance");
+ initFloat("sim.clock.speed", 0.5f, "Simulation play speed");
+ }
+
+ /**
+ * Fill default longs.
+ */
+ public void fillDefaultLongs() {
+ /* Simulator prefs */
+ initLong("message.sendingtime.min", 500, "Max transmission time", "ms");
+ initLong("message.sendingtime.max", 2000, "Min transmission time", "ms");
+ }
+
+ /**
+ * Fill with default colors.
+ */
+ public void fillDefaultColors() {
+ /* Internal prefs */
+ initColor("col.background", new Color(0xFF, 0xFF, 0xFF));
+ initColor("col.process.default", new Color(0x00, 0x00, 0x00));
+ initColor("col.process.running", new Color(0x0D, 0xD8, 0x09));
+ initColor("col.process.crashed", new Color(0xff, 0x00, 0x00));
+ initColor("col.process.highlight", new Color(0xff, 0xA5, 0x00));
+ initColor("col.process.line", new Color(0x00, 0x00, 0x00));
+ initColor("col.process.secondline", new Color(0xAA, 0xAA, 0xAA));
+ initColor("col.process.sepline", new Color(0xff, 0x00, 0x00));
+ initColor("col.process.stopped", new Color(0x00, 0x00, 0x00));
+ initColor("col.message.arrived", new Color(0x00, 0x85, 0xD2));
+ initColor("col.message.sending", new Color(0x0D, 0xD8, 0x09));
+ initColor("col.message.lost", new Color(0xFF, 0x00, 0x00));
+ }
+
+ /**
+ * Fill with default booleans.
+ */
+ public void fillDefaultBooleans() {
+ initBoolean("sim.mode.expert", false, "Expert mode");
+ initBoolean("sim.message.own.recv", false, "Processes receive own messages");
+ initBoolean("sim.message.prob.mean", true, "Use mean value of message lost prob.");
+ initBoolean("sim.message.sendingtime.mean", true, "Use mean value of transmission times");
+ initBoolean("sim.messages.relevant", true, "Only show relevant messages");
+ initBoolean("sim.periodic", false, "Repeat simulation periodically");
+ initBoolean("sim.update.lamporttime.all", false, "Lamport timestamps affect all events");
+ initBoolean("sim.update.vectortime.all", false, "Vector timestamps affect all events");
+ }
+}
diff --git a/src/main/java/prefs/VSPrefs.java b/src/main/java/prefs/VSPrefs.java
new file mode 100644
index 0000000..e7b5295
--- /dev/null
+++ b/src/main/java/prefs/VSPrefs.java
@@ -0,0 +1,1163 @@
+package prefs;
+
+import java.awt.Color;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Set;
+import java.util.Vector;
+
+import serialize.VSSerialize;
+
+/**
+ * The class VSPrefs, this class is for dynamic data storage. It can hold
+ * various different types such as Boolean, Floats, Integers, Strings, Colors.
+ *
+ * @author Paul C. Buetow
+ */
+public class VSPrefs {
+ /** The Constant BOOLEAN_PREFIX. */
+ public static final String BOOLEAN_PREFIX = "Boolean: ";
+
+ /** The Constant COLOR_PREFIX. */
+ public static final String COLOR_PREFIX = "Color: ";
+
+ /** The Constant FLOAT_PREFIX. */
+ public static final String FLOAT_PREFIX = "Float: ";
+
+ /** The Constant INTEGER_PREFIX. */
+ public static final String INTEGER_PREFIX = "Integer: ";
+
+ /** The Constant VECTOR_PREFIX. */
+ public static final String VECTOR_PREFIX = "Vector: ";
+
+ /** The Constant LONG_PREFIX. */
+ public static final String LONG_PREFIX = "Long: ";
+
+ /** The Constant STRING_PREFIX. */
+ public static final String STRING_PREFIX = "String: ";
+
+ /** The color prefs. */
+ private HashMap<String,Color> colorPrefs;
+
+ /** The float prefs. */
+ private HashMap<String,Float> floatPrefs;
+
+ /** The integer prefs. */
+ private HashMap<String,Integer> integerPrefs;
+
+ /** The integer vector prefs. */
+ private HashMap<String,Vector<Integer>> vectorPrefs;
+
+ /** The long prefs. */
+ private HashMap<String,Long> longPrefs;
+
+ /** The setting restriction prefs. */
+ private HashMap<String,VSPrefsRestriction> restrictions;
+
+ /** The description prefs. */
+ private HashMap<String,String> descriptionPrefs;
+
+ /** The string prefs. */
+ private HashMap<String,String> stringPrefs;
+
+ /** The boolean prefs. */
+ private HashMap<String,Boolean> booleanPrefs;
+
+ /** The object prefs. */
+ private HashMap<String,Object> objectPrefs;
+
+ /** The units. */
+ private HashMap<String,String> units;
+
+ /** The id counter. */
+ private static int idCounter;
+
+ /** The id. */
+ protected int id;
+
+ /**
+ * Instantiates a new lang.process.removeprefs.
+ */
+ public VSPrefs() {
+ colorPrefs = new HashMap<String,Color>();
+ descriptionPrefs = new HashMap<String,String>();
+ floatPrefs = new HashMap<String,Float>();
+ integerPrefs = new HashMap<String,Integer>();
+ vectorPrefs = new HashMap<String,Vector<Integer>>();
+ longPrefs = new HashMap<String,Long>();
+ restrictions = new HashMap<String,VSPrefsRestriction>();
+ stringPrefs = new HashMap<String,String>();
+ booleanPrefs = new HashMap<String,Boolean>();
+ objectPrefs = new HashMap<String,Object>();
+ units = new HashMap<String,String>();
+ id = ++idCounter;
+ }
+
+ /**
+ * Clear.
+ */
+ protected synchronized void clear() {
+ colorPrefs.clear();
+ floatPrefs.clear();
+ integerPrefs.clear();
+ vectorPrefs.clear();
+ longPrefs.clear();
+ stringPrefs.clear();
+ booleanPrefs.clear();
+ objectPrefs.clear();
+ descriptionPrefs.clear();
+ restrictions.clear();
+ }
+
+ /* Unit methods */
+
+ /**
+ * Gets the unit.
+ *
+ * @param fullKey the full key
+ *
+ * @return the unit
+ */
+ public synchronized String getUnit(String fullKey) {
+ return units.get(fullKey);
+ }
+
+ /**
+ * Sets the unit.
+ *
+ * @param key the key
+ * @param unit the unit
+ */
+ public synchronized void initUnit(String key, String unit) {
+ if (unit == null /*|| units.containsKey(key)*/)
+ return;
+ units.put(key, unit);
+ }
+
+ /* Description methods */
+ /**
+ * Sets the description if unset.
+ *
+ * @param key the key
+ * @param descr the descr
+ */
+ public synchronized void initDescription(String key, String descr) {
+ if (descr == null /*|| descriptionPrefs.containsKey(key)*/)
+ return;
+ descriptionPrefs.put(key, descr);
+ }
+
+ /**
+ * Gets the description.
+ *
+ * @param fullKey the full key
+ *
+ * @return the description
+ */
+ public synchronized String getDescription(String fullKey) {
+ return descriptionPrefs.get(fullKey);
+ }
+
+ /* Restriction methods */
+
+ /**
+ * Gets the restriction.
+ *
+ * @param fullKey the full key
+ *
+ * @return the restriction
+ */
+ public synchronized VSPrefsRestriction getRestriction(String fullKey) {
+ return restrictions.get(fullKey);
+ }
+
+ /**
+ * Sets the restriction.
+ *
+ * @param key the key
+ * @param settingRestriction the setting restriction
+ */
+ public synchronized void initRestriction(String key,
+ VSPrefsRestriction settingRestriction) {
+ restrictions.put(key, settingRestriction);
+ }
+
+ /* Object methods */
+
+ /**
+ * Object exists.
+ *
+ * @param key the key
+ *
+ * @return true, if successful
+ */
+ public synchronized boolean objectExists(String key) {
+ return null != objectPrefs.get(key);
+ }
+
+ /**
+ * Gets the object.
+ *
+ * @param key the key
+ *
+ * @return the object
+ */
+ public synchronized Object getObject(String key) {
+ Object val = objectPrefs.get(key);
+
+ if (val == null) {
+ System.err.println("Fatal: No such object config value \"" + key + "\"");
+ System.exit(1);
+ }
+
+ return val;
+ }
+
+ /**
+ * Removes the object.
+ *
+ * @param key the key
+ */
+ public synchronized void removeObject(String key) {
+ objectPrefs.remove(key);
+ }
+
+ /**
+ * Sets the object.
+ *
+ * @param key the key
+ * @param val the val
+ */
+ public synchronized void setObject(String key, Object val) {
+ objectPrefs.put(key, val);
+ }
+
+ /* Boolean methods */
+
+ /**
+ * Gets the boolean.
+ *
+ * @param key the key
+ *
+ * @return the boolean
+ */
+ public boolean getBoolean(String key) {
+ return getBooleanObj(key).booleanValue();
+ }
+
+ /**
+ * Gets the boolean key set.
+ *
+ * @return the boolean key set
+ */
+ public synchronized Set<String> getBooleanKeySet() {
+ return booleanPrefs.keySet();
+ }
+
+ /**
+ * Gets the boolean obj.
+ *
+ * @param key the key
+ *
+ * @return the boolean obj
+ */
+ public synchronized Boolean getBooleanObj(String key) {
+ Boolean val = booleanPrefs.get(key);
+
+ if (val == null)
+ return Boolean.valueOf(false);
+
+ return val;
+ }
+
+ /**
+ * Inits the boolean.
+ *
+ * @param key the key
+ * @param val the val
+ */
+ public synchronized void initBoolean(String key, Boolean val) {
+ if (!booleanPrefs.containsKey(key))
+ booleanPrefs.put(key, val);
+ }
+
+ /**
+ * Inits the boolean.
+ *
+ * @param key the key
+ * @param val the val
+ */
+ public void initBoolean(String key, boolean val) {
+ initBoolean(key, Boolean.valueOf(val));
+ }
+
+ /**
+ * Inits the boolean.
+ *
+ * @param key the key
+ * @param val the val
+ * @param descr the descr
+ */
+ public void initBoolean(String key, boolean val, String descr) {
+ initBoolean(key, val);
+ initDescription(BOOLEAN_PREFIX + key, descr);
+ }
+
+ /**
+ * Sets the boolean.
+ *
+ * @param key the key
+ * @param val the val
+ */
+ public synchronized void setBoolean(String key, Boolean val) {
+ booleanPrefs.put(key, val);
+ }
+
+ /**
+ * Sets the boolean.
+ *
+ * @param key the key
+ * @param val the val
+ */
+ public void setBoolean(String key, boolean val) {
+ setBoolean(key, Boolean.valueOf(val));
+ }
+
+ /* Color methods */
+
+ /**
+ * Gets the color.
+ *
+ * @param key the key
+ *
+ * @return the color
+ */
+ public synchronized Color getColor(String key) {
+ Color color = colorPrefs.get(key);
+
+ if (color == null) {
+ System.err.println("Fatal: No such color config value \""
+ + key + "\"");
+ System.exit(1);
+ }
+
+ return color;
+ }
+
+ /**
+ * Gets the color key set.
+ *
+ * @return the color key set
+ */
+ public synchronized Set<String> getColorKeySet() {
+ return colorPrefs.keySet();
+ }
+
+ /**
+ * Inits the color.
+ *
+ * @param key the key
+ * @param color the color
+ */
+ public synchronized void initColor(String key, Color color) {
+ if (!colorPrefs.containsKey(key))
+ colorPrefs.put(key, color);
+ }
+
+ /**
+ * Inits the color.
+ *
+ * @param key the key
+ * @param val the val
+ * @param descr the descr
+ */
+ public void initColor(String key, Color val, String descr) {
+ initColor(key, val);
+ initDescription(COLOR_PREFIX + key, descr);
+ }
+
+ /**
+ * Sets the color.
+ *
+ * @param key the key
+ * @param color the color
+ */
+ public synchronized void setColor(String key, Color color) {
+ colorPrefs.put(key, color);
+ }
+
+ /* Float methods */
+
+ /**
+ * Gets the float.
+ *
+ * @param key the key
+ *
+ * @return the float
+ */
+ public float getFloat(String key) {
+ return getFloatObj(key).floatValue();
+ }
+
+ /**
+ * Gets the float key set.
+ *
+ * @return the float key set
+ */
+ public synchronized Set<String> getFloatKeySet() {
+ return floatPrefs.keySet();
+ }
+
+ /**
+ * Gets the float obj.
+ *
+ * @param key the key
+ *
+ * @return the float obj
+ */
+ public synchronized Float getFloatObj(String key) {
+ Float val = floatPrefs.get(key);
+
+ if (val == null) {
+ System.err.println("Fatal: No such float config value \""
+ + key + "\"");
+ System.exit(1);
+ }
+
+ return val;
+ }
+
+ /**
+ * Inits the float.
+ *
+ * @param key the key
+ * @param val the val
+ */
+ public synchronized void initFloat(String key, Float val) {
+ if (!floatPrefs.containsKey(key))
+ floatPrefs.put(key, val);
+ }
+
+ /**
+ * Inits the float.
+ *
+ * @param key the key
+ * @param val the val
+ */
+ public void initFloat(String key, float val) {
+ initFloat(key, Float.valueOf(val));
+ }
+
+ /**
+ * Inits the float.
+ *
+ * @param key the key
+ * @param val the val
+ * @param descr the descr
+ */
+ public void initFloat(String key, float val, String descr) {
+ initFloat(key, val);
+ initDescription(FLOAT_PREFIX + key, descr);
+ }
+
+ /**
+ * Inits the float plus unit.
+ *
+ * @param key the key
+ * @param val the val
+ * @param descr the descr
+ * @param unit the unit
+ */
+ public void initFloat(String key, float val, String descr, String unit) {
+ initFloat(key, val, descr);
+ initUnit(FLOAT_PREFIX + key, unit);
+ }
+
+ /**
+ * Sets the float.
+ *
+ * @param key the key
+ * @param val the val
+ */
+ public synchronized void setFloat(String key, Float val) {
+ floatPrefs.put(key, val);
+ }
+
+ /**
+ * Sets the float.
+ *
+ * @param key the key
+ * @param val the val
+ */
+ public void setFloat(String key, float val) {
+ setFloat(key, Float.valueOf(val));
+ }
+
+ /* Integer methods */
+
+ /**
+ * Gets the integer.
+ *
+ * @param key the key
+ *
+ * @return the integer
+ */
+ public int getInteger(String key) {
+ return getIntegerObj(key).intValue();
+ }
+
+ /**
+ * Gets the integer key set.
+ *
+ * @return the integer key set
+ */
+ public synchronized Set<String> getIntegerKeySet() {
+ return integerPrefs.keySet();
+ }
+
+ /**
+ * Gets the integer obj.
+ *
+ * @param key the key
+ *
+ * @return the integer obj
+ */
+ public synchronized Integer getIntegerObj(String key) {
+ Integer val = integerPrefs.get(key);
+
+ if (val == null) {
+ System.err.println("Fatal: No such integer config value \"" + key + "\"");
+ System.exit(1);
+ }
+
+ return val;
+ }
+
+ /**
+ * Inits the integer.
+ *
+ * @param key the key
+ * @param val the val
+ */
+ public void initInteger(String key, int val) {
+ if (!integerPrefs.containsKey(key))
+ setInteger(key, Integer.valueOf(val));
+ }
+
+ /**
+ * Inits the integer.
+ *
+ * @param key the key
+ * @param val the val
+ * @param descr the descr
+ */
+ public void initInteger(String key, int val, String descr) {
+ initInteger(key, val);
+ initDescription(INTEGER_PREFIX + key, descr);
+ }
+
+ /**
+ * Inits the integer.
+ *
+ * @param key the key
+ * @param val the val
+ * @param descr the descr
+ * @param r the restriction
+ */
+ public void initInteger(String key, int val, String descr,
+ VSPrefsRestriction.VSIntegerPrefsRestriction r) {
+ initInteger(key, val, descr);
+ initRestriction(INTEGER_PREFIX + key, r);
+ }
+
+ /**
+ * Inits the integer.
+ *
+ * @param key the key
+ * @param val the val
+ * @param descr the descr
+ * @param r the restriction
+ */
+ public void initInteger(String key, int val, String descr,
+ VSPrefsRestriction.VSIntegerPrefsRestriction r,
+ String unit) {
+ initInteger(key, val, descr, r);
+ initUnit(INTEGER_PREFIX + key, unit);
+ }
+
+ /**
+ * Inits the integer.
+ *
+ * @param key the key
+ * @param val the val
+ * @param descr the descr
+ * @param minValue the min value
+ * @param maxValue the max value
+ */
+ public void initInteger(String key, int val, String descr, int minValue,
+ int maxValue) {
+ initInteger(key, val, descr,
+ new VSPrefsRestriction.VSIntegerPrefsRestriction(
+ minValue, maxValue));
+ }
+
+ /**
+ * Inits the integer plus unit.
+ *
+ * @param key the key
+ * @param val the val
+ * @param descr the descr
+ * @param minValue the min value
+ * @param maxValue the max value
+ * @param unit the unit
+ */
+ public void initInteger(String key, int val, String descr, int minValue,
+ int maxValue, String unit) {
+ initInteger(key, val, descr, minValue, maxValue);
+ initUnit(INTEGER_PREFIX + key, unit);
+ }
+
+ /**
+ * Sets the integer.
+ *
+ * @param key the key
+ * @param val the val
+ */
+ public synchronized void setInteger(String key, Integer val) {
+ integerPrefs.put(key, val);
+ }
+
+ /**
+ * Sets the integer.
+ *
+ * @param key the key
+ * @param val the val
+ */
+ public void setInteger(String key, int val) {
+ setInteger(key, Integer.valueOf(val));
+ }
+
+ /* Integer vector methods */
+
+ /**
+ * Gets the integer key set.
+ *
+ * @return the integer key set
+ */
+ public synchronized Set<String> getVectorKeySet() {
+ return vectorPrefs.keySet();
+ }
+
+ /**
+ * Gets the integer obj.
+ *
+ * @param key the key
+ *
+ * @return the integer obj
+ */
+ public synchronized Vector<Integer> getVector(String key) {
+ Vector<Integer> val = vectorPrefs.get(key);
+
+ if (val == null) {
+ System.err.println("Fatal: No such integer config value \"" + key + "\"");
+ System.exit(1);
+ }
+
+ return val;
+ }
+
+ /**
+ * Inits the integer.
+ *
+ * @param key the key
+ * @param val the val
+ */
+ public synchronized void initVector(String key, Vector<Integer> val) {
+ if (!vectorPrefs.containsKey(key))
+ setVector(key, val);
+ }
+
+ /**
+ * Inits the integer vector.
+ *
+ * @param key the key
+ * @param val the val
+ * @param descr the descr
+ */
+ public void initVector(String key, Vector<Integer> val, String descr) {
+ initVector(key, val);
+ initDescription(VECTOR_PREFIX + key, descr);
+ }
+
+ /**
+ * Inits the integer vector plus unit.
+ *
+ * @param key the key
+ * @param val the val
+ * @param descr the descr
+ */
+ public void initVector(String key, Vector<Integer> val, String descr,
+ String unit) {
+ initVector(key, val, descr);
+ initUnit(VECTOR_PREFIX + key, unit);
+ }
+
+ /**
+ * Sets the integer vector.
+ *
+ * @param key the key
+ * @param val the val
+ */
+ public synchronized void setVector(String key, Vector<Integer> val) {
+ vectorPrefs.put(key, val);
+ }
+
+ /* Long methods */
+
+ /**
+ * Gets the long.
+ *
+ * @param key the key
+ *
+ * @return the long
+ */
+ public long getLong(String key) {
+ return getLongObj(key).longValue();
+ }
+
+ /**
+ * Get