diff options
Diffstat (limited to 'sources/utils')
| -rw-r--r-- | sources/utils/VS3Tupel.java | 84 | ||||
| -rw-r--r-- | sources/utils/VSAboutFrame.java | 106 | ||||
| -rw-r--r-- | sources/utils/VSClassLoader.java | 55 | ||||
| -rw-r--r-- | sources/utils/VSFrame.java | 135 | ||||
| -rw-r--r-- | sources/utils/VSInfoArea.java | 69 | ||||
| -rw-r--r-- | sources/utils/VSPriorityQueue.java | 55 | ||||
| -rw-r--r-- | sources/utils/VSRandom.java | 63 | ||||
| -rw-r--r-- | sources/utils/VSTools.java | 119 |
8 files changed, 0 insertions, 686 deletions
diff --git a/sources/utils/VS3Tupel.java b/sources/utils/VS3Tupel.java deleted file mode 100644 index 4d4c896..0000000 --- a/sources/utils/VS3Tupel.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2008 Paul C. Buetow, vs@dev.buetow.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * All icons of the icons/ folder are under a Creative Commons - * Attribution-Noncommercial-Share Alike License a CC-by-nc-sa. - * - * The icon's homepage is http://code.google.com/p/ultimate-gnome/ - */ - -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 serial version uid */ - private static final long serialVersionUID = 1L; - - /** 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 03ed8c4..0000000 --- a/sources/utils/VSAboutFrame.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2008 Paul C. Buetow, vs@dev.buetow.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * All icons of the icons/ folder are under a Creative Commons - * Attribution-Noncommercial-Share Alike License a CC-by-nc-sa. - * - * The icon's homepage is http://code.google.com/p/ultimate-gnome/ - */ - -package utils; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; - -import prefs.*; -//import utils.*; - -/** - * 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 serial version uid */ - private static final long serialVersionUID = 1L; - - /** 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.en.name") + " - " - + prefs.getString("lang.en.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.en.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.en.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.en.close"))) - dispose(); - } - }); - buttonPane.add(closeButton); - - return buttonPane; - } -} diff --git a/sources/utils/VSClassLoader.java b/sources/utils/VSClassLoader.java deleted file mode 100644 index 49fcc6b..0000000 --- a/sources/utils/VSClassLoader.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2008 Paul C. Buetow, vs@dev.buetow.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * All icons of the icons/ folder are under a Creative Commons - * Attribution-Noncommercial-Share Alike License a CC-by-nc-sa. - * - * The icon's homepage is http://code.google.com/p/ultimate-gnome/ - */ - -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 { - /** The serial version uid */ - private static final long serialVersionUID = 1L; - - /** - * 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).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 fbc2139..0000000 --- a/sources/utils/VSFrame.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2008 Paul C. Buetow, vs@dev.buetow.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * All icons of the icons/ folder are under a Creative Commons - * Attribution-Noncommercial-Share Alike License a CC-by-nc-sa. - * - * The icon's homepage is http://code.google.com/p/ultimate-gnome/ - */ - -package utils; - -import java.awt.*; -import java.awt.event.*; -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 ce88699..0000000 --- a/sources/utils/VSInfoArea.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2008 Paul C. Buetow, vs@dev.buetow.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * All icons of the icons/ folder are under a Creative Commons - * Attribution-Noncommercial-Share Alike License a CC-by-nc-sa. - * - * The icon's homepage is http://code.google.com/p/ultimate-gnome/ - */ - -package utils; - -import java.awt.*; -import javax.swing.*; -import javax.swing.border.*; - -/** - * 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 739a886..0000000 --- a/sources/utils/VSPriorityQueue.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2008 Paul C. Buetow, vs@dev.buetow.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * All icons of the icons/ folder are under a Creative Commons - * Attribution-Noncommercial-Share Alike License a CC-by-nc-sa. - * - * The icon's homepage is http://code.google.com/p/ultimate-gnome/ - */ - -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 d955aae..0000000 --- a/sources/utils/VSRandom.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2008 Paul C. Buetow, vs@dev.buetow.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * All icons of the icons/ folder are under a Creative Commons - * Attribution-Noncommercial-Share Alike License a CC-by-nc-sa. - * - * The icon's homepage is http://code.google.com/p/ultimate-gnome/ - */ - -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 { - /** The serial version uid */ - private static final long serialVersionUID = 1L; - - /** - * 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 feece80..0000000 --- a/sources/utils/VSTools.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2008 Paul C. Buetow, vs@dev.buetow.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * All icons of the icons/ folder are under a Creative Commons - * Attribution-Noncommercial-Share Alike License a CC-by-nc-sa. - * - * The icon's homepage is http://code.google.com/p/ultimate-gnome/ - */ - -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 { - /** The serial version uid */ - private static final long serialVersionUID = 1L; - - /** - * 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; - } -} |
