|
@@ -2,6 +2,8 @@ package ui.view;
|
|
|
|
|
|
import java.awt.BorderLayout;
|
|
import java.awt.BorderLayout;
|
|
import java.awt.Color;
|
|
import java.awt.Color;
|
|
|
|
+import java.awt.Dimension;
|
|
|
|
+import java.awt.FlowLayout;
|
|
import java.awt.Image;
|
|
import java.awt.Image;
|
|
import java.awt.event.ActionEvent;
|
|
import java.awt.event.ActionEvent;
|
|
import java.awt.event.ActionListener;
|
|
import java.awt.event.ActionListener;
|
|
@@ -10,20 +12,20 @@ import java.awt.event.MouseEvent;
|
|
|
|
|
|
import javax.swing.ImageIcon;
|
|
import javax.swing.ImageIcon;
|
|
import javax.swing.JButton;
|
|
import javax.swing.JButton;
|
|
|
|
+import javax.swing.JLabel;
|
|
import javax.swing.JPanel;
|
|
import javax.swing.JPanel;
|
|
|
|
+import javax.swing.JSeparator;
|
|
import javax.swing.JSlider;
|
|
import javax.swing.JSlider;
|
|
|
|
+import javax.swing.JTextField;
|
|
import javax.swing.Timer;
|
|
import javax.swing.Timer;
|
|
import javax.swing.border.LineBorder;
|
|
import javax.swing.border.LineBorder;
|
|
|
|
+import javax.swing.event.CaretEvent;
|
|
|
|
+import javax.swing.event.CaretListener;
|
|
import javax.swing.event.ChangeEvent;
|
|
import javax.swing.event.ChangeEvent;
|
|
import javax.swing.event.ChangeListener;
|
|
import javax.swing.event.ChangeListener;
|
|
|
|
|
|
-import classes.HolonElement;
|
|
|
|
-import classes.HolonObject;
|
|
|
|
-import classes.HolonSwitch;
|
|
|
|
-import classes.SubNet;
|
|
|
|
import ui.controller.Control;
|
|
import ui.controller.Control;
|
|
import ui.model.Model;
|
|
import ui.model.Model;
|
|
-import javax.swing.BoxLayout;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* This Class represents a Panel where the User can start and stop the
|
|
* This Class represents a Panel where the User can start and stop the
|
|
@@ -37,6 +39,8 @@ public class TimePanel extends JPanel {
|
|
private Model model;
|
|
private Model model;
|
|
private Control controller;
|
|
private Control controller;
|
|
|
|
|
|
|
|
+ JLabel simSpeedLabel = new JLabel(Languages.getLanguage()[84]);
|
|
|
|
+ private JTextField simSpeedText = new JTextField("1000");
|
|
JSlider timeSlider = new JSlider();
|
|
JSlider timeSlider = new JSlider();
|
|
private final JPanel timeBtnPanel = new JPanel();
|
|
private final JPanel timeBtnPanel = new JPanel();
|
|
final JButton playBtn = new JButton();
|
|
final JButton playBtn = new JButton();
|
|
@@ -62,7 +66,7 @@ public class TimePanel extends JPanel {
|
|
this.controller = cont;
|
|
this.controller = cont;
|
|
|
|
|
|
// One Iteration
|
|
// One Iteration
|
|
- timer = new Timer(model.getTimerSpeed(), new ActionListener() {
|
|
|
|
|
|
+ timer = new Timer(0, new ActionListener() {
|
|
@Override
|
|
@Override
|
|
public void actionPerformed(ActionEvent ae) {
|
|
public void actionPerformed(ActionEvent ae) {
|
|
timeSlider.setValue(timeSlider.getValue() + 1);
|
|
timeSlider.setValue(timeSlider.getValue() + 1);
|
|
@@ -106,7 +110,7 @@ public class TimePanel extends JPanel {
|
|
// Panel
|
|
// Panel
|
|
timeBtnPanel.setBorder(null);
|
|
timeBtnPanel.setBorder(null);
|
|
timeBtnPanel.setBackground(Color.WHITE);
|
|
timeBtnPanel.setBackground(Color.WHITE);
|
|
- timeBtnPanel.setLayout(new BoxLayout(timeBtnPanel, BoxLayout.X_AXIS));
|
|
|
|
|
|
+ timeBtnPanel.setLayout(new FlowLayout());
|
|
|
|
|
|
// Buttons
|
|
// Buttons
|
|
playBtn.setToolTipText(Languages.getLanguage()[89]);
|
|
playBtn.setToolTipText(Languages.getLanguage()[89]);
|
|
@@ -174,6 +178,21 @@ public class TimePanel extends JPanel {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ // timerSpeed
|
|
|
|
+ simSpeedText.addCaretListener(new CaretListener() {
|
|
|
|
+ @Override
|
|
|
|
+ public void caretUpdate(CaretEvent e) {
|
|
|
|
+ try {
|
|
|
|
+ controller.setTimerSpeed(Integer.parseInt(simSpeedText.getText()));
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
+ // TODO: handle exception
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ timeBtnPanel.add(simSpeedLabel);
|
|
|
|
+ timeBtnPanel.add(simSpeedText);
|
|
timeBtnPanel.add(playBtn);
|
|
timeBtnPanel.add(playBtn);
|
|
timeBtnPanel.add(timeResetBtn);
|
|
timeBtnPanel.add(timeResetBtn);
|
|
/*
|
|
/*
|