diff options
| author | Paul Buetow <paul@buetow.org> | 2008-05-31 04:18:37 +0000 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2008-05-31 04:18:37 +0000 |
| commit | 8b7220b414da44508d3806051c065066933f85d1 (patch) | |
| tree | 42eb845e68e4a2222d52a43ffbcd4cac4a241e8d | |
| parent | 240a13415775a92f221b8b1fdda66258ae371cb1 (diff) | |
a bit of refactoring
| -rw-r--r-- | sources/core/VSMessage.java | 2 | ||||
| -rw-r--r-- | sources/core/VSProcess.java | 38 | ||||
| -rw-r--r-- | sources/core/VSTask.java | 4 | ||||
| -rw-r--r-- | sources/core/VSTaskManager.java | 4 | ||||
| -rw-r--r-- | sources/prefs/VSDefaultPrefs.java | 32 | ||||
| -rw-r--r-- | sources/prefs/editors/VSAbstractEditor.java | 2 | ||||
| -rw-r--r-- | sources/prefs/editors/VSSimulatorEditor.java | 36 | ||||
| -rw-r--r-- | sources/simulator/VSLogging.java | 8 | ||||
| -rw-r--r-- | sources/simulator/VSMenuItemStates.java | 4 | ||||
| -rw-r--r-- | sources/simulator/VSSimulator.java | 38 | ||||
| -rw-r--r-- | sources/simulator/VSSimulatorCanvas.java | 116 | ||||
| -rw-r--r-- | sources/simulator/VSSimulatorFrame.java | 156 |
12 files changed, 220 insertions, 220 deletions
diff --git a/sources/core/VSMessage.java b/sources/core/VSMessage.java index 2f2a0e4..c6b936d 100644 --- a/sources/core/VSMessage.java +++ b/sources/core/VSMessage.java @@ -29,7 +29,7 @@ import prefs.VSPrefs; /** * This class represents a message which is send from one process to another - * process in the simulation. + * process in the simulator. * * @author Paul C. Buetow */ diff --git a/sources/core/VSProcess.java b/sources/core/VSProcess.java index e0392fc..0c9694e 100644 --- a/sources/core/VSProcess.java +++ b/sources/core/VSProcess.java @@ -36,7 +36,7 @@ import utils.*; /** * The class VSProcess, an object of this class represents a process of a - * simulation. + * simulator. * * @author Paul C. Buetow */ @@ -44,13 +44,13 @@ public class VSProcess extends VSPrefs { /** The data serialization id. */ private static final long serialVersionUID = 1L; - /** The protocols to reset if the simulation is over or the reset + /** The protocols to reset if the simulator is over or the reset * button has been pressed. */ private ArrayList<VSAbstractProtocol> protocolsToReset; /** The crash history. represents all crashes of the process using the - * global simulation time. + * global simulator time. */ private ArrayList<Long> crashHistory; @@ -72,13 +72,13 @@ public class VSProcess extends VSPrefs { /** The logging object. */ private VSLogging logging; - /** The simulation's default prefs. */ + /** The simulator's default prefs. */ private VSPrefs prefs; /** The random generator of the process. */ private VSRandom random; - /** The simulation canvas. */ + /** The simulator canvas. */ private VSSimulatorCanvas simulatorCanvas; /** The random crash task. May be null if there is no such random task. */ @@ -191,9 +191,9 @@ public class VSProcess extends VSPrefs { /** * Instantiates a new process. * - * @param prefs the simulation's default prefs + * @param prefs the simulator's default prefs * @param processNum the process num - * @param simulatorCanvas the simulation canvas + * @param simulatorCanvas the simulator canvas * @param logging the logging object */ public VSProcess(VSPrefs prefs, int processNum, @@ -282,7 +282,7 @@ public class VSProcess extends VSPrefs { /** * Syncs the process' time. This method is using the clockOffset and * clockVariance variables. This method is called repeatedly from the - * VSSimulationCanvas in order to update the process' local and global + * VSSimulatorCanvas in order to update the process' local and global * time values. * * @param globalTime the global time. @@ -407,7 +407,7 @@ public class VSProcess extends VSPrefs { } /** - * The process' state is 'play'. Called by the simulation canvas. + * The process' state is 'play'. Called by the simulator canvas. */ public synchronized void play() { isPaused = false; @@ -415,7 +415,7 @@ public class VSProcess extends VSPrefs { } /** - * The process' state is 'pause'. Called by the simulation canvas. + * The process' state is 'pause'. Called by the simulator canvas. */ public synchronized void pause() { isPaused = true; @@ -423,7 +423,7 @@ public class VSProcess extends VSPrefs { } /** - * The process' state is 'Finish'. Called by the simulation canvas. + * The process' state is 'Finish'. Called by the simulator canvas. */ public synchronized void finish() { isPaused = true; @@ -526,7 +526,7 @@ public class VSProcess extends VSPrefs { /** * Checks if the process has crashed. The difference to isCrashed is, * that the process may be fully functional again after crashing. This - * method is needed by the simulation canvas in order to see if it should + * method is needed by the simulator canvas in order to see if it should * paint 'crashed areas' using the crash history of this process. * * @return true, if yes @@ -906,16 +906,16 @@ public class VSProcess extends VSPrefs { } /** - * Gets the simulation canvas. + * Gets the simulator canvas. * - * @return the simulation canvas + * @return the simulator canvas */ public VSSimulatorCanvas getSimulatorCanvas() { return simulatorCanvas; } /** - * Gets the simulation's default prefs. + * Gets the simulator's default prefs. * * @return the default prefs */ @@ -924,8 +924,8 @@ public class VSProcess extends VSPrefs { } /** - * Removes the process at the specified index. Called by the simulation - * canvas if a process has been removed from the simulation. Needed in + * Removes the process at the specified index. Called by the simulator + * canvas if a process has been removed from the simulator. Needed in * order to update the vector time and the local processNum. * * @param index the index the process has to get removed. @@ -941,8 +941,8 @@ public class VSProcess extends VSPrefs { /** * Added a process. Needed in order to update the vector time's size. - * Called by the simulation canvas if a process has been added to the - * simulation. + * Called by the simulator canvas if a process has been added to the + * simulator. */ public void addedAProcess() { vectorTime.add(new Long(0)); diff --git a/sources/core/VSTask.java b/sources/core/VSTask.java index 47de17b..d1e122e 100644 --- a/sources/core/VSTask.java +++ b/sources/core/VSTask.java @@ -33,7 +33,7 @@ import protocols.VSAbstractProtocol; * The class VSTask, an object of this class represents a task to do or done. * All tasks are managed by the task manager. There are local and global timed * tasks. Local timed tasks are being fullfilled if the process' local time is - * reached. Global timed tasks are being fullfilled if the simulation's time is + * reached. Global timed tasks are being fullfilled if the simulator's time is * reached. * * @author Paul C. Buetow @@ -61,7 +61,7 @@ public class VSTask implements Comparable { /** The process to run the task at. */ private VSProcess process; - /** The simulation's default prefs. */ + /** The simulator's default prefs. */ private VSPrefs prefs; /** The task is programmed. The task will be still in the task manager diff --git a/sources/core/VSTaskManager.java b/sources/core/VSTaskManager.java index 15d9eef..96bbb9e 100644 --- a/sources/core/VSTaskManager.java +++ b/sources/core/VSTaskManager.java @@ -72,8 +72,8 @@ public class VSTaskManager { } /** - * Run tasks. This method gets called by the simulation canvas repeatedly. - * Almost all simulation actions take place in this method. + * Run tasks. This method gets called by the simulator canvas repeatedly. + * Almost all simulator actions take place in this method. * * @param step the step * @param offset the offset diff --git a/sources/prefs/VSDefaultPrefs.java b/sources/prefs/VSDefaultPrefs.java index 2a8a4eb..50d3555 100644 --- a/sources/prefs/VSDefaultPrefs.java +++ b/sources/prefs/VSDefaultPrefs.java @@ -61,7 +61,7 @@ public class VSDefaultPrefs extends VSPrefs { */ 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 als 1. Prüfer sowie Betreuer und Prof. Dr. rer. nat. Fassbender als 2. Prüfer 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!"); + 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 Simulator verteilter Systeme\" bei Prof. Dr.-Ing. Oßmann als 1. Prüfer sowie Betreuer und Prof. Dr. rer. nat. Fassbender als 2. Prüfer 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!"); initString("lang.activate", "aktivieren"); initString("lang.activated", "aktiviert"); initString("lang.actualize", "Aktualisieren"); @@ -110,7 +110,7 @@ public class VSDefaultPrefs extends VSPrefs { initString("lang.prefs.process.ext", "Erweiterte Prozesseinstellungen"); initString("lang.prefs.process.info!", "Änderungen werden erst nach Betätigen des \"Übernehmen\" Knopfes übernommen!"); initString("lang.prefs.protocols", "Protokolleinstellungen"); - initString("lang.prefs.simulation", "Simulationseinstellungen"); + initString("lang.prefs.simulator", "Simulatorseinstellungen"); initString("lang.process", "Prozess"); initString("lang.process.add.new", "Neuen Prozess hinzufügen"); initString("lang.process.crash", "Prozess abstürzen"); @@ -137,14 +137,14 @@ public class VSDefaultPrefs extends VSPrefs { initString("lang.save", "Speichern"); initString("lang.saveas", "Speichern unter"); initString("lang.server", "Server"); - initString("lang.simulation", "Simulation"); - initString("lang.simulation.close", "Simulation schliessen"); - initString("lang.simulation.finished", "Simulation beendet"); - initString("lang.simulation.new", "Neue Simulation"); - initString("lang.simulation.new", "Neue Simulation"); - initString("lang.simulation.paused", "Simulation pausiert"); - initString("lang.simulation.resetted", "Simulation zurückgesetzt"); - initString("lang.simulation.started", "Simulation gestartet"); + initString("lang.simulator", "Simulator"); + initString("lang.simulator.close", "Simulator schliessen"); + initString("lang.simulator.finished", "Simulator beendet"); + initString("lang.simulator.new", "Neue Simulator"); + initString("lang.simulator.new", "Neue Simulator"); + initString("lang.simulator.paused", "Simulator pausiert"); + initString("lang.simulator.resetted", "Simulator zurückgesetzt"); + initString("lang.simulator.started", "Simulator gestartet"); initString("lang.start", "Starten"); initString("lang.stop", "Stoppen"); initString("lang.takeover", "Übernehmen"); @@ -171,11 +171,11 @@ public class VSDefaultPrefs extends VSPrefs { * @see prefs.VSPrefs#fillDefaultIntegers() */ public void fillDefaultIntegers() { - /* Simulation prefs */ + /* Simulator prefs */ initInteger("sim.process.num", 3, "Anzahl der Prozesse", 1, 6); initInteger("message.prob.outage", 0, "Nachrichtenverlustw'keit", 0, 100, "%"); initInteger("process.prob.crash", 0, "Prozessausfallw'keit", 0, 100, "%"); - initInteger("sim.seconds", 15, "Simulationsdauer", 5, 120, "s"); + initInteger("sim.seconds", 15, "Simulatorsdauer", 5, 120, "s"); /* Internal prefs */ initInteger("keyevent.about", KeyEvent.VK_A, null, 0, 100); @@ -197,7 +197,7 @@ public class VSDefaultPrefs extends VSPrefs { initInteger("keyevent.reset", KeyEvent.VK_R, null, 0, 100); initInteger("keyevent.save", KeyEvent.VK_S, null, 0, 100); initInteger("keyevent.saveas", KeyEvent.VK_V, null, 0, 100); - initInteger("keyevent.simulation", KeyEvent.VK_S, null, 0, 100); + initInteger("keyevent.simulator", KeyEvent.VK_S, null, 0, 100); initInteger("keyevent.start", KeyEvent.VK_S, null, 0, 100); initInteger("keyevent.stop", KeyEvent.VK_P, null, 0, 100); @@ -213,16 +213,16 @@ public class VSDefaultPrefs extends VSPrefs { * @see prefs.VSPrefs#fillDefaultFloats() */ public void fillDefaultFloats() { - /* Simulation prefs */ + /* Simulator prefs */ initFloat("process.clock.variance", 0, "Uhrabweichung"); - initFloat("sim.clock.speed", 0.5f, "Abspielgeschwindigkeit der Simulation"); + initFloat("sim.clock.speed", 0.5f, "Abspielgeschwindigkeit der Simulator"); } /** * Fill default longs. */ public void fillDefaultLongs() { - /* Simulation prefs */ + /* Simulator prefs */ initLong("message.sendingtime.min", 500, "Minimale Übertragungszeit", "ms"); initLong("message.sendingtime.max", 2000, "Maximale Übertragungszeit", "ms"); } diff --git a/sources/prefs/editors/VSAbstractEditor.java b/sources/prefs/editors/VSAbstractEditor.java index 2063eeb..f4d913a 100644 --- a/sources/prefs/editors/VSAbstractEditor.java +++ b/sources/prefs/editors/VSAbstractEditor.java @@ -595,7 +595,7 @@ public abstract class VSAbstractEditor implements ActionListener { if (key.startsWith("sim.")) { if (!flag) { flag = true; - addSeparator(prefs.getString("lang.prefs.simulation")); + addSeparator(prefs.getString("lang.prefs.simulator")); } addVariable(labels.get(fullKey), components.get(fullKey), prefsToEdit); } diff --git a/sources/prefs/editors/VSSimulatorEditor.java b/sources/prefs/editors/VSSimulatorEditor.java index c9b4fab..a8d3705 100644 --- a/sources/prefs/editors/VSSimulatorEditor.java +++ b/sources/prefs/editors/VSSimulatorEditor.java @@ -43,14 +43,14 @@ public class VSSimulatorEditor extends VSAbstractBetterEditor { /** The simulator frame. */ private VSSimulatorFrame simulatorFrame; - /** The simulation. */ - private VSSimulator simulation; + /** The simulator. */ + private VSSimulator simulator; /** The TAKEOVE r_ button. */ public static boolean TAKEOVER_BUTTON; - /** The dont start new simulation. */ - private boolean dontStartNewSimulation; + /** The dont start new simulator. */ + private boolean dontStartNewSimulator; /** Open a new simulator window. */ private boolean openedNewWindow; @@ -60,15 +60,15 @@ public class VSSimulatorEditor extends VSAbstractBetterEditor { * * @param prefs the prefs * @param simulatorFrame the simulator frame - * @param simulation the simulation + * @param simulator the simulator */ public VSSimulatorEditor(VSPrefs prefs, VSSimulatorFrame simulatorFrame, - VSSimulator simulation) { + VSSimulator simulator) { super(prefs, prefs, prefs.getString("lang.name") + " - " + prefs.getString("lang.prefs")); - this.dontStartNewSimulation = true;//simulation != null; + this.dontStartNewSimulator = true;//simulator != null; this.simulatorFrame = simulatorFrame; - this.simulation = simulation; + this.simulator = simulator; } /** @@ -108,26 +108,26 @@ public class VSSimulatorEditor extends VSAbstractBetterEditor { if (actionCommand.equals(prefs.getString("lang.takeover"))) { savePrefs(); - if (simulation != null) { + if (simulator != null) { if (expertModeChanged()) - simulation.fireExpertModeChanged(); - simulation.updateFromPrefs(); + simulator.fireExpertModeChanged(); + simulator.updateFromPrefs(); } } else if (actionCommand.equals(prefs.getString("lang.cancel"))) { - if (!dontStartNewSimulation && openedNewWindow) + if (!dontStartNewSimulator && openedNewWindow) simulatorFrame.dispose(); } else if (actionCommand.equals(prefs.getString("lang.ok"))) { savePrefs(); if (expertModeChanged()) { - if (simulation != null) - simulation.fireExpertModeChanged(); + if (simulator != null) + simulator.fireExpertModeChanged(); } - if (!dontStartNewSimulation) - simulatorFrame.addSimulation(new VSSimulator(prefsToEdit, simulatorFrame)); - else if (simulation != null) - simulation.updateFromPrefs(); + if (!dontStartNewSimulator) + simulatorFrame.addSimulator(new VSSimulator(prefsToEdit, simulatorFrame)); + else if (simulator != null) + simulator.updateFromPrefs(); } else { super.actionPerformed(e); diff --git a/sources/simulator/VSLogging.java b/sources/simulator/VSLogging.java index f240e78..4570b0f 100644 --- a/sources/simulator/VSLogging.java +++ b/sources/simulator/VSLogging.java @@ -53,7 +53,7 @@ public class VSLogging { /** The logging lines. */ private ArrayList<StringBuffer> loggingLines; - /** The simulation canvas. */ + /** The simulator canvas. */ private VSSimulatorCanvas simulatorCanvas; /** The logging messages are filtered. */ @@ -79,11 +79,11 @@ public class VSLogging { } /** - * Sets the simulation canvas. + * Sets the simulator canvas. * - * @param simulatorCanvas the simulation canvas + * @param simulatorCanvas the simulator canvas */ - public void setSimulationCanvas(VSSimulatorCanvas simulatorCanvas) { + public void setSimulatorCanvas(VSSimulatorCanvas simulatorCanvas) { this.simulatorCanvas = simulatorCanvas; } diff --git a/sources/simulator/VSMenuItemStates.java b/sources/simulator/VSMenuItemStates.java index 4823bff..fe69d92 100644 --- a/sources/simulator/VSMenuItemStates.java +++ b/sources/simulator/VSMenuItemStates.java @@ -24,8 +24,8 @@ package simulator; /** - * The class VSMenuItemStates. Used by the VSSimulation to update the - * "simulation" bar of the VSSimulationFrame. + * The class VSMenuItemStates. Used by the VSSimulator to update the + * "simulator" bar of the VSSimulatorFrame. * * @author Paul C. Buetow */ diff --git a/sources/simulator/VSSimulator.java b/sources/simulator/VSSimulator.java index 29cb5d7..3ae6a3c 100644 --- a/sources/simulator/VSSimulator.java +++ b/sources/simulator/VSSimulator.java @@ -38,8 +38,8 @@ import prefs.editors.*; import utils.*; /** - * The class VSSimulator, an object of this class represents a whole simulation. - * It may be, that several parallel simulations exist. They are independent + * The class VSSimulator, an object of this class represents a whole simulator. + * It may be, that several parallel simulators exist. They are independent * fron each other. * * @author Paul C. Buetow @@ -126,7 +126,7 @@ public class VSSimulator extends JPanel { /** The prefs. */ private VSPrefs prefs; - /** The simulation canvas. */ + /** The simulator canvas. */ private VSSimulatorCanvas simulatorCanvas; /** The simulator frame. */ @@ -141,7 +141,7 @@ public class VSSimulator extends JPanel { /** The task manager local model. */ private VSTaskManagerTableModel taskManagerLocalModel; - /** The simulation has started. */ + /** The simulator has started. */ private boolean hasStarted = false; /** The last selected process num. */ @@ -150,11 +150,11 @@ public class VSSimulator extends JPanel { /** The last expert state. */ private boolean lastExpertState; - /** The simulation counter. */ - private static int simulationCounter; + /** The simulator counter. */ + private static int simulatorCounter; - /** The simulation num. */ - private static int simulationNum; + /** The simulator num. */ + private static int simulatorNum; /** * The class VSTaskManagerTableModel, an object of this class handles @@ -385,12 +385,12 @@ public class VSSimulator extends JPanel { this.prefs = prefs; this.simulatorFrame = simulatorFrame; this.logging = new VSLogging(); - this.simulationNum = ++simulationCounter; + this.simulatorNum = ++simulatorCounter; this.menuItemStates = new VSMenuItemStates(false, false, false, true); this.localTextFields = new ArrayList<String>(); this.globalTextFields = new ArrayList<String>(); - logging.logg(prefs.getString("lang.simulation.new")); + logging.logg(prefs.getString("lang.simulator.new")); fillContentPane(); updateFromPrefs(); splitPaneH.setDividerLocation( @@ -427,7 +427,7 @@ public class VSSimulator extends JPanel { simulatorCanvas = new VSSimulatorCanvas(prefs, this, logging); taskManager = simulatorCanvas.getTaskManager(); - logging.setSimulationCanvas(simulatorCanvas); + logging.setSimulatorCanvas(simulatorCanvas); JPanel canvasPanel = new JPanel(); canvasPanel.setLayout(new GridLayout(1, 1, 3, 3)); @@ -1051,23 +1051,23 @@ public class VSSimulator extends JPanel { } /** - * The simulation has finished. + * The simulator has finished. */ public void finish() { menuItemStates.setStart(false); menuItemStates.setPause(false); menuItemStates.setReset(true); menuItemStates.setReplay(true); - simulatorFrame.updateSimulationMenu(); + simulatorFrame.updateSimulatorMenu(); } /** - * Gets the simulation num. + * Gets the simulator num. * - * @return the simulation num + * @return the simulator num */ - public int getSimulationNum() { - return simulationNum; + public int getSimulatorNum() { + return simulatorNum; } /** @@ -1080,9 +1080,9 @@ public class VSSimulator extends JPanel { } /** - * Gets the simulation canvas. + * Gets the simulator canvas. * - * @return the simulation canvas + * @return the simulator canvas */ public VSSimulatorCanvas getSimulatorCanvas() { return simulatorCanvas; diff --git a/sources/simulator/VSSimulatorCanvas.java b/sources/simulator/VSSimulatorCanvas.java index d8071bc..c972570 100644 --- a/sources/simulator/VSSimulatorCanvas.java +++ b/sources/simulator/VSSimulatorCanvas.java @@ -39,8 +39,8 @@ import prefs.editors.*; /** * The class VSSimulatorCanvas. An instance of this object represents the - * graphical paint area of a simulation. It contains all graphic calculations. - * Also the simulation thread takes place in this class in a loop! This class + * graphical paint area of a simulator. It contains all graphic calculations. + * Also the simulator thread takes place in this class in a loop! This class * is probably the most cryptic of the whole simulator source code. This is * this way in order to gain more performance of the painting area! * @@ -53,8 +53,8 @@ public class VSSimulatorCanvas extends Canvas implements Runnable { /** The highlighted process. */ private VSProcess highlightedProcess; - /** The simulation. */ - private VSSimulator simulation; + /** The simulator. */ + private VSSimulator simulator; /** The prefs. */ private VSPrefs prefs; @@ -71,31 +71,31 @@ public class VSSimulatorCanvas extends Canvas implements Runnable { /** The thread sleep. */ private int threadSleep; - /** The until time. Until then goes the simulation? */ + /** The until time. Until then goes the simulator? */ private long untilTime; - /** The simulation is paused. */ + /** The simulator is paused. */ private volatile boolean isPaused = true; - /** The simulation thread is stopped. */ + /** The simulator thread is stopped. */ private volatile boolean hasThreadStopped = false; - /** The simulation is finished. */ + /** The simulator is finished. */ private volatile boolean isFinished = false; - /** The simulation is resetted. */ + /** The simulator is resetted. */ private volatile boolean isResetted = false; - /** The simulation is anti aliased. */ + /** The simulator is anti aliased. */ private volatile boolean isAntiAliased = false; - /** The simulation's anti aliasing has changed. */ + /** The simulator's anti aliasing has changed. */ private volatile boolean isAntiAliasedChanged = false; - /** The simulation shows the lamport time. */ + /** The simulator shows the lamport time. */ private volatile boolean showLamport = false; - /** The simulation shows the vector time. */ + /** The simulator shows the vector time. */ private volatile boolean showVectorTime = false; /** The pause time. */ @@ -128,8 +128,8 @@ public class VSSimulatorCanvas extends Canvas implements Runnable { /** The clock offset. */ private double clockOffset; - /** The simulation time. */ - private long simulationTime; + /** The simulator time. */ + private long simulatorTime; /** The x paint size. */ double xPaintSize; @@ -401,13 +401,13 @@ public class VSSimulatorCanvas extends Canvas implements Runnable { } /** - * Called if a process within the simulation has been removed at a + * Called if a process within the simulator has been removed at a * specified index. * * @param index the index * * @return true, if the sender or the receiver of the message has been - * removed from the simulation. Else false is returned. + * removed from the simulator. Else false is returned. */ public boolean removedAProcessAtIndex(int index) { if (index == receiverNum || index == senderNum) @@ -459,13 +459,13 @@ public class VSSimulatorCanvas extends Canvas implements Runnable { * Instantiates a new VSSimulatorCanvas object. * * @param prefs the prefs - * @param simulation the simulation + * @param simulator the simulator * @param logging the logging */ - public VSSimulatorCanvas(VSPrefs prefs, VSSimulator simulation, + public VSSimulatorCanvas(VSPrefs prefs, VSSimulator simulator, VSLogging logging) { this.prefs = prefs; - this.simulation = simulation; + this.simulator = simulator; this.logging = logging; this.taskManager = new VSTaskManager(prefs, this); this.messageLines = new LinkedList<VSMessageLine>(); @@ -649,10 +649,10 @@ public class VSSimulatorCanvas extends Canvas implements Runnable { messageLostColor = prefs.getColor("col.message.lost"); backgroundColor = prefs.getColor("col.background"); - paintSize = simulation.getPaintSize(); - xPaintSize = simulation.getWidth() - - (3 * XOFFSET + simulation.getSplitSize()); - yDistance = (simulation.getPaintSize() - + paintSize = simulator.getPaintSize(); + xPaintSize = simulator.getWidth() - + (3 * XOFFSET + simulator.getSplitSize()); + yDistance = (simulator.getPaintSize() - 2 * (YOFFSET + YOUTER_SPACEING))/ numProcesses; xpaintsize_dividedby_untiltime = xPaintSize / (double) untilTime; @@ -705,41 +705,41 @@ public class VSSimulatorCanvas extends Canvas implements Runnable { } /** - * Updates the simulation. + * Updates the simulator. * * @param globalTime the global time * @param lastGlobalTime the last global time */ - private void updateSimulation(long globalTime, long lastGlobalTime) { + private void updateSimulator(long globalTime, long lastGlobalTime) { if (isPaused || isFinished) return; - long lastSimulationTime = simulationTime; + long lastSimulatorTime = simulatorTime; long offset = globalTime - lastGlobalTime; clockOffset += offset * clockSpeed; while (clockOffset >= 1) { --clockOffset; - ++simulationTime; + ++simulatorTime; } - if (simulationTime > untilTime) - simulationTime = untilTime; + if (simulatorTime > untilTime) + simulatorTime = untilTime; - offset = simulationTime - lastSimulationTime; + offset = simulatorTime - lastSimulatorTime; for (long l = 0; l < offset; ++l) - taskManager.runTasks(l, offset, lastSimulationTime); + taskManager.runTasks(l, offset, lastSimulatorTime); synchronized (processes) { for (VSProcess process : processes) - process.syncTime(simulationTime); + process.syncTime(simulatorTime); } } /** - * Paints the simulation. + * Paints the simulator. */ public void paint() { while (getBufferStrategy() == null) { @@ -764,7 +764,7 @@ public class VSSimulatorCanvas extends Canvas implements Runnable { } g.fillRect(0, 0, getWidth(), getHeight()); - long globalTime = simulationTime; + long globalTime = simulatorTime; globalTimeXPosition = getTimeXPosition(globalTime); paintSecondlines(g); @@ -1034,7 +1034,7 @@ public class VSSimulatorCanvas extends Canvas implements Runnable { * @return the time */ public long getTime() { - return simulationTime; + return simulatorTime; } /** @@ -1122,9 +1122,9 @@ public class VSSimulatorCanvas extends Canvas implements Runnable { System.out.println(e); } - updateSimulation(time, lastTime); + updateSimulator(time, lastTime); - if (simulationTime == untilTime) { + if (simulatorTime == untilTime) { finish(); break; } @@ -1134,16 +1134,16 @@ public class VSSimulatorCanvas extends Canvas implements Runnable { time = System.currentTimeMillis() - startTime; } - updateSimulation(time, lastTime); + updateSimulator(time, lastTime); paint(); } } /** - * Starts/plays the simulation. + * Starts/plays the simulator. */ public void play() { - logging.logg(prefs.getString("lang.simulation.started")); + logging.logg(prefs.getString("lang.simulator.started")); final long currentTime = System.currentTimeMillis(); synchronized (processes) { @@ -1171,7 +1171,7 @@ public class VSSimulatorCanvas extends Canvas implements Runnable { } /** - * Called if the simulation has finished. + * Called if the simulator has finished. */ public void finish() { synchronized (processes) { @@ -1179,14 +1179,14 @@ public class VSSimulatorCanvas extends Canvas implements Runnable { p.finish(); } - simulation.finish(); + simulator.finish(); isFinished = true; - logging.logg(prefs.getString("lang.simulation.finished")); + logging.logg(prefs.getString("lang.simulator.finished")); paint(); } /** - * Call this, in order to pause the simulation. + * Call this, in order to pause the simulator. */ public void pause() { isPaused = true; @@ -1196,16 +1196,16 @@ public class VSSimulatorCanvas extends Canvas implements Runnable { } pauseTime = System.currentTimeMillis(); - logging.logg(prefs.getString("lang.simulation.paused")); + logging.logg(prefs.getString("lang.simulator.paused")); paint(); } /** - * Call this, in order to reset the simulation. + * Call this, in order to reset the simulator. */ public void reset() { if (!isResetted) { - logging.logg(prefs.getString("lang.simulation.resetted")); + logging.logg(prefs.getString("lang.simulator.resetted")); isResetted = true; isPaused = false; @@ -1214,7 +1214,7 @@ public class VSSimulatorCanvas extends Canvas implements Runnable { time = 0; lastTime = 0; clockOffset = 0; - simulationTime = 0; + simulatorTime = 0; synchronized (processes) { for (VSProcess process : processes) @@ -1244,7 +1244,7 @@ public class VSSimulatorCanvas extends Canvas implements Runnable { } /** - * Stops the thread of the simulation. + * Stops the thread of the simulator. */ public void stopThread() { hasThreadStopped = true; @@ -1284,9 +1284,9 @@ public class VSSimulatorCanvas extends Canvas implements Runnable { } /** - * Sets if the simulation graphics are anti aliased. + * Sets if the simulator graphics are anti aliased. * - * @param isAntiAliased true, if the simulation is anti aliased + * @param isAntiAliased true, if the simulator is anti aliased */ public void isAntiAliased(boolean isAntiAliased) { this.isAntiAliased = isAntiAliased; @@ -1371,7 +1371,7 @@ public class VSSimulatorCanvas extends Canvas implements Runnable { public void editProcess(VSProcess process) { if (process != null) { process.updatePrefs(); - new VSEditorFrame(prefs, simulation.getSimulatorFrame(), + new VSEditorFrame(prefs, simulator.getSimulatorFrame(), new VSProcessEditor(prefs, process)); } } @@ -1432,13 +1432,13 @@ public class VSSimulatorCanvas extends Canvas implements Runnable { } /** - * Removes a process from the simulation. + * Removes a process from the simulator. * * @param process the process */ private void removeProcess(VSProcess process) { if (numProcesses == 1) { - simulation.getSimulatorFrame().removeSimulation(simulation); + simulator.getSimulatorFrame().removeSimulator(simulator); } else { int index = processes.indexOf(process); @@ -1452,7 +1452,7 @@ public class VSSimulatorCanvas extends Canvas implements Runnable { numProcesses = processes.size(); taskManager.removeTasksOf(process); - simulation.removedAProcessAtIndex(index); + simulator.removedAProcessAtIndex(index); recalcOnChange(); ArrayList<VSMessageLine> removeThose = @@ -1489,7 +1489,7 @@ public class VSSimulatorCanvas extends Canvas implements Runnable { } /** - * Adds a new process to the simulation. + * Adds a new process to the simulator. */ private void addProcess() { numProcesses = processes.size() + 1; @@ -1501,6 +1501,6 @@ public class VSSimulatorCanvas extends Canvas implements Runnable { process.addedAProcess(); } recalcOnChange(); - simulation.addProcessAtIndex(processes.size()-1); + simulator.addProcessAtIndex(processes.size()-1); } } diff --git a/sources/simulator/VSSimulatorFrame.java b/sources/simulator/VSSimulatorFrame.java index 44476e7..890eb28 100644 --- a/sources/simulator/VSSimulatorFrame.java +++ b/sources/simulator/VSSimulatorFrame.java @@ -37,7 +37,7 @@ import utils.*; /** * The class VSSimulatorFrame, an object of this class represents a window * of the simulator. The window can have several tabs. Each tab contains - * an independent simulation. + * an independent simulator. * * @author Paul C. Buetow */ @@ -75,8 +75,8 @@ public class VSSimulatorFrame extends VSFrame { /** The menu file. */ private JMenu menuFile; - /** The menu simulation. */ - private JMenu menuSimulation; + /** The menu simulator. */ + private JMenu menuSimulator; /** The tool bar. */ private JToolBar toolBar; @@ -84,11 +84,11 @@ public class VSSimulatorFrame extends VSFrame { /** The prefs. */ private VSPrefs prefs; - /** The simulations. */ - private Vector<VSSimulator> simulations; + /** The simulators. */ + private Vector<VSSimulator> simulators; - /** The current simulation. */ - private VSSimulator currentSimulation; + /** The current simulator. */ + private VSSimulator currentSimulator; /** The tabbed pane. */ private JTabbedPane tabbedPane; @@ -105,7 +105,7 @@ public class VSSimulatorFrame extends VSFrame { public VSSimulatorFrame(VSPrefs prefs, Component relativeTo) { super(prefs.getString("lang.name"), relativeTo); this.prefs = prefs; - this.simulations = new Vector<VSSimulator>(); + this.simulators = new Vector<VSSimulator>(); final VSPrefs finalPrefs = this.prefs; actionListener = new ActionListener() { @@ -120,11 +120,11 @@ public class VSSimulatorFrame extends VSFrame { getDescription(); if (sourceText.equals( - finalPrefs.getString("lang.simulation.close"))) { - removeCurrentSimulation(); + finalPrefs.getString("lang.simulator.close"))) { + removeCurrentSimulator(); } else if (sourceText.equals( - finalPrefs.getString("lang.simulation.new"))) { + finalPrefs.getString("lang.simulator.new"))) { VSPrefs newPrefs = VSDefaultPrefs.init(); VSSimulatorEditor simulatorEditor = new VSSimulatorEditor(newPrefs, VSSimulatorFrame.this, @@ -152,47 +152,47 @@ public class VSSimulatorFrame extends VSFrame { } else if (sourceText.equals( finalPrefs.getString("lang.start"))) { VSMenuItemStates menuItemState = - currentSimulation.getMenuItemStates(); + currentSimulator.getMenuItemStates(); menuItemState.setStart(false); menuItemState.setPause(true); menuItemState.setReset(false); menuItemState.setReplay(true); - currentSimulation.getSimulatorCanvas().play(); - updateSimulationMenu(); + currentSimulator.getSimulatorCanvas().play(); + updateSimulatorMenu(); } else if (sourceText.equals( finalPrefs.getString("lang.pause"))) { VSMenuItemStates menuItemState = - currentSimulation.getMenuItemStates(); + currentSimulator.getMenuItemStates(); menuItemState.setStart(true); menuItemState.setPause(false); menuItemState.setReset(true); menuItemState.setReplay(true); - currentSimulation.getSimulatorCanvas().pause(); - updateSimulationMenu(); + currentSimulator.getSimulatorCanvas().pause(); + updateSimulatorMenu(); } else if (sourceText.equals( finalPrefs.getString("lang.reset"))) { VSMenuItemStates menuItemState = - currentSimulation.getMenuItemStates(); + currentSimulator.getMenuItemStates(); menuItemState.setStart(true); menuItemState.setPause(false); menuItemState.setReset(false); menuItemState.setReplay(false); - currentSimulation.getSimulatorCanvas().reset(); - updateSimulationMenu(); + currentSimulator.getSimulatorCanvas().reset(); + updateSimulatorMenu(); } else if (sourceText.equals( finalPrefs.getString("lang.replay"))) { VSMenuItemStates menuItemState = - currentSimulation.getMenuItemStates(); + currentSimulator.getMenuItemStates(); menuItemState.setStart(false); menuItemState.setPause(true); menuItemState.setReset(false); menuItemState.setReplay(true); - currentSimulation.getSimulatorCanvas().reset(); - currentSimulation.getSimulatorCanvas().play(); - updateSimulationMenu(); + currentSimulator.getSimulatorCanvas().reset(); + currentSimulator.getSimulatorCanvas().play(); + updateSimulatorMenu(); } } }; @@ -213,7 +213,7 @@ public class VSSimulatorFrame extends VSFrame { startButton.setEnabled(false); menuEdit.setEnabled(false); menuFile.setEnabled(false); - menuSimulation.setEnabled(false); + menuSimulator.setEnabled(false); } /** @@ -227,7 +227,7 @@ public class VSSimulatorFrame extends VSFrame { menuFile.setMnemonic(prefs.getInteger("keyevent.file")); JMenuItem menuItem; - menuItem = new JMenuItem(prefs.getString("lang.simulation.new")); + menuItem = new JMenuItem(prefs.getString("lang.simulator.new")); menuItem.setAccelerator(KeyStroke.getKeyStroke( prefs.getInteger("keyevent.new"), ActionEvent.ALT_MASK)); @@ -235,7 +235,7 @@ public class VSSimulatorFrame extends VSFrame { menuFile.add(menuItem); menuItem = new JMenuItem( - prefs.getString("lang.simulation.close")); + prefs.getString("lang.simulator.close")); menuItem.setAccelerator(KeyStroke.getKeyStroke( prefs.getInteger("keyevent.close"), ActionEvent.ALT_MASK)); @@ -269,11 +269,11 @@ public class VSSimulatorFrame extends VSFrame { menuEdit.setMnemonic(prefs.getInteger("keyevent.edit")); updateEditMenu(); - /* Simulation menu */ + /* Simulator menu */ toolBar = new JToolBar(); - menuSimulation = new JMenu( - prefs.getString("lang.simulation")); - menuSimulation.setMnemonic(prefs.getInteger("keyevent.simulation")); + menuSimulator = new JMenu( + prefs.getString("lang.simulator")); + menuSimulator.setMnemonic(prefs.getInteger("keyevent.simulator")); resetItem = new JMenuItem(prefs.getString("lang.reset")); resetItem.setAccelerator(KeyStroke.getKeyStroke( @@ -281,7 +281,7 @@ public class VSSimulatorFrame extends VSFrame { ActionEvent.ALT_MASK)); resetItem.addActionListener(actionListener); resetItem.setEnabled(false); - menuSimulation.add(resetItem); + menuSimulator.add(resetItem); resetButton = new JButton(getImageIcon("reset.png", prefs.getString("lang.reset"))); resetButton.addActionListener(actionListener); @@ -294,7 +294,7 @@ public class VSSimulatorFrame extends VSFrame { ActionEvent.ALT_MASK)); replayItem.addActionListener(actionListener); replayItem.setEnabled(false); - menuSimulation.add(replayItem); + menuSimulator.add(replayItem); replayButton = new JButton( getImageIcon("replay.png", prefs.getString("lang.replay"))); replayButton.addActionListener(actionListener); @@ -305,7 +305,7 @@ public class VSSimulatorFrame extends VSFrame { prefs.getInteger("keyevent.pause"), ActionEvent.ALT_MASK)); pauseItem.addActionListener(actionListener); - menuSimulation.add(pauseItem); + menuSimulator.add(pauseItem); pauseItem.setEnabled(false); pauseButton = new JButton(getImageIcon("pause.png", prefs.getString("lang.pause"))); @@ -317,7 +317,7 @@ public class VSSimulatorFrame extends VSFrame { prefs.getInteger("keyevent.start"), ActionEvent.ALT_MASK)); startItem.addActionListener(actionListener); - menuSimulation.add(startItem); + menuSimulator.add(startItem); startButton = new JButton(getImageIcon("start.png", prefs.getString("lang.start"))); startButton.addActionListener(actionListener); @@ -327,7 +327,7 @@ public class VSSimulatorFrame extends VSFrame { JMenuBar mainMenuBar = new JMenuBar(); mainMenuBar.add(menuFile); mainMenuBar.add(menuEdit); - mainMenuBar.add(menuSimulation); + mainMenuBar.add(menuSimulator); return mainMenuBar; } @@ -345,10 +345,10 @@ public class VSSimulatorFrame extends VSFrame { tabbedPane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent ce) { JTabbedPane pane = (JTabbedPane) ce.getSource(); - currentSimulation = (VSSimulator) pane.getSelectedComponent(); - currentSimulation.getSimulatorCanvas().paint(); + currentSimulator = (VSSimulator) pane.getSelectedComponent(); + currentSimulator.getSimulatorCanvas().paint(); updateEditMenu(); - updateSimulationMenu(); + updateSimulatorMenu(); } }); @@ -369,23 +369,23 @@ public class VSSimulatorFrame extends VSFrame { prefs.getString("lang.prefs")); globalPrefsItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { - VSPrefs simulationPrefs = currentSimulation.getPrefs(); + VSPrefs simulatorPrefs = currentSimulator.getPrefs(); VSSimulatorEditor.TAKEOVER_BUTTON = true; - VSSimulatorEditor simulationEditor = new VSSimulatorEditor( - simulationPrefs, VSSimulatorFrame.this, currentSimulation); + VSSimulatorEditor simulatorEditor = new VSSimulatorEditor( + simulatorPrefs, VSSimulatorFrame.this, currentSimulator); new VSEditorFrame(prefs, VSSimulatorFrame.this, - simulationEditor); + simulatorEditor); } }); menuEdit.add(globalPrefsItem); menuEdit.addSeparator(); - if (currentSimulation == null) + if (currentSimulator == null) return; final String processString = prefs.getString("lang.process"); final ArrayList<VSProcess> arr = - currentSimulation.getSimulatorCanvas().getProcessesArray(); + currentSimulator.getSimulatorCanvas().getProcessesArray(); final int numProcesses = arr.size(); int processNum = 0; @@ -400,7 +400,7 @@ public class VSSimulatorFrame extends VSFrame { final int finalProcessNum = processNum++; processItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { - currentSimulation.getSimulatorCanvas().editProcess( + currentSimulator.getSimulatorCanvas().editProcess( finalProcessNum); } }); @@ -409,11 +409,11 @@ public class VSSimulatorFrame extends VSFrame { } /** - * Updates the simulation menu. Called if the simulator state has changed + * Updates the simulator menu. Called if the simulator state has changed * (e.g. start/play/stop/replay etc) */ - public synchronized void updateSimulationMenu() { - VSMenuItemStates menuItemState = currentSimulation.getMenuItemStates(); + public synchronized void updateSimulatorMenu() { + VSMenuItemStates menuItemState = currentSimulator.getMenuItemStates(); pauseItem.setEnabled(menuItemState.getPause()); replayItem.setEnabled(menuItemState.getReplay()); @@ -430,65 +430,65 @@ public class VSSimulatorFrame extends VSFrame { * @see java.awt.Window#dispose() */ public void dispose() { - synchronized (simulations) { - for (VSSimulator simulation : simulations) - simulation.getSimulatorCanvas().stopThread(); + synchronized (simulators) { + for (VSSimulator simulator : simulators) + simulator.getSimulatorCanvas().stopThread(); } super.dispose(); } /** - * Adds the simulation. + * Adds the simulator. * - * @param simulation the simulation + * @param simulator the simulator */ - public void addSimulation(VSSimulator simulation) { - simulation.setLayout(new GridLayout(1, 1, 3, 3)); - simulation.setMinimumSize(new Dimension(0, 0)); - simulation.setMaximumSize(new Dimension(0, 0)); + public void addSimulator(VSSimulator simulator) { + simulator.setLayout(new GridLayout(1, 1, 3, 3)); + simulator.setMinimumSize(new Dimension(0, 0)); + simulator.setMaximumSize(new Dimension(0, 0)); - simulations.add(simulation); - tabbedPane.addTab(prefs.getString("lang.simulation") - + " " + simulation.getSimulationNum(), simulation); - tabbedPane.setSelectedComponent(simulation); + simulators.add(simulator); + tabbedPane.addTab(prefs.getString("lang.simulator") + + " " + simulator.getSimulatorNum(), simulator); + tabbedPane.setSelectedComponent(simulator); - if (simulations.size() == 1) { + if (simulators.size() == 1) { menuEdit.setEnabled(true); menuFile.setEnabled(true); - menuSimulation.setEnabled(true); + menuSimulator.setEnabled(true); } } /** - * Removes the simulation. + * Removes the simulator. * - * @param simulationToRemove the simulation to remove + * @param simulatorToRemove the simulator to remove */ - public void removeSimulation(VSSimulator simulationToRemove) { - if (simulations.size() == 1) { + public void removeSimulator(VSSimulator simulatorToRemove) { + if (simulators.size() == 1) { dispose(); } else { - simulations.remove(simulationToRemove); - tabbedPane.remove(simulationToRemove); - simulationToRemove.getSimulatorCanvas().stopThread(); + simulators.remove(simulatorToRemove); + tabbedPane.remove(simulatorToRemove); + simulatorToRemove.getSimulatorCanvas().stopThread(); } } /** - * Removes the current simulation. + * Removes the current simulator. */ - private void removeCurrentSimulation() { - removeSimulation(currentSimulation); + private void removeCurrentSimulator() { + removeSimulator(currentSimulator); } /** - * Gets the current simulation. + * Gets the current simulator. * - * @return the current simulation + * @return the current simulator */ - public VSSimulator getCurrentSimulation() { - return currentSimulation; + public VSSimulator getCurrentSimulator() { + return currentSimulator; } /** |
