diff options
| author | Paul Buetow <paul@buetow.org> | 2008-05-26 13:55:22 +0000 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2008-05-26 13:55:22 +0000 |
| commit | 9ffbf6d8b94e8ae40ebc291eab6bd96aff3477b0 (patch) | |
| tree | 4b0e3f59bee77c51663044ef331fc47413c78758 | |
| parent | 71d9caff2cc21a39971b69670c481c28b0399b9c (diff) | |
all relevant variables now do have units.
| -rw-r--r-- | ROADMAP | 1 | ||||
| -rw-r--r-- | build.xml | 2 | ||||
| -rw-r--r-- | sources/core/VSProcess.java | 2 | ||||
| -rw-r--r-- | sources/prefs/VSDefaultPrefs.java | 68 | ||||
| -rw-r--r-- | sources/prefs/VSPrefs.java | 134 | ||||
| -rw-r--r-- | sources/prefs/editors/VSEditor.java | 22 | ||||
| -rw-r--r-- | sources/protocols/implementations/BerkelyTimeProtocol.java | 2 | ||||
| -rw-r--r-- | sources/protocols/implementations/InternalTimeSyncProtocol.java | 4 |
8 files changed, 115 insertions, 120 deletions
@@ -1,4 +1,3 @@ -Alle Protokoll und Prozess VSPrefs' mit Einheiten versehen Periodische Tasks anlegen koennen Ganze simulationseinstellungen abspeichern/laden koennen TaskManager + Tasks serialisierbar machen @@ -35,7 +35,7 @@ </target> <target name="clean" description="clean up" > - <!-- Delete the ${classes} and ${dist} directory trees --> + <delete dir="${basedir}/javadoc/" /> <delete dir="${classes}" /> <delete dir="${dist}" /> <delete file="MANIFEST.MF" /> diff --git a/sources/core/VSProcess.java b/sources/core/VSProcess.java index 39986f0..ffb17e4 100644 --- a/sources/core/VSProcess.java +++ b/sources/core/VSProcess.java @@ -181,7 +181,7 @@ public class VSProcess extends VSPrefs { currentColor = getColor("col.process.default"); /* Make additional process settings editable through GUI */ - initLongUnit("process.localtime", localTime, prefs.getString("lang.process.time.local"), "ms"); + initLong("process.localtime", localTime, prefs.getString("lang.process.time.local"), "ms"); crashedColor = getColor("col.process.crashed"); createRandomCrashTask(); diff --git a/sources/prefs/VSDefaultPrefs.java b/sources/prefs/VSDefaultPrefs.java index d3738a8..e1ac3f3 100644 --- a/sources/prefs/VSDefaultPrefs.java +++ b/sources/prefs/VSDefaultPrefs.java @@ -150,41 +150,41 @@ public class VSDefaultPrefs extends VSPrefs { */ public void fillDefaultIntegers() { /* Simulation prefs */ - initInteger("sim.process.num", 3, "Anzahl der Prozesse", 1, 6); - initIntegerUnit("message.prob.outage", 0, "Nachrichtenverlustw'keit", 0, 100, "%"); - initIntegerUnit("process.prob.crash", 0, "Prozessausfallw'keit", 0, 100, "%"); - initIntegerUnit("sim.seconds", 15, "Simulationsdauer", 5, 120, "s"); + initLong("sim.process.num", 3, "Anzahl der Prozesse", 1, 6); + initLong("message.prob.outage", 0, "Nachrichtenverlustw'keit", 0, 100, "%"); + initLong("process.prob.crash", 0, "Prozessausfallw'keit", 0, 100, "%"); + initLong("sim.seconds", 15, "Simulationsdauer", 5, 120, "s"); /* Internal prefs */ - initInteger("keyevent.about", KeyEvent.VK_A, null, 0, 100); - initInteger("keyevent.cancel", KeyEvent.VK_N, 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_R, 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.simulation", KeyEvent.VK_S, null, 0, 100); - initInteger("keyevent.start", KeyEvent.VK_S, null, 0, 100); - initInteger("keyevent.stop", KeyEvent.VK_P, null, 0, 100); + initLong("keyevent.about", KeyEvent.VK_A, null, 0, 100); + initLong("keyevent.cancel", KeyEvent.VK_N, null, 0, 100); + initLong("keyevent.close", KeyEvent.VK_C, null, 0, 100); + initLong("keyevent.default", KeyEvent.VK_F, null, 0, 100); + initLong("keyevent.edit", KeyEvent.VK_E, null, 0, 100); + initLong("keyevent.file", KeyEvent.VK_D, null, 0, 100); + initLong("keyevent.new", KeyEvent.VK_N, null, 0, 100); + initLong("keyevent.actualize", KeyEvent.VK_A, null, 0, 100); + initLong("keyevent.takeover", KeyEvent.VK_B, null, 0, 100); + initLong("keyevent.ok", KeyEvent.VK_O, null, 0, 100); + initLong("keyevent.open", KeyEvent.VK_O, null, 0, 100); + initLong("keyevent.pause", KeyEvent.VK_P, null, 0, 100); + initLong("keyevent.prefs", KeyEvent.VK_P, null, 0, 100); + initLong("keyevent.prefs.ext", KeyEvent.VK_E, null, 0, 100); + initLong("keyevent.quit", KeyEvent.VK_B, null, 0, 100); + initLong("keyevent.replay", KeyEvent.VK_R, null, 0, 100); + initLong("keyevent.reset", KeyEvent.VK_R, null, 0, 100); + initLong("keyevent.save", KeyEvent.VK_S, null, 0, 100); + initLong("keyevent.saveas", KeyEvent.VK_V, null, 0, 100); + initLong("keyevent.simulation", KeyEvent.VK_S, null, 0, 100); + initLong("keyevent.start", KeyEvent.VK_S, null, 0, 100); + initLong("keyevent.stop", KeyEvent.VK_P, null, 0, 100); - initIntegerUnit("div.window.prefs.xsize", 400, "Einstellungsfenster X-Achse", 550, 3200, "px"); - initIntegerUnit("div.window.prefs.ysize", 400, "Einstellungsfenster Y-Achse", 640, 2400, "px"); - initIntegerUnit("div.window.loggsize", 300, "Loggfenster Y-Achse", 100, 1000, "px"); - initIntegerUnit("div.window.splitsize", 320, "Toolbar X-Achse", 100, 1000, "px"); - initIntegerUnit("div.window.xsize", 1024, "Hauptfenster X-Achse", 800, 3200, "px"); - initIntegerUnit("div.window.ysize", 768, "Hauptfenster Y-Achse", 600, 2400, "px"); + initLong("div.window.prefs.xsize", 400, "Einstellungsfenster X-Achse", 550, 3200, "px"); + initLong("div.window.prefs.ysize", 400, "Einstellungsfenster Y-Achse", 640, 2400, "px"); + initLong("div.window.loggsize", 300, "Loggfenster Y-Achse", 100, 1000, "px"); + initLong("div.window.splitsize", 320, "Toolbar X-Achse", 100, 1000, "px"); + initLong("div.window.xsize", 1024, "Hauptfenster X-Achse", 800, 3200, "px"); + initLong("div.window.ysize", 768, "Hauptfenster Y-Achse", 600, 2400, "px"); } /* (non-Javadoc) @@ -201,8 +201,8 @@ public class VSDefaultPrefs extends VSPrefs { */ public void fillDefaultLongs() { /* Simulation prefs */ - initLongUnit("message.sendingtime.min", 500l, "Minimale Übertragungszeit", "ms"); - initLongUnit("message.sendingtime.max", 2000l, "Maximale Übertragungszeit", "ms"); + initLong("message.sendingtime.min", 500, "Minimale Übertragungszeit", "ms"); + initLong("message.sendingtime.max", 2000, "Maximale Übertragungszeit", "ms"); } /* (non-Javadoc) diff --git a/sources/prefs/VSPrefs.java b/sources/prefs/VSPrefs.java index 39cafcc..5d23ad0 100644 --- a/sources/prefs/VSPrefs.java +++ b/sources/prefs/VSPrefs.java @@ -592,22 +592,12 @@ public abstract class VSPrefs implements Serializable { * @param key the key * @param val the val */ - public synchronized void initInteger(String key, Integer val) { + public synchronized void initLong(String key, Integer val) { if (!integerPrefs.containsKey(key)) integerPrefs.put(key, val); } /** - * Inits the integer. - * - * @param key the key - * @param val the val - */ - public void initInteger(String key, int val) { - initInteger(key, new Integer(val)); - } - - /** * Inits the long. * * @param key the key @@ -619,16 +609,6 @@ public abstract class VSPrefs implements Serializable { } /** - * Inits the long. - * - * @param key the key - * @param val the val - */ - public void initLong(String key, int val) { - initLong(key, new Long(val)); - } - - /** * Inits the float. * * @param key the key @@ -655,19 +635,8 @@ public abstract class VSPrefs implements Serializable { * @param key the key * @param val the val */ - public synchronized void setLongIfUnset(String key, Long val) { - if (!longPrefs.containsKey(key)) - longPrefs.put(key, val); - } - - /** - * Sets the long if unset. - * - * @param key the key - * @param val the val - */ - public void setLongIfUnset(String key, long val) { - setLongIfUnset(key, new Long(val)); + public void initLong(String key, long val) { + initLong(key, new Long(val)); } /** @@ -708,7 +677,7 @@ public abstract class VSPrefs implements Serializable { * @param key the key * @param descr the descr */ - public synchronized void setDescriptionIfUnset(String key, String descr) { + public synchronized void initDescription(String key, String descr) { if (descr == null || descriptionPrefs.containsKey(key)) return; descriptionPrefs.put(key, descr); @@ -743,19 +712,7 @@ public abstract class VSPrefs implements Serializable { */ public void initString(String key, String val, String descr) { initString(key, val); - setDescriptionIfUnset(STRING_PREFIX + key, descr); - } - - /** - * Sets the long if unset. - * - * @param key the key - * @param val the val - * @param descr the descr - */ - public void setLongIfUnset(String key, long val, String descr) { - setLongIfUnset(key, val); - setDescriptionIfUnset(LONG_PREFIX + key, descr); + initDescription(STRING_PREFIX + key, descr); } /** @@ -767,7 +724,7 @@ public abstract class VSPrefs implements Serializable { */ public void initBoolean(String key, boolean val, String descr) { initBoolean(key, val); - setDescriptionIfUnset(BOOLEAN_PREFIX + key, descr); + initDescription(BOOLEAN_PREFIX + key, descr); } /** @@ -778,7 +735,7 @@ public abstract class VSPrefs implements Serializable { * @param descr the descr * @param unit the unit */ - public void initBooleanUnit(String key, boolean val, String descr, String unit) { + public void initBooleanInteger(String key, boolean val, String descr, String unit) { initBoolean(key, val, descr); setUnit(BOOLEAN_PREFIX + key, unit); } @@ -791,9 +748,9 @@ public abstract class VSPrefs implements Serializable { * @param descr the descr * @param r the r */ - public void initInteger(String key, Integer val, String descr, IntegerSettingRestriction r) { - initInteger(key, val); - setDescriptionIfUnset(INTEGER_PREFIX + key, descr); + public void initLong(String key, Integer val, String descr, IntegerSettingRestriction r) { + initLong(key, val); + initDescription(INTEGER_PREFIX + key, descr); setRestriction(INTEGER_PREFIX + key, r); } @@ -806,8 +763,8 @@ public abstract class VSPrefs implements Serializable { * @param minValue the min value * @param maxValue the max value */ - public void initInteger(String key, Integer val, String descr, int minValue, int maxValue) { - initInteger(key, val, descr, new IntegerSettingRestriction(minValue, maxValue)); + public void initLong(String key, Integer val, String descr, int minValue, int maxValue) { + initLong(key, val, descr, new IntegerSettingRestriction(minValue, maxValue)); } /** @@ -818,8 +775,8 @@ public abstract class VSPrefs implements Serializable { * @param descr the descr * @param r the r */ - public void initInteger(String key, int val, String descr, IntegerSettingRestriction r) { - initInteger(key, new Integer(val), descr, r); + public void initLong(String key, int val, String descr, IntegerSettingRestriction r) { + initLong(key, new Integer(val), descr, r); } /** @@ -831,8 +788,23 @@ public abstract class VSPrefs implements Serializable { * @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, new Integer(val), descr, minValue, maxValue); + public void initLong(String key, int val, String descr, int minValue, int maxValue) { + initLong(key, new Integer(val), descr, minValue, maxValue); + } + + /** + * Inits the integer 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 initLong(String key, int val, String descr, int minValue, int maxValue, String unit) { + initLong(key, new Integer(val), descr, minValue, maxValue); + setUnit(INTEGER_PREFIX + key, unit); } /** @@ -845,8 +817,8 @@ public abstract class VSPrefs implements Serializable { * @param maxValue the max value * @param unit the unit */ - public void initIntegerUnit(String key, int val, String descr, int minValue, int maxValue, String unit) { - initInteger(key, new Integer(val), descr, minValue, maxValue); + public void initLong(String key, int val, String descr, IntegerSettingRestriction sr, String unit) { + initLong(key, new Integer(val), descr, sr); setUnit(INTEGER_PREFIX + key, unit); } @@ -859,7 +831,7 @@ public abstract class VSPrefs implements Serializable { */ public void initLong(String key, Long val, String descr) { initLong(key, val); - setDescriptionIfUnset(LONG_PREFIX + key, descr); + initDescription(LONG_PREFIX + key, descr); } /** @@ -869,7 +841,7 @@ public abstract class VSPrefs implements Serializable { * @param val the val * @param descr the descr */ - public void initLong(String key, int val, String descr) { + public void initLong(String key, long val, String descr) { initLong(key, new Long(val), descr); } @@ -881,7 +853,7 @@ public abstract class VSPrefs implements Serializable { * @param descr the descr * @param unit the unit */ - public void initLongUnit(String key, long val, String descr, String unit) { + public void initLong(String key, long val, String descr, String unit) { initLong(key, new Long(val), descr); setUnit(LONG_PREFIX + key, unit); } @@ -895,7 +867,7 @@ public abstract class VSPrefs implements Serializable { */ public void initFloat(String key, Float val, String descr) { initFloat(key, val); - setDescriptionIfUnset(FLOAT_PREFIX + key, descr); + initDescription(FLOAT_PREFIX + key, descr); } /** @@ -917,7 +889,7 @@ public abstract class VSPrefs implements Serializable { * @param descr the descr * @param unit the unit */ - public void initFloatUnit(String key, float val, String descr, String unit) { + public void initFloatInteger(String key, float val, String descr, String unit) { initFloat(key, new Float(val), descr); setUnit(FLOAT_PREFIX + key, unit); } @@ -932,7 +904,7 @@ public abstract class VSPrefs implements Serializable { */ public void initColor(String key, Color val, String descr) { initColor(key, val); - setDescriptionIfUnset(COLOR_PREFIX + key, descr); + initDescription(COLOR_PREFIX + key, descr); } /** @@ -1047,8 +1019,10 @@ public abstract class VSPrefs implements Serializable { */ public void copyIntegers(VSPrefs copyInto, String[] keys) { for (String key : keys) - copyInto.initInteger(key, getInteger(key), getDescription(INTEGER_PREFIX + key), - (IntegerSettingRestriction) getRestriction(INTEGER_PREFIX + key)); + copyInto.initLong(key, + getInteger(key), getDescription(INTEGER_PREFIX + key), + (IntegerSettingRestriction) getRestriction(INTEGER_PREFIX + key), + getUnit(INTEGER_PREFIX + key)); } /** @@ -1059,7 +1033,9 @@ public abstract class VSPrefs implements Serializable { */ public void copyLongs(VSPrefs copyInto, String[] keys) { for (String key : keys) - copyInto.initLong(key, getLong(key), getDescription(LONG_PREFIX + key)); + copyInto.initLong(key, getLong(key), + getDescription(LONG_PREFIX + key), + getUnit(LONG_PREFIX + key)); } /** @@ -1070,7 +1046,9 @@ public abstract class VSPrefs implements Serializable { */ public void copyFloats(VSPrefs copyInto, String[] keys) { for (String key : keys) - copyInto.initFloat(key, getFloat(key), getDescription(FLOAT_PREFIX + key)); + copyInto.initFloatInteger(key, getFloat(key), + getDescription(FLOAT_PREFIX + key), + getUnit(FLOAT_PREFIX + key)); } /** @@ -1081,7 +1059,8 @@ public abstract class VSPrefs implements Serializable { */ public void copyStrings(VSPrefs copyInto, String[] keys) { for (String key : keys) - copyInto.initString(key, getString(key), getDescription(STRING_PREFIX + key)); + copyInto.initString(key, getString(key), + getDescription(STRING_PREFIX + key)); } /** @@ -1095,6 +1074,17 @@ public abstract class VSPrefs implements Serializable { copyInto.initColor(key, getColor(key), getDescription(COLOR_PREFIX + key)); } + /** + * Copy colors. + * + * @param copyInto the copy into + * @param keys the keys + */ + public void copyBooleans(VSPrefs copyInto, String[] keys) { + for (String key : keys) + copyInto.initBoolean(key, getBoolean(key), getDescription(BOOLEAN_PREFIX + key)); + } + /* (non-Javadoc) * @see java.lang.Object#toString() */ diff --git a/sources/prefs/editors/VSEditor.java b/sources/prefs/editors/VSEditor.java index 0264e2b..35bacea 100644 --- a/sources/prefs/editors/VSEditor.java +++ b/sources/prefs/editors/VSEditor.java @@ -256,12 +256,12 @@ public abstract class VSEditor implements ActionListener { * * @return the j panel */ - private JPanel createUnitPanel(Component comp, String key) { + private JPanel createUnitPanel(VSPrefs prefsToEdit, Component comp, String fullKey) { JPanel unitPanel = new JPanel(new GridBagLayout()); unitPanel.setBackground(Color.WHITE); unitPanel.setBorder(null); - String unitText = prefs.getUnit(key); + String unitText = prefsToEdit.getUnit(fullKey); if (unitText == null) unitText = ""; @@ -327,7 +327,8 @@ public abstract class VSEditor implements ActionListener { valComboBox.addItem(new Integer(i)); valComboBox.setBorder(null); - return new VSTupel<String,Component,JComboBox>(label, createUnitPanel(valComboBox, fullKey), valComboBox); + return new VSTupel<String,Component,JComboBox>(label, + createUnitPanel(prefsToEdit, valComboBox, fullKey), valComboBox); } /** @@ -346,7 +347,8 @@ public abstract class VSEditor implements ActionListener { JCheckBox valField = new JCheckBox(activated, prefsToEdit.getBoolean(key)); valField.setBackground(Color.WHITE); valField.setBorder(null); - return new VSTupel<String,Component,JCheckBox>(label, createUnitPanel(valField, fullKey), valField); + return new VSTupel<String,Component,JCheckBox>(label, + createUnitPanel(prefsToEdit, valField, fullKey), valField); } /** @@ -371,7 +373,8 @@ public abstract class VSEditor implements ActionListener { }); valField.setText(""+prefsToEdit.getLong(key)); valField.setBorder(null); - return new VSTupel<String,Component,JTextField>(label, createUnitPanel(valField, fullKey), valField); + return new VSTupel<String,Component,JTextField>(label, + createUnitPanel(prefsToEdit, valField, fullKey), valField); } /** @@ -396,7 +399,8 @@ public abstract class VSEditor implements ActionListener { }); valField.setText(""+prefsToEdit.getFloat(key)); valField.setBorder(null); - return new VSTupel<String,Component,JTextField>(label, createUnitPanel(valField, fullKey), valField); + return new VSTupel<String,Component,JTextField>(label, + createUnitPanel(prefsToEdit, valField, fullKey), valField); } /** @@ -437,7 +441,8 @@ public abstract class VSEditor implements ActionListener { } }); valField.setBorder(null); - return new VSTupel<String,Component,JTextField>(label, createUnitPanel(valField, fullKey), valField); + return new VSTupel<String,Component,JTextField>(label, + createUnitPanel(prefsToEdit, valField, fullKey), valField); } /** @@ -462,7 +467,8 @@ public abstract class VSEditor implements ActionListener { }); valField.setText(prefsToEdit.getString(key)); valField.setBorder(null); - return new VSTupel<String,Component,JTextField>(label, createUnitPanel(valField, fullKey), valField); + return new VSTupel<String,Component,JTextField>(label, + createUnitPanel(prefsToEdit, valField, fullKey), valField); } /** diff --git a/sources/protocols/implementations/BerkelyTimeProtocol.java b/sources/protocols/implementations/BerkelyTimeProtocol.java index 6241cd4..c4ce772 100644 --- a/sources/protocols/implementations/BerkelyTimeProtocol.java +++ b/sources/protocols/implementations/BerkelyTimeProtocol.java @@ -38,7 +38,7 @@ public class BerkelyTimeProtocol extends VSProtocol { setClassname(getClass().toString()); /* Those prefs are editable through the VSProtocol VSEditor GUI. t_min and t_max in milliseconds */ - setInteger("numProcesses", 0); + initLong("numProcesses", 0, "Anzahl beteilitger Prozesse"); } /* (non-Javadoc) diff --git a/sources/protocols/implementations/InternalTimeSyncProtocol.java b/sources/protocols/implementations/InternalTimeSyncProtocol.java index f6c4afa..2e1c013 100644 --- a/sources/protocols/implementations/InternalTimeSyncProtocol.java +++ b/sources/protocols/implementations/InternalTimeSyncProtocol.java @@ -24,8 +24,8 @@ public class InternalTimeSyncProtocol extends VSProtocol { setClassname(getClass().toString()); /* Those prefs are editable through the VSProtocol VSEditor GUI. t_min and t_max in milliseconds */ - setLong("t_min", 500); - setLong("t_max", 2000); + initLong("t_min", 500, "Max. Übetragungszeit", "ms"); + initLong("t_max", 2000, "Min. Übertragungszeit", "ms"); } /* (non-Javadoc) |
