diff options
| author | Paul Buetow <paul@buetow.org> | 2008-06-11 09:48:10 +0000 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2008-06-11 09:48:10 +0000 |
| commit | 0e2e70d5a393024f3ae4a3a3560b4df51075000a (patch) | |
| tree | 27c659d282bec3508304d5fa80a34a1662185950 /sources/prefs | |
| parent | 412a1ac0e6311fe39452ae41b6eada4ef17cce34 (diff) | |
More javadoc.
Several bugfixes.
New feauture: Boolean: sim.periodic
A lot of more which i forgot!
Diffstat (limited to 'sources/prefs')
| -rw-r--r-- | sources/prefs/2DOCUMENT | 0 | ||||
| -rw-r--r-- | sources/prefs/VSDefaultPrefs.java | 8 | ||||
| -rw-r--r-- | sources/prefs/VSPrefs.java | 78 | ||||
| -rw-r--r-- | sources/prefs/VSPrefsRestriction.java | 6 | ||||
| -rw-r--r-- | sources/prefs/editors/2DOCUMENT | 0 | ||||
| -rw-r--r-- | sources/prefs/editors/VSAbstractBetterEditor.java | 21 | ||||
| -rw-r--r-- | sources/prefs/editors/VSAbstractEditor.java | 227 | ||||
| -rw-r--r-- | sources/prefs/editors/VSColorChooser.java | 15 | ||||
| -rw-r--r-- | sources/prefs/editors/VSEditorFrame.java | 19 | ||||
| -rw-r--r-- | sources/prefs/editors/VSEditorTable.java | 76 | ||||
| -rw-r--r-- | sources/prefs/editors/VSProcessEditor.java | 37 | ||||
| -rw-r--r-- | sources/prefs/editors/VSSimulatorEditor.java | 21 |
12 files changed, 308 insertions, 200 deletions
diff --git a/sources/prefs/2DOCUMENT b/sources/prefs/2DOCUMENT deleted file mode 100644 index e69de29..0000000 --- a/sources/prefs/2DOCUMENT +++ /dev/null diff --git a/sources/prefs/VSDefaultPrefs.java b/sources/prefs/VSDefaultPrefs.java index bbf3c5f..e8ac8b5 100644 --- a/sources/prefs/VSDefaultPrefs.java +++ b/sources/prefs/VSDefaultPrefs.java @@ -27,9 +27,14 @@ import java.awt.Color; import java.awt.event.KeyEvent; /** - * The class VSDefaultPrefs. + * The class VSDefaultPrefs, makes sure that the simulator has its default + * configuration values. (Btw: This is the only class which is allowed to have + * code lines which are longer than 80 chars!) + * + * @author Paul C. Buetow */ public class VSDefaultPrefs extends VSPrefs { + /** The serial version uid */ private static final long serialVersionUID = 1L; /** @@ -256,5 +261,6 @@ public class VSDefaultPrefs extends VSPrefs { initBoolean("sim.message.own.recv", false, "Prozesse empfangen eigene Nachrichten"); initBoolean("sim.message.prob.mean", true, "Mittelwerte der Nachrichtausfallw'k. bilden"); initBoolean("sim.messages.relevant", true, "Nur alle relevanten Nachrichten ausliefern"); + initBoolean("sim.periodic", false, "Simulation periodisch wiederholen"); } } diff --git a/sources/prefs/VSPrefs.java b/sources/prefs/VSPrefs.java index f17732c..e9ede88 100644 --- a/sources/prefs/VSPrefs.java +++ b/sources/prefs/VSPrefs.java @@ -30,7 +30,10 @@ import java.util.*; import serialize.*; /** - * The class VSPrefs. + * 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 implements VSSerializable { /** The Constant BOOLEAN_PREFIX. */ @@ -90,9 +93,6 @@ public class VSPrefs implements VSSerializable { /** The Constant serialVersionUID. */ private static final long serialVersionUID = 4L; - /** The Constant PREFERENCES_FILENAME. */ - protected final static String PREFERENCES_FILENAME = "vs.dat"; - /** The id counter. */ private static int idCounter; @@ -201,7 +201,8 @@ public class VSPrefs implements VSSerializable { * @param key the key * @param settingRestriction the setting restriction */ - public synchronized void initRestriction(String key, VSPrefsRestriction settingRestriction) { + public synchronized void initRestriction(String key, + VSPrefsRestriction settingRestriction) { restrictions.put(key, settingRestriction); } @@ -589,7 +590,8 @@ public class VSPrefs implements VSSerializable { * @param descr the descr * @param r the restriction */ - public void initInteger(String key, int val, String descr, VSPrefsRestriction.VSIntegerPrefRestriction r) { + public void initInteger(String key, int val, String descr, + VSPrefsRestriction.VSIntegerPrefsRestriction r) { initInteger(key, val, descr); initRestriction(INTEGER_PREFIX + key, r); } @@ -602,7 +604,9 @@ public class VSPrefs implements VSSerializable { * @param descr the descr * @param r the restriction */ - public void initInteger(String key, int val, String descr, VSPrefsRestriction.VSIntegerPrefRestriction r, String unit) { + public void initInteger(String key, int val, String descr, + VSPrefsRestriction.VSIntegerPrefsRestriction r, + String unit) { initInteger(key, val, descr, r); initUnit(INTEGER_PREFIX + key, unit); } @@ -616,9 +620,11 @@ public class VSPrefs implements VSSerializable { * @param minValue the min value * @param maxValue the max value */ - public void initInteger(String key, int val, String descr, int minValue, int maxValue) { + public void initInteger(String key, int val, String descr, int minValue, + int maxValue) { initInteger(key, val, descr, - new VSPrefsRestriction.VSIntegerPrefRestriction(minValue, maxValue)); + new VSPrefsRestriction.VSIntegerPrefsRestriction( + minValue, maxValue)); } /** @@ -631,7 +637,8 @@ public class VSPrefs implements VSSerializable { * @param maxValue the max value * @param unit the unit */ - public void initInteger(String key, int val, String descr, int minValue, int maxValue, String 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); } @@ -716,7 +723,8 @@ public class VSPrefs implements VSSerializable { * @param val the val * @param descr the descr */ - public void initVector(String key, Vector<Integer> val, String descr, String unit) { + public void initVector(String key, Vector<Integer> val, String descr, + String unit) { initVector(key, val, descr); initUnit(VECTOR_PREFIX + key, unit); } @@ -932,11 +940,6 @@ public class VSPrefs implements VSSerializable { */ public void fillWithDefaults() {} - @SuppressWarnings("unchecked") - public synchronized void readObject(ObjectInputStream objectInputStream) - throws IOException, ClassNotFoundException { - } - /* (non-Javadoc) * @see serialize.VSSerializable#serialize(serialize.VSSerialize, * java.io.ObjectOutputStream) @@ -974,16 +977,23 @@ public class VSPrefs implements VSSerializable { /** For later backwards compatibility, to add more stuff */ objectInputStream.readObject(); - booleanPrefs = (HashMap<String,Boolean>) objectInputStream.readObject(); - colorPrefs = (HashMap<String,Color>) objectInputStream.readObject(); + booleanPrefs = (HashMap<String,Boolean>) + objectInputStream.readObject(); + colorPrefs = (HashMap<String,Color>) + objectInputStream.readObject(); descriptionPrefs = (HashMap<String,String>) objectInputStream.readObject(); - floatPrefs = (HashMap<String,Float>) objectInputStream.readObject(); - integerPrefs = (HashMap<String,Integer>) objectInputStream.readObject(); - longPrefs = (HashMap<String,Long>) objectInputStream.readObject(); + floatPrefs = (HashMap<String,Float>) + objectInputStream.readObject(); + integerPrefs = (HashMap<String,Integer>) + objectInputStream.readObject(); + longPrefs = (HashMap<String,Long>) + objectInputStream.readObject(); restrictions = new HashMap<String,VSPrefsRestriction>(); - stringPrefs = (HashMap<String,String>) objectInputStream.readObject(); - units = (HashMap<String,String>) objectInputStream.readObject(); + stringPrefs = (HashMap<String,String>) + objectInputStream.readObject(); + units = (HashMap<String,String>) + objectInputStream.readObject(); vectorPrefs = (HashMap<String,Vector<Integer>>) objectInputStream.readObject(); @@ -992,7 +1002,7 @@ public class VSPrefs implements VSSerializable { } /** - * Copy integers. + * Copies integers into another VSPrefs object. * * @param copyInto the copy into * @param keys the keys @@ -1002,13 +1012,13 @@ public class VSPrefs implements VSSerializable { copyInto.initInteger(key, getInteger(key), getDescription(INTEGER_PREFIX + key), - (VSPrefsRestriction.VSIntegerPrefRestriction) + (VSPrefsRestriction.VSIntegerPrefsRestriction) getRestriction(INTEGER_PREFIX + key), getUnit(INTEGER_PREFIX + key)); } /** - * Copy longs. + * Copies longs into another VSPrefs object. * * @param copyInto the copy into * @param keys the keys @@ -1021,7 +1031,7 @@ public class VSPrefs implements VSSerializable { } /** - * Copy floats. + * Copies floats into another VSPrefs object. * * @param copyInto the copy into * @param keys the keys @@ -1034,7 +1044,7 @@ public class VSPrefs implements VSSerializable { } /** - * Copy strings. + * Copies strings into another VSPrefs object. * * @param copyInto the copy into * @param keys the keys @@ -1046,7 +1056,7 @@ public class VSPrefs implements VSSerializable { } /** - * Copy colors. + * Copies color references into another VSPrefs object. * * @param copyInto the copy into * @param keys the keys @@ -1058,7 +1068,7 @@ public class VSPrefs implements VSSerializable { } /** - * Copy colors. + * Copies colors. * * @param copyInto the copy into * @param keys the keys @@ -1135,9 +1145,9 @@ public class VSPrefs implements VSSerializable { } /** - * Checks if is empty. + * Checks if the prefs are empty. * - * @return true, if is empty + * @return true, if empty */ public boolean isEmpty() { if (!colorPrefs.isEmpty()) @@ -1165,9 +1175,9 @@ public class VSPrefs implements VSSerializable { } /** - * Return all full keys + * Returns all full keys. * - * @return Allf ull keys + * @return All full keys */ public ArrayList<String> getAllFullKeys() { ArrayList<String> allKeys = new ArrayList<String>(); diff --git a/sources/prefs/VSPrefsRestriction.java b/sources/prefs/VSPrefsRestriction.java index 5a716bd..f66246c 100644 --- a/sources/prefs/VSPrefsRestriction.java +++ b/sources/prefs/VSPrefsRestriction.java @@ -33,9 +33,9 @@ public class VSPrefsRestriction implements Serializable { private static final long serialVersionUID = 1L; /** - * The class VSIntegerPrefRestriction. + * The class VSIntegerPrefsRestriction. */ - public static class VSIntegerPrefRestriction extends VSPrefsRestriction { + public static class VSIntegerPrefsRestriction extends VSPrefsRestriction { private static final long serialVersionUID = 1L; /** The min value. */ private int minValue; @@ -49,7 +49,7 @@ public class VSPrefsRestriction implements Serializable { * @param minValue the min value * @param maxValue the max value */ - public VSIntegerPrefRestriction(int minValue, int maxValue) { + public VSIntegerPrefsRestriction(int minValue, int maxValue) { this.minValue = minValue; this.maxValue = maxValue; } diff --git a/sources/prefs/editors/2DOCUMENT b/sources/prefs/editors/2DOCUMENT deleted file mode 100644 index e69de29..0000000 --- a/sources/prefs/editors/2DOCUMENT +++ /dev/null diff --git a/sources/prefs/editors/VSAbstractBetterEditor.java b/sources/prefs/editors/VSAbstractBetterEditor.java index 47ae1a7..8779e56 100644 --- a/sources/prefs/editors/VSAbstractBetterEditor.java +++ b/sources/prefs/editors/VSAbstractBetterEditor.java @@ -30,11 +30,13 @@ import javax.swing.*; import prefs.*; import utils.*; -// TODO: Auto-generated Javadoc /** - * The class VSAbstractBetterEditor. + * The class VSAbstractBetterEditor, is an improved VSAbstractEditor. + * + * @author Paul C. Buetow */ public abstract class VSAbstractBetterEditor extends VSAbstractEditor { + /** The serial version uid */ private static final long serialVersionUID = 1L; /** The content pane. */ @@ -47,13 +49,14 @@ public abstract class VSAbstractBetterEditor extends VSAbstractEditor { private String title; /** - * Instantiates a new lang.process.removebetter editor. + * An simple constructor. * * @param prefs the prefs * @param prefsToEdit the prefs to edit * @param title the title */ - public VSAbstractBetterEditor(VSPrefs prefs, VSPrefs prefsToEdit, String title) { + public VSAbstractBetterEditor(VSPrefs prefs, VSPrefs prefsToEdit, + String title) { super(prefs, prefsToEdit); this.title = title; this.contentPane = createContentPane(); @@ -100,12 +103,14 @@ public abstract class VSAbstractBetterEditor extends VSAbstractEditor { } /* (non-Javadoc) - * @see prefs.editors.VSAbstractEditor#addToButtonPanelFront(javax.swing.JPanel) + * @see prefs.editors.VSAbstractEditor#addToButtonPanelFront( + * javax.swing.JPanel) */ protected void addToButtonPanelFront(JPanel buttonPanel) { } /* (non-Javadoc) - * @see prefs.editors.VSAbstractEditor#addToButtonPanelLast(javax.swing.JPanel) + * @see prefs.editors.VSAbstractEditor#addToButtonPanelLast( + * javax.swing.JPanel) */ protected void addToButtonPanelLast(JPanel buttonPanel) { } @@ -115,11 +120,11 @@ public abstract class VSAbstractBetterEditor extends VSAbstractEditor { protected void addToEditTableLast() { } /* (non-Javadoc) - * @see prefs.editors.VSAbstractEditor#actionPerformed(java.awt.event.ActionEvent) + * @see prefs.editors.VSAbstractEditor#actionPerformed( + * java.awt.event.ActionEvent) */ public void actionPerformed(ActionEvent e) { //String actionCommand = e.getActionCommand(); - /* More action in the super class!!! */ super.actionPerformed(e); } diff --git a/sources/prefs/editors/VSAbstractEditor.java b/sources/prefs/editors/VSAbstractEditor.java index f4d913a..a3f5fe3 100644 --- a/sources/prefs/editors/VSAbstractEditor.java +++ b/sources/prefs/editors/VSAbstractEditor.java @@ -31,11 +31,14 @@ import java.util.*; import utils.*; import prefs.*; -// TODO: Auto-generated Javadoc /** - * The class VSAbstractEditor. + * The class VSAbstractEditor, an object of this class is used in order to + * edit a VSPrefs object. + * + * @author Paul C. Buetow */ public abstract class VSAbstractEditor implements ActionListener { + /** The serial version uid */ private static final long serialVersionUID = 1L; /** The boolean keys. */ @@ -117,7 +120,7 @@ public abstract class VSAbstractEditor implements ActionListener { public static final int SIMULATION_PREFERENCES = 1; /** - * Instantiates a new lang.process.removeeditor. + * The standard constructor. * * @param prefs the prefs * @param prefsToEdit the prefs to edit @@ -127,14 +130,14 @@ public abstract class VSAbstractEditor implements ActionListener { } /** - * Adds the to button panel front. + * Adds components to the front of the button panel . * * @param buttonPanel the button panel */ abstract protected void addToButtonPanelFront(JPanel buttonPanel); /** - * Adds the to button panel last. + * Adds components to last of the button panel. * * @param buttonPanel the button panel */ @@ -146,7 +149,7 @@ public abstract class VSAbstractEditor implements ActionListener { abstract protected void addToEditTableLast(); /** - * Sets the prefs. + * Sets the default prefs. * * @param prefs the new prefs */ @@ -164,7 +167,7 @@ public abstract class VSAbstractEditor implements ActionListener { } /** - * Sets the frame. + * Sets the frame being used by the editor, if any. * * @param frame the new frame */ @@ -182,7 +185,8 @@ public abstract class VSAbstractEditor implements ActionListener { } /** - * Dispose frame if exists. + * The given editors frame will get disposed if the "OK" button has been + * pressed. This can only happen if the editor has its own frame. */ protected void disposeFrameIfExists() { if (frame != null) @@ -190,7 +194,8 @@ public abstract class VSAbstractEditor implements ActionListener { } /** - * Dispose frame with parent if exists. + * The given editors frame will get disposed if its parent component + * disposes. This can only happen if the editor has its own frame. */ protected void disposeFrameWithParentIfExists() { if (frame != null) @@ -198,7 +203,7 @@ public abstract class VSAbstractEditor implements ActionListener { } /** - * Inits the. + * Inits the editor. * * @param prefs the prefs * @param prefsToEdit the prefs to edit @@ -232,11 +237,11 @@ public abstract class VSAbstractEditor implements ActionListener { } /** - * Filter keys. + * Filters out all keys to edit. * - * @param set the set + * @param set the set which contains all keys of a given hash * - * @return the array list< string> + * @return the filtered keys */ private ArrayList<String> filterKeys(Set<String> set) { ArrayList<String> filtered = new ArrayList<String>(); @@ -257,7 +262,7 @@ public abstract class VSAbstractEditor implements ActionListener { /** * Creates the button panel. * - * @return the j panel + * @return the panel */ private JPanel createButtonPanel() { JPanel buttonPanel = new JPanel(); @@ -281,9 +286,10 @@ public abstract class VSAbstractEditor implements ActionListener { * @param comp the comp * @param key the key * - * @return the j panel + * @return the panel */ - private JPanel createUnitPanel(VSPrefs prefsToEdit, Component comp, String fullKey) { + private JPanel createUnitPanel(VSPrefs prefsToEdit, Component comp, + String fullKey) { JPanel unitPanel = new JPanel(new GridBagLayout()); unitPanel.setBackground(Color.WHITE); unitPanel.setBorder(null); @@ -307,7 +313,7 @@ public abstract class VSAbstractEditor implements ActionListener { /** * Creates the edit panel. * - * @return the j panel + * @return the panel */ private JPanel createEditPanel() { JPanel editPanel = new JPanel(); @@ -328,20 +334,24 @@ public abstract class VSAbstractEditor implements ActionListener { * @param key the key * @param prefsToEdit the prefs to edit * - * @return the lang.process.removetupel< string, component, j combo box> + * @return the tupel representing the component */ - protected VSTupel<String,Component,JComboBox> createIntegerComponent(String fullKey, String key, VSPrefs prefsToEdit) { + protected VSTupel<String,Component,JComboBox> createIntegerComponent( + String fullKey, String key, VSPrefs prefsToEdit) { String descr = prefsToEdit.getDescription(fullKey); String label = descr == null ? fullKey : descr; Integer integer = prefsToEdit.getInteger(key); Integer initialSelection[] = { integer }; JComboBox valComboBox = new JComboBox(initialSelection); - VSPrefsRestriction settingRestriction = prefsToEdit.getRestriction(fullKey); + VSPrefsRestriction settingRestriction = + prefsToEdit.getRestriction(fullKey); int minValue, maxValue; if (settingRestriction != null) { - VSPrefsRestriction.VSIntegerPrefRestriction integerVSPrefsRestriction = - (VSPrefsRestriction.VSIntegerPrefRestriction) settingRestriction; + VSPrefsRestriction.VSIntegerPrefsRestriction + integerVSPrefsRestriction = + (VSPrefsRestriction.VSIntegerPrefsRestriction) + settingRestriction; minValue = integerVSPrefsRestriction.getMinValue(); maxValue = integerVSPrefsRestriction.getMaxValue(); @@ -355,7 +365,8 @@ public abstract class VSAbstractEditor implements ActionListener { valComboBox.setBorder(null); return new VSTupel<String,Component,JComboBox>(label, - createUnitPanel(prefsToEdit, valComboBox, fullKey), valComboBox); + createUnitPanel(prefsToEdit, valComboBox, fullKey), + valComboBox); } /** @@ -364,8 +375,11 @@ public abstract class VSAbstractEditor implements ActionListener { * @param fullKey the full key * @param key the key * @param prefsToEdit the prefs to edit + * + * @return the tupel representing the component */ - protected VSTupel<String,Component,JTextField> createVectorComponent(String fullKey, String key, VSPrefs prefsToEdit) { + protected VSTupel<String,Component,JTextField> createVectorComponent( + String fullKey, String key, VSPrefs prefsToEdit) { String descr = prefsToEdit.getDescription(fullKey); String label = descr == null ? fullKey : descr; @@ -385,11 +399,13 @@ public abstract class VSAbstractEditor implements ActionListener { * @param key the key * @param prefsToEdit the prefs to edit */ - protected VSTupel<String,Component,JCheckBox> createBooleanComponent(String fullKey, String key, VSPrefs prefsToEdit) { + protected VSTupel<String,Component,JCheckBox> createBooleanComponent( + String fullKey, String key, VSPrefs prefsToEdit) { final String activated = prefs.getString("lang.activated"); String descr = prefsToEdit.getDescription(fullKey); String label = descr == null ? fullKey : descr; - JCheckBox valField = new JCheckBox(activated, prefsToEdit.getBoolean(key)); + JCheckBox valField = new JCheckBox(activated, + prefsToEdit.getBoolean(key)); valField.setBackground(Color.WHITE); valField.setBorder(null); return new VSTupel<String,Component,JCheckBox>(label, @@ -403,9 +419,10 @@ public abstract class VSAbstractEditor implements ActionListener { * @param key the key * @param prefsToEdit the prefs to edit * - * @return the lang.process.removetupel< string, component, j text field> + * @return the tupel representing the component */ - protected VSTupel<String,Component,JTextField> createLongComponent(String fullKey, String key, VSPrefs prefsToEdit) { + protected VSTupel<String,Component,JTextField> createLongComponent( + String fullKey, String key, VSPrefs prefsToEdit) { String descr = prefsToEdit.getDescription(fullKey); String label = descr == null ? fullKey : descr; JTextField valField = new JTextField(VALUE_FIELD_COLS); @@ -429,9 +446,10 @@ public abstract class VSAbstractEditor implements ActionListener { * @param key the key * @param prefsToEdit the prefs to edit * - * @return the lang.process.removetupel< string, component, j text field> + * @return the tupel representing the component */ - protected VSTupel<String,Component,JTextField> createFloatComponent(String fullKey, String key, VSPrefs prefsToEdit) { + protected VSTupel<String,Component,JTextField> createFloatComponent( + String fullKey, String key, VSPrefs prefsToEdit) { String descr = prefsToEdit.getDescription(fullKey); String label = descr == null ? fullKey : descr; JTextField valField = new JTextField(VALUE_FIELD_COLS); @@ -455,9 +473,10 @@ public abstract class VSAbstractEditor implements ActionListener { * @param key the key * @param prefsToEdit the prefs to edit * - * @return the lang.process.removetupel< string, component, j text field> + * @return the tupel representing the component */ - protected VSTupel<String,Component,JTextField> createColorComponent(String fullKey, String key, final VSPrefs prefsToEdit) { + protected VSTupel<String,Component,JTextField> createColorComponent( + String fullKey, String key, final VSPrefs prefsToEdit) { String descr = prefsToEdit.getDescription(fullKey); String label = descr == null ? fullKey : descr; final JTextField valField = new JTextField(VALUE_FIELD_COLS); @@ -477,7 +496,8 @@ public abstract class VSAbstractEditor implements ActionListener { "lang.colorchooser"),parentFrame); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - JComponent colorChooserPane = new VSColorChooser(prefs, valField); + JComponent colorChooserPane = new VSColorChooser(prefs, + valField); colorChooserPane.setOpaque(true); frame.setContentPane(colorChooserPane); @@ -497,9 +517,10 @@ public abstract class VSAbstractEditor implements ActionListener { * @param key the key * @param prefsToEdit the prefs to edit * - * @return the lang.process.removetupel< string, component, j text field> + * @return the tupel representing the component */ - protected VSTupel<String,Component,JTextField> createStringComponent(String fullKey, String key, VSPrefs prefsToEdit) { + protected VSTupel<String,Component,JTextField> createStringComponent( + String fullKey, String key, VSPrefs prefsToEdit) { String descr = prefsToEdit.getDescription(fullKey); String label = descr == null ? fullKey : descr; JTextField valField = new JTextField(VALUE_FIELD_COLS); @@ -517,7 +538,7 @@ public abstract class VSAbstractEditor implements ActionListener { } /** - * Fill edit panel. + * Fills the edit panel. * * @param prefsToEdit the prefs to edit */ @@ -545,7 +566,8 @@ public abstract class VSAbstractEditor implements ActionListener { for (String key : booleanKeys) { String fullKey = VSPrefs.BOOLEAN_PREFIX + key; - VSTupel<String,Component,JCheckBox> tupel = createBooleanComponent(fullKey, key, prefsToEdit); + VSTupel<String,Component,JCheckBox> tupel = + createBooleanComponent(fullKey, key, prefsToEdit); labels.put(fullKey, tupel.getA()); components.put(fullKey, tupel.getB()); booleanFields.put(key, tupel.getC()); @@ -553,7 +575,8 @@ public abstract class VSAbstractEditor implements ActionListener { for (String key : longKeys) { String fullKey = VSPrefs.LONG_PREFIX + key; - VSTupel<String,Component,JTextField> tupel = createLongComponent(fullKey, key, prefsToEdit); + VSTupel<String,Component,JTextField> tupel = + createLongComponent(fullKey, key, prefsToEdit); labels.put(fullKey, tupel.getA()); components.put(fullKey, tupel.getB()); longFields.put(key, tupel.getC()); @@ -562,7 +585,8 @@ public abstract class VSAbstractEditor implements ActionListener { for (String key : floatKeys) { String fullKey = VSPrefs.FLOAT_PREFIX + key; - VSTupel<String,Component,JTextField> tupel = createFloatComponent(fullKey, key, prefsToEdit); + VSTupel<String,Component,JTextField> tupel = + createFloatComponent(fullKey, key, prefsToEdit); labels.put(fullKey, tupel.getA()); components.put(fullKey, tupel.getB()); floatFields.put(key, tupel.getC()); @@ -571,7 +595,8 @@ public abstract class VSAbstractEditor implements ActionListener { for (String key : colorKeys) { String fullKey = VSPrefs.COLOR_PREFIX + key; - VSTupel<String,Component,JTextField> tupel = createColorComponent(fullKey, key, prefsToEdit); + VSTupel<String,Component,JTextField> tupel = + createColorComponent(fullKey, key, prefsToEdit); labels.put(fullKey, tupel.getA()); components.put(fullKey, tupel.getB()); colorFields.put(key, tupel.getC()); @@ -579,7 +604,8 @@ public abstract class VSAbstractEditor implements ActionListener { for (String key : stringKeys) { String fullKey = VSPrefs.STRING_PREFIX + key; - VSTupel<String,Component,JTextField> tupel = createStringComponent(fullKey, key, prefsToEdit); + VSTupel<String,Component,JTextField> tupel = + createStringComponent(fullKey, key, prefsToEdit); labels.put(fullKey, tupel.getA()); components.put(fullKey, tupel.getB()); stringFields.put(key, tupel.getC()); @@ -597,7 +623,8 @@ public abstract class VSAbstractEditor implements ActionListener { flag = true; addSeparator(prefs.getString("lang.prefs.simulator")); } - addVariable(labels.get(fullKey), components.get(fullKey), prefsToEdit); + addVariable(labels.get(fullKey), components.get(fullKey), + prefsToEdit); } } @@ -610,9 +637,11 @@ public abstract class VSAbstractEditor implements ActionListener { if (this instanceof VSProcessEditor) addSeparator(prefs.getString("lang.prefs.process")); else - addSeparator(prefs.getString("lang.prefs.process.defaults")); + addSeparator(prefs.getString( + "lang.prefs.process.defaults")); } - addVariable(labels.get(fullKey), components.get(fullKey), prefsToEdit); + addVariable(labels.get(fullKey), components.get(fullKey), + prefsToEdit); } } @@ -623,11 +652,14 @@ public abstract class VSAbstractEditor implements ActionListener { if (!flag) { flag = true; if (this instanceof VSProcessEditor) - addSeparator(prefs.getString("lang.prefs.message")); + addSeparator(prefs.getString( + "lang.prefs.message")); else - addSeparator(prefs.getString("lang.prefs.message.defaults")); + addSeparator(prefs.getString( + "lang.prefs.message.defaults")); } - addVariable(labels.get(fullKey), components.get(fullKey), prefsToEdit); + addVariable(labels.get(fullKey), components.get(fullKey), + prefsToEdit); } } @@ -639,7 +671,8 @@ public abstract class VSAbstractEditor implements ActionListener { flag = true; addSeparator(prefs.getString("lang.prefs.color")); } - addVariable(labels.get(fullKey), components.get(fullKey), prefsToEdit); + addVariable(labels.get(fullKey), components.get(fullKey), + prefsToEdit); } } @@ -651,7 +684,8 @@ public abstract class VSAbstractEditor implements ActionListener { flag = true; addSeparator(prefs.getString("lang.prefs.diverse")); } - addVariable(labels.get(fullKey), components.get(fullKey), prefsToEdit); + addVariable(labels.get(fullKey), components.get(fullKey), + prefsToEdit); } } @@ -659,7 +693,18 @@ public abstract class VSAbstractEditor implements ActionListener { editTable.fireTableDataChanged(); } - private ArrayList<String> filterOut(Set<String> set, ArrayList<String> filter, String prefix) { + /** + * Filters out stuff. + * + * @param set The set to filter stuff out from + * @param filter Only return elemens of the filter which are in the set + * @param prefix The prefix to use + * + * @return The filtered keys + */ + private ArrayList<String> filterOut(Set<String> set, + ArrayList<String> filter, + String prefix) { ArrayList<String> ret = new ArrayList<String>(); for (String key : set) { @@ -672,25 +717,39 @@ public abstract class VSAbstractEditor implements ActionListener { } /** - * Adds the to editor. + * Adds the to editor more variables. * * @param label the label * @param prefsKey the prefs key * @param prefsToAdd the prefs to add * @param addOnlyThisVariables only add variables which are in this list */ - protected void addToEditor(String label, String prefsKey, VSPrefs prefsToAdd, ArrayList<String> addOnlyThisVariables) { + protected void addToEditor(String label, String prefsKey, + VSPrefs prefsToAdd, + ArrayList<String> addOnlyThisVariables) { addSeparator(label); prefsKey = "(" + prefsKey + ")"; ArrayList<String> fullKeys = new ArrayList<String>(); - fullKeys.addAll(filterOut(prefsToAdd.getIntegerKeySet(), addOnlyThisVariables, VSPrefs.INTEGER_PREFIX)); - fullKeys.addAll(filterOut(prefsToAdd.getVectorKeySet(), addOnlyThisVariables, VSPrefs.VECTOR_PREFIX)); - fullKeys.addAll(filterOut(prefsToAdd.getFloatKeySet(), addOnlyThisVariables, VSPrefs.FLOAT_PREFIX)); - fullKeys.addAll(filterOut(prefsToAdd.getLongKeySet(), addOnlyThisVariables, VSPrefs.LONG_PREFIX)); - fullKeys.addAll(filterOut(prefsToAdd.getBooleanKeySet(), addOnlyThisVariables, VSPrefs.BOOLEAN_PREFIX)); - fullKeys.addAll(filterOut(prefsToAdd.getStringKeySet(), addOnlyThisVariables, VSPrefs.STRING_PREFIX)); + fullKeys.addAll(filterOut(prefsToAdd.getIntegerKeySet(), + addOnlyThisVariables, + VSPrefs.INTEGER_PREFIX)); + fullKeys.addAll(filterOut(prefsToAdd.getVectorKeySet(), + addOnlyThisVariables, + VSPrefs.VECTOR_PREFIX)); + fullKeys.addAll(filterOut(prefsToAdd.getFloatKeySet(), + addOnlyThisVariables, + VSPrefs.FLOAT_PREFIX)); + fullKeys.addAll(filterOut(prefsToAdd.getLongKeySet(), + addOnlyThisVariables, + VSPrefs.LONG_PREFIX)); + fullKeys.addAll(filterOut(prefsToAdd.getBooleanKeySet(), + addOnlyThisVariables, + VSPrefs.BOOLEAN_PREFIX)); + fullKeys.addAll(filterOut(prefsToAdd.getStringKeySet(), + addOnlyThisVariables, + VSPrefs.STRING_PREFIX)); |
