View Javadoc

1   /*
2    * Trip Tracker, a real-time position tracking system for the Internet.
3    * Copyright (C) 2006  Team Trip Tracker
4    *
5    * This program is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU General Public License as published by the
7    * Free Software Foundation; either version 2 of the License, or (at your
8    * option) any later version.
9    *
10   * This program is distributed in the hope that it will be useful, but
11   * WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13   * General Public License for more details.
14   *
15   * You should have received a copy of the GNU General Public License along
16   * with this program; if not, write to the Free Software Foundation, Inc.,
17   * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
18   */
19  
20  package triptracker.client.map.ui;
21  
22  import java.awt.BorderLayout;
23  import java.util.List;
24  
25  import javax.swing.JComponent;
26  import javax.swing.JPanel;
27  import javax.swing.JTabbedPane;
28  
29  import triptracker.client.net.MapSocket;
30  import triptracker.client.ui.Form;
31  import triptracker.core.Coordinate;
32  import triptracker.core.Route;
33  import triptracker.core.User;
34  
35  public class TabbedForm implements Form {
36  	protected static int nameCount = 1;
37  	protected final String name;
38  //	private MapClientGui view;
39  //	private MapSocket model;
40  	private JPanel panel;
41  	Route route;
42  	User user;
43  	
44  	private	JTabbedPane tabbedPane;
45  	private	ConfigPanel panel1;
46  	private	MapViewPanel panel2;
47  	private	InfoPanel panel3;
48  //	private	MapViewPanel panel4;
49  	
50  	public TabbedForm(MapClientGui view, MapSocket model) {
51  		this(view, TabbedForm.class.getClass().getName() + "-" + nameCount++,
52  				model);
53  	}
54  	
55  	public TabbedForm(MapClientGui view, String name, MapSocket model) {
56  		this.name = name;
57  //		this.view = view;
58  //		this.model = model;
59  		
60  		panel = new JPanel();
61  		panel.setLayout(new BorderLayout());
62  		
63  		// Create tab pages
64  		panel1 = new ConfigPanel(model, this);
65  		panel2 = new MapViewPanel(model, this);
66  		panel3 = new InfoPanel(model, this);
67  //		panel4 = new MapViewPanel(model, this);
68  //		panel3.setLayout( new FlowLayout() );
69  //		panel3.add( new JButton( "Button" ));
70  		
71  		// Create a tabbed pane
72  		tabbedPane = new JTabbedPane();
73  		tabbedPane.addTab("Setup", panel1);
74  		tabbedPane.addTab("Map", panel2);
75  		tabbedPane.addTab("Info", panel3);
76  //		tabbedPane.addTab("Map", panel4);
77  		panel.add(tabbedPane, BorderLayout.CENTER);
78  		
79  		view.register(this);
80  	}
81  	
82  	public void gotoMap(boolean realtime, Route route) {
83  		tabbedPane.setSelectedComponent(panel2); //panel2.set
84  		panel2.setRoute(realtime, route);
85  //		setInfo(route);
86  	}
87  	
88  	public void setInfo(Route route, User user) {
89  		this.route = route;
90  		this.user = user;
91  		panel3.setRoute(route);
92  		panel3.setUser(user);
93  	}
94  	
95  	public void setInfo() {
96  		panel3.setRoute(route);
97  		panel3.setUser(user);
98  	}
99  	
100 	public void setRoute(List<Coordinate> coordList) {
101 		panel3.setRouteList(coordList);
102 	}
103 	
104 	public void setMapView(boolean nr, boolean dot, boolean map, int thick){
105 		panel2.getMap().setView(nr,dot,map,thick);
106 	}
107 	
108 	public JComponent getFormComponent() {
109 		return panel;
110 	}
111 
112 	public String getName() {
113 		return name;
114 	}
115 
116 	public void refreshView() {
117 		panel1.start();
118 	}
119 }