1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package nl.tudelft.goal.ut2004.visualizer.gui.dialogs;
18
19 import java.awt.Color;
20 import java.awt.FlowLayout;
21 import java.awt.Frame;
22 import java.awt.event.ActionEvent;
23 import java.awt.event.ActionListener;
24
25 import javax.swing.JButton;
26 import javax.swing.JColorChooser;
27 import javax.swing.JDialog;
28
29 import nl.tudelft.goal.ut2004.visualizer.timeline.map.FlagRenderer;
30 import nl.tudelft.goal.ut2004.visualizer.timeline.map.MapRenderer;
31 import nl.tudelft.goal.ut2004.visualizer.timeline.map.PlayerRenderer;
32 import nl.tudelft.goal.ut2004.visualizer.timeline.map.WaypointRenderer;
33 import nl.tudelft.goal.ut2004.visualizer.util.WindowPersistenceHelper;
34
35
36
37
38
39
40
41 public class SettingsDialog extends JDialog {
42
43
44
45
46 private WindowPersistenceHelper persistenceHelper;
47
48 public SettingsDialog(Frame parent) {
49 super(parent, false);
50
51 setTitle("Visualizer Settings");
52
53 this.setSize(200, 200);
54
55 persistenceHelper = new WindowPersistenceHelper(this);
56 persistenceHelper.load();
57
58 this.setLayout(new FlowLayout());
59
60 JButton selectHighColor = new JButton("Change Map High Color");
61 selectHighColor.addActionListener(new ActionListener() {
62
63 @Override
64 public void actionPerformed(ActionEvent e) {
65 Color current = MapRenderer.getHighColor();
66 Color selected = JColorChooser.showDialog(SettingsDialog.this, "Pick a color", current);
67 MapRenderer.setHighColor(selected);
68 }
69 });
70 add(selectHighColor);
71
72 JButton selectLowColor = new JButton("Change Map Low Color");
73 selectLowColor.addActionListener(new ActionListener() {
74
75 @Override
76 public void actionPerformed(ActionEvent e) {
77 Color current = MapRenderer.getLowColor();
78 Color selected = JColorChooser.showDialog(SettingsDialog.this, "Pick a color", current);
79 if (selected == null)
80 return;
81 MapRenderer.setLowColor(selected);
82 }
83 });
84 add(selectLowColor);
85
86 JButton selectNavpointColor = new JButton("Change Navpoint Color");
87 selectNavpointColor.addActionListener(new ActionListener() {
88
89 @Override
90 public void actionPerformed(ActionEvent e) {
91 Color current = WaypointRenderer.getColor();
92 Color selected = JColorChooser.showDialog(SettingsDialog.this, "Pick a color", current);
93 if (selected == null)
94 return;
95 WaypointRenderer.setColor(selected);
96 }
97 });
98 add(selectNavpointColor);
99
100 JButton selectRedTeamColor = new JButton("Change Red Team Color");
101 selectRedTeamColor.addActionListener(new ActionListener() {
102
103 @Override
104 public void actionPerformed(ActionEvent e) {
105
106 {
107 Color current = FlagRenderer.getRedFlagColor();
108 Color selected = JColorChooser.showDialog(SettingsDialog.this, "Pick a color", current);
109 if (selected == null)
110 return;
111
112
113 FlagRenderer.setRedFlagColor(selected);
114 PlayerRenderer.setRedTeamColor(selected);
115 }
116
117 }
118 });
119 add(selectRedTeamColor);
120
121 JButton selectBlueTeamColor = new JButton("Change Blue Team Color");
122 selectBlueTeamColor.addActionListener(new ActionListener() {
123
124 @Override
125 public void actionPerformed(ActionEvent e) {
126
127 {
128 Color current = FlagRenderer.getBlueFlagColor();
129 Color selected = JColorChooser.showDialog(SettingsDialog.this, "Pick a color", current);
130 if (selected == null)
131 return;
132 FlagRenderer.setBlueFlagColor(selected);
133 PlayerRenderer.setBlueTeamColor(selected);
134
135 }
136 }
137 });
138 add(selectBlueTeamColor);
139 }
140
141 }