1 | package panels;
|
---|
2 |
|
---|
3 | import java.awt.*;
|
---|
4 | import java.awt.event.*;
|
---|
5 |
|
---|
6 | import javax.swing.*;
|
---|
7 |
|
---|
8 | import java.util.*;
|
---|
9 |
|
---|
10 | import messages.Messages;
|
---|
11 | import smed.SmedAction;
|
---|
12 | import seamarks.SeaMark.*;
|
---|
13 |
|
---|
14 | public class PanelRadar extends JPanel {
|
---|
15 |
|
---|
16 | private SmedAction dlg;
|
---|
17 | private JToggleButton aisButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/AISButton.png")));
|
---|
18 | private ActionListener alAis = new ActionListener() {
|
---|
19 | public void actionPerformed(java.awt.event.ActionEvent e) {
|
---|
20 | if (aisButton.isSelected()) {
|
---|
21 | radioCatBox.setVisible(true);
|
---|
22 | aisButton.setBorderPainted(true);
|
---|
23 | } else {
|
---|
24 | radioCatBox.setSelectedIndex(0);
|
---|
25 | radioCatBox.setVisible(false);
|
---|
26 | aisButton.setBorderPainted(false);
|
---|
27 | }
|
---|
28 | }
|
---|
29 | };
|
---|
30 | private JComboBox radioCatBox;
|
---|
31 | private EnumMap<Cat, Integer> radioCats = new EnumMap<Cat, Integer>(Cat.class);
|
---|
32 | private ActionListener alRadioCatBox = new ActionListener() {
|
---|
33 | public void actionPerformed(java.awt.event.ActionEvent e) {
|
---|
34 | for (Cat cat : radioCats.keySet()) {
|
---|
35 | int idx = radioCats.get(cat);
|
---|
36 | if (dlg.node != null && (idx == radioCatBox.getSelectedIndex())) {
|
---|
37 | dlg.panelMain.mark.setRadio(cat);
|
---|
38 | }
|
---|
39 | }
|
---|
40 | }
|
---|
41 | };
|
---|
42 | private ButtonGroup radarButtons = new ButtonGroup();
|
---|
43 | public JRadioButton noRadButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/OffButton.png")));
|
---|
44 | public JRadioButton reflButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RadarReflectorButton.png")));
|
---|
45 | public JRadioButton ramarkButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RamarkButton.png")));
|
---|
46 | public JRadioButton raconButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RaconButton.png")));
|
---|
47 | public JRadioButton leadingButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LeadingRaconButton.png")));
|
---|
48 | private EnumMap<Rtb, JRadioButton> rads = new EnumMap<Rtb, JRadioButton>(Rtb.class);
|
---|
49 | private ActionListener alRad = new ActionListener() {
|
---|
50 | public void actionPerformed(java.awt.event.ActionEvent e) {
|
---|
51 | for (Rtb rtb : rads.keySet()) {
|
---|
52 | JRadioButton button = rads.get(rtb);
|
---|
53 | if (button.isSelected()) {
|
---|
54 | dlg.panelMain.mark.setRadar(rtb);
|
---|
55 | }
|
---|
56 | }
|
---|
57 | syncPanel();
|
---|
58 | }
|
---|
59 | };
|
---|
60 | public JLabel groupLabel;
|
---|
61 | public JTextField groupBox;
|
---|
62 | private FocusListener flGroup = new FocusAdapter() {
|
---|
63 | public void focusLost(java.awt.event.FocusEvent e) {
|
---|
64 | dlg.panelMain.mark.setRaconGroup(groupBox.getText());
|
---|
65 | }
|
---|
66 | };
|
---|
67 | public JLabel periodLabel;
|
---|
68 | public JTextField periodBox;
|
---|
69 | private FocusListener flPeriod = new FocusAdapter() {
|
---|
70 | public void focusLost(java.awt.event.FocusEvent e) {
|
---|
71 | dlg.panelMain.mark.setRaconPeriod(periodBox.getText());
|
---|
72 | }
|
---|
73 | };
|
---|
74 | public JLabel seqLabel;
|
---|
75 | public JTextField seqBox;
|
---|
76 | private FocusListener flSeq = new FocusAdapter() {
|
---|
77 | public void focusLost(java.awt.event.FocusEvent e) {
|
---|
78 | dlg.panelMain.mark.setRaconSequence(seqBox.getText());
|
---|
79 | }
|
---|
80 | };
|
---|
81 | public JLabel rangeLabel;
|
---|
82 | public JTextField rangeBox;
|
---|
83 | private FocusListener flRange = new FocusAdapter() {
|
---|
84 | public void focusLost(java.awt.event.FocusEvent e) {
|
---|
85 | dlg.panelMain.mark.setRaconRange(rangeBox.getText());
|
---|
86 | }
|
---|
87 | };
|
---|
88 | public JLabel sector1Label;
|
---|
89 | public JTextField sector1Box;
|
---|
90 | private FocusListener flSector1 = new FocusAdapter() {
|
---|
91 | public void focusLost(java.awt.event.FocusEvent e) {
|
---|
92 | dlg.panelMain.mark.setRaconSector1(sector1Box.getText());
|
---|
93 | }
|
---|
94 | };
|
---|
95 | public JLabel sector2Label;
|
---|
96 | public JTextField sector2Box;
|
---|
97 | private FocusListener flSector2 = new FocusAdapter() {
|
---|
98 | public void focusLost(java.awt.event.FocusEvent e) {
|
---|
99 | dlg.panelMain.mark.setRaconSector2(sector2Box.getText());
|
---|
100 | }
|
---|
101 | };
|
---|
102 | public JLabel sectorsLabel;
|
---|
103 |
|
---|
104 | public PanelRadar(SmedAction dia) {
|
---|
105 | dlg = dia;
|
---|
106 | setLayout(null);
|
---|
107 | add(getRadButton(noRadButton, 0, 3, 27, 27, "NoRadar", Rtb.NORTB));
|
---|
108 | add(getRadButton(reflButton, 0, 33, 27, 27, "RadarReflector", Rtb.REFLECTOR));
|
---|
109 | add(getRadButton(ramarkButton, 0, 63, 27, 27, "Ramark", Rtb.RAMARK));
|
---|
110 | add(getRadButton(raconButton, 0, 93, 27, 27, "Racon", Rtb.RACON));
|
---|
111 | add(getRadButton(leadingButton, 0, 123, 27, 27, "LeadingRacon", Rtb.LEADING));
|
---|
112 |
|
---|
113 | groupLabel = new JLabel(Messages.getString("Group"), SwingConstants.CENTER);
|
---|
114 | groupLabel.setBounds(new Rectangle(30, 0, 100, 20));
|
---|
115 | add(groupLabel);
|
---|
116 | groupBox = new JTextField();
|
---|
117 | groupBox.setBounds(new Rectangle(55, 20, 50, 20));
|
---|
118 | groupBox.setHorizontalAlignment(SwingConstants.CENTER);
|
---|
119 | add(groupBox);
|
---|
120 | groupBox.addFocusListener(flGroup);
|
---|
121 |
|
---|
122 | periodLabel = new JLabel(Messages.getString("Period"), SwingConstants.CENTER);
|
---|
123 | periodLabel.setBounds(new Rectangle(130, 0, 100, 20));
|
---|
124 | add(periodLabel);
|
---|
125 | periodBox = new JTextField();
|
---|
126 | periodBox.setBounds(new Rectangle(155, 20, 50, 20));
|
---|
127 | periodBox.setHorizontalAlignment(SwingConstants.CENTER);
|
---|
128 | add(periodBox);
|
---|
129 | periodBox.addFocusListener(flPeriod);
|
---|
130 |
|
---|
131 | seqLabel = new JLabel(Messages.getString("Sequence"), SwingConstants.CENTER);
|
---|
132 | seqLabel.setBounds(new Rectangle(30, 40, 100, 20));
|
---|
133 | add(seqLabel);
|
---|
134 | seqBox = new JTextField();
|
---|
135 | seqBox.setBounds(new Rectangle(55, 60, 50, 20));
|
---|
136 | seqBox.setHorizontalAlignment(SwingConstants.CENTER);
|
---|
137 | add(seqBox);
|
---|
138 | seqBox.addFocusListener(flSeq);
|
---|
139 |
|
---|
140 | rangeLabel = new JLabel(Messages.getString("Range"), SwingConstants.CENTER);
|
---|
141 | rangeLabel.setBounds(new Rectangle(130, 40, 100, 20));
|
---|
142 | add(rangeLabel);
|
---|
143 | rangeBox = new JTextField();
|
---|
144 | rangeBox.setBounds(new Rectangle(155, 60, 50, 20));
|
---|
145 | rangeBox.setHorizontalAlignment(SwingConstants.CENTER);
|
---|
146 | add(rangeBox);
|
---|
147 | rangeBox.addFocusListener(flRange);
|
---|
148 |
|
---|
149 | sectorsLabel = new JLabel(Messages.getString("VisibleSector"), SwingConstants.CENTER);
|
---|
150 | sectorsLabel.setBounds(new Rectangle(75, 85, 100, 20));
|
---|
151 | add(sectorsLabel);
|
---|
152 |
|
---|
153 | sector1Label = new JLabel(Messages.getString("Start"), SwingConstants.CENTER);
|
---|
154 | sector1Label.setBounds(new Rectangle(30, 100, 100, 20));
|
---|
155 | add(sector1Label);
|
---|
156 | sector1Box = new JTextField();
|
---|
157 | sector1Box.setBounds(new Rectangle(55, 120, 50, 20));
|
---|
158 | sector1Box.setHorizontalAlignment(SwingConstants.CENTER);
|
---|
159 | add(sector1Box);
|
---|
160 | sector1Box.addFocusListener(flSector1);
|
---|
161 |
|
---|
162 | sector2Label = new JLabel(Messages.getString("End"), SwingConstants.CENTER);
|
---|
163 | sector2Label.setBounds(new Rectangle(130, 100, 100, 20));
|
---|
164 | add(sector2Label);
|
---|
165 | sector2Box = new JTextField();
|
---|
166 | sector2Box.setBounds(new Rectangle(155, 120, 50, 20));
|
---|
167 | sector2Box.setHorizontalAlignment(SwingConstants.CENTER);
|
---|
168 | add(sector2Box);
|
---|
169 | sector2Box.addFocusListener(flSector2);
|
---|
170 |
|
---|
171 | aisButton.setBounds(new Rectangle(270, 3, 27, 27));
|
---|
172 | aisButton.setBorder(BorderFactory.createLoweredBevelBorder());
|
---|
173 | aisButton.setToolTipText("AIS");
|
---|
174 | aisButton.addActionListener(alAis);
|
---|
175 | add(aisButton);
|
---|
176 |
|
---|
177 | radioCatBox = new JComboBox();
|
---|
178 | radioCatBox.setBounds(new Rectangle(210, 40, 150, 20));
|
---|
179 | add(radioCatBox);
|
---|
180 | radioCatBox.addActionListener(alRadioCatBox);
|
---|
181 | addROItem("", Cat.NOROS);
|
---|
182 | addROItem(Messages.getString("CircularBeacon"), Cat.ROS_OMNI);
|
---|
183 | addROItem(Messages.getString("DirectionalBeacon"), Cat.ROS_DIRL);
|
---|
184 | addROItem(Messages.getString("RotatingBeacon"), Cat.ROS_ROTP);
|
---|
185 | addROItem(Messages.getString("ConsolBeacon"), Cat.ROS_CNSL);
|
---|
186 | addROItem(Messages.getString("DirectionFinding"), Cat.ROS_RDF);
|
---|
187 | addROItem(Messages.getString("QTGService"), Cat.ROS_QTG);
|
---|
188 | addROItem(Messages.getString("AeronaticalBeacon"), Cat.ROS_AERO);
|
---|
189 | addROItem(Messages.getString("Decca"), Cat.ROS_DECA);
|
---|
190 | addROItem(Messages.getString("LoranC"), Cat.ROS_LORN);
|
---|
191 | addROItem(Messages.getString("DGPS"), Cat.ROS_DGPS);
|
---|
192 | addROItem(Messages.getString("Toran"), Cat.ROS_TORN);
|
---|
193 | addROItem(Messages.getString("Omega"), Cat.ROS_OMGA);
|
---|
194 | addROItem(Messages.getString("Syledis"), Cat.ROS_SYLD);
|
---|
195 | addROItem(Messages.getString("Chiaka"), Cat.ROS_CHKA);
|
---|
196 | addROItem(Messages.getString("PublicCommunication"), Cat.ROS_PCOM);
|
---|
197 | addROItem(Messages.getString("CommercialBroadcast"), Cat.ROS_COMB);
|
---|
198 | addROItem(Messages.getString("Facsimile"), Cat.ROS_FACS);
|
---|
199 | addROItem(Messages.getString("TimeSignal"), Cat.ROS_TIME);
|
---|
200 | addROItem(Messages.getString("AIS"), Cat.ROS_PAIS);
|
---|
201 | addROItem(Messages.getString("S-AIS"), Cat.ROS_SAIS);
|
---|
202 | radioCatBox.setVisible(false);
|
---|
203 | }
|
---|
204 |
|
---|
205 | public void syncPanel() {
|
---|
206 | boolean rad = ((dlg.panelMain.mark.getRadar() != Rtb.NORTB) && (dlg.panelMain.mark.getRadar() != Rtb.REFLECTOR));
|
---|
207 | groupLabel.setVisible(rad);
|
---|
208 | groupBox.setVisible(rad);
|
---|
209 | periodLabel.setVisible(rad);
|
---|
210 | periodBox.setVisible(rad);
|
---|
211 | seqLabel.setVisible(rad);
|
---|
212 | seqBox.setVisible(rad);
|
---|
213 | rangeLabel.setVisible(rad);
|
---|
214 | rangeBox.setVisible(rad);
|
---|
215 | sector1Label.setVisible(rad);
|
---|
216 | sector1Box.setVisible(rad);
|
---|
217 | sector2Label.setVisible(rad);
|
---|
218 | sector2Box.setVisible(rad);
|
---|
219 | sectorsLabel.setVisible(rad);
|
---|
220 | for (Rtb rtb : rads.keySet()) {
|
---|
221 | rads.get(rtb).setBorderPainted(dlg.panelMain.mark.getRadar() == rtb);
|
---|
222 | }
|
---|
223 | groupBox.setText(dlg.panelMain.mark.getRaconGroup());
|
---|
224 | seqBox.setText(dlg.panelMain.mark.getRaconSequence());
|
---|
225 | periodBox.setText(dlg.panelMain.mark.getRaconPeriod());
|
---|
226 | rangeBox.setText(dlg.panelMain.mark.getRaconRange());
|
---|
227 | sector1Box.setText(dlg.panelMain.mark.getRaconSector1());
|
---|
228 | sector2Box.setText(dlg.panelMain.mark.getRaconSector2());
|
---|
229 | aisButton.setSelected(dlg.panelMain.mark.getRadio() != Cat.NOROS);
|
---|
230 | aisButton.setBorderPainted(aisButton.isSelected());
|
---|
231 | radioCatBox.setVisible(dlg.panelMain.mark.getRadio() != Cat.NOROS);
|
---|
232 | }
|
---|
233 |
|
---|
234 | private JRadioButton getRadButton(JRadioButton button, int x, int y, int w, int h, String tip, Rtb rtb) {
|
---|
235 | button.setBounds(new Rectangle(x, y, w, h));
|
---|
236 | button.setBorder(BorderFactory.createLoweredBevelBorder());
|
---|
237 | button.setToolTipText(Messages.getString(tip));
|
---|
238 | button.addActionListener(alRad);
|
---|
239 | radarButtons.add(button);
|
---|
240 | rads.put(rtb, button);
|
---|
241 | return button;
|
---|
242 | }
|
---|
243 |
|
---|
244 | private void addROItem(String str, Cat cat) {
|
---|
245 | radioCats.put(cat, radioCatBox.getItemCount());
|
---|
246 | radioCatBox.addItem(str);
|
---|
247 | }
|
---|
248 | }
|
---|