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 oseam.Messages;
|
---|
11 | import oseam.OSeaMAction;
|
---|
12 | import seamarks.SeaMark.*;
|
---|
13 |
|
---|
14 | public class PanelRadar extends JPanel {
|
---|
15 |
|
---|
16 | private OSeaMAction dlg;
|
---|
17 | private ButtonGroup radarButtons = new ButtonGroup();
|
---|
18 | public JRadioButton noRadButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/OffButton.png")));
|
---|
19 | public JRadioButton reflButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RadarReflectorButton.png")));
|
---|
20 | public JRadioButton ramarkButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RamarkButton.png")));
|
---|
21 | public JRadioButton raconButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RaconButton.png")));
|
---|
22 | public JRadioButton leadingButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LeadingRaconButton.png")));
|
---|
23 | private EnumMap<Rtb, JRadioButton> rads = new EnumMap<Rtb, JRadioButton>(Rtb.class);
|
---|
24 | private ActionListener alRad = new ActionListener() {
|
---|
25 | public void actionPerformed(java.awt.event.ActionEvent e) {
|
---|
26 | for (Rtb rtb : rads.keySet()) {
|
---|
27 | JRadioButton button = rads.get(rtb);
|
---|
28 | if (button.isSelected()) {
|
---|
29 | dlg.panelMain.mark.setRadar(rtb);
|
---|
30 | }
|
---|
31 | }
|
---|
32 | syncPanel();
|
---|
33 | }
|
---|
34 | };
|
---|
35 | public JLabel groupLabel;
|
---|
36 | public JTextField groupBox;
|
---|
37 | private FocusListener flGroup = new FocusAdapter() {
|
---|
38 | public void focusLost(java.awt.event.FocusEvent e) {
|
---|
39 | dlg.panelMain.mark.setRaconGroup(groupBox.getText());
|
---|
40 | }
|
---|
41 | };
|
---|
42 | public JLabel periodLabel;
|
---|
43 | public JTextField periodBox;
|
---|
44 | private FocusListener flPeriod = new FocusAdapter() {
|
---|
45 | public void focusLost(java.awt.event.FocusEvent e) {
|
---|
46 | dlg.panelMain.mark.setRaconPeriod(periodBox.getText());
|
---|
47 | }
|
---|
48 | };
|
---|
49 | public JLabel seqLabel;
|
---|
50 | public JTextField seqBox;
|
---|
51 | private FocusListener flSeq = new FocusAdapter() {
|
---|
52 | public void focusLost(java.awt.event.FocusEvent e) {
|
---|
53 | dlg.panelMain.mark.setRaconSequence(seqBox.getText());
|
---|
54 | }
|
---|
55 | };
|
---|
56 | public JLabel rangeLabel;
|
---|
57 | public JTextField rangeBox;
|
---|
58 | private FocusListener flRange = new FocusAdapter() {
|
---|
59 | public void focusLost(java.awt.event.FocusEvent e) {
|
---|
60 | dlg.panelMain.mark.setRaconRange(rangeBox.getText());
|
---|
61 | }
|
---|
62 | };
|
---|
63 | public JLabel sector1Label;
|
---|
64 | public JTextField sector1Box;
|
---|
65 | private FocusListener flSector1 = new FocusAdapter() {
|
---|
66 | public void focusLost(java.awt.event.FocusEvent e) {
|
---|
67 | dlg.panelMain.mark.setRaconSector1(sector1Box.getText());
|
---|
68 | }
|
---|
69 | };
|
---|
70 | public JLabel sector2Label;
|
---|
71 | public JTextField sector2Box;
|
---|
72 | private FocusListener flSector2 = new FocusAdapter() {
|
---|
73 | public void focusLost(java.awt.event.FocusEvent e) {
|
---|
74 | dlg.panelMain.mark.setRaconSector2(sector2Box.getText());
|
---|
75 | }
|
---|
76 | };
|
---|
77 | public JLabel sectorsLabel;
|
---|
78 |
|
---|
79 | public PanelRadar(OSeaMAction dia) {
|
---|
80 | dlg = dia;
|
---|
81 | setLayout(null);
|
---|
82 | add(getRadButton(noRadButton, 0, 3, 27, 27, "NoRadar", Rtb.NORTB));
|
---|
83 | add(getRadButton(reflButton, 0, 33, 27, 27, "RadarReflector", Rtb.REFLECTOR));
|
---|
84 | add(getRadButton(ramarkButton, 0, 63, 27, 27, "Ramark", Rtb.RAMARK));
|
---|
85 | add(getRadButton(raconButton, 0, 93, 27, 27, "Racon", Rtb.RACON));
|
---|
86 | add(getRadButton(leadingButton, 0, 123, 27, 27, "LeadingRacon", Rtb.LEADING));
|
---|
87 |
|
---|
88 | groupLabel = new JLabel(Messages.getString("Group"), SwingConstants.CENTER);
|
---|
89 | groupLabel.setBounds(new Rectangle(30, 0, 100, 20));
|
---|
90 | add(groupLabel);
|
---|
91 | groupBox = new JTextField();
|
---|
92 | groupBox.setBounds(new Rectangle(55, 20, 50, 20));
|
---|
93 | groupBox.setHorizontalAlignment(SwingConstants.CENTER);
|
---|
94 | add(groupBox);
|
---|
95 | groupBox.addFocusListener(flGroup);
|
---|
96 |
|
---|
97 | periodLabel = new JLabel(Messages.getString("Period"), SwingConstants.CENTER);
|
---|
98 | periodLabel.setBounds(new Rectangle(130, 0, 100, 20));
|
---|
99 | add(periodLabel);
|
---|
100 | periodBox = new JTextField();
|
---|
101 | periodBox.setBounds(new Rectangle(155, 20, 50, 20));
|
---|
102 | periodBox.setHorizontalAlignment(SwingConstants.CENTER);
|
---|
103 | add(periodBox);
|
---|
104 | periodBox.addFocusListener(flPeriod);
|
---|
105 |
|
---|
106 | seqLabel = new JLabel(Messages.getString("Sequence"), SwingConstants.CENTER);
|
---|
107 | seqLabel.setBounds(new Rectangle(30, 40, 100, 20));
|
---|
108 | add(seqLabel);
|
---|
109 | seqBox = new JTextField();
|
---|
110 | seqBox.setBounds(new Rectangle(55, 60, 50, 20));
|
---|
111 | seqBox.setHorizontalAlignment(SwingConstants.CENTER);
|
---|
112 | add(seqBox);
|
---|
113 | seqBox.addFocusListener(flSeq);
|
---|
114 |
|
---|
115 | rangeLabel = new JLabel(Messages.getString("Range"), SwingConstants.CENTER);
|
---|
116 | rangeLabel.setBounds(new Rectangle(130, 40, 100, 20));
|
---|
117 | add(rangeLabel);
|
---|
118 | rangeBox = new JTextField();
|
---|
119 | rangeBox.setBounds(new Rectangle(155, 60, 50, 20));
|
---|
120 | rangeBox.setHorizontalAlignment(SwingConstants.CENTER);
|
---|
121 | add(rangeBox);
|
---|
122 | rangeBox.addFocusListener(flRange);
|
---|
123 |
|
---|
124 | sectorsLabel = new JLabel(Messages.getString("VisibleSector"), SwingConstants.CENTER);
|
---|
125 | sectorsLabel.setBounds(new Rectangle(75, 85, 100, 20));
|
---|
126 | add(sectorsLabel);
|
---|
127 |
|
---|
128 | sector1Label = new JLabel(Messages.getString("Start"), SwingConstants.CENTER);
|
---|
129 | sector1Label.setBounds(new Rectangle(30, 100, 100, 20));
|
---|
130 | add(sector1Label);
|
---|
131 | sector1Box = new JTextField();
|
---|
132 | sector1Box.setBounds(new Rectangle(55, 120, 50, 20));
|
---|
133 | sector1Box.setHorizontalAlignment(SwingConstants.CENTER);
|
---|
134 | add(sector1Box);
|
---|
135 | sector1Box.addFocusListener(flSector1);
|
---|
136 |
|
---|
137 | sector2Label = new JLabel(Messages.getString("End"), SwingConstants.CENTER);
|
---|
138 | sector2Label.setBounds(new Rectangle(130, 100, 100, 20));
|
---|
139 | add(sector2Label);
|
---|
140 | sector2Box = new JTextField();
|
---|
141 | sector2Box.setBounds(new Rectangle(155, 120, 50, 20));
|
---|
142 | sector2Box.setHorizontalAlignment(SwingConstants.CENTER);
|
---|
143 | add(sector2Box);
|
---|
144 | sector2Box.addFocusListener(flSector2);
|
---|
145 | }
|
---|
146 |
|
---|
147 | public void syncPanel() {
|
---|
148 | boolean rad = ((dlg.panelMain.mark.getRadar() != Rtb.NORTB) && (dlg.panelMain.mark.getRadar() != Rtb.REFLECTOR));
|
---|
149 | groupLabel.setVisible(rad);
|
---|
150 | groupBox.setVisible(rad);
|
---|
151 | periodLabel.setVisible(rad);
|
---|
152 | periodBox.setVisible(rad);
|
---|
153 | seqLabel.setVisible(rad);
|
---|
154 | seqBox.setVisible(rad);
|
---|
155 | rangeLabel.setVisible(rad);
|
---|
156 | rangeBox.setVisible(rad);
|
---|
157 | sector1Label.setVisible(rad);
|
---|
158 | sector1Box.setVisible(rad);
|
---|
159 | sector2Label.setVisible(rad);
|
---|
160 | sector2Box.setVisible(rad);
|
---|
161 | sectorsLabel.setVisible(rad);
|
---|
162 | for (Rtb rtb : rads.keySet()) {
|
---|
163 | rads.get(rtb).setBorderPainted(dlg.panelMain.mark.getRadar() == rtb);
|
---|
164 | }
|
---|
165 | groupBox.setText(dlg.panelMain.mark.getRaconGroup());
|
---|
166 | seqBox.setText(dlg.panelMain.mark.getRaconSequence());
|
---|
167 | periodBox.setText(dlg.panelMain.mark.getRaconPeriod());
|
---|
168 | rangeBox.setText(dlg.panelMain.mark.getRaconRange());
|
---|
169 | sector1Box.setText(dlg.panelMain.mark.getRaconSector1());
|
---|
170 | sector2Box.setText(dlg.panelMain.mark.getRaconSector2());
|
---|
171 | }
|
---|
172 |
|
---|
173 | private JRadioButton getRadButton(JRadioButton button, int x, int y, int w, int h, String tip, Rtb rtb) {
|
---|
174 | button.setBounds(new Rectangle(x, y, w, h));
|
---|
175 | button.setBorder(BorderFactory.createLoweredBevelBorder());
|
---|
176 | button.setToolTipText(Messages.getString(tip));
|
---|
177 | button.addActionListener(alRad);
|
---|
178 | radarButtons.add(button);
|
---|
179 | rads.put(rtb, button);
|
---|
180 | return button;
|
---|
181 | }
|
---|
182 |
|
---|
183 | }
|
---|