source: osm/applications/editors/josm/plugins/smed/src/panels/PanelFog.java@ 30532

Last change on this file since 30532 was 29894, checked in by malcolmh, 11 years ago

clean

File size: 5.5 KB
Line 
1package panels;
2
3import javax.swing.*;
4
5import java.awt.*;
6import java.awt.event.*;
7import java.util.EnumMap;
8
9import messages.Messages;
10import smed.SmedAction;
11import seamarks.SeaMark.*;
12
13public class PanelFog extends JPanel {
14
15 private SmedAction dlg;
16 private ButtonGroup fogButtons = new ButtonGroup();
17 public JRadioButton noFogButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/OffButton.png")));
18 public JRadioButton yesFogButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogYesButton.png")));
19 public JRadioButton hornButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogHornButton.png")));
20 public JRadioButton sirenButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogSirenButton.png")));
21 public JRadioButton diaButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogDiaButton.png")));
22 public JRadioButton bellButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogBellButton.png")));
23 public JRadioButton whisButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogWhisButton.png")));
24 public JRadioButton gongButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogGongButton.png")));
25 public JRadioButton explosButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogExplosButton.png")));
26 private EnumMap<Fog, JRadioButton> fogs = new EnumMap<Fog, JRadioButton>(Fog.class);
27 private ActionListener alFog = new ActionListener() {
28 public void actionPerformed(java.awt.event.ActionEvent e) {
29 for (Fog fog : fogs.keySet()) {
30 JRadioButton button = fogs.get(fog);
31 if (button.isSelected()) {
32 dlg.panelMain.mark.setFogSound(fog);
33 button.setBorderPainted(true);
34 } else
35 button.setBorderPainted(false);
36 }
37 }
38 };
39 public JLabel groupLabel;
40 public JTextField groupBox;
41 private FocusListener flGroup = new FocusAdapter() {
42 public void focusLost(java.awt.event.FocusEvent e) {
43 dlg.panelMain.mark.setFogGroup(groupBox.getText());
44 }
45 };
46 public JLabel periodLabel;
47 public JTextField periodBox;
48 private FocusListener flPeriod = new FocusAdapter() {
49 public void focusLost(java.awt.event.FocusEvent e) {
50 dlg.panelMain.mark.setFogPeriod(periodBox.getText());
51 }
52 };
53 public JLabel seqLabel;
54 public JTextField seqBox;
55 private FocusListener flSeq = new FocusAdapter() {
56 public void focusLost(java.awt.event.FocusEvent e) {
57 dlg.panelMain.mark.setFogSequence(seqBox.getText());
58 }
59 };
60 public JLabel rangeLabel;
61 public JTextField rangeBox;
62 private FocusListener flRange = new FocusAdapter() {
63 public void focusLost(java.awt.event.FocusEvent e) {
64 dlg.panelMain.mark.setFogRange(rangeBox.getText());
65 }
66 };
67
68 public PanelFog(SmedAction dia) {
69 dlg = dia;
70 setLayout(null);
71 add(getFogButton(noFogButton, 0, 2, 27, 27, "NoFog", Fog.NOFOG));
72 add(getFogButton(yesFogButton, 0, 32, 27, 27, "FogSignal", Fog.FOGSIG));
73 add(getFogButton(hornButton, 0, 62, 27, 27, "Horn", Fog.HORN));
74 add(getFogButton(sirenButton, 0, 92, 27, 27, "Siren", Fog.SIREN));
75 add(getFogButton(gongButton, 0, 122, 27, 27, "Gong", Fog.GONG));
76 add(getFogButton(diaButton, 30, 2, 27, 27, "Diaphone", Fog.DIA));
77 add(getFogButton(bellButton, 30, 32, 27, 27, "Bell", Fog.BELL));
78 add(getFogButton(whisButton, 30, 62, 27, 27, "Whistle", Fog.WHIS));
79 add(getFogButton(explosButton, 30, 92, 27, 27, "Explosion", Fog.EXPLOS));
80
81 groupLabel = new JLabel(Messages.getString("Group"), SwingConstants.CENTER);
82 groupLabel.setBounds(new Rectangle(75, 0, 100, 20));
83 add(groupLabel);
84 groupBox = new JTextField();
85 groupBox.setBounds(new Rectangle(100, 20, 50, 20));
86 groupBox.setHorizontalAlignment(SwingConstants.CENTER);
87 add(groupBox);
88 groupBox.addFocusListener(flGroup);
89
90 periodLabel = new JLabel(Messages.getString("Period"), SwingConstants.CENTER);
91 periodLabel.setBounds(new Rectangle(75, 40, 100, 20));
92 add(periodLabel);
93 periodBox = new JTextField();
94 periodBox.setBounds(new Rectangle(100, 60, 50, 20));
95 periodBox.setHorizontalAlignment(SwingConstants.CENTER);
96 add(periodBox);
97 periodBox.addFocusListener(flPeriod);
98
99 seqLabel = new JLabel(Messages.getString("Sequence"), SwingConstants.CENTER);
100 seqLabel.setBounds(new Rectangle(75, 80, 100, 20));
101 add(seqLabel);
102 seqBox = new JTextField();
103 seqBox.setBounds(new Rectangle(100, 100, 50, 20));
104 seqBox.setHorizontalAlignment(SwingConstants.CENTER);
105 add(seqBox);
106 seqBox.addFocusListener(flSeq);
107
108 rangeLabel = new JLabel(Messages.getString("Range"), SwingConstants.CENTER);
109 rangeLabel.setBounds(new Rectangle(75, 120, 100, 20));
110 add(rangeLabel);
111 rangeBox = new JTextField();
112 rangeBox.setBounds(new Rectangle(100, 140, 50, 20));
113 rangeBox.setHorizontalAlignment(SwingConstants.CENTER);
114 add(rangeBox);
115 rangeBox.addFocusListener(flRange);
116
117 }
118
119 public void syncPanel() {
120 for (Fog fog : fogs.keySet()) {
121 JRadioButton button = fogs.get(fog);
122 button.setBorderPainted(dlg.panelMain.mark.getFogSound() == fog);
123 }
124 groupBox.setText(dlg.panelMain.mark.getFogGroup());
125 seqBox.setText(dlg.panelMain.mark.getFogSequence());
126 periodBox.setText(dlg.panelMain.mark.getFogPeriod());
127 rangeBox.setText(dlg.panelMain.mark.getFogRange());
128 }
129
130 private JRadioButton getFogButton(JRadioButton button, int x, int y, int w, int h, String tip, Fog fog) {
131 button.setBounds(new Rectangle(x, y, w, h));
132 button.setBorder(BorderFactory.createLoweredBevelBorder());
133 button.setToolTipText(Messages.getString(tip));
134 button.addActionListener(alFog);
135 fogButtons.add(button);
136 fogs.put(fog, button);
137 return button;
138 }
139
140}
Note: See TracBrowser for help on using the repository browser.