summaryrefslogtreecommitdiff
path: root/sources/utils
diff options
context:
space:
mode:
Diffstat (limited to 'sources/utils')
-rw-r--r--sources/utils/VS3Tupel.java58
-rw-r--r--sources/utils/VSAboutFrame.java87
-rw-r--r--sources/utils/VSClassLoader.java29
-rw-r--r--sources/utils/VSFrame.java118
-rw-r--r--sources/utils/VSInfoArea.java49
-rw-r--r--sources/utils/VSPriorityQueue.java32
-rw-r--r--sources/utils/VSRandom.java37
-rw-r--r--sources/utils/VSTools.java92
8 files changed, 0 insertions, 502 deletions
diff --git a/sources/utils/VS3Tupel.java b/sources/utils/VS3Tupel.java
deleted file mode 100644
index ac7ffba..0000000
--- a/sources/utils/VS3Tupel.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package utils;
-
-/**
- * The class VS3Tupel, 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 VS3Tupel<A,B,C> {
- /** The a. */
- private A a;
-
- /** The b. */
- private B b;
-
- /** The c. */
- private C c;
-
- /**
- * Instantiates a new tupel.
- *
- * @param a the a
- * @param b the b
- * @param c the c
- */
- public VS3Tupel(A a, B b, C c) {
- this.a = a;
- this.b = b;
- this.c = c;
- }
-
- /**
- * Gets the a.
- *
- * @return the a
- */
- public A getA() {
- return a;
- }
-
- /**
- * Gets the b.
- *
- * @return the b
- */
- public B getB() {
- return b;
- }
-
- /**
- * Gets the c.
- *
- * @return the c
- */
- public C getC() {
- return c;
- }
-}
diff --git a/sources/utils/VSAboutFrame.java b/sources/utils/VSAboutFrame.java
deleted file mode 100644
index e07289f..0000000
--- a/sources/utils/VSAboutFrame.java
+++ /dev/null
@@ -1,87 +0,0 @@
-package utils;
-
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Container;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.JButton;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-
-//import utils.*;
-import prefs.VSPrefs;
-
-/**
- * The class VSAboutFrame. This class is only for the about window which
- * shows up if selected in the GUI.
- *
- * @author Paul C. Buetow
- */
-public class VSAboutFrame extends VSFrame {
- /** The prefs. */
- private VSPrefs prefs;
-
- /**
- * Instantiates a new VSAboutFrame object.
- *
- * @param prefs the prefs
- * @param relativeTo the component to open the about window relative to
- */
- public VSAboutFrame(VSPrefs prefs, Component relativeTo) {
- super(prefs.getString("lang.name") + " - "
- + prefs.getString("lang.about"), relativeTo);
- this.prefs = prefs;
-
- disposeWithParent();
- setContentPane(createContentPane());
- setSize(350, 250);
- setResizable(false);
- setVisible(true);
- }
-
- /**
- * Creates the content pane.
- *
- * @return the container
- */
- public Container createContentPane() {
- Container contentPane = getContentPane();
-
- VSInfoArea infoArea = new VSInfoArea(
- prefs.getString("lang.about.info"));
- JPanel buttonPane = createButtonPanel();
- JScrollPane scrollPane = new JScrollPane(infoArea);
-
- contentPane.add(scrollPane, BorderLayout.CENTER);
- contentPane.add(buttonPane, BorderLayout.SOUTH);
-
- return contentPane;
- }
-
- /**
- * Creates the button panel.
- *
- * @return the panel
- */
- 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(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- String actionCommand = e.getActionCommand();
- if (actionCommand.equals(prefs.getString("lang.close")))
- dispose();
- }
- });
- buttonPane.add(closeButton);
-
- return buttonPane;
- }
-}
diff --git a/sources/utils/VSClassLoader.java b/sources/utils/VSClassLoader.java
deleted file mode 100644
index 37f4027..0000000
--- a/sources/utils/VSClassLoader.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package utils;
-
-/**
- * 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 {
- /**
- * Creates a new instance of the given classname.
- *
- * @param classname the classname
- *
- * @return the object
- */
- public Object newInstance(String classname) {
- Object object = null;
-
- try {
- object = super.loadClass(classname, true).getDeclaredConstructor().newInstance();
-
- } catch (Exception e) {
- System.out.println(e + "; Classname " + classname);
- }
-
- return object;
- }
-}
diff --git a/sources/utils/VSFrame.java b/sources/utils/VSFrame.java
deleted file mode 100644
index 818a72d..0000000
--- a/sources/utils/VSFrame.java
+++ /dev/null
@@ -1,118 +0,0 @@
-package utils;
-
-import java.awt.Component;
-import java.awt.Dimension;
-import java.awt.Point;
-import java.awt.Toolkit;
-import java.awt.Window;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-
-import javax.swing.JFrame;
-
-/**
- * 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. */
- private final static int X_LOCATION_OFFSET = 40;
-
- /** The Constant Y_LOCATION_OFFSET. */
- private final static int Y_LOCATION_OFFSET = 80;
-
- /** The parent window/component. */
- private Component parent;
-
- /** True, if the current window will get disposed with its parent. */
- private boolean dispose;
-
- /**
- * Instantiates a VSFrame object.
- *
- * @param title the title
- * @param parent the parent
- */
- public VSFrame(String title, Component parent) {
- super(title);
- init(parent);
- }
-
- /**
- * Instantiates a new VSFrame object.
- *
- * @param title the title
- */
- public VSFrame(String title) {
- super(title);
- init(null);
- }
-
- /**
- * Inits the VSFrame.
- *
- * @param parent the parent
- */
- private void init(Component parent) {
- this.parent = parent;
- this.dispose = false;
- }
-
- /**
- * Dispose with its parent.
- */
- public void disposeWithParent() {
- if (!dispose && parent != null && parent instanceof Window) {
- Window window = (Window) parent;
- window.addWindowListener(new WindowAdapter() {
- public void windowClosed(WindowEvent we) {
- VSFrame.this.dispose();
- }
- });
- }
- dispose = true;
- }
-
- /**
- * Sets the correct location of the window.
- */
- private void setCorrectLocation() {
- int x = 0, y = 0;
- final Dimension screenSize =
- Toolkit.getDefaultToolkit().getScreenSize();
-
- if (parent == null) {
- x = (int) (screenSize.width - getWidth()) / 2;
- y = 50;//(int) (screenSize.height - getHeight()) / 2;
-
- } else {
- final Point location = parent.getLocation();
- x = (int) location.getX() + X_LOCATION_OFFSET;
- y = (int) location.getY() + Y_LOCATION_OFFSET;
- }
-
- if (x + super.getWidth() >= screenSize.width)
- x = screenSize.width - super.getWidth();
- else if (x < 0)
- x = 0;
-
- if (y + super.getHeight() >= screenSize.height)
- y = screenSize.height - super.getHeight();
-
- super.setLocation(x, y);
- }
-
- /* (non-Javadoc)
- * @see java.awt.Window#setSize(int, int)
- */
- public void setSize(int width, int height) {
- super.setSize(width, height);
- setCorrectLocation();
- }
-}
diff --git a/sources/utils/VSInfoArea.java b/sources/utils/VSInfoArea.java
deleted file mode 100644
index 645afb1..0000000
--- a/sources/utils/VSInfoArea.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package utils;
-
-import java.awt.Color;
-
-import javax.swing.JTextPane;
-import javax.swing.border.CompoundBorder;
-import javax.swing.border.EmptyBorder;
-import javax.swing.border.LineBorder;
-
-/**
- * The class VSInfoArea, an object of this class is used for some information
- * areas. E.g. in the VSAboutFrame class.
- *
- * @author Paul C. Buetow
- */
-public class VSInfoArea extends JTextPane {
- /** The serial version uid */
- private static final long serialVersionUID = 1L;
-
- /**
- * Instantiates a new VSInfoArea.
- */
- public VSInfoArea() {
- init();
- }
-
- /**
- * Instantiates a new VSInfoArea.
- *
- * @param text the text to display
- */
- public VSInfoArea(String text) {
- setText(text);
- init();
- }
-
- /**
- * Inits the info area.
- */
- private void init() {
- setOpaque(false);
- setBorder(null);
- setFocusable(false);
- setBorder(new CompoundBorder(
- new LineBorder(Color.BLACK),
- new EmptyBorder(15, 15, 15, 15)));
- setBackground(Color.WHITE);
- }
-}
diff --git a/sources/utils/VSPriorityQueue.java b/sources/utils/VSPriorityQueue.java
deleted file mode 100644
index d706352..0000000
--- a/sources/utils/VSPriorityQueue.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package utils;
-
-import java.util.PriorityQueue;
-
-/**
- * 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 specific element. If the index is out of bounds, it will return
- * null.
- *
- * @param index the index
- *
- * @return the element, or null, if out of bounds
- */
- public T get(int index) {
- int i = 0;
-
- for (T t : this)
- if (i++ == index)
- return t;
-
- return null;
- }
-}
diff --git a/sources/utils/VSRandom.java b/sources/utils/VSRandom.java
deleted file mode 100644
index 6c1de90..0000000
--- a/sources/utils/VSRandom.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package utils;
-
-import java.util.Random;
-
-/**
- * The class VSRandom. Some customization of the standard Random class of Java.
- *
- * @author Paul C. Buetow
- */
-public final class VSRandom extends Random {
- /**
- * Instantiates a new VSrandom object.
- *
- * @param seedAdd the seed to add.
- */
- public VSRandom(long seedAdd) {
- super(seedAdd*System.currentTimeMillis()+seedAdd);
- }
-
- /* (non-Javadoc)
- * @see java.util.Random#nextInt()
- */
- public int nextInt() {
- return Math.abs(super.nextInt());
- }
-
- /**
- * Next long.
- *
- * @param mod the mod
- *
- * @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
deleted file mode 100644
index ceb5760..0000000
--- a/sources/utils/VSTools.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package utils;
-
-import java.util.Vector;
-
-/**
- * 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 {
- /**
- * Gets the time string.
- *
- * @param time the time
- *
- * @return the time string
- */
- public static String getTimeString(long time) {
- String ret = ""+time;
-
- while (ret.length() < 6)
- ret = "0" + ret;
-
- return ret + "ms";
- }
-
- /**
- * Gets the string time.
- *
- * @param string the string
- *
- * @return the string time
- */
- public static long getStringTime(String string) {
- try {
- /* Ignore the "ms" postfix */
- Long longValue = Long.valueOf(
- string.substring(0, string.length()-2));
- return longValue.longValue();
- } catch (NumberFormatException e) {
- }
-
- return 0;
- }
-
- /**
- * Gets the integer vector represented by a comma separated string.
- *
- * @param string the string
- *
- * @return the parsed vector
- */
- public static Vector<Integer> parseIntegerVector(String string)
- throws exceptions.VSParseIntegerVectorException {
- Vector<Integer> vec = new Vector<Integer>();
-
- int index = string.indexOf('[');
- if (index == -1)
- throw new exceptions.VSParseIntegerVectorException();
-
- string = string.substring(index+1);
-
- index = string.indexOf(']');
- if (index == -1)
- throw new exceptions.VSParseIntegerVectorException();
-
- string = string.substring(0, index);
-
- try {
- while ( (index = string.indexOf(',')) != -1 ) {
- String substring = string.substring(0, index);
-
- /* Remove leading whitespaces */
- while (substring.charAt(0) == ' ')
- substring = substring.substring(1);
-
- vec.add(Integer.parseInt(substring));
- string = string.substring(index+1);
- }
-
- /* Remove leading whitespaces */
- while (string.charAt(0) == ' ')
- string = string.substring(1);
- vec.add(Integer.parseInt(string));
-
- } catch (StringIndexOutOfBoundsException e) {
- } catch (NumberFormatException e) {
- }
- return vec;
- }
-}