summaryrefslogtreecommitdiff
path: root/sources/utils
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2008-05-29 20:30:46 +0000
committerPaul Buetow <paul@buetow.org>2008-05-29 20:30:46 +0000
commitdf1dbe48b99a5c86345a58d6da5727cb39547727 (patch)
tree6f3a83225f47592e94b1a1ba9953707f348ad21f /sources/utils
parenta4d12944746dcb4f9d1140dfd52c7d58b930c17d (diff)
new package documented.
Diffstat (limited to 'sources/utils')
-rw-r--r--sources/utils/2DOCUMENT0
-rw-r--r--sources/utils/VSAbout.java46
-rw-r--r--sources/utils/VSClassLoader.java11
-rw-r--r--sources/utils/VSFrame.java25
-rw-r--r--sources/utils/VSInfoArea.java15
-rw-r--r--sources/utils/VSPriorityQueue.java11
-rw-r--r--sources/utils/VSRandom.java12
-rw-r--r--sources/utils/VSTools.java12
-rw-r--r--sources/utils/VSTupel.java8
9 files changed, 82 insertions, 58 deletions
diff --git a/sources/utils/2DOCUMENT b/sources/utils/2DOCUMENT
deleted file mode 100644
index e69de29..0000000
--- a/sources/utils/2DOCUMENT
+++ /dev/null
diff --git a/sources/utils/VSAbout.java b/sources/utils/VSAbout.java
index 5aca9a3..7580b6c 100644
--- a/sources/utils/VSAbout.java
+++ b/sources/utils/VSAbout.java
@@ -11,27 +11,30 @@ import javax.swing.*;
import prefs.*;
import utils.*;
-// TODO: Auto-generated Javadoc
/**
- * The Class VSAbout.
+ * The Class VSAbout. This class is only for the about window which shows up
+ * if selected in the GUI.
+ *
+ * @author Paul C. Buetow
*/
-public class VSAbout extends VSFrame implements ActionListener {
+public class VSAbout extends VSFrame {
+ /** The serial version uid */
private static final long serialVersionUID = 1L;
/** The prefs. */
private VSPrefs prefs;
/**
- * Instantiates a new lang.process.removeabout.
+ * Instantiates a new VSAbout object.
*
* @param prefs the prefs
- * @param relativeTo the relative to
+ * @param relativeTo the component to open the about window relative to
*/
public VSAbout(VSPrefs prefs, Component relativeTo) {
super(prefs.getString("lang.name") + " - "
+ prefs.getString("lang.about"), relativeTo);
-
this.prefs = prefs;
+
disposeWithParent();
setContentPane(createContentPane());
setSize(350, 250);
@@ -39,7 +42,6 @@ public class VSAbout extends VSFrame implements ActionListener {
setVisible(true);
}
-
/**
* Creates the content pane.
*
@@ -48,8 +50,9 @@ public class VSAbout extends VSFrame implements ActionListener {
public Container createContentPane() {
Container contentPane = getContentPane();
- VSInfoArea infoArea = new VSInfoArea(prefs.getString("lang.about.info!"));
- JPanel buttonPane = createButtonPane();
+ VSInfoArea infoArea = new VSInfoArea(
+ prefs.getString("lang.about.info!"));
+ JPanel buttonPane = createButtonPanel();
JScrollPane scrollPane = new JScrollPane(infoArea);
contentPane.add(scrollPane, BorderLayout.CENTER);
@@ -59,31 +62,26 @@ public class VSAbout extends VSFrame implements ActionListener {
}
/**
- * Creates the button pane.
+ * Creates the button panel.
*
- * @return the j panel
+ * @return the panel
*/
- public JPanel createButtonPane() {
+ public JPanel createButtonPanel() {
JPanel buttonPane = new JPanel();
buttonPane.setBackground(Color.WHITE);
JButton closeButton = new JButton(
prefs.getString("lang.close"));
closeButton.setMnemonic(prefs.getInteger("keyevent.close"));
- closeButton.addActionListener(this);
+ closeButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ String actionCommand = e.getActionCommand();
+ if (actionCommand.equals(prefs.getString("lang.close")))
+ dispose();
+ }
+ });
buttonPane.add(closeButton);
return buttonPane;
}
-
-
- /* (non-Javadoc)
- * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
- */
- public void actionPerformed(ActionEvent e) {
- String actionCommand = e.getActionCommand();
-
- if (actionCommand.equals(prefs.getString("lang.close")))
- dispose();
- }
}
diff --git a/sources/utils/VSClassLoader.java b/sources/utils/VSClassLoader.java
index 60b3c9d..8e7e860 100644
--- a/sources/utils/VSClassLoader.java
+++ b/sources/utils/VSClassLoader.java
@@ -4,17 +4,18 @@
*/
package utils;
-
-
-// TODO: Auto-generated Javadoc
/**
- * The Class VSClassLoader.
+ * The Class VSClassLoader. This class is used in order to create new objects
+ * by its classnames.
+ *
+ * @author Paul C. Buetow
*/
public class VSClassLoader extends ClassLoader {
+ /** The serial version uid */
private static final long serialVersionUID = 1L;
/**
- * New instance.
+ * Creates a new instance of the given classname.
*
* @param classname the classname
*
diff --git a/sources/utils/VSFrame.java b/sources/utils/VSFrame.java
index 25c84e6..06a6958 100644
--- a/sources/utils/VSFrame.java
+++ b/sources/utils/VSFrame.java
@@ -8,11 +8,15 @@ import java.awt.*;
import java.awt.event.*;
import javax.swing.JFrame;
-// TODO: Auto-generated Javadoc
/**
- * The Class VSFrame.
+ * The Class VSFrame. All frames of the simulator extend this VSFrame class.
+ * This class makes sure that all 'subwindows' get closed if its parent gets
+ * closed. And it also makes sure to open new windows relative to its parent.
+ *
+ * @author Paul C. Buetow
*/
public class VSFrame extends JFrame {
+ /** The serial version uid */
private static final long serialVersionUID = 1L;
/** The Constant X_LOCATION_OFFSET. */
@@ -21,14 +25,14 @@ public class VSFrame extends JFrame {
/** The Constant Y_LOCATION_OFFSET. */
private final static int Y_LOCATION_OFFSET = 80;
- /** The parent. */
+ /** The parent window/component. */
private Component parent;
- /** The dispose. */
+ /** True, if the current window will get disposed with its parent. */
private boolean dispose;
/**
- * Instantiates a new lang.process.removeframe.
+ * Instantiates a VSFrame object.
*
* @param title the title
* @param parent the parent
@@ -39,7 +43,7 @@ public class VSFrame extends JFrame {
}
/**
- * Instantiates a new lang.process.removeframe.
+ * Instantiates a new VSFrame object.
*
* @param title the title
*/
@@ -49,7 +53,7 @@ public class VSFrame extends JFrame {
}
/**
- * Inits the.
+ * Inits the VSFrame.
*
* @param parent the parent
*/
@@ -59,7 +63,7 @@ public class VSFrame extends JFrame {
}
/**
- * Dispose with parent.
+ * Dispose with its parent.
*/
public void disposeWithParent() {
if (!dispose && parent != null && parent instanceof Window) {
@@ -74,11 +78,12 @@ public class VSFrame extends JFrame {
}
/**
- * Sets the correct location.
+ * Sets the correct location of the window.
*/
private void setCorrectLocation() {
int x = 0, y = 0;
- final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+ final Dimension screenSize =
+ Toolkit.getDefaultToolkit().getScreenSize();
if (parent == null) {
x = (int) (screenSize.width - getWidth()) / 2;
diff --git a/sources/utils/VSInfoArea.java b/sources/utils/VSInfoArea.java
index f6b4499..1652f04 100644
--- a/sources/utils/VSInfoArea.java
+++ b/sources/utils/VSInfoArea.java
@@ -8,24 +8,27 @@ import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
-// TODO: Auto-generated Javadoc
/**
- * The Class VSInfoArea.
+ * The Class VSInfoArea. An object of this class is used for some information
+ *areas. E.g. in the VSAbout class.
+ *
+ * @author Paul C. Buetow
*/
public class VSInfoArea extends JTextPane {
+ /** The serial version uid */
private static final long serialVersionUID = 1L;
/**
- * Instantiates a new lang.process.removeinfo area.
+ * Instantiates a new VSInfoArea.
*/
public VSInfoArea() {
init();
}
/**
- * Instantiates a new lang.process.removeinfo area.
+ * Instantiates a new VSInfoArea.
*
- * @param text the text
+ * @param text the text to display
*/
public VSInfoArea(String text) {
setText(text);
@@ -33,7 +36,7 @@ public class VSInfoArea extends JTextPane {
}
/**
- * Inits the.
+ * Inits the info area.
*/
private void init() {
setOpaque(false);
diff --git a/sources/utils/VSPriorityQueue.java b/sources/utils/VSPriorityQueue.java
index 5b6b765..b320c1d 100644
--- a/sources/utils/VSPriorityQueue.java
+++ b/sources/utils/VSPriorityQueue.java
@@ -7,17 +7,22 @@ package utils;
import java.util.PriorityQueue;
/**
- * The Class VSPriorityQueue.
+ * The Class VSPriorityQueue. This class is the same like the standard
+ * VSPriorityQueue of the Java API. It only overrides the get(int) method.
+ *
+ * @author Paul C. Buetow
*/
public final class VSPriorityQueue<T> extends PriorityQueue<T> {
+ /** The serial version uid */
private static final long serialVersionUID = 1L;
/**
- * Gets the element.
+ * Gets the specific element. If the index is out of bounds, it will return
+ * null.
*
* @param index the index
*
- * @return the element.
+ * @return the element, or null, if out of bounds
*/
public T get(int index) {
int i = 0;
diff --git a/sources/utils/VSRandom.java b/sources/utils/VSRandom.java
index 8881aeb..5a6391a 100644
--- a/sources/utils/VSRandom.java
+++ b/sources/utils/VSRandom.java
@@ -6,17 +6,19 @@ package utils;
import java.util.Random;
-// TODO: Auto-generated Javadoc
/**
- * The Class VSRandom.
+ * The Class VSRandom. Some customization of the standard Random class of Java.
+ *
+ * @author Paul C. Buetow
*/
public final class VSRandom extends Random {
+ /** The serial version uid */
private static final long serialVersionUID = 1L;
/**
- * Instantiates a new lang.process.removerandom.
+ * Instantiates a new VSrandom object.
*
- * @param seedAdd the seed add
+ * @param seedAdd the seed to add.
*/
public VSRandom(long seedAdd) {
super(seedAdd*System.currentTimeMillis()+seedAdd);
@@ -34,7 +36,7 @@ public final class VSRandom extends Random {
*
* @param mod the mod
*
- * @return the long
+ * @return the random long
*/
public long nextLong(long mod) {
return Math.abs((super.nextLong() + System.currentTimeMillis()) % mod);
diff --git a/sources/utils/VSTools.java b/sources/utils/VSTools.java
index 1a8338e..7f2f00e 100644
--- a/sources/utils/VSTools.java
+++ b/sources/utils/VSTools.java
@@ -7,9 +7,13 @@ package utils;
import java.util.Vector;
/**
- * The Class VSTools.
+ * The Class VSTools. This class contains only static methods. Those methods
+ * are for general usage and don't fit into other classes.
+ *
+ * @author Paul C. Buetow
*/
public final class VSTools {
+ /** The serial version uid */
private static final long serialVersionUID = 1L;
/**
@@ -38,7 +42,8 @@ public final class VSTools {
public static long getStringTime(String string) {
try {
/* Ignore the "ms" postfix */
- Long longValue = Long.valueOf(string.substring(0, string.length()-2));
+ Long longValue = Long.valueOf(
+ string.substring(0, string.length()-2));
return longValue.longValue();
} catch (NumberFormatException e) {
}
@@ -47,7 +52,7 @@ public final class VSTools {
}
/**
- * Gets the integer vector represented by a string comma separated.
+ * Gets the integer vector represented by a comma separated string.
*
* @param string the string
*
@@ -80,6 +85,7 @@ public final class VSTools {
vec.add(Integer.parseInt(substring));
string = string.substring(index+1);
}
+
/* Remove leading whitespaces */
while (string.charAt(0) == ' ')
string = string.substring(1);
diff --git a/sources/utils/VSTupel.java b/sources/utils/VSTupel.java
index 144b981..cb903f4 100644
--- a/sources/utils/VSTupel.java
+++ b/sources/utils/VSTupel.java
@@ -5,9 +5,13 @@
package utils;
/**
- * The Class VSTupel.
+ * The Class VSTupel. An object of this class represents a 3-Tupel of objects.
+ * Each object can have its own type.
+ *
+ * @author Paul C. Buetow
*/
public final class VSTupel<A,B,C> {
+ /** The serial version uid */
private static final long serialVersionUID = 1L;
/** The a. */
@@ -20,7 +24,7 @@ public final class VSTupel<A,B,C> {
private C c;
/**
- * Instantiates a new lang.process.removetupel.
+ * Instantiates a new tupel.
*
* @param a the a
* @param b the b