summaryrefslogtreecommitdiff
path: root/sources/simulator
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2008-05-25 08:10:13 +0000
committerPaul Buetow <paul@buetow.org>2008-05-25 08:10:13 +0000
commitc015d586d22b69078b6da61858e5675793856b0b (patch)
treeefbc9881cf59363abef52a0beb5eedf9e81a224a /sources/simulator
parent62fe28f0b0b0c9ebde18a6dc33907889ff3aa21b (diff)
JAutoDoc :)
Diffstat (limited to 'sources/simulator')
-rw-r--r--sources/simulator/VSAbout.java29
-rw-r--r--sources/simulator/VSLogging.java74
-rw-r--r--sources/simulator/VSMain.java31
-rw-r--r--sources/simulator/VSSimulator.java405
-rw-r--r--sources/simulator/VSSimulatorCanvas.java402
-rw-r--r--sources/simulator/VSSimulatorFrame.java94
6 files changed, 1035 insertions, 0 deletions
diff --git a/sources/simulator/VSAbout.java b/sources/simulator/VSAbout.java
index 88ccbf0..4b33e82 100644
--- a/sources/simulator/VSAbout.java
+++ b/sources/simulator/VSAbout.java
@@ -1,3 +1,7 @@
+/*
+ * VS is (c) 2008 by Paul C. Buetow
+ * vs@dev.buetow.org
+ */
package simulator;
import java.awt.*;
@@ -7,9 +11,21 @@ import javax.swing.*;
import prefs.*;
import utils.*;
+// TODO: Auto-generated Javadoc
+/**
+ * The Class VSAbout.
+ */
public class VSAbout extends VSFrame implements ActionListener {
+
+ /** The prefs. */
private VSPrefs prefs;
+ /**
+ * Instantiates a new vS about.
+ *
+ * @param prefs the prefs
+ * @param relativeTo the relative to
+ */
public VSAbout(VSPrefs prefs, Component relativeTo) {
super(prefs.getString("lang.name") + " - "
+ prefs.getString("lang.about"), relativeTo);
@@ -23,6 +39,11 @@ public class VSAbout extends VSFrame implements ActionListener {
}
+ /**
+ * Creates the content pane.
+ *
+ * @return the container
+ */
public Container createContentPane() {
Container contentPane = getContentPane();
@@ -36,6 +57,11 @@ public class VSAbout extends VSFrame implements ActionListener {
return contentPane;
}
+ /**
+ * Creates the button pane.
+ *
+ * @return the j panel
+ */
public JPanel createButtonPane() {
JPanel buttonPane = new JPanel();
buttonPane.setBackground(Color.WHITE);
@@ -50,6 +76,9 @@ public class VSAbout extends VSFrame implements ActionListener {
}
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ */
public void actionPerformed(ActionEvent e) {
String actionCommand = e.getActionCommand();
diff --git a/sources/simulator/VSLogging.java b/sources/simulator/VSLogging.java
index c303bec..fe76abc 100644
--- a/sources/simulator/VSLogging.java
+++ b/sources/simulator/VSLogging.java
@@ -1,3 +1,7 @@
+/*
+ * VS is (c) 2008 by Paul C. Buetow
+ * vs@dev.buetow.org
+ */
package simulator;
import java.util.*;
@@ -6,16 +10,39 @@ import javax.swing.*;
import utils.*;
+// TODO: Auto-generated Javadoc
+/**
+ * The Class VSLogging.
+ */
public class VSLogging {
+
+ /** The logging area. */
private JTextArea loggingArea;
+
+ /** The filter text. */
private String filterText;
+
+ /** The pause lines. */
private ArrayList<StringBuffer> pauseLines;
+
+ /** The logging lines. */
private ArrayList<StringBuffer> loggingLines;
+
+ /** The simulation canvas. */
private VSSimulatorCanvas simulationCanvas;
+
+ /** The is filtered. */
private boolean isFiltered;
+
+ /** The is paused. */
private boolean isPaused;
+
+ /** The filter pattern. */
private Pattern filterPattern;
+ /**
+ * Instantiates a new vS logging.
+ */
public VSLogging() {
loggingArea = new JTextArea(0, 0);
loggingArea.setEditable(false);
@@ -26,14 +53,29 @@ public class VSLogging {
filterText = "";
}
+ /**
+ * Sets the simulation canvas.
+ *
+ * @param simulationCanvas the new simulation canvas
+ */
public void setSimulationCanvas(VSSimulatorCanvas simulationCanvas) {
this.simulationCanvas = simulationCanvas;
}
+ /**
+ * Gets the logging area.
+ *
+ * @return the logging area
+ */
public JTextArea getLoggingArea() {
return loggingArea;
}
+ /**
+ * Logg.
+ *
+ * @param message the message
+ */
public void logg(String message) {
if (simulationCanvas == null)
logg(message, 0);
@@ -41,6 +83,12 @@ public class VSLogging {
logg(message, simulationCanvas.getTime());
}
+ /**
+ * Logg.
+ *
+ * @param message the message
+ * @param time the time
+ */
public synchronized void logg(String message, long time) {
StringBuffer buffer = new StringBuffer();
buffer.append(VSTools.getTimeString(time));
@@ -53,6 +101,11 @@ public class VSLogging {
loggFiltered(buffer);
}
+ /**
+ * Checks if is paused.
+ *
+ * @param isPaused the is paused
+ */
public synchronized void isPaused(boolean isPaused) {
this.isPaused = isPaused;
@@ -64,6 +117,11 @@ public class VSLogging {
}
}
+ /**
+ * Logg filtered.
+ *
+ * @param buffer the buffer
+ */
private void loggFiltered(StringBuffer buffer) {
loggingLines.add(buffer);
if (!isFiltered) {
@@ -76,6 +134,11 @@ public class VSLogging {
}
}
+ /**
+ * Checks if is filtered.
+ *
+ * @param isFiltered the is filtered
+ */
public synchronized void isFiltered(boolean isFiltered) {
this.isFiltered = isFiltered;
@@ -85,17 +148,28 @@ public class VSLogging {
filter();
}
+ /**
+ * Sets the filter text.
+ *
+ * @param filterText the new filter text
+ */
public synchronized void setFilterText(String filterText) {
this.filterText = filterText;
filter();
}
+ /**
+ * Clear.
+ */
public synchronized void clear() {
loggingLines.clear();
pauseLines.clear();
loggingArea.setText("");
}
+ /**
+ * Filter.
+ */
private void filter() {
try {
filterPattern = Pattern.compile(filterText);
diff --git a/sources/simulator/VSMain.java b/sources/simulator/VSMain.java
index bdfd631..79a0a7e 100644
--- a/sources/simulator/VSMain.java
+++ b/sources/simulator/VSMain.java
@@ -1,3 +1,7 @@
+/*
+ * VS is (c) 2008 by Paul C. Buetow
+ * vs@dev.buetow.org
+ */
package simulator;
import java.awt.*;
@@ -7,20 +11,47 @@ import events.*;
import prefs.*;
import prefs.editors.*;
+// TODO: Auto-generated Javadoc
+/**
+ * The Class VSMain.
+ */
public class VSMain {
+
+ /**
+ * Instantiates a new vS main.
+ *
+ * @param prefs the prefs
+ */
public VSMain(VSPrefs prefs) {
init(prefs, null);
}
+ /**
+ * Instantiates a new vS main.
+ *
+ * @param prefs the prefs
+ * @param relativeTo the relative to
+ */
public VSMain(VSPrefs prefs, Component relativeTo) {
init(prefs, relativeTo);
}
+ /**
+ * Inits the.
+ *
+ * @param prefs the prefs
+ * @param relativeTo the relative to
+ */
private void init(VSPrefs prefs, Component relativeTo) {
VSSimulatorFrame simulatorFrame = new VSSimulatorFrame(prefs, relativeTo);
new VSEditorFrame(prefs, relativeTo, new VSSimulatorEditor(prefs, simulatorFrame));
}
+ /**
+ * The main method.
+ *
+ * @param args the arguments
+ */
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(
diff --git a/sources/simulator/VSSimulator.java b/sources/simulator/VSSimulator.java
index 742bd27..c42b848 100644
--- a/sources/simulator/VSSimulator.java
+++ b/sources/simulator/VSSimulator.java
@@ -1,3 +1,7 @@
+/*
+ * VS is (c) 2008 by Paul C. Buetow
+ * vs@dev.buetow.org
+ */
package simulator;
import java.awt.*;
@@ -14,49 +18,142 @@ import prefs.*;
import prefs.editors.*;
import utils.*;
+// TODO: Auto-generated Javadoc
+/**
+ * The Class VSSimulator.
+ */
public class VSSimulator extends JPanel {
+
+ /** The global text fields. */
private ArrayList<String> globalTextFields;
+
+ /** The local text fields. */
private ArrayList<String> localTextFields;
+
+ /** The create tasks. */
private ArrayList<VSCreateTask> createTasks;
+
+ /** The filter active check box. */
private JCheckBox filterActiveCheckBox;
+
+ /** The lamport active check box. */
private JCheckBox lamportActiveCheckBox;
+
+ /** The vector time active check box. */
private JCheckBox vectorTimeActiveCheckBox;
+
+ /** The global pid combo box. */
private JComboBox globalPIDComboBox;
+
+ /** The local pid combo box. */
private JComboBox localPIDComboBox;
+
+ /** The processes combo box. */
private JComboBox processesComboBox;
+
+ /** The global add panel. */
private JPanel globalAddPanel;
+
+ /** The local add panel. */
private JPanel localAddPanel;
+
+ /** The local panel. */
private JPanel localPanel;
+
+ /** The logging panel. */
private JPanel loggingPanel;
+
+ /** The tools panel. */
private JPanel toolsPanel;
+
+ /** The split pane1. */
private JSplitPane splitPane1;
+
+ /** The split pane h. */
private JSplitPane splitPaneH;
+
+ /** The split pane v. */
private JSplitPane splitPaneV;
+
+ /** The tabbed pane. */
private JTabbedPane tabbedPane;
+
+ /** The logging area. */
private JTextArea loggingArea;
+
+ /** The filter text field. */
private JTextField filterTextField;
+
+ /** The global text field. */
private JTextField globalTextField;
+
+ /** The local text field. */
private JTextField localTextField;
+
+ /** The thread. */
private Thread thread;
+
+ /** The logging. */
private VSLogging logging;
+
+ /** The menu item states. */
private VSMenuItemStates menuItemStates;
+
+ /** The prefs. */
private VSPrefs prefs;
+
+ /** The simulation canvas. */
private VSSimulatorCanvas simulationCanvas;
+
+ /** The simulator frame. */
private VSSimulatorFrame simulatorFrame;
+
+ /** The task manager. */
private VSTaskManager taskManager;
+
+ /** The task manager global model. */
private VSTaskManagerTableModel taskManagerGlobalModel;
+
+ /** The task manager local model. */
private VSTaskManagerTableModel taskManagerLocalModel;
+
+ /** The has started. */
private boolean hasStarted = false;
+
+ /** The last selected process num. */
private int lastSelectedProcessNum;
+
+ /** The simulation counter. */
private static int simulationCounter;
+
+ /** The simulation num. */
private static int simulationNum;
+ /**
+ * The Class VSMenuItemStates.
+ */
public class VSMenuItemStates {
+
+ /** The pause. */
private volatile boolean pause;
+
+ /** The replay. */
private volatile boolean replay;
+
+ /** The reset. */
private volatile boolean reset;
+
+ /** The start. */
private volatile boolean start;
+ /**
+ * Instantiates a new vS menu item states.
+ *
+ * @param pause the pause
+ * @param replay the replay
+ * @param reset the reset
+ * @param start the start
+ */
public VSMenuItemStates(boolean pause, boolean replay, boolean reset, boolean start) {
this.pause = pause;
this.replay = replay;
@@ -64,39 +161,85 @@ public class VSSimulator extends JPanel {
this.start = start;
}
+ /**
+ * Sets the pause.
+ *
+ * @param pause the new pause
+ */
public void setPause(boolean pause) {
this.pause = pause;
}
+ /**
+ * Sets the replay.
+ *
+ * @param replay the new replay
+ */
public void setReplay(boolean replay) {
this.replay = replay;
}
+ /**
+ * Sets the reset.
+ *
+ * @param reset the new reset
+ */
public void setReset(boolean reset) {
this.reset = reset;
}
+ /**
+ * Sets the start.
+ *
+ * @param start the new start
+ */
public void setStart(boolean start) {
this.start = start;
}
+ /**
+ * Gets the pause.
+ *
+ * @return the pause
+ */
public boolean getPause() {
return pause;
}
+ /**
+ * Gets the replay.
+ *
+ * @return the replay
+ */
public boolean getReplay() {
return replay;
}
+ /**
+ * Gets the reset.
+ *
+ * @return the reset
+ */
public boolean getReset() {
return reset;
}
+ /**
+ * Gets the start.
+ *
+ * @return the start
+ */
public boolean getStart() {
return start;
}
}
+ /**
+ * Instantiates a new vS simulator.
+ *
+ * @param prefs the prefs
+ * @param simulatorFrame the simulator frame
+ */
public VSSimulator(VSPrefs prefs, VSSimulatorFrame simulatorFrame) {
this.prefs = prefs;
this.simulatorFrame = simulatorFrame;
@@ -132,6 +275,9 @@ public class VSSimulator extends JPanel {
thread.start();
}
+ /**
+ * Fill content pane.
+ */
private void fillContentPane() {
loggingArea = logging.getLoggingArea();
@@ -167,7 +313,14 @@ public class VSSimulator extends JPanel {
this.add(splitPaneV);
}
+ /** The last expert state. */
private boolean lastExpertState;
+
+ /**
+ * Creates the tools panel.
+ *
+ * @return the j panel
+ */
private JPanel createToolsPanel() {
JPanel toolsPanel = new JPanel();
boolean expertMode = prefs.getBoolean("sim.mode.expert");
@@ -285,6 +438,11 @@ public class VSSimulator extends JPanel {
return toolsPanel;
}
+ /**
+ * Creates the process pane.
+ *
+ * @return the j panel
+ */
private JPanel createProcessPane() {
JPanel editPanel = new JPanel(new GridBagLayout());
boolean expertMode = prefs.getBoolean("sim.mode.expert");
@@ -366,6 +524,13 @@ public class VSSimulator extends JPanel {
return editPanel;
}
+ /**
+ * Creates the label panel.
+ *
+ * @param text the text
+ *
+ * @return the j panel
+ */
private JPanel createLabelPanel(String text) {
JPanel panel = new JPanel();
JLabel label = new JLabel(text);
@@ -374,6 +539,13 @@ public class VSSimulator extends JPanel {
return panel;
}
+ /**
+ * Creates the task label.
+ *
+ * @param localTasks the local tasks
+ *
+ * @return the j panel
+ */
private JPanel createTaskLabel(boolean localTasks) {
JPanel panel = new JPanel(new GridBagLayout());
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
@@ -394,23 +566,48 @@ public class VSSimulator extends JPanel {
return panel;
}
+ /**
+ * The Class VSCreateTask.
+ */
private class VSCreateTask {
+
+ /** The event classname. */
private String eventClassname;
+
+ /** The protocol classname. */
private String protocolClassname;
+
+ /** The shortname. */
private String shortname;
/* Those 3 values are for ProtocolEvent events */
+ /** The is protocol activation. */
private boolean isProtocolActivation;
+
+ /** The is protocol deactivation. */
private boolean isProtocolDeactivation;
+
+ /** The is client protocol. */
private boolean isClientProtocol;
/* Those values are for ProtocolClient onStart events */
+ /** The is client request. */
private boolean isClientRequest;
+ /**
+ * Instantiates a new vS create task.
+ *
+ * @param eventClassname the event classname
+ */
public VSCreateTask(String eventClassname) {
this.eventClassname = eventClassname;
}
+ /**
+ * Checks if is protocol activation.
+ *
+ * @param isProtocolActivation the is protocol activation
+ */
public void isProtocolActivation(boolean isProtocolActivation) {
this.isProtocolActivation = isProtocolActivation;
@@ -418,6 +615,11 @@ public class VSSimulator extends JPanel {
isProtocolDeactivation(false);
}
+ /**
+ * Checks if is protocol deactivation.
+ *
+ * @param isProtocolDeactivation the is protocol deactivation
+ */
public void isProtocolDeactivation(boolean isProtocolDeactivation) {
this.isProtocolDeactivation = isProtocolDeactivation;
@@ -425,22 +627,51 @@ public class VSSimulator extends JPanel {
isProtocolActivation(false);
}
+ /**
+ * Checks if is client protocol.
+ *
+ * @param isClientProtocol the is client protocol
+ */
public void isClientProtocol(boolean isClientProtocol) {
this.isClientProtocol = isClientProtocol;
}
+ /**
+ * Checks if is client request.
+ *
+ * @param isClientRequest the is client request
+ */
public void isClientRequest(boolean isClientRequest) {
this.isClientRequest = isClientRequest;
}
+ /**
+ * Sets the protocol classname.
+ *
+ * @param protocolClassname the new protocol classname
+ */
public void setProtocolClassname(String protocolClassname) {
this.protocolClassname = protocolClassname;
}
+ /**
+ * Sets the shortname.
+ *
+ * @param shortname the new shortname
+ */
public void setShortname(String shortname) {
this.shortname = shortname;
}
+ /**
+ * Creates the task.
+ *
+ * @param process the process
+ * @param time the time
+ * @param localTimedTask the local timed task
+ *
+ * @return the vS task
+ */
public VSTask createTask(VSProcess process, long time, boolean localTimedTask) {
VSEvent event = null;
@@ -466,17 +697,44 @@ public class VSSimulator extends JPanel {
}
}
+ /**
+ * The Class VSTaskManagerTableModel.
+ */
private class VSTaskManagerTableModel extends AbstractTableModel implements MouseListener {
+
+ /** The Constant LOCAL. */
public static final boolean LOCAL = true;
+
+ /** The Constant GLOBAL. */
public static final boolean GLOBAL = false;
+
+ /** The Constant ALL_PROCESSES. */
public static final boolean ALL_PROCESSES = true;
+
+ /** The Constant ONE_PROCESS. */
public static final boolean ONE_PROCESS = false;
+
+ /** The all processes. */
public boolean allProcesses;
+
+ /** The tasks. */
private VSPriorityQueue<VSTask> tasks;
+
+ /** The column names. */
private String columnNames[];
+
+ /** The num columns. */
private int numColumns;
+
+ /** The table. */
private JTable table;
+ /**
+ * Instantiates a new vS task manager table model.
+ *
+ * @param process the process
+ * @param localTask the local task
+ */
public VSTaskManagerTableModel(VSProcess process, boolean localTask) {
set(process, localTask, ONE_PROCESS);
columnNames = new String[3];
@@ -486,10 +744,22 @@ public class VSSimulator extends JPanel {
numColumns = 3;
}
+ /**
+ * Sets the table.
+ *
+ * @param table the new table
+ */
public void setTable(JTable table) {
this.table = table;
}
+ /**
+ * Sets the.
+ *
+ * @param process the process
+ * @param localTasks the local tasks
+ * @param allProcesses the all processes
+ */
public void set(VSProcess process, boolean localTasks, boolean allProcesses) {
this.allProcesses = allProcesses;
@@ -506,18 +776,30 @@ public class VSSimulator extends JPanel {
fireTableDataChanged();
}
+ /* (non-Javadoc)
+ * @see javax.swing.table.AbstractTableModel#getColumnName(int)
+ */
public String getColumnName(int col) {
return columnNames[col];
}
+ /* (non-Javadoc)
+ * @see javax.swing.table.TableModel#getRowCount()
+ */
public int getRowCount() {
return tasks == null ? 0 : tasks.size();
}
+ /* (non-Javadoc)
+ * @see javax.swing.table.TableModel#getColumnCount()
+ */
public int getColumnCount() {
return numColumns;
}
+ /* (non-Javadoc)
+ * @see javax.swing.table.TableModel#getValueAt(int, int)
+ */
public Object getValueAt(int row, int col) {
VSTask task = tasks.get(row);
@@ -531,19 +813,35 @@ public class VSSimulator extends JPanel {
return task.getEvent().getShortname();
}
+ /* (non-Javadoc)
+ * @see javax.swing.table.AbstractTableModel#isCellEditable(int, int)
+ */
public boolean isCellEditable(int row, int col) {
return false;
}
+ /* (non-Javadoc)
+ * @see javax.swing.table.AbstractTableModel#setValueAt(java.lang.Object, int, int)
+ */
public void setValueAt(Object value, int row, int col) {
fireTableDataChanged();
}
+ /**
+ * Adds the task.
+ *
+ * @param task the task
+ */
public void addTask(VSTask task) {
tasks.add(task);
fireTableDataChanged();
}
+ /**
+ * Removes the task at row.
+ *
+ * @param row the row
+ */
private void removeTaskAtRow(int row) {
VSTask task = tasks.get(row);
tasks.remove(task);
@@ -551,6 +849,9 @@ public class VSSimulator extends JPanel {
fireTableDataChanged();
}
+ /* (non-Javadoc)
+ * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
+ */
public void mouseClicked(MouseEvent me) {
JTable source = (JTable) me.getSource();
final int row = source.rowAtPoint(me.getPoint());
@@ -575,12 +876,34 @@ public class VSSimulator extends JPanel {
}
}
+ /* (non-Javadoc)
+ * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
+ */
public void mouseEntered(MouseEvent me) { }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
+ */
public void mouseExited(MouseEvent me) { }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
+ */
public void mousePressed(MouseEvent me) { }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
+ */
public void mouseReleased(MouseEvent me) { }
}
+ /**
+ * Creates the task table.
+ *
+ * @param localTasks the local tasks
+ *
+ * @return the j table
+ */
private JTable createTaskTable(boolean localTasks) {
VSProcess process = getSelectedProcess();
VSTaskManagerTableModel model = new VSTaskManagerTableModel(process, localTasks);
@@ -609,6 +932,14 @@ public class VSSimulator extends JPanel {
return table;
}
+ /**
+ * Inits the add panel.
+ *
+ * @param panel the panel
+ * @param localTasks the local tasks
+ *
+ * @return the j panel
+ */
private JPanel initAddPanel(JPanel panel, final boolean localTasks) {
JPanel addPanel = new JPanel();
addPanel.setLayout(new BoxLayout(addPanel, BoxLayout.X_AXIS));
@@ -810,23 +1141,50 @@ public class VSSimulator extends JPanel {
return addPanel;
}
+ /**
+ * Gets the split size.
+ *
+ * @return the split size
+ */
public int getSplitSize() {
return splitPaneH.getDividerLocation();
}
+ /**
+ * Gets the paint size.
+ *
+ * @return the paint size
+ */
public int getPaintSize() {
return splitPaneV.getDividerLocation();
}
+ /**
+ * Gets the selected process num.
+ *
+ * @return the selected process num
+ */
private int getSelectedProcessNum() {
return processesComboBox.getSelectedIndex();
}
+ /**
+ * Gets the selected process.
+ *
+ * @return the selected process
+ */
private VSProcess getSelectedProcess() {
int processNum = getSelectedProcessNum();
return simulationCanvas.getProcess(processNum);
}
+ /**
+ * Gets the concerned processes.
+ *
+ * @param localTasks the local tasks
+ *
+ * @return the concerned processes
+ */
private ArrayList<VSProcess> getConcernedProcesses(boolean localTasks) {
int processNum = localTasks
? localPIDComboBox.getSelectedIndex()
@@ -841,6 +1199,9 @@ public class VSSimulator extends JPanel {
return arr;
}
+ /**
+ * Update task manager table.
+ */
public void updateTaskManagerTable() {
VSProcess process = getSelectedProcess();
boolean allProcesses = process == null;
@@ -848,6 +1209,9 @@ public class VSSimulator extends JPanel {
taskManagerGlobalModel.set(process, VSTaskManagerTableModel.GLOBAL, allProcesses);
}
+ /**
+ * Finish.
+ */
public void finish() {
menuItemStates.setStart(false);
menuItemStates.setPause(false);
@@ -856,27 +1220,55 @@ public class VSSimulator extends JPanel {
simulatorFrame.updateSimulationMenu();
}
+ /**
+ * Gets the simulation num.
+ *
+ * @return the simulation num
+ */
public int getSimulationNum() {
return simulationNum;
}
+ /**
+ * Gets the menu item states.
+ *
+ * @return the menu item states
+ */
public VSSimulator.VSMenuItemStates getMenuItemStates() {
return menuItemStates;
}
+ /**
+ * Gets the simulation canvas.
+ *
+ * @return the simulation canvas
+ */
public VSSimulatorCanvas getSimulationCanvas() {
return simulationCanvas;
}
+ /**
+ * Gets the simulator frame.
+ *
+ * @return the simulator frame
+ */
public VSSimulatorFrame getSimulatorFrame() {
return simulatorFrame;
}
+ /**
+ * Update from prefs.
+ */
public void updateFromPrefs() {
simulationCanvas.setBackground(prefs.getColor("col.background"));
simulationCanvas.updateFromPrefs();
}
+ /**
+ * Removes the process at index.
+ *
+ * @param index the index
+ */
public void removeProcessAtIndex(int index) {
if (lastSelectedProcessNum > index)
--lastSelectedProcessNum;
@@ -893,6 +1285,11 @@ public class VSSimulator extends JPanel {
updateTaskManagerTable();
}
+ /**
+ * Adds the process at index.
+ *
+ * @param index the index
+ */
public void addProcessAtIndex(int index) {
int processID = simulationCanvas.getProcess(index).getProcessID();
String processString = prefs.getString("lang.process");
@@ -907,6 +1304,9 @@ public class VSSimulator extends JPanel {
simulatorFrame.updateEditMenu();
}
+ /**
+ * Fire expert mode changed.
+ */
public void fireExpertModeChanged() {
boolean expertMode = prefs.getBoolean("sim.mode.expert");
@@ -945,6 +1345,11 @@ public class VSSimulator extends JPanel {
updateUI();
}
+ /**
+ * Gets the prefs.
+ *
+ * @return the prefs
+ */
public VSPrefs getPrefs() {
return prefs;
}
diff --git a/sources/simulator/VSSimulatorCanvas.java b/sources/simulator/VSSimulatorCanvas.java
index fb11fa5..2241883 100644
--- a/sources/simulator/VSSimulatorCanvas.java
+++ b/sources/simulator/VSSimulatorCanvas.java
@@ -1,3 +1,7 @@
+/*
+ * VS is (c) 2008 by Paul C. Buetow
+ * vs@dev.buetow.org
+ */
package simulator;
import java.awt.*;
@@ -14,80 +18,223 @@ import events.internal.*;
import prefs.*;
import prefs.editors.*;
+// TODO: Auto-generated Javadoc
+/**
+ * The Class VSSimulatorCanvas.
+ */
public class VSSimulatorCanvas extends Canvas implements Runnable, MouseMotionListener, MouseListener, HierarchyBoundsListener {
+
+ /** The highlighted process. */
private VSProcess highlightedProcess;
+
+ /** The simulation. */
private VSSimulator simulation;
+
+ /** The prefs. */
private VSPrefs prefs;
+
+ /** The logging. */
private VSLogging logging;
+
+ /** The num processes. */
private volatile int numProcesses;
+
+ /** The seconds spaceing. */
private int secondsSpaceing;
+
+ /** The thread sleep. */
private int threadSleep;
+
+ /** The until time. */
private long untilTime;
+
+ /** The is paused. */
private volatile boolean isPaused = true;
+
+ /** The is thread stopped. */
private volatile boolean isThreadStopped = false;
+
+ /** The is finished. */
private volatile boolean isFinished = false;
+
+ /** The is resetted. */
private volatile boolean isResetted = false;
+
+ /** The is anti aliased. */
private volatile boolean isAntiAliased = false;
+
+ /** The is anti aliased changed. */
private volatile boolean isAntiAliasedChanged = false;
+
+ /** The show lamport. */
private volatile boolean showLamport = false;
+
+ /** The show vector time. */
private volatile boolean showVectorTime = false;
+
+ /** The pause time. */
private volatile long pauseTime;
+
+ /** The start time. */
private volatile long startTime;
+
+ /** The time. */
private volatile long time;
+
+ /** The last time. */
private volatile long lastTime;
+
+ /** The task manager. */
private VSTaskManager taskManager;
+
+ /** The message lines. */
private LinkedList<VSMessageLine> messageLines;
+
+ /** The processes. */
private Vector<VSProcess> processes;
+
+ /** The clock speed. */
private double clockSpeed;
+
+ /** The clock offset. */
private double clockOffset;
+
+ /** The simulation time. */
private long simulationTime;
/* GFX buffering */
+ /** The strategy. */
private BufferStrategy strategy;
+
+ /** The g. */
private Graphics2D g;
/* Static constats */
+ /** The Constant LINE_WIDTH. */
private static final int LINE_WIDTH = 5;
+
+ /** The Constant SEPLINE_WIDTH. */
private static final int SEPLINE_WIDTH = 2;
+
+ /** The Constant XOFFSET. */
private static final int XOFFSET = 50;
+
+ /** The Constant YOFFSET. */
private static final int YOFFSET = 30;
+
+ /** The Constant YOUTER_SPACEING. */
private static final int YOUTER_SPACEING = 15;
+
+ /** The Constant YSEPLINE_SPACEING. */
private static final int YSEPLINE_SPACEING = 20;
+
+ /** The Constant TEXT_SPACEING. */
private static final int TEXT_SPACEING = 10;
+
+ /** The Constant ROW_HEIGHT. */
private static final int ROW_HEIGHT = 14;
/* Constats, which have to get calculated once after start */
+ /** The processline color. */
private Color processlineColor;
+
+ /** The process secondline color. */
private Color processSecondlineColor;
+
+ /** The process sepline color. */
private Color processSeplineColor;
+
+ /** The message arrived color. */
private Color messageArrivedColor;
+
+ /** The message sending color. */
private Color messageSendingColor;
+
+ /** The message lost color. */
private Color messageLostColor;
+
+ /** The background color. */
private Color backgroundColor;
+ /** The message line counter. */
private long messageLineCounter;
+
+ /**
+ * The Class VSMessageLine.
+ */
private class VSMessageLine {
+
+ /** The receiver process. */
private VSProcess receiverProcess;
+
+ /** The color. */
private Color color;
+
+ /** The send time. */
private long sendTime;
+
+ /** The recv time. */
private long recvTime;
+
+ /** The sender num. */
private int senderNum;
+
+ /** The receiver num. */
private int receiverNum;
+
+ /** The offset1. */
private int offset1;
+
+ /** The offset2. */
private int offset2;
+
+ /** The is arrived. */
private boolean isArrived;
+
+ /** The is lost. */
private boolean isLost;
+
+ /** The x1. */
private double x1;
+
+ /** The y1. */
private double y1;
+
+ /** The x2. */
private double x2;
+
+ /** The y2. */
private double y2;
+
+ /** The x. */
private double x;
+
+ /** The y. */
private double y;
+
+ /** The outage time. */
private long outageTime;
+
+ /** The z. */
private long z;
+
+ /** The message line num. */
private long messageLineNum;
+
+ /** The task. */
private VSTask task;
+ /**
+ * Instantiates a new vS message line.
+ *
+ * @param receiverProcess the receiver process
+ * @param sendTime the send time
+ * @param recvTime the recv time
+ * @param outageTime the outage time
+ * @param senderNum the sender num
+ * @param receiverNum the receiver num
+ * @param task the task
+ */
public VSMessageLine(VSProcess receiverProcess, long sendTime, long recvTime, long outageTime, int senderNum , int receiverNum, VSTask task) {
this.receiverProcess = receiverProcess;
this.sendTime = sendTime;
@@ -116,6 +263,9 @@ public class VSSimulatorCanvas extends Canvas implements Runnable, MouseMotionLi
paint();
}
+ /**
+ * Recalc on change.
+ */
public void recalcOnChange() {
x1 = getTimeXPosition(sendTime);
y1 = getProcessYPosition(senderNum+1) + offset1;
@@ -129,6 +279,12 @@ public class VSSimulatorCanvas extends Canvas implements Runnable, MouseMotionLi
}
+ /**
+ * Draw.
+ *
+ * @param g the g
+ * @param globalTime the global time
+ */
public void draw(final Graphics2D g, final long globalTime) {
if (isArrived) {
g.setColor(color);
@@ -159,6 +315,13 @@ public class VSSimulatorCanvas extends Canvas implements Runnable, MouseMotionLi
}
}
+ /**
+ * Removes the process at index.
+ *
+ * @param index the index
+ *
+ * @return true, if successful
+ */
public boolean removeProcessAtIndex(int index) {
if (index == receiverNum || index == senderNum)
return true;
@@ -174,19 +337,43 @@ public class VSSimulatorCanvas extends Canvas implements Runnable, MouseMotionLi
return false;
}
+ /**
+ * Gets the message line num.
+ *
+ * @return the message line num
+ */
public long getMessageLineNum() {
return messageLineNum;
}
+ /**
+ * Equals.
+ *
+ * @param line the line
+ *
+ * @return true, if successful
+ */
public boolean equals(VSMessageLine line) {
return messageLineNum == line.getMessageLineNum();
}
+ /**
+ * Gets the task.
+ *
+ * @return the task
+ */
public VSTask getTask() {
return task;
}
}
+ /**
+ * Instantiates a new vS simulator canvas.
+ *
+ * @param prefs the prefs
+ * @param simulation the simulation
+ * @param logging the logging
+ */
public VSSimulatorCanvas(VSPrefs prefs, VSSimulator simulation, VSLogging logging) {
this.prefs = prefs;
this.simulation = simulation;
@@ -207,22 +394,46 @@ public class VSSimulatorCanvas extends Canvas implements Runnable, MouseMotionLi
addHierarchyBoundsListener(this);
}
+ /** The x paint size. */
double xPaintSize;
+
+ /** The paint size. */
double paintSize;
+
+ /** The y distance. */
double yDistance;
+
+ /** The global time x position. */
double globalTimeXPosition;
+ /** The xoffset_plus_xpaintsize. */
int xoffset_plus_xpaintsize;
+
+ /** The xpaintsize_dividedby_untiltime. */
double xpaintsize_dividedby_untiltime;
+
+ /** The paint processes offset. */
int paintProcessesOffset;
+ /** The paint secondlines seconds. */
int paintSecondlinesSeconds;
+
+ /** The paint secondlines line. */
int paintSecondlinesLine[] = new int[4];
+
+ /** The paint secondlines y string pos1. */
int paintSecondlinesYStringPos1;
+
+ /** The paint secondlines y string pos2. */
int paintSecondlinesYStringPos2;
+
+ /** The paint global time y position. */
int paintGlobalTimeYPosition;
/* This method contains very ugly code. But this has to be in order to gain performance! */
+ /**
+ * Recalc on change.
+ */
private void recalcOnChange() {
processlineColor = prefs.getColor("col.process.line");
processSecondlineColor = prefs.getColor("col.process.secondline");
@@ -274,6 +485,12 @@ public class VSSimulatorCanvas extends Canvas implements Runnable, MouseMotionLi
}
}
+ /**
+ * Update simulation.
+ *
+ * @param globalTime the global time
+ * @param lastGlobalTime the last global time
+ */
private void updateSimulation(final long globalTime, final long lastGlobalTime) {
if (isPaused || isFinished)
return;
@@ -302,6 +519,9 @@ public class VSSimulatorCanvas extends Canvas implements Runnable, MouseMotionLi
}
}
+ /**
+ * Paint.
+ */
public void paint() {
while (getBufferStrategy() == null) {
createBufferStrategy(3);
@@ -341,6 +561,12 @@ public class VSSimulatorCanvas extends Canvas implements Runnable, MouseMotionLi
}
}
+ /**
+ * Paint processes.
+ *
+ * @param g the g
+ * @param globalTime the global time
+ */
private void paintProcesses(Graphics2D g, long globalTime) {
/* First paint the horizontal process timelines
* Second paint the processes
@@ -400,6 +626,15 @@ public class VSSimulatorCanvas extends Canvas implements Runnable, MouseMotionLi
}
}
+ /**
+ * Paint time.
+ *
+ * @param g the g
+ * @param times the times
+ * @param process the process
+ * @param yStart the y start
+ * @param distance the distance
+ */
private void paintTime(final Graphics2D g, final VSTime times[], final VSProcess process,
final int yStart, final int distance) {
@@ -439,6 +674,11 @@ public class VSSimulatorCanvas extends Canvas implements Runnable, MouseMotionLi
}
}
+ /**
+ * Paint secondlines.
+ *
+ * @param g the g
+ */
private void paintSecondlines(Graphics2D g) {
g.setColor(processSecondlineColor);
@@ -459,6 +699,12 @@ public class VSSimulatorCanvas extends Canvas implements Runnable, MouseMotionLi
}
}
+ /**
+ * Paint global time.
+ *
+ * @param g the g
+ * @param globalTime the global time
+ */
private void paintGlobalTime(Graphics2D g, long globalTime) {
g.setColor(processSeplineColor);
final int xOffset = (int) globalTimeXPosition;
@@ -471,6 +717,13 @@ public class VSSimulatorCanvas extends Canvas implements Runnable, MouseMotionLi
g.drawString(globalTime+"ms", xPoints[1]+1, yPoints[0]+TEXT_SPACEING);
}
+ /**
+ * Gets the process at y pos.
+ *
+ * @param yPos the y pos
+ *
+ * @return the process at y pos
+ */
private VSProcess getProcessAtYPos(int yPos) {
final int reachDistance = (int) (yDistance/3);
int y = YOFFSET + YOUTER_SPACEING + YSEPLINE_SPACEING;
@@ -489,10 +742,24 @@ public class VSSimulatorCanvas extends Canvas implements Runnable, MouseMotionLi
return null;
}
+ /**
+ * Gets the time x position.
+ *
+ * @param time the time
+ *
+ * @return the time x position
+ */
private double getTimeXPosition(long time) {
return XOFFSET + xpaintsize_dividedby_untiltime * time;
}
+ /**
+ * Gets the process y position.
+ *
+ * @param i the i
+ *
+ * @return the process y position
+ */
private int getProcessYPosition(int i) {
int y;
@@ -506,26 +773,58 @@ public class VSSimulatorCanvas extends Canvas implements Runnable, MouseMotionLi
return y * (i - 1) + YOFFSET + YOUTER_SPACEING + YSEPLINE_SPACEING;
}
+ /**
+ * Gets the time.
+ *
+ * @return the time
+ */
public long getTime() {
return simulationTime;
}
+ /**
+ * Gets the until time.
+ *
+ * @return the until time
+ */
public long getUntilTime() {
return untilTime;
}
+ /**
+ * Gets the start time.
+ *
+ * @return the start time
+ */
public long getStartTime() {
return startTime;
}
+ /**
+ * Gets the task manager.
+ *
+ * @return the task manager
+ */
public VSTaskManager getTaskManager() {
return taskManager;
}
+ /**
+ * Gets the num processes.
+ *
+ * @return the num processes
+ */
public int getNumProcesses() {
return numProcesses;
}
+ /**
+ * Gets the process.
+ *
+ * @param processNum the process num
+ *
+ * @return the process
+ */
public VSProcess getProcess(int processNum) {
if (processNum >= processes.size())
return null;
@@ -533,6 +832,9 @@ public class VSSimulatorCanvas extends Canvas implements Runnable, MouseMotionLi
return processes.get(processNum);
}
+ /* (non-Javadoc)
+ * @see java.lang.Runnable#run()
+ */
public void run() {
while (true) {
while (!isThreadStopped && (isPaused || isFinished || isResetted)) {
@@ -572,6 +874,9 @@ public class VSSimulatorCanvas extends Canvas implements Runnable, MouseMotionLi
}
}
+ /**
+ * Play.
+ */
public void play() {
logging.logg(prefs.getString("lang.simulation.started"));
final long currentTime = System.currentTimeMillis();
@@ -600,6 +905,9 @@ public class VSSimulatorCanvas extends Canvas implements Runnable, MouseMotionLi
paint();
}
+ /**
+ * Finish.
+ */
public void finish() {
synchronized (processes) {
for (VSProcess p : processes)
@@ -613,6 +921,9 @@ public class VSSimulatorCanvas extends Canvas implements Runnable, MouseMotionLi
paint();
}
+ /**
+ * Pause.
+ */
public void pause() {
isPaused = true;
synchronized (processes) {
@@ -626,6 +937,9 @@ public class VSSimulatorCanvas extends Canvas implements Runnable, MouseMotionLi
paint();
}
+ /**
+ * Reset.
+ */
public void reset() {
if (!isResetted) {
logging.logg(prefs.getString("lang.simulation.resetted"));
@@ -661,26 +975,49 @@ public class VSSimulatorCanvas extends Canvas implements Runnable, MouseMotionLi
}
}
+ /**
+ * Stop thread.
+ */
public void stopThread() {
isThreadStopped = true;
}
+ /**
+ * Checks if is thread stopped.
+ *
+ * @return true, if is thread stopped
+ */
public boolean isThreadStopped() {
return isThreadStopped;
}
+ /**
+ * Show lamport.
+ *
+ * @param showLamport the show lamport
+ */
public void showLamport(boolean showLamport) {
this.showLamport = showLamport;
if (isPaused)
paint();
}
+ /**
+ * Show vector time.
+ *
+ * @param showVectorTime the show vector time
+ */
public void showVectorTime(boolean showVectorTime) {
this.showVectorTime = showVectorTime;
if (isPaused)
paint();
}
+ /**
+ * Checks if is anti aliased.
+ *
+ * @param isAntiAliased the is anti aliased
+ */
public void isAntiAliased(boolean isAntiAliased) {
this.isAntiAliased = isAntiAliased;
this.isAntiAliasedChanged = true;
@@ -688,6 +1025,11 @@ public class VSSimulatorCanvas extends Canvas implements Runnable, MouseMotionLi
paint();
}
+ /**
+ * Send message.
+ *
+ * @param message the message
+ */
public void sendMessage(VSMessage message) {
VSTask task = null;
VSEvent messageReceiveEvent = null;
@@ -728,6 +1070,9 @@ public class VSSimulatorCanvas extends Canvas implements Runnable, MouseMotionLi
}
}
+ /* (non-Javadoc)
+ * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
+ */
public void mouseClicked(MouseEvent me) {
final VSProcess process = getProcessAtYPos(me.getY());
@@ -799,11 +1144,21 @@ public class VSSimulatorCanvas extends Canvas implements Runnable, MouseMotionLi
}
}
+ /**
+ * Edits the process.
+ *
+ * @param processNum the process num
+ */
public void editProcess(int processNum) {
VSProcess process = processes.get(processNum);
editProcess(process);
}
+ /**
+ * Edits the process.
+ *
+ * @param process the process
+ */
public void editProcess(VSProcess process) {
if (process != null) {
process.updatePrefs();
@@ -812,8 +1167,14 @@ public class VSSimulatorCanvas extends Canvas implements Runnable, MouseMotionLi
}
}
+ /* (non-Javadoc)
+ * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
+ */
public void mouseEntered(MouseEvent e) { }
+ /* (non-Javadoc)
+ * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
+ */
public void mouseExited(MouseEvent e) {
if (highlightedProcess != null) {
highlightedProcess.highlightOff();
@@ -822,15 +1183,27 @@ public class VSSimulatorCanvas extends Canvas implements Runnable, MouseMotionLi
}
}
+ /* (non-Javadoc)
+ * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
+ */
public void mousePressed(MouseEvent e) {
}
+ /* (non-Javadoc)
+ * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
+ */
public void mouseReleased(MouseEvent e) {
}
+ /* (non-Javadoc)
+ * @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent)
+ */
public void mouseDragged(MouseEvent e) {
}
+ /* (non-Javadoc)
+ * @see java.awt.event.MouseMotionListener#mouseMoved(java.awt.event.MouseEvent)
+ */
public void mouseMoved(MouseEvent e) {
VSProcess p = getProcessAtYPos(e.getY());
@@ -861,12 +1234,23 @@ public class VSSimulatorCanvas extends Canvas implements Runnable, MouseMotionLi
paint();
}
+ /* (non-Javadoc)
+ * @see java.awt.event.HierarchyBoundsListener#ancestorMoved(java.awt.event.HierarchyEvent)
+ */
public void ancestorMoved(HierarchyEvent e) { }
+ /* (non-Javadoc)
+ * @see java.awt.event.HierarchyBoundsListener#ancestorResized(java.awt.event.HierarchyEvent)
+ */
public void ancestorResized(HierarchyEvent e) {
recalcOnChange();
}
+ /**
+ * Gets the processes array.
+ *
+ * @return the processes array
+ */
public ArrayList<VSProcess> getProcessesArray() {
ArrayList<VSProcess> arr = new ArrayList<VSProcess>();
@@ -878,6 +1262,9 @@ public class VSSimulatorCanvas extends Canvas implements Runnable, MouseMotionLi
return arr;
}
+ /**
+ * Update from prefs.
+ */
public void updateFromPrefs() {
untilTime = prefs.getInteger("sim.seconds") * 1000;
clockSpeed = prefs.getFloat("sim.clock.speed");
@@ -893,6 +1280,11 @@ public class VSSimulatorCanvas extends Canvas implements Runnable, MouseMotionLi
recalcOnChange();
}
+ /**
+ * Removes the process.
+ *
+ * @param process the process
+ */
private void removeProcess(VSProcess process) {
if (numProcesses == 1) {
simulation.getSimulatorFrame().removeSimulation(simulation);
@@ -925,12 +1317,22 @@ public class VSSimulatorCanvas extends Canvas implements Runnable, MouseMotionLi
}
}
+ /**
+ * Creates the process.
+ *
+ * @param processNum the process num
+ *
+ * @return the vS process
+ */
private VSProcess createProcess(int processNum) {
VSProcess process = new VSProcess(prefs, processNum, this, logging);
logging.logg(prefs.getString("lang.process.new") + "; " + process);
return process;
}
+ /**
+ * Adds the process.
+ */
private void addProcess() {
numProcesses = processes.size() + 1;
VSProcess newProcess = createProcess(processes.size());
diff --git a/sources/simulator/VSSimulatorFrame.java b/sources/simulator/VSSimulatorFrame.java
index 4c77ad1..ccb1efe 100644
--- a/sources/simulator/VSSimulatorFrame.java
+++ b/sources/simulator/VSSimulatorFrame.java
@@ -1,3 +1,7 @@
+/*
+ * VS is (c) 2008 by Paul C. Buetow
+ * vs@dev.buetow.org
+ */
package simulator;
import java.awt.*;
@@ -11,25 +15,67 @@ import prefs.*;
import prefs.editors.*;
import utils.*;
+// TODO: Auto-generated Javadoc
+/**
+ * The Class VSSimulatorFrame.
+ */
public class VSSimulatorFrame extends VSFrame implements ActionListener {
+
+ /** The pause item. */
private JMenuItem pauseItem;
+
+ /** The replay item. */
private JMenuItem replayItem;
+
+ /** The reset item. */
private JMenuItem resetItem;
+
+ /** The start item. */
private JMenuItem startItem;
+
+ /** The pause button. */
private JButton pauseButton;
+
+ /** The replay button. */
private JButton replayButton;
+
+ /** The reset button. */
private JButton resetButton;
+
+ /** The start button. */
private JButton startButton;
+
+ /** The menu edit. */
private JMenu menuEdit;
+
+ /** The menu file. */
private JMenu menuFile;
+
+ /** The menu simulation. */
private JMenu menuSimulation;
+
+ /** The tool bar. */
private JToolBar toolBar;
+
+ /** The prefs. */
private VSPrefs prefs;
+
+ /** The simulations. */
private Vector<VSSimulator> simulations;
+
+ /** The current simulation. */
private VSSimulator currentSimulation;
+
+ /** The tabbed pane. */
private JTabbedPane tabbedPane;
//private JSlider speedSlider;
+ /**
+ * Instantiates a new vS simulator frame.
+ *
+ * @param prefs the prefs
+ * @param relativeTo the relative to
+ */
public VSSimulatorFrame(VSPrefs prefs, Component relativeTo) {
super(prefs.getString("lang.name"), relativeTo);
this.prefs = prefs;
@@ -54,6 +100,11 @@ public class VSSimulatorFrame extends VSFrame implements ActionListener {
menuSimulation.setEnabled(false);
}
+ /**
+ * Creates the menu bar.
+ *
+ * @return the j menu bar
+ */
private JMenuBar createMenuBar() {
/* File menu */
menuFile = new JMenu(prefs.getString("lang.file"));
@@ -161,6 +212,11 @@ public class VSSimulatorFrame extends VSFrame implements ActionListener {
return mainMenuBar;
}
+ /**
+ * Creates the content pane.
+ *
+ * @return the container
+ */
private Container createContentPane() {
Container pane = getContentPane();
tabbedPane = new JTabbedPane(JTabbedPane.BOTTOM, JTabbedPane.SCROLL_TAB_LAYOUT);
@@ -180,6 +236,9 @@ public class VSSimulatorFrame extends VSFrame implements ActionListener {
return pane;
}
+ /**
+ * Update edit menu.
+ */
public void updateEditMenu() {
menuEdit.removeAll();
@@ -221,6 +280,9 @@ public class VSSimulatorFrame extends VSFrame implements ActionListener {
}
/* updateSimulationMenu can be called from concurrent threads */
+ /**
+ * Update simulation menu.
+ */
public synchronized void updateSimulationMenu() {
VSSimulator.VSMenuItemStates menuItemState = currentSimulation.getMenuItemStates();
@@ -235,6 +297,9 @@ public class VSSimulatorFrame extends VSFrame implements ActionListener {
startButton.setEnabled(menuItemState.getStart());
}
+ /* (non-Javadoc)
+ * @see java.awt.Window#dispose()
+ */
public void dispose() {
synchronized (simulations) {
for (VSSimulator simulation : simulations)
@@ -243,6 +308,9 @@ public class VSSimulatorFrame extends VSFrame implements ActionListener {
super.dispose();
}
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ */
public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
String sourceText = null;
@@ -310,6 +378,11 @@ public class VSSimulatorFrame extends VSFrame implements ActionListener {
}
}
+ /**
+ * Adds the simulation.
+ *
+ * @param simulation the simulation
+ */
public void addSimulation(VSSimulator simulation) {
simulation.setLayout(new GridLayout(1, 1, 3, 3));
simulation.setMinimumSize(new Dimension(0, 0));
@@ -327,6 +400,11 @@ public class VSSimulatorFrame extends VSFrame implements ActionListener {
}
}
+ /**
+ * Removes the simulation.
+ *
+ * @param simulationToRemove the simulation to remove
+ */
public void removeSimulation(VSSimulator simulationToRemove) {
if (simulations.size() == 1) {
dispose();
@@ -338,14 +416,30 @@ public class VSSimulatorFrame extends VSFrame implements ActionListener {
}
}
+ /**
+ * Removes the current simulation.
+ */
private void removeCurrentSimulation() {
removeSimulation(currentSimulation);
}
+ /**
+ * Gets the current simulation.
+ *
+ * @return the current simulation
+ */
public VSSimulator getCurrentSimulation() {
return currentSimulation;
}
+ /**
+ * Gets the image icon.
+ *
+ * @param name the name
+ * @param descr the descr
+ *
+ * @return the image icon
+ */
private ImageIcon getImageIcon(String name, String descr) {
java.net.URL imageURL = getClass().getResource("/icons/"+name);