Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 72 additions & 16 deletions src/jls/sim/InterractiveSimulator.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,15 @@ public InterractiveSimulator() {
public void actionPerformed(ActionEvent event) {
if (scaleField.getText().length() == 0)
scaleFactor = 1;
else
scaleFactor = Math.max(1,Integer.parseInt(scaleField.getText()));
else {
try {
scaleFactor = Math.max(1,Integer.parseInt(scaleField.getText()));
} catch (NumberFormatException ex) {
JOptionPane.showMessageDialog(null,
"Scale factor must be an integer", "Error",
JOptionPane.ERROR_MESSAGE);
}
}
scaleField.setText(scaleFactor+"");
traces.setScaleFactor();
if (now != 0)
Expand Down Expand Up @@ -271,8 +278,15 @@ public void actionPerformed(ActionEvent event) {
action.validate();
if (scaleField.getText().length() == 0)
scaleFactor = 1;
else
scaleFactor = Math.max(1,Integer.parseInt(scaleField.getText()));
else {
try {
scaleFactor = Math.max(1,Integer.parseInt(scaleField.getText()));
} catch (NumberFormatException ex) {
JOptionPane.showMessageDialog(null,
"Scale factor must be an integer", "Error",
JOptionPane.ERROR_MESSAGE);
}
}
scaleField.setText(scaleFactor+"");
traces.setScaleFactor();
setMaxTime();
Expand All @@ -295,14 +309,28 @@ public void actionPerformed(ActionEvent event) {
action.validate();
if (scaleField.getText().length() == 0)
scaleFactor = 1;
else
scaleFactor = Math.max(1,Integer.parseInt(scaleField.getText()));
else {
try {
scaleFactor = Math.max(1,Integer.parseInt(scaleField.getText()));
} catch (NumberFormatException ex) {
JOptionPane.showMessageDialog(null,
"Scale factor must be an integer", "Error",
JOptionPane.ERROR_MESSAGE);
}
}
scaleField.setText(scaleFactor+"");
traces.setScaleFactor();
if (stepField.getText().length() == 0)
stepAmount = 1;
else
stepAmount = Math.max(1,Integer.parseInt(stepField.getText()));
else {
try {
stepAmount = Math.max(1,Integer.parseInt(stepField.getText()));
} catch (NumberFormatException ex) {
JOptionPane.showMessageDialog(null,
"Step amount must be an integer", "Error",
JOptionPane.ERROR_MESSAGE);
}
}
stepField.setText(stepAmount+"");
setMaxTime();
if (sim == null) {
Expand Down Expand Up @@ -337,14 +365,28 @@ public void actionPerformed(ActionEvent event) {
// set up step info
if (scaleField.getText().length() == 0)
scaleFactor = 1;
else
scaleFactor = Math.max(1,Integer.parseInt(scaleField.getText()));
else {
try {
scaleFactor = Math.max(1,Integer.parseInt(scaleField.getText()));
} catch (NumberFormatException ex) {
JOptionPane.showMessageDialog(null,
"Scale factor must be an integer", "Error",
JOptionPane.ERROR_MESSAGE);
}
}
scaleField.setText(scaleFactor+"");
traces.setScaleFactor();
if (stepField.getText().length() == 0)
stepAmount = 1;
else
stepAmount = Math.max(1,Integer.parseInt(stepField.getText()));
else {
try {
stepAmount = Math.max(1,Integer.parseInt(stepField.getText()));
} catch (NumberFormatException ex) {
JOptionPane.showMessageDialog(null,
"Step amount must be an integer", "Error",
JOptionPane.ERROR_MESSAGE);
}
}
stepField.setText(stepAmount+"");
setMaxTime();

Expand Down Expand Up @@ -427,8 +469,15 @@ public void actionPerformed(ActionEvent event) {
action.validate();
if (scaleField.getText().length() == 0)
scaleFactor = 1;
else
scaleFactor = Math.max(1,Integer.parseInt(scaleField.getText()));
else {
try {
scaleFactor = Math.max(1,Integer.parseInt(scaleField.getText()));
} catch (NumberFormatException ex) {
JOptionPane.showMessageDialog(null,
"Scale factor must be an integer", "Error",
JOptionPane.ERROR_MESSAGE);
}
}
scaleField.setText(scaleFactor+"");
traces.setScaleFactor();
paused = false;
Expand Down Expand Up @@ -476,8 +525,15 @@ public void setMaxTime() {

if (tlimit.getText().length() == 0)
maxTime = 1;
else
maxTime = Math.max(1,Integer.parseInt(tlimit.getText()));
else {
try {
maxTime = Math.max(1,Integer.parseInt(tlimit.getText()));
} catch (NumberFormatException ex) {
JOptionPane.showMessageDialog(null,
"Time limit must be an integer", "Error",
JOptionPane.ERROR_MESSAGE);
}
}
tlimit.setText(maxTime+"");
} // end of setMaxTime method

Expand Down