View Javadoc

1   /*
2    * Copyright (C) 2010 Unreal Visualizer Authors
3    *
4    * This program is free software: you can redistribute it and/or modify
5    * it under the terms of the GNU General Public License as published by
6    * the Free Software Foundation, either version 3 of the License, or
7    * (at your option) any later version.
8    *
9    * This program is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   * GNU General Public License for more details.
13   *
14   * You should have received a copy of the GNU General Public License
15   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16   */
17  package nl.tudelft.goal.ut2004.visualizer.gui.dialogs;
18  
19  import java.awt.FlowLayout;
20  import java.awt.Frame;
21  import java.awt.GridLayout;
22  import java.awt.event.ActionEvent;
23  import java.awt.event.ActionListener;
24  import java.util.Collection;
25  
26  import javax.swing.JButton;
27  import javax.swing.JComboBox;
28  import javax.swing.JDialog;
29  import javax.swing.JLabel;
30  import javax.swing.JList;
31  import javax.swing.JOptionPane;
32  import javax.swing.JScrollPane;
33  import javax.swing.JSpinner;
34  import javax.swing.JTextField;
35  import javax.swing.ListSelectionModel;
36  import javax.swing.SpinnerNumberModel;
37  
38  import nl.tudelft.goal.ut2004.visualizer.controller.ServerController;
39  import nl.tudelft.goal.ut2004.visualizer.gui.action.AddNativeBotAction;
40  import nl.tudelft.goal.ut2004.visualizer.gui.action.PauseResumeAction;
41  import nl.tudelft.goal.ut2004.visualizer.gui.action.SetSpeedAction;
42  import nl.tudelft.goal.ut2004.visualizer.gui.widgets.WaypointBox;
43  import nl.tudelft.goal.ut2004.visualizer.util.SelectableWayPoint;
44  
45  import cz.cuni.amis.pogamut.base3d.worldview.object.Location;
46  import cz.cuni.amis.pogamut.unreal.communication.worldview.map.IUnrealWaypoint;
47  import cz.cuni.amis.pogamut.ut2004.communication.messages.gbcommands.AddBot;
48  import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.NavPoint;
49  import cz.cuni.amis.pogamut.ut2004.communication.worldview.map.Waypoint;
50  import cz.cuni.amis.pogamut.ut2004.server.IUT2004Server;
51  import cz.cuni.amis.utils.exception.PogamutException;
52  
53  /**
54   * Dialog for changing speed of the game.
55   * 
56   * @author M.P. Korstanje
57   * 
58   */
59  public class ChangeGameSpeedDialog extends JDialog {
60  
61  	private JSpinner speedSelection;
62  	private JLabel setSpeed;
63  	private JButton pauseResume;
64  
65  	public ChangeGameSpeedDialog(Frame parent) {
66  		super(parent, false);
67  		setTitle("Change Game Speed");
68  
69  		this.pauseResume = new JButton(new PauseResumeAction());
70  
71  		this.speedSelection = new JSpinner(
72  		// 1 = default speed, 0.1 minimum, 10.0 max. 0.1 step size.
73  				new SpinnerNumberModel(1, 0.1, 10.0, 0.1));
74  		this.speedSelection
75  				.setEditor(new JSpinner.NumberEditor(speedSelection));
76  		this.setSpeed = new JLabel("Game Speed");
77  
78  		this.speedSelection
79  				.addChangeListener(new SetSpeedAction(speedSelection));
80  
81  		setLayout(new FlowLayout());
82  		add(pauseResume);
83  		add(setSpeed);
84  		add(speedSelection);
85  
86  		this.setSize(400, 75);
87  
88  	}
89  }