1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
39
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
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
58
59
60 panel = new JPanel();
61 panel.setLayout(new BorderLayout());
62
63
64 panel1 = new ConfigPanel(model, this);
65 panel2 = new MapViewPanel(model, this);
66 panel3 = new InfoPanel(model, this);
67
68
69
70
71
72 tabbedPane = new JTabbedPane();
73 tabbedPane.addTab("Setup", panel1);
74 tabbedPane.addTab("Map", panel2);
75 tabbedPane.addTab("Info", panel3);
76
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);
84 panel2.setRoute(realtime, route);
85
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 }