From c015d586d22b69078b6da61858e5675793856b0b Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 25 May 2008 08:10:13 +0000 Subject: JAutoDoc :) --- sources/core/VSMessage.java | 76 ++- sources/core/VSProcess.java | 343 +++++++++++- sources/core/VSTask.java | 121 +++++ sources/core/VSTaskManager.java | 90 ++++ sources/core/time/VSLamportTime.java | 28 +- sources/core/time/VSTime.java | 16 +- sources/core/time/VSVectorTime.java | 39 ++ sources/events/VSEvent.java | 70 +++ sources/events/VSRegisteredEvents.java | 92 ++++ .../events/implementations/ProcessCrashEvent.java | 15 + .../implementations/ProcessRecoverEvent.java | 15 + sources/events/internal/MessageReceiveEvent.java | 21 + sources/events/internal/ProtocolEvent.java | 45 ++ sources/prefs/VSDefaultPrefs.java | 42 ++ sources/prefs/VSPrefs.java | 596 +++++++++++++++++++++ sources/prefs/editors/VSBetterEditor.java | 55 ++ sources/prefs/editors/VSColorChooser.java | 25 + sources/prefs/editors/VSEditor.java | 253 +++++++++ sources/prefs/editors/VSEditorFrame.java | 30 ++ sources/prefs/editors/VSEditorTable.java | 110 ++++ sources/prefs/editors/VSProcessEditor.java | 28 + sources/prefs/editors/VSSimulatorEditor.java | 35 ++ sources/protocols/VSProtocol.java | 78 +++ .../implementations/BerkelyTimeProtocol.java | 44 +- .../implementations/BroadcastSturmProtocol.java | 36 ++ .../protocols/implementations/DummyProtocol.java | 33 ++ .../implementations/ExternalTimeSyncProtocol.java | 36 ++ .../implementations/InternalTimeSyncProtocol.java | 34 ++ .../implementations/PingPongProtocol.java | 36 ++ sources/simulator/VSAbout.java | 29 + sources/simulator/VSLogging.java | 74 +++ sources/simulator/VSMain.java | 31 ++ sources/simulator/VSSimulator.java | 405 ++++++++++++++ sources/simulator/VSSimulatorCanvas.java | 402 ++++++++++++++ sources/simulator/VSSimulatorFrame.java | 94 ++++ sources/utils/VSClassLoader.java | 16 + sources/utils/VSFrame.java | 41 ++ sources/utils/VSInfoArea.java | 20 + sources/utils/VSPriorityQueue.java | 16 + sources/utils/VSRandom.java | 24 + sources/utils/VSTools.java | 24 + sources/utils/VSTupel.java | 36 ++ 42 files changed, 3606 insertions(+), 48 deletions(-) diff --git a/sources/core/VSMessage.java b/sources/core/VSMessage.java index 05c9e6a..a16d35b 100644 --- a/sources/core/VSMessage.java +++ b/sources/core/VSMessage.java @@ -1,45 +1,53 @@ +/* + * VS is (c) 2008 by Paul C. Buetow + * vs@dev.buetow.org + */ package core; import core.time.*; import events.*; import prefs.VSPrefs; -/** This class represents a message which is send from one process to another process in the simulation. +// TODO: Auto-generated Javadoc +/** + * This class represents a message which is send from one process to another process in the simulation. */ public class VSMessage extends VSPrefs { - /** Each message belongs to a specific protocol. This variable defined the class name of the protocol being used. - */ + + /** Each message belongs to a specific protocol. This variable defined the class name of the protocol being used. */ private String protocolClassname; - /** The default application preferences. - */ + + /** The default application preferences. */ private VSPrefs prefs; - /** A reference to the process who sent this message. - */ + + /** A reference to the process who sent this message. */ private VSProcess sendingProcess; - /** The vector time of the sending process after sending. The receiver process will use this vector time in order to update the local vector time. - */ + + /** The vector time of the sending process after sending. The receiver process will use this vector time in order to update the local vector time. */ private VSVectorTime vectorTime; - /** The lamport time of the sending process after sending. The receiver process will use this lamport time in order to update the local vector time. - */ + + /** The lamport time of the sending process after sending. The receiver process will use this lamport time in order to update the local vector time. */ private long lamportTime; - /** Each message has its own unique ID. The ID will show up in the logging window of the simulator as well. - */ + + /** Each message has its own unique ID. The ID will show up in the logging window of the simulator as well. */ private long messageID; - /** This counter is used in order to generate unique message ID's. - */ + + /** This counter is used in order to generate unique message ID's. */ private static long messageCounter; - /** The constructor of the message. + /** + * The constructor of the message. * - * @param protocolClassname The classname of the protocol this message - * belongs to. + * @param protocolClassname The classname of the protocol this message + * belongs to. */ public VSMessage(String protocolClassname) { this.protocolClassname = protocolClassname; this.messageID = ++messageCounter; } - /** Initialized the message. + /** + * Initialized the message. * * @param process The sending process of this message. */ @@ -50,7 +58,7 @@ public class VSMessage extends VSPrefs { vectorTime = sendingProcess.getVectorTime().getCopy(); } - /** + /** * Getter method. * * @return The protocol name of the message. @@ -59,7 +67,8 @@ public class VSMessage extends VSPrefs { return VSRegisteredEvents.getName(getProtocolClassname()); } - /** Getter method. + /** + * Getter method. * * @return The protocol classname of the message. */ @@ -67,7 +76,8 @@ public class VSMessage extends VSPrefs { return protocolClassname; } - /** Getter method. + /** + * Getter method. * * @return The ID of the message. */ @@ -75,7 +85,8 @@ public class VSMessage extends VSPrefs { return messageID; } - /** Getter method. + /** + * Getter method. * * @return The process which sent this message. */ @@ -83,7 +94,8 @@ public class VSMessage extends VSPrefs { return sendingProcess; } - /** Getter method. + /** + * Getter method. * * @return The lamport time of the sending process. */ @@ -91,7 +103,8 @@ public class VSMessage extends VSPrefs { return lamportTime; } - /** Getter method. + /** + * Getter method. * * @return The vector time of the sending process. */ @@ -99,7 +112,8 @@ public class VSMessage extends VSPrefs { return vectorTime; } - /** String representation of the message object. + /** + * String representation of the message object. * * @return String representation of the message object. */ @@ -116,7 +130,8 @@ public class VSMessage extends VSPrefs { return buffer.toString(); } - /** Extended string representation of the message object. + /** + * Extended string representation of the message object. * * @return Extended string representation of the message object. */ @@ -124,16 +139,19 @@ public class VSMessage extends VSPrefs { return toString() + "; " + super.toString(); } - /** Compares two messages. + /** + * Compares two messages. * * @param message The message to compare with. + * * @return true, if the messages have the same ID. Otherwise false. */ public boolean equals(VSMessage message) { return messageID == message.getMessageID(); } - /** For logging in the simulator's logging window! + /** + * For logging in the simulator's logging window!. * * @param message The message to logg. */ diff --git a/sources/core/VSProcess.java b/sources/core/VSProcess.java index 3773bd6..e4c7561 100644 --- a/sources/core/VSProcess.java +++ b/sources/core/VSProcess.java @@ -1,3 +1,7 @@ +/* + * VS is (c) 2008 by Paul C. Buetow + * vs@dev.buetow.org + */ package core; import java.awt.*; @@ -11,39 +15,97 @@ import protocols.*; import simulator.*; import utils.*; +/** + * The Class VSProcess. A object of this class represents a process of a simulation. + */ public class VSProcess extends VSPrefs { + + /** The protocols to reset if the simulation is over or the reset button has been pressed. */ private ArrayList protocolsToReset; + + /** The crash history. represents all crashes of the process using the global simulation time. */ private ArrayList crashHistory; + + /** The lamport time history. */ private ArrayList lamportTimeHistory; + + /** The vector time history. */ private ArrayList vectorTimeHistory; + + /** The crashed color. */ private Color crashedColor;; + + /** The current color. */ private Color currentColor; + + /** The tmp color. For internal usage. */ private Color tmpColor; + + /** The logging object. */ private VSLogging logging; + + /** The simulation's default prefs. */ private VSPrefs prefs; + + /** The random generator of the process. */ private VSRandom random; + + /** The simulation canvas. */ private VSSimulatorCanvas simulationCanvas; + + /** The random crash task. May be null if there is no such random task. */ private VSTask randomCrashTask; + + /** The vector time. */ private VSVectorTime vectorTime; + + /** The process has crashed. But may be working again. */ private boolean hasCrashed; + + /** The process has started. But may be paused or crashed.. */ private boolean hasStarted; + + /** The process is crashed. */ private boolean isCrashed; + + /** The process is highlighted. */ private boolean isHighlighted; + + /** The process is paused. */ private boolean isPaused; + + /** The time has been modified in a task. Needed by the task manager to calculate correct offsets. */ private boolean timeModified; + + /** The clock offset. Used by the task manager and also by the process' clock variance. */ private double clockOffset; + + /** The clock variance. */ private float clockVariance; + + /** The process id. */ private int processID; // Represents the PID of a process + + /** The process num. It is different to the process id. It represents the array index of the process. */ private int processNum; // Represents the array index of the process, for internal usage + + /** The global time. */ private long globalTime; + + /** The lamport time. */ private long lamportTime; + + /** The local time. */ private long localTime; + + /** The process counter. Needed for the unique process id's. */ private static int processCounter; /* This array contains all Integer prefs of the process which should show * up in the prefs menu! All keys which dont start with "sim." only show * up in the extended prefs menu! */ + /** The Constant DEFAULT_INTEGER_VALUE_KEYS. */ private static final String DEFAULT_INTEGER_VALUE_KEYS[] = { "process.prob.crash", "message.prob.outage", @@ -53,12 +115,14 @@ public class VSProcess extends VSPrefs { * up in the prefs menu! All keys which dont start with "sim." only show * up in the extended prefs menu! */ + /** The Constant DEFAULT_LONG_VALUE_KEYS. */ private static final String DEFAULT_LONG_VALUE_KEYS[] = { "message.sendingtime.min", "message.sendingtime.max", }; - /* This array contains all Float prefs of the process which should show + /** The Constant DEFAULT_FLOAT_VALUE_KEYS. */ + /** This array contains all Float prefs of the process which should show * up in the prefs menu! All keys which dont start with "sim." only show * up in the extended prefs menu! */ @@ -66,7 +130,8 @@ public class VSProcess extends VSPrefs { "process.clock.variance", }; - /* This array contains all Color prefs of the process which should show + /** The Constant DEFAULT_COLOR_VALUE_KEYS. */ + /** This array contains all Color prefs of the process which should show * up in the prefs menu! All keys which dont start with "sim." only show * up in the extended prefs menu! */ @@ -78,13 +143,22 @@ public class VSProcess extends VSPrefs { "col.process.crashed", }; - /* This array contains all String prefs of the process which should show + /** The Constant DEFAULT_STRING_VALUE_KEYS. */ + /** This array contains all String prefs of the process which should show * up in the prefs menu! All keys which dont start with "sim." only show * up in the extended prefs menu! */ private static final String DEFAULT_STRING_VALUE_KEYS[] = { }; + /** + * Instantiates a new process. + * + * @param prefs the simulation's default prefs + * @param processNum the process num + * @param simulationCanvas the simulation canvas + * @param logging the logging object + */ public VSProcess(VSPrefs prefs, int processNum, VSSimulatorCanvas simulationCanvas, VSLogging logging) { this.protocolsToReset = new ArrayList(); this.processNum = processNum; @@ -112,6 +186,9 @@ public class VSProcess extends VSPrefs { createRandomCrashTask(); } + /** + * Inits the time formats. + */ private void initTimeFormats() { lamportTime = 0; lamportTimeHistory = new ArrayList(); @@ -125,6 +202,9 @@ public class VSProcess extends VSPrefs { vectorTime.add(new Long(0)); } + /** + * Reset time formats. + */ private void resetTimeFormats() { lamportTime = 0; lamportTimeHistory.clear(); @@ -140,7 +220,7 @@ public class VSProcess extends VSPrefs { /** - * Called from the VSProcessEditor, after finishing editing! + * Called from the VSProcessEditor, after finishing editing!. */ public synchronized void updateFromVSPrefs() { setClockVariance(getFloat("process.clock.variance")); @@ -151,13 +231,18 @@ public class VSProcess extends VSPrefs { } /** - * Called from the VSProcessEditor, before starting editing! + * Called from the VSProcessEditor, before starting editing!. */ public synchronized void updatePrefs() { setFloat("process.clock.variance", getClockVariance()); setLong("process.localtime", getTime()); } + /** + * Sync time. Using the clockOffset and clockVariance. + * + * @param globalTime the global time + */ public synchronized void syncTime(final long globalTime) { final long currentGlobalTimestep = globalTime - this.globalTime; this.globalTime = globalTime; @@ -179,6 +264,11 @@ public class VSProcess extends VSPrefs { localTime = 0; } + /** + * Sets the current color. + * + * @param newColor the new current color + */ private void setCurrentColor(Color newColor) { if (isHighlighted) tmpColor = newColor; @@ -186,17 +276,26 @@ public class VSProcess extends VSPrefs { currentColor = newColor; } + /** + * Highlights the process. + */ public synchronized void highlightOn() { tmpColor = currentColor; currentColor = getColor("col.process.highlight"); isHighlighted = true; } + /** + * Unhighlights the process. + */ public synchronized void highlightOff() { currentColor = tmpColor; isHighlighted = false; } + /** + * Resets the process. + */ public synchronized void reset() { isPaused = true; isCrashed = false; @@ -212,6 +311,9 @@ public class VSProcess extends VSPrefs { resetTimeFormats(); } + /** + * Creates the random crash task. + */ public void createRandomCrashTask() { if (!isCrashed) { VSTaskManager taskManager = simulationCanvas.getTaskManager(); @@ -236,41 +338,80 @@ public class VSProcess extends VSPrefs { } } + /** + * Adds the clock offset. This method is used by the task manager. + * + * @param add the clock offset to add. + */ public synchronized void addClockOffset(long add) { this.clockOffset += add; } + /** + * Play. Called by the simulation canvas. + */ public synchronized void play() { isPaused = false; setCurrentColor(getColor("col.process.running")); } + /** + * Pause. Called by the simulation canvas. + */ public synchronized void pause() { isPaused = true; setCurrentColor(getColor("col.process.stopped")); } + /** + * Finish. Called by the simulation canvas. + */ public synchronized void finish() { isPaused = true; setCurrentColor(getColor("col.process.default")); } + /** + * Gets the process id. + * + * @return the process id + */ public synchronized int getProcessID() { return processID; } + /** + * Gets the process num. + * + * @return the process num + */ public synchronized int getProcessNum() { return processNum; } + /** + * Sets the process id. + * + * @param processID the new process id + */ public synchronized void setProcessID(int processID) { this.processID = processID; } + /** + * Gets the current process' color. + * + * @return the current color of the process. + */ public synchronized Color getColor() { return currentColor; } + /** + * Sets the local time. + * + * @param localTime the new local time. + */ public synchronized void setLocalTime(final long localTime) { if (localTime >= 0) this.localTime = localTime; @@ -278,10 +419,20 @@ public class VSProcess extends VSPrefs { this.localTime = 0; } + /** + * Gets the process' local time. + * + * @return the process' local time + */ public synchronized long getTime() { return localTime; } + /** + * Sets the process' local time. + * + * @param time the new local time of the process. + */ public synchronized void setTime(final long time) { if (time >= 0) this.localTime = time; @@ -291,10 +442,20 @@ public class VSProcess extends VSPrefs { this.timeModified = true; } + /** + * Checks if the process is crashed. + * + * @return true, if is crashed + */ public synchronized boolean isCrashed() { return isCrashed; } + /** + * Sets if the process is crashed. + * + * @param isCrashed true if the process is crashed. + */ public synchronized void isCrashed(boolean isCrashed) { this.isCrashed = isCrashed; crashHistory.add(new Long(globalTime)); @@ -302,34 +463,76 @@ public class VSProcess extends VSPrefs { hasCrashed = true; } + /** + * Checks if the process has crashed at least once during the current + * simulation. + * + * @return true, if yes + */ public synchronized boolean hasCrashed() { return hasCrashed; } + /** + * Gets the crashed color. + * + * @return the crashed color + */ public synchronized Color getCrashedColor() { return crashedColor; } + /** + * Checks if the time has been modified. by a task. + * This mehod is needed by the task manager. + * + * @return true, if yes + */ public synchronized boolean timeModified() { return timeModified; } + /** + * Sets if the time has been modified by a task. + * + * @param timeModified true, if it has been modified. + */ public synchronized void timeModified(boolean timeModified) { this.timeModified = timeModified; } + /** + * Gets the global time. + * + * @return the global time + */ public synchronized long getGlobalTime() { return globalTime; } + /** + * Sets the global time. + * + * @param globalTime the new global time + */ public synchronized void setGlobalTime(final long globalTime) { this.globalTime = globalTime >= 0 ? globalTime : 0; } + /** + * Gets the clock variance. + * + * @return the clock variance + */ public synchronized float getClockVariance() { return clockVariance; } + /** + * Sets the clock variance. + * + * @param clockVariance the new clock variance + */ public synchronized void setClockVariance(float clockVariance) { /* If negative, only allow < 1 prefs */ if (clockVariance < 0) { @@ -343,6 +546,11 @@ public class VSProcess extends VSPrefs { this.clockVariance = clockVariance; } + /** + * Gets the duration time. + * + * @return the duration time + */ public synchronized long getDurationTime() { final long maxDurationTime = getLong("message.sendingtime.max"); final long minDurationTime = getLong("message.sendingtime.min"); @@ -359,6 +567,13 @@ public class VSProcess extends VSPrefs { return minDurationTime + random.nextInt(diff+1); } + /** + * Gets the a random message outage time. + * + * @param durationTime the duration time + * + * @return the a random message outage time + */ public synchronized long getARandomMessageOutageTime(final long durationTime) { /* Check if the message will have an outage or not */ if (random.nextInt(100) < getInteger("message.prob.outage")) { @@ -371,6 +586,11 @@ public class VSProcess extends VSPrefs { return -1; } + /** + * Gets the a random crash time. + * + * @return the a random crash time + */ private long getARandomCrashTime() { /* Check if the process will crash or not */ if (random.nextInt(100) <= getInteger("process.prob.crash")) { @@ -383,18 +603,36 @@ public class VSProcess extends VSPrefs { return -1; } + /** + * Gets the random crash task. + * + * @return the random crash task + */ public synchronized VSTask getCrashTask() { return randomCrashTask; } + /** + * Checks if is paused. + * + * @return true, if is paused + */ public synchronized boolean isPaused() { return isPaused; } + /** + * Increases the lamport time. + */ public void increaseLamportTime() { setLamportTime(getLamportTime()+1); } + /** + * Updates the lamport time. + * + * @param time the lamport time + */ public void updateLamportTime(long time) { final long lamportTime = getLamportTime() + 1; @@ -404,15 +642,30 @@ public class VSProcess extends VSPrefs { setLamportTime(lamportTime); } + /** + * Gets the lamport time. + * + * @return the lamport time. + */ public synchronized long getLamportTime() { return lamportTime; } + /** + * Sets the lamport time. + * + * @param lamportTime the new lamport time + */ public synchronized void setLamportTime(long lamportTime) { this.lamportTime = lamportTime; lamportTimeHistory.add(new VSLamportTime(globalTime, lamportTime)); } + /** + * Gets the lamport time history as an array. + * + * @return the lamport time history array + */ public synchronized VSTime[] getLamportTimeArray() { final int size = lamportTimeHistory.size(); final VSTime[] arr = new VSLamportTime[size]; @@ -423,12 +676,20 @@ public class VSProcess extends VSPrefs { return arr; } + /** + * Increases the vector time. + */ public synchronized void increaseVectorTime() { vectorTime.set(processNum, new Long(vectorTime.get(processNum).longValue()+1)); vectorTime.setGlobalTime(globalTime); vectorTimeHistory.add(vectorTime.getCopy()); } + /** + * Updates the vector time. + * + * @param vectorTimeUpdate the vector time of the other process to use for the update + */ public synchronized void updateVectorTime(VSVectorTime vectorTimeUpdate) { final int size = vectorTime.size(); @@ -443,10 +704,20 @@ public class VSProcess extends VSPrefs { vectorTimeHistory.add(vectorTime.getCopy()); } + /** + * Gets the vector time. + * + * @return the vector time + */ public synchronized VSVectorTime getVectorTime() { return vectorTime; } + /** + * Gets the vector time history as an array. + * + * @return the vector time history array + */ public synchronized VSTime[] getVectorTimeArray() { final int size = vectorTimeHistory.size(); final VSTime[] arr = new VSTime[size]; @@ -457,6 +728,11 @@ public class VSProcess extends VSPrefs { return arr; } + /** + * Gets the crash history array. + * + * @return the crash history array + */ public synchronized Long[] getCrashHistoryArray() { final int size = crashHistory.size(); final Long[] arr = new Long[size]; @@ -467,6 +743,11 @@ public class VSProcess extends VSPrefs { return arr; } + /** + * Called by a task if the process sends a message. + * + * @param message the message to send. + */ public void sendMessage(VSMessage message) { StringBuffer buffer = new StringBuffer(); buffer.append(prefs.getString("lang.message.sent")); @@ -476,10 +757,18 @@ public class VSProcess extends VSPrefs { simulationCanvas.sendMessage(message); } + /** + * Logg a message to the logging area. + * + * @param message the message to logg + */ public void logg(String message) { logging.logg(toString() + "; " + message, globalTime); } + /* (non-Javadoc) + * @see prefs.VSPrefs#fillWithDefaults() + */ public void fillWithDefaults() { prefs.copyIntegers(this, DEFAULT_INTEGER_VALUE_KEYS); prefs.copyLongs(this, DEFAULT_LONG_VALUE_KEYS); @@ -488,6 +777,9 @@ public class VSProcess extends VSPrefs { prefs.copyStrings(this, DEFAULT_STRING_VALUE_KEYS); } + /* (non-Javadoc) + * @see prefs.VSPrefs#toString() + */ public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append(prefs.getString("lang.process.id")); @@ -508,6 +800,11 @@ public class VSProcess extends VSPrefs { return buffer.toString(); } + /** + * The extended string representation of the process object. + * + * @return the extended string representation + */ public String toStringFull() { StringBuffer buffer = new StringBuffer(); buffer.append(toString()); @@ -520,22 +817,48 @@ public class VSProcess extends VSPrefs { return buffer.toString(); } + /** + * Equals. Checks, if both processes have the same process id. + * + * @param process the process to compare to + * + * @return true, if both processes are the same. + */ public boolean equals(VSProcess process) { return process.getProcessID() == processID; } + /** + * Gets the simulation canvas. + * + * @return the simulation canvas + */ public VSSimulatorCanvas getSimulationCanvas() { return simulationCanvas; } + /** + * Gets the simulation's default prefs. + * + * @return the default prefs + */ public VSPrefs getPrefs() { return prefs; } + /** + * Resets the process counter. + */ public static void resetProcessCounter() { processCounter = 0; } + /** + * Removes the process at the specified index. + * Needed in order to update the vector time and the local processNum. + * + * @param index the index the process has to get removed. + */ public void removeProcessAtIndex(int index) { if (index < processNum) --processNum; @@ -545,12 +868,22 @@ public class VSProcess extends VSPrefs { vectorTime.remove(index); } + /** + * Added a process. Needed in order to update the vector time's size. + */ public void addedAProcess() { vectorTime.add(new Long(0)); for (VSVectorTime vectorTime : vectorTimeHistory) vectorTime.add(new Long(0)); } + /** + * Gets the protocol object. + * + * @param protocolClassname the protocol classname + * + * @return the protocol object + */ public VSProtocol getProtocolObject(String protocolClassname) { VSProtocol protocol = null; diff --git a/sources/core/VSTask.java b/sources/core/VSTask.java index e38c1de..43d9cb5 100644 --- a/sources/core/VSTask.java +++ b/sources/core/VSTask.java @@ -1,3 +1,7 @@ +/* + * VS is (c) 2008 by Paul C. Buetow + * vs@dev.buetow.org + */ package core; import events.*; @@ -6,18 +10,50 @@ import events.internal.*; import prefs.VSPrefs; import protocols.VSProtocol; +// TODO: Auto-generated Javadoc +/** + * The Class VSTask. + */ public class VSTask implements Comparable { + + /** The Constant LOCAL. */ public final static boolean LOCAL = true; + + /** The Constant GLOBAL. */ public final static boolean GLOBAL = false; + + /** The task time. */ private long taskTime; + + /** The event. */ private VSEvent event; + + /** The process. */ private VSProcess process; + + /** The prefs. */ private VSPrefs prefs; + + /** The is programmed. */ private boolean isProgrammed; + + /** The is global timed. */ private boolean isGlobalTimed; + + /** The task counter. */ private static int taskCounter; + + /** The task num. */ private int taskNum; + /** + * Instantiates a new vS task. + * + * @param taskTime the task time + * @param process the process + * @param event the event + * @param isLocal the is local + */ public VSTask(long taskTime, VSProcess process, VSEvent event, boolean isLocal) { this.process = process; this.taskTime = taskTime > 0 ? taskTime : 0; @@ -27,26 +63,58 @@ public class VSTask implements Comparable { this.taskNum = ++taskCounter; } + /** + * Gets the task num. + * + * @return the task num + */ public int getTaskNum() { return taskNum; } + /** + * Checks if is programmed. + * + * @param isProgrammed the is programmed + */ public void isProgrammed(boolean isProgrammed) { this.isProgrammed = isProgrammed; } + /** + * Checks if is programmed. + * + * @return true, if is programmed + */ public boolean isProgrammed() { return isProgrammed; } + /** + * Checks if is message receive event. + * + * @return true, if is message receive event + */ public boolean isMessageReceiveEvent() { return event instanceof MessageReceiveEvent; } + /** + * Checks if is process recover event. + * + * @return true, if is process recover event + */ public boolean isProcessRecoverEvent() { return event instanceof ProcessRecoverEvent; } + /** + * Checks if is protocol. + * + * @param protocol the protocol + * + * @return true, if is protocol + */ public boolean isProtocol(VSProtocol protocol) { if (event instanceof VSProtocol) return ((VSProtocol) event).equals(protocol); @@ -54,6 +122,11 @@ public class VSTask implements Comparable { return false; } + /** + * Time over. + * + * @return true, if successful + */ public boolean timeOver() { if (isGlobalTimed) return taskTime < process.getGlobalTime(); @@ -61,6 +134,13 @@ public class VSTask implements Comparable { return taskTime < process.getTime(); } + /** + * Equals. + * + * @param task the task + * + * @return true, if successful + */ public boolean equals(VSTask task) { return taskNum == task.getTaskNum(); /* @@ -71,36 +151,74 @@ public class VSTask implements Comparable { */ } + /** + * Checks if is process. + * + * @param process the process + * + * @return true, if is process + */ public boolean isProcess(VSProcess process) { return this.process.equals(process); } + /** + * Checks if is global timed. + * + * @return true, if is global timed + */ public boolean isGlobalTimed() { return isGlobalTimed; } + /** + * Gets the process. + * + * @return the process + */ public VSProcess getProcess() { return process; } + /** + * Run. + */ public void run() { if (event.getProcess() == null) event.init(process); event.onStart(); } + /** + * Gets the task time. + * + * @return the task time + */ public long getTaskTime() { return taskTime; } + /** + * Gets the event. + * + * @return the event + */ public VSEvent getEvent() { return event; } + /** + * Logg. + * + * @param message the message + */ private void logg(String message) { process.logg(message); } + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append(prefs.getString("lang.task")); @@ -112,6 +230,9 @@ public class VSTask implements Comparable { return buffer.toString(); } + /* (non-Javadoc) + * @see java.lang.Comparable#compareTo(java.lang.Object) + */ public int compareTo(Object object) { if (object instanceof VSTask) { final VSTask task = (VSTask) object; diff --git a/sources/core/VSTaskManager.java b/sources/core/VSTaskManager.java index cc2f262..272922f 100644 --- a/sources/core/VSTaskManager.java +++ b/sources/core/VSTaskManager.java @@ -1,3 +1,7 @@ +/* + * VS is (c) 2008 by Paul C. Buetow + * vs@dev.buetow.org + */ package core; import java.util.*; @@ -5,14 +9,35 @@ import java.util.*; import prefs.*; import utils.*; +// TODO: Auto-generated Javadoc +/** + * The Class VSTaskManager. + */ public class VSTaskManager { + + /** The tasks. */ private PriorityQueue tasks; + + /** The global tasks. */ private PriorityQueue globalTasks; + + /** The fullfilled programmed tasks. */ private LinkedList fullfilledProgrammedTasks; + + /** The Constant PROGRAMMED. */ public final static boolean PROGRAMMED = true; + + /** The Constant ONLY_ONCE. */ public final static boolean ONLY_ONCE = false; + + /** The prefs. */ private VSPrefs prefs; + /** + * Instantiates a new vS task manager. + * + * @param prefs the prefs + */ public VSTaskManager(VSPrefs prefs) { this.prefs = prefs; this.tasks = new PriorityQueue();//100, comparator); @@ -20,6 +45,13 @@ public class VSTaskManager { this.fullfilledProgrammedTasks = new LinkedList(); } + /** + * Run tasks. + * + * @param step the step + * @param offset the offset + * @param lastGlobalTime the last global time + */ public synchronized void runTasks(final long step, final long offset, final long lastGlobalTime) { VSTask task = null; VSProcess process = null; @@ -140,6 +172,9 @@ public class VSTaskManager { } while (redo); } + /** + * Reset. + */ public synchronized void reset() { PriorityQueue tmp = tasks; PriorityQueue tmp2 = globalTasks; @@ -165,6 +200,11 @@ public class VSTaskManager { } } + /** + * Insert. + * + * @param task the task + */ private void insert(VSTask task) { if (task.timeOver()) fullfilledProgrammedTasks.addLast(task); @@ -176,15 +216,33 @@ public class VSTaskManager { tasks.add(task); } + /** + * Adds the task. + * + * @param task the task + */ public void addTask(VSTask task) { addTask(task, VSTaskManager.ONLY_ONCE); } + /** + * Adds the task. + * + * @param task the task + * @param isProgrammed the is programmed + */ public synchronized void addTask(VSTask task, boolean isProgrammed) { task.isProgrammed(isProgrammed); insert(task); } + /** + * Removes the task. + * + * @param task the task + * + * @return true, if successful + */ public synchronized boolean removeTask(VSTask task) { if (fullfilledProgrammedTasks.remove(task)) return true; @@ -198,6 +256,11 @@ public class VSTaskManager { return false; } + /** + * Removes the tasks of. + * + * @param process the process + */ public synchronized void removeTasksOf(VSProcess process) { ArrayList removeThose = new ArrayList(); for (VSTask task : fullfilledProgrammedTasks) @@ -221,6 +284,11 @@ public class VSTaskManager { tasks.remove(task); } + /** + * Gets the local tasks. + * + * @return the local tasks + */ public synchronized VSPriorityQueue getLocalTasks() { VSPriorityQueue processTasks = new VSPriorityQueue(); @@ -235,6 +303,11 @@ public class VSTaskManager { return processTasks; } + /** + * Gets the global tasks. + * + * @return the global tasks + */ public synchronized VSPriorityQueue getGlobalTasks() { VSPriorityQueue processTasks = new VSPriorityQueue(); @@ -249,6 +322,13 @@ public class VSTaskManager { return processTasks; } + /** + * Gets the process local tasks. + * + * @param process the process + * + * @return the process local tasks + */ public synchronized VSPriorityQueue getProcessLocalTasks(VSProcess process) { VSPriorityQueue processTasks = new VSPriorityQueue(); @@ -263,6 +343,13 @@ public class VSTaskManager { return processTasks; } + /** + * Gets the process global tasks. + * + * @param process the process + * + * @return the process global tasks + */ public synchronized VSPriorityQueue getProcessGlobalTasks(VSProcess process) { VSPriorityQueue processTasks = new VSPriorityQueue(); @@ -277,6 +364,9 @@ public class VSTaskManager { return processTasks; } + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ public String toString() { StringBuffer buffer = new StringBuffer(); diff --git a/sources/core/time/VSLamportTime.java b/sources/core/time/VSLamportTime.java index 592507a..4ee5ebd 100644 --- a/sources/core/time/VSLamportTime.java +++ b/sources/core/time/VSLamportTime.java @@ -1,16 +1,23 @@ +/* + * VS is (c) 2008 by Paul C. Buetow + * vs@dev.buetow.org + */ package core.time; -/** This class defined how the lamport timestamps are represented. +// TODO: Auto-generated Javadoc +/** + * This class defined how the lamport timestamps are represented. */ public class VSLamportTime implements VSTime { - /** Specified the global time of the lamport timestamp. It's used for correct painting in the simulator paint area. - */ + + /** Specified the global time of the lamport timestamp. It's used for correct painting in the simulator paint area. */ private long globalTime; - /** Specified the process' local lamport time. - */ + + /** Specified the process' local lamport time. */ private long lamportTime; - /** A simple constructor. + /** + * A simple constructor. * * @param globalTime The global time. * @param lamportTime The local lamport time. @@ -20,7 +27,8 @@ public class VSLamportTime implements VSTime { this.lamportTime = lamportTime; } - /** Getter method. + /** + * Getter method. * * @return The global time. */ @@ -28,7 +36,8 @@ public class VSLamportTime implements VSTime { return globalTime; } - /** Getter method. + /** + * Getter method. * * @return The process' local lamport time. */ @@ -36,7 +45,8 @@ public class VSLamportTime implements VSTime { return lamportTime; } - /** String representation. + /** + * String representation. * * @return The string representation of the lamport time. */ diff --git a/sources/core/time/VSTime.java b/sources/core/time/VSTime.java index ce20ecc..0aebf4a 100644 --- a/sources/core/time/VSTime.java +++ b/sources/core/time/VSTime.java @@ -1,14 +1,24 @@ +/* + * VS is (c) 2008 by Paul C. Buetow + * vs@dev.buetow.org + */ package core.time; -/** This interface is a guidline for general time format classes. +// TODO: Auto-generated Javadoc +/** + * This interface is a guidline for general time format classes. */ public interface VSTime { - /** Getter method. + + /** + * Getter method. * * @return The global time. */ public long getGlobalTime(); - /** String representation. + + /** + * String representation. * * @return The representation of the implementing object as a string. */ diff --git a/sources/core/time/VSVectorTime.java b/sources/core/time/VSVectorTime.java index eb6c0aa..647eb7a 100644 --- a/sources/core/time/VSVectorTime.java +++ b/sources/core/time/VSVectorTime.java @@ -1,14 +1,34 @@ +/* + * VS is (c) 2008 by Paul C. Buetow + * vs@dev.buetow.org + */ package core.time; import java.util.ArrayList; +// TODO: Auto-generated Javadoc +/** + * The Class VSVectorTime. + */ public class VSVectorTime extends ArrayList implements VSTime { + + /** The global time. */ private long globalTime; + /** + * Instantiates a new vS vector time. + * + * @param globalTime the global time + */ public VSVectorTime(long globalTime) { this.globalTime = globalTime; } + /** + * To long array. + * + * @return the long[] + */ public long[] toLongArray() { final int size = super.size(); final long[] arr = new long[size]; @@ -19,14 +39,27 @@ public class VSVectorTime extends ArrayList implements VSTime { return arr; } + /** + * Sets the global time. + * + * @param globalTime the new global time + */ public void setGlobalTime(long globalTime) { this.globalTime = globalTime; } + /* (non-Javadoc) + * @see core.time.VSTime#getGlobalTime() + */ public long getGlobalTime() { return globalTime; } + /** + * Gets the copy. + * + * @return the copy + */ public VSVectorTime getCopy() { final VSVectorTime vectorTime = new VSVectorTime(globalTime); final int size = super.size(); @@ -37,6 +70,9 @@ public class VSVectorTime extends ArrayList implements VSTime { return vectorTime; } + /* (non-Javadoc) + * @see java.util.AbstractCollection#toString() + */ public String toString() { final int size = super.size(); final StringBuffer buffer = new StringBuffer(); @@ -49,6 +85,9 @@ public class VSVectorTime extends ArrayList implements VSTime { return buffer.toString(); } + /* (non-Javadoc) + * @see java.util.ArrayList#get(int) + */ public Long get(int index) { if (index >= super.size()) return new Long(0); diff --git a/sources/events/VSEvent.java b/sources/events/VSEvent.java index d058e33..c5cb5df 100644 --- a/sources/events/VSEvent.java +++ b/sources/events/VSEvent.java @@ -1,14 +1,35 @@ +/* + * VS is (c) 2008 by Paul C. Buetow + * vs@dev.buetow.org + */ package events; import core.VSProcess; import prefs.VSPrefs; +// TODO: Auto-generated Javadoc +/** + * The Class VSEvent. + */ abstract public class VSEvent extends VSPrefs { + + /** The prefs. */ protected VSPrefs prefs; + + /** The process. */ protected VSProcess process; + + /** The event shortname. */ private String eventShortname; + + /** The event classname. */ private String eventClassname; + /** + * Inits the. + * + * @param process the process + */ public void init(VSProcess process) { this.process = process; this.prefs = process.getPrefs(); @@ -16,6 +37,11 @@ abstract public class VSEvent extends VSPrefs { onInit(); } + /** + * Sets the classname. + * + * @param eventClassname the new classname + */ protected final void setClassname(String eventClassname) { if (eventClassname.startsWith("class ")) eventClassname = eventClassname.substring(6); @@ -23,18 +49,38 @@ abstract public class VSEvent extends VSPrefs { this.eventClassname = eventClassname; } + /** + * Gets the classname. + * + * @return the classname + */ public String getClassname() { return eventClassname; } + /** + * Gets the name. + * + * @return the name + */ public String getName() { return VSRegisteredEvents.getName(eventClassname); } + /** + * Sets the shortname. + * + * @param eventShortname the new shortname + */ public void setShortname(String eventShortname) { this.eventShortname = eventShortname; } + /** + * Gets the shortname. + * + * @return the shortname + */ public String getShortname() { if (eventShortname == null) return VSRegisteredEvents.getShortname(eventClassname); @@ -42,18 +88,42 @@ abstract public class VSEvent extends VSPrefs { return eventShortname; } + /** + * Gets the process. + * + * @return the process + */ public VSProcess getProcess() { return process; } + /** + * Logg. + * + * @param message the message + */ public void logg(String message) { process.logg(/*toString() + "; " + */message); } + /** + * Equals. + * + * @param event the event + * + * @return true, if successful + */ public boolean equals(VSEvent event) { return super.getID() == event.getID(); } + /** + * On init. + */ abstract protected void onInit(); + + /** + * On start. + */ abstract public void onStart(); } diff --git a/sources/events/VSRegisteredEvents.java b/sources/events/VSRegisteredEvents.java index 2643d6f..d41ffea 100644 --- a/sources/events/VSRegisteredEvents.java +++ b/sources/events/VSRegisteredEvents.java @@ -1,3 +1,7 @@ +/* + * VS is (c) 2008 by Paul C. Buetow + * vs@dev.buetow.org + */ package events; import java.util.*; @@ -6,13 +10,32 @@ import prefs.*; import core.*; import utils.*; +// TODO: Auto-generated Javadoc +/** + * The Class VSRegisteredEvents. + */ public final class VSRegisteredEvents { + + /** The event classnames. */ private static HashMap eventClassnames; + + /** The event shortnames. */ private static HashMap eventShortnames; + + /** The event names. */ private static HashMap eventNames; + + /** The editable protocols classnames. */ private static ArrayList editableProtocolsClassnames; + + /** The prefs. */ private static VSPrefs prefs; + /** + * Inits the. + * + * @param prefs_ the prefs_ + */ public static void init(VSPrefs prefs_) { prefs = prefs_; eventNames = new HashMap(); @@ -42,10 +65,20 @@ public final class VSRegisteredEvents { } } + /** + * Gets the editable protocols classnames. + * + * @return the editable protocols classnames + */ public static ArrayList getEditableProtocolsClassnames() { return editableProtocolsClassnames; } + /** + * Gets the protocol names. + * + * @return the protocol names + */ public static Vector getProtocolNames() { Set set = eventClassnames.keySet(); Vector vector = new Vector(); @@ -59,6 +92,11 @@ public final class VSRegisteredEvents { return vector; } + /** + * Gets the protocol classnames. + * + * @return the protocol classnames + */ public static Vector getProtocolClassnames() { Set set = eventNames.keySet(); Vector vector = new Vector(); @@ -72,6 +110,11 @@ public final class VSRegisteredEvents { return vector; } + /** + * Gets the non protocol names. + * + * @return the non protocol names + */ public static Vector getNonProtocolNames() { Set set = eventClassnames.keySet(); Vector vector = new Vector(); @@ -85,6 +128,11 @@ public final class VSRegisteredEvents { return vector; } + /** + * Gets the non protocol classnames. + * + * @return the non protocol classnames + */ public static Vector getNonProtocolClassnames() { Set set = eventNames.keySet(); Vector vector = new Vector(); @@ -98,18 +146,47 @@ public final class VSRegisteredEvents { return vector; } + /** + * Gets the classname. + * + * @param eventName the event name + * + * @return the classname + */ public static String getClassname(String eventName) { return eventClassnames.get(eventName); } + /** + * Gets the name. + * + * @param eventClassname the event classname + * + * @return the name + */ public static String getName(String eventClassname) { return eventNames.get(eventClassname); } + /** + * Gets the shortname. + * + * @param eventClassname the event classname + * + * @return the shortname + */ public static String getShortname(String eventClassname) { return eventShortnames.get(eventClassname); } + /** + * Creates the event instance by classname. + * + * @param eventClassname the event classname + * @param process the process + * + * @return the vS event + */ public static VSEvent createEventInstanceByClassname(String eventClassname, VSProcess process) { final Object protocolObj = new VSClassLoader().newInstance(eventClassname); @@ -122,10 +199,25 @@ public final class VSRegisteredEvents { return null; } + /** + * Creates the event instance by name. + * + * @param eventName the event name + * @param process the process + * + * @return the vS event + */ public static VSEvent createEventInstanceByName(String eventName, VSProcess process) { return createEventInstanceByClassname(eventClassnames.get(eventName), process); } + /** + * Register event. + * + * @param eventClassname the event classname + * @param eventName the event name + * @param eventShortname the event shortname + */ private static void registerEvent(String eventClassname, String eventName, String eventShortname) { if (eventShortname == null) eventShortname = eventName; diff --git a/sources/events/implementations/ProcessCrashEvent.java b/sources/events/implementations/ProcessCrashEvent.java index c8a9348..e55d18a 100644 --- a/sources/events/implementations/ProcessCrashEvent.java +++ b/sources/events/implementations/ProcessCrashEvent.java @@ -1,12 +1,27 @@ +/* + * VS is (c) 2008 by Paul C. Buetow + * vs@dev.buetow.org + */ package events.implementations; import events.VSEvent; +// TODO: Auto-generated Javadoc +/** + * The Class ProcessCrashEvent. + */ public class ProcessCrashEvent extends VSEvent { + + /* (non-Javadoc) + * @see events.VSEvent#onInit() + */ protected void onInit() { setClassname(getClass().toString()); } + /* (non-Javadoc) + * @see events.VSEvent#onStart() + */ public void onStart() { if (!process.isCrashed()) { process.isCrashed(true); diff --git a/sources/events/implementations/ProcessRecoverEvent.java b/sources/events/implementations/ProcessRecoverEvent.java index 00b2164..cae67cb 100644 --- a/sources/events/implementations/ProcessRecoverEvent.java +++ b/sources/events/implementations/ProcessRecoverEvent.java @@ -1,12 +1,27 @@ +/* + * VS is (c) 2008 by Paul C. Buetow + * vs@dev.buetow.org + */ package events.implementations; import events.VSEvent; +// TODO: Auto-generated Javadoc +/** + * The Class ProcessRecoverEvent. + */ public class ProcessRecoverEvent extends VSEvent { + + /* (non-Javadoc) + * @see events.VSEvent#onInit() + */ protected void onInit() { setClassname(getClass().toString()); } + /* (non-Javadoc) + * @see events.VSEvent#onStart() + */ public void onStart() { if (process.isCrashed()) { process.isCrashed(false); diff --git a/sources/events/internal/MessageReceiveEvent.java b/sources/events/internal/MessageReceiveEvent.java index b59c779..0b4af83 100644 --- a/sources/events/internal/MessageReceiveEvent.java +++ b/sources/events/internal/MessageReceiveEvent.java @@ -1,20 +1,41 @@ +/* + * VS is (c) 2008 by Paul C. Buetow + * vs@dev.buetow.org + */ package events.internal; import core.VSMessage; import events.VSEvent; import protocols.VSProtocol; +// TODO: Auto-generated Javadoc +/** + * The Class MessageReceiveEvent. + */ public class MessageReceiveEvent extends VSEvent { + + /** The message. */ private VSMessage message; + /** + * Instantiates a new message receive event. + * + * @param message the message + */ public MessageReceiveEvent(VSMessage message) { this.message = message; } + /* (non-Javadoc) + * @see events.VSEvent#onInit() + */ protected void onInit() { setClassname(getClass().toString()); } + /* (non-Javadoc) + * @see events.VSEvent#onStart() + */ public void onStart() { String eventName = message.getName(); String protocolClassname = message.getProtocolClassname(); diff --git a/sources/events/internal/ProtocolEvent.java b/sources/events/internal/ProtocolEvent.java index 0cece54..b29a828 100644 --- a/sources/events/internal/ProtocolEvent.java +++ b/sources/events/internal/ProtocolEvent.java @@ -1,37 +1,82 @@ +/* + * VS is (c) 2008 by Paul C. Buetow + * vs@dev.buetow.org + */ package events.internal; import events.*; import protocols.VSProtocol; +// TODO: Auto-generated Javadoc +/** + * The Class ProtocolEvent. + */ public class ProtocolEvent extends VSEvent { + + /** The protocol classname. */ private String protocolClassname; + + /** The is client protocol. */ private boolean isClientProtocol; /* true = client, false = server */ + + /** The is protocol activation. */ private boolean isProtocolActivation; /* true = activate, false = deactivate */ + /* (non-Javadoc) + * @see events.VSEvent#onInit() + */ protected void onInit() { setClassname(getClass().toString()); } + /** + * Checks if is client protocol. + * + * @param isClientProtocol the is client protocol + */ public void isClientProtocol(boolean isClientProtocol) { this.isClientProtocol = isClientProtocol; } + /** + * Checks if is client protocol. + * + * @return true, if is client protocol + */ public boolean isClientProtocol() { return isClientProtocol; } + /** + * Checks if is protocol activation. + * + * @param isProtocolActivation the is protocol activation + */ public void isProtocolActivation(boolean isProtocolActivation) { this.isProtocolActivation = isProtocolActivation; } + /** + * Checks if is protocol activation. + * + * @return true, if is protocol activation + */ public boolean isProtocolActivation() { return isProtocolActivation; } + /** + * Sets the protocol classname. + * + * @param protocolClassname the new protocol classname + */ public void setProtocolClassname(String protocolClassname) { this.protocolClassname = protocolClassname; } + /* (non-Javadoc) + * @see events.VSEvent#onStart() + */ public void onStart() { VSProtocol protocol = process.getProtocolObject(protocolClassname); diff --git a/sources/prefs/VSDefaultPrefs.java b/sources/prefs/VSDefaultPrefs.java index f41692b..5363967 100644 --- a/sources/prefs/VSDefaultPrefs.java +++ b/sources/prefs/VSDefaultPrefs.java @@ -1,19 +1,43 @@ +/* + * VS is (c) 2008 by Paul C. Buetow + * vs@dev.buetow.org + */ package prefs; import java.awt.Color; import java.awt.event.KeyEvent; +// TODO: Auto-generated Javadoc +/** + * The Class VSDefaultPrefs. + */ public class VSDefaultPrefs extends VSPrefs { + + /** + * Inits the. + * + * @return the vS prefs + */ public static VSPrefs init() { return init(VSPrefs.PREFERENCES_FILENAME); } + /** + * Inits the. + * + * @param fileName the file name + * + * @return the vS prefs + */ public static VSPrefs init(String fileName) { VSPrefs prefs = new VSDefaultPrefs(); prefs.fillWithDefaults(); return prefs; } + /* (non-Javadoc) + * @see prefs.VSPrefs#fillWithDefaults() + */ public void fillWithDefaults() { super.clear(); fillDefaultBooleans(); @@ -24,6 +48,9 @@ public class VSDefaultPrefs extends VSPrefs { fillDefaultStrings(); } + /* (non-Javadoc) + * @see prefs.VSPrefs#fillDefaultStrings() + */ public void fillDefaultStrings() { initString("lang.about", "About"); initString("lang.about.info!", "Dieses Programm wurde von Paul Bütow im Rahmen der Diplomarbeit \"Objektorientierte Entwicklung eines GUI-basierten Tools für die ereignisbasierte Simulation verteilter Systeme\" bei Prof. Dr.-Ing. Oßmann erstellt. Dieses Programm stellt noch keinesfalls eine fertige Version dar, da es sich noch in Entwicklung befindet und die Diplomarbeit erst mitte August abgeschlossen sein wird! Bei Fehlern bitte eine kurze Mail mitsamt Fehlerbeschreibung an paul@buetow.org schicken! Dieser Simulator wird später außerdem unter einer open source Linzenz (wahrscheinlich der GNU General Public License) freigegeben!"); @@ -129,6 +156,9 @@ public class VSDefaultPrefs extends VSPrefs { initString("lang.window.new", "Neues Fenster"); } + /* (non-Javadoc) + * @see prefs.VSPrefs#fillDefaultIntegers() + */ public void fillDefaultIntegers() { /* Simulation prefs */ initInteger("sim.process.num", 3, "Anzahl der Prozesse", 1, 6); @@ -168,18 +198,27 @@ public class VSDefaultPrefs extends VSPrefs { initIntegerUnit("div.window.ysize", 768, "Hauptfenster Y-Achse", 600, 2400, "px"); } + /* (non-Javadoc) + * @see prefs.VSPrefs#fillDefaultFloats() + */ public void fillDefaultFloats() { /* Simulation prefs */ initFloat("process.clock.variance", 0, "Uhrabweichung"); initFloat("sim.clock.speed", 0.5f, "Simulationsgeschwindigkeit"); } + /** + * Fill default longs. + */ public void fillDefaultLongs() { /* Simulation prefs */ initLongUnit("message.sendingtime.min", 500, "Minimale Übertragungszeit", "ms"); initLongUnit("message.sendingtime.max", 2000, "Maximale Übertragungszeit", "ms"); } + /* (non-Javadoc) + * @see prefs.VSPrefs#fillDefaultColors() + */ public void fillDefaultColors() { /* Internal prefs */ initColor("col.background", new Color(0xFF, 0xFF, 0xFF)); @@ -196,6 +235,9 @@ public class VSDefaultPrefs extends VSPrefs { initColor("col.message.lost", new Color(0xFF, 0x00, 0x00)); } + /* (non-Javadoc) + * @see prefs.VSPrefs#fillDefaultBooleans() + */ public void fillDefaultBooleans() { //initBoolean("message.broadcast", false, "Nachrichten sind immer Broadcasts"); initBoolean("sim.mode.expert", false, "Expertenmodus aktivieren"); diff --git a/sources/prefs/VSPrefs.java b/sources/prefs/VSPrefs.java index 7211219..65dfcde 100644 --- a/sources/prefs/VSPrefs.java +++ b/sources/prefs/VSPrefs.java @@ -1,55 +1,139 @@ +/* + * VS is (c) 2008 by Paul C. Buetow + * vs@dev.buetow.org + */ package prefs; import java.awt.Color; import java.io.*; import java.util.*; +// TODO: Auto-generated Javadoc +/** + * The Class VSPrefs. + */ public abstract class VSPrefs implements Serializable { + + /** The Constant BOOLEAN_PREFIX. */ public static final String BOOLEAN_PREFIX = "Boolean: "; + + /** The Constant COLOR_PREFIX. */ public static final String COLOR_PREFIX = "Color: "; + + /** The Constant FLOAT_PREFIX. */ public static final String FLOAT_PREFIX = "Float: "; + + /** The Constant INTEGER_PREFIX. */ public static final String INTEGER_PREFIX = "Integer: "; + + /** The Constant LONG_PREFIX. */ public static final String LONG_PREFIX = "Long: "; + + /** The Constant STRING_PREFIX. */ public static final String STRING_PREFIX = "String: "; + + /** The color prefs. */ private HashMap colorPrefs; + + /** The float prefs. */ private HashMap floatPrefs; + + /** The integer prefs. */ private HashMap integerPrefs; + + /** The long prefs. */ private HashMap longPrefs; + + /** The setting restriction prefs. */ private HashMap settingRestrictionPrefs; + + /** The description prefs. */ private HashMap descriptionPrefs; + + /** The string prefs. */ private HashMap stringPrefs; + + /** The boolean prefs. */ private HashMap booleanPrefs; + + /** The object prefs. */ private HashMap objectPrefs; + + /** The units. */ private HashMap units; + + /** 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 long idCounter; + + /** The id. */ protected long id; + /** + * The Class SettingRestriction. + */ public class SettingRestriction implements Serializable {