1 | package oseam.panels;
|
---|
2 |
|
---|
3 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
4 |
|
---|
5 | import javax.swing.BorderFactory;
|
---|
6 | import javax.swing.JPanel;
|
---|
7 |
|
---|
8 | import java.awt.Color;
|
---|
9 | import java.awt.Dimension;
|
---|
10 | import java.awt.Rectangle;
|
---|
11 | import java.awt.Font;
|
---|
12 |
|
---|
13 | import javax.swing.ButtonGroup;
|
---|
14 | import javax.swing.ImageIcon;
|
---|
15 | import javax.swing.JLabel;
|
---|
16 | import javax.swing.JTextField;
|
---|
17 | import javax.swing.JComboBox;
|
---|
18 | import javax.swing.JCheckBox;
|
---|
19 | import javax.swing.JRadioButton;
|
---|
20 |
|
---|
21 | import oseam.Messages;
|
---|
22 |
|
---|
23 | import java.awt.Cursor;
|
---|
24 | import java.awt.event.ActionListener;
|
---|
25 |
|
---|
26 | public class PanelCol extends JPanel {
|
---|
27 |
|
---|
28 | private ButtonGroup colourButtons = null;
|
---|
29 | public JRadioButton offButton = null;
|
---|
30 | public JRadioButton whiteButton = null;
|
---|
31 | public JRadioButton redButton = null;
|
---|
32 | public JRadioButton orangeButton = null;
|
---|
33 | public JRadioButton amberButton = null;
|
---|
34 | public JRadioButton yellowButton = null;
|
---|
35 | public JRadioButton greenButton = null;
|
---|
36 | public JRadioButton blueButton = null;
|
---|
37 | public JRadioButton violetButton = null;
|
---|
38 | public JRadioButton blackButton = null;
|
---|
39 | private ActionListener alColour = null;
|
---|
40 |
|
---|
41 | public PanelCol() {
|
---|
42 | super();
|
---|
43 | this.setLayout(null);
|
---|
44 |
|
---|
45 | this.add(getOffButton(), null);
|
---|
46 | this.add(getWhiteButton(), null);
|
---|
47 | this.add(getRedButton(), null);
|
---|
48 | this.add(getOrangeButton(), null);
|
---|
49 | this.add(getAmberButton(), null);
|
---|
50 | this.add(getYellowButton(), null);
|
---|
51 | this.add(getGreenButton(), null);
|
---|
52 | this.add(getBlueButton(), null);
|
---|
53 | this.add(getVioletButton(), null);
|
---|
54 | this.add(getBlackButton(), null);
|
---|
55 | colourButtons = new ButtonGroup();
|
---|
56 | colourButtons.add(whiteButton);
|
---|
57 | colourButtons.add(offButton);
|
---|
58 | colourButtons.add(redButton);
|
---|
59 | colourButtons.add(orangeButton);
|
---|
60 | colourButtons.add(amberButton);
|
---|
61 | colourButtons.add(yellowButton);
|
---|
62 | colourButtons.add(greenButton);
|
---|
63 | colourButtons.add(blueButton);
|
---|
64 | colourButtons.add(violetButton);
|
---|
65 | colourButtons.add(blackButton);
|
---|
66 | alColour = new ActionListener() {
|
---|
67 | public void actionPerformed(java.awt.event.ActionEvent e) {
|
---|
68 | offButton.setBorderPainted(offButton.isSelected());
|
---|
69 | whiteButton.setBorderPainted(whiteButton.isSelected());
|
---|
70 | redButton.setBorderPainted(redButton.isSelected());
|
---|
71 | orangeButton.setBorderPainted(orangeButton.isSelected());
|
---|
72 | amberButton.setBorderPainted(amberButton.isSelected());
|
---|
73 | yellowButton.setBorderPainted(yellowButton.isSelected());
|
---|
74 | greenButton.setBorderPainted(greenButton.isSelected());
|
---|
75 | blueButton.setBorderPainted(blueButton.isSelected());
|
---|
76 | violetButton.setBorderPainted(violetButton.isSelected());
|
---|
77 | blackButton.setBorderPainted(blackButton.isSelected());
|
---|
78 | }
|
---|
79 | };
|
---|
80 | offButton.addActionListener(alColour);
|
---|
81 | whiteButton.addActionListener(alColour);
|
---|
82 | redButton.addActionListener(alColour);
|
---|
83 | orangeButton.addActionListener(alColour);
|
---|
84 | amberButton.addActionListener(alColour);
|
---|
85 | yellowButton.addActionListener(alColour);
|
---|
86 | greenButton.addActionListener(alColour);
|
---|
87 | blueButton.addActionListener(alColour);
|
---|
88 | violetButton.addActionListener(alColour);
|
---|
89 | blackButton.addActionListener(alColour);
|
---|
90 | }
|
---|
91 |
|
---|
92 | public void clearSelections() {
|
---|
93 | colourButtons.clearSelection();
|
---|
94 | alColour.actionPerformed(null);
|
---|
95 | }
|
---|
96 |
|
---|
97 | private JRadioButton getOffButton() {
|
---|
98 | if (offButton == null) {
|
---|
99 | offButton = new JRadioButton(new ImageIcon(getClass()
|
---|
100 | .getResource("/images/OffButton.png")));
|
---|
101 | offButton.setBounds(new Rectangle(0, 0, 34, 16));
|
---|
102 | offButton.setBorder(BorderFactory.createLineBorder(Color.magenta, 2));
|
---|
103 | offButton.setToolTipText(tr("No colour"));
|
---|
104 | }
|
---|
105 | return offButton;
|
---|
106 | }
|
---|
107 |
|
---|
108 | private JRadioButton getWhiteButton() {
|
---|
109 | if (whiteButton == null) {
|
---|
110 | whiteButton = new JRadioButton(new ImageIcon(getClass()
|
---|
111 | .getResource("/images/WhiteButton.png")));
|
---|
112 | whiteButton.setBounds(new Rectangle(0, 16, 34, 16));
|
---|
113 | whiteButton.setBorder(BorderFactory.createLineBorder(Color.magenta, 2));
|
---|
114 | whiteButton.setToolTipText(tr("White"));
|
---|
115 | }
|
---|
116 | return whiteButton;
|
---|
117 | }
|
---|
118 |
|
---|
119 | private JRadioButton getRedButton() {
|
---|
120 | if (redButton == null) {
|
---|
121 | redButton = new JRadioButton(new ImageIcon(getClass().getResource(
|
---|
122 | "/images/RedButton.png")));
|
---|
123 | redButton.setBounds(new Rectangle(0, 32, 34, 16));
|
---|
124 | redButton.setBorder(BorderFactory.createLineBorder(Color.magenta, 2));
|
---|
125 | redButton.setToolTipText(tr("Red"));
|
---|
126 | }
|
---|
127 | return redButton;
|
---|
128 | }
|
---|
129 |
|
---|
130 | private JRadioButton getOrangeButton() {
|
---|
131 | if (orangeButton == null) {
|
---|
132 | orangeButton = new JRadioButton(new ImageIcon(getClass()
|
---|
133 | .getResource("/images/OrangeButton.png")));
|
---|
134 | orangeButton.setBounds(new Rectangle(0, 48, 34, 16));
|
---|
135 | orangeButton.setBorder(BorderFactory.createLineBorder(Color.magenta, 2));
|
---|
136 | orangeButton.setToolTipText(tr("Orange"));
|
---|
137 | }
|
---|
138 | return orangeButton;
|
---|
139 | }
|
---|
140 |
|
---|
141 | private JRadioButton getAmberButton() {
|
---|
142 | if (amberButton == null) {
|
---|
143 | amberButton = new JRadioButton(new ImageIcon(getClass()
|
---|
144 | .getResource("/images/AmberButton.png")));
|
---|
145 | amberButton.setBounds(new Rectangle(0, 64, 34, 16));
|
---|
146 | amberButton.setBorder(BorderFactory.createLineBorder(Color.magenta, 2));
|
---|
147 | amberButton.setToolTipText(tr("Amber"));
|
---|
148 | }
|
---|
149 | return amberButton;
|
---|
150 | }
|
---|
151 |
|
---|
152 | private JRadioButton getYellowButton() {
|
---|
153 | if (yellowButton == null) {
|
---|
154 | yellowButton = new JRadioButton(new ImageIcon(getClass()
|
---|
155 | .getResource("/images/YellowButton.png")));
|
---|
156 | yellowButton.setBounds(new Rectangle(0, 80, 34, 16));
|
---|
157 | yellowButton.setBorder(BorderFactory.createLineBorder(Color.magenta, 2));
|
---|
158 | yellowButton.setToolTipText(tr("Yellow"));
|
---|
159 | }
|
---|
160 | return yellowButton;
|
---|
161 | }
|
---|
162 |
|
---|
163 | private JRadioButton getGreenButton() {
|
---|
164 | if (greenButton == null) {
|
---|
165 | greenButton = new JRadioButton(new ImageIcon(getClass()
|
---|
166 | .getResource("/images/GreenButton.png")));
|
---|
167 | greenButton.setBounds(new Rectangle(0, 96, 34, 16));
|
---|
168 | greenButton.setBorder(BorderFactory.createLineBorder(Color.magenta, 2));
|
---|
169 | greenButton.setToolTipText(tr("Green"));
|
---|
170 | }
|
---|
171 | return greenButton;
|
---|
172 | }
|
---|
173 |
|
---|
174 | private JRadioButton getBlueButton() {
|
---|
175 | if (blueButton == null) {
|
---|
176 | blueButton = new JRadioButton(new ImageIcon(getClass().getResource(
|
---|
177 | "/images/BlueButton.png")));
|
---|
178 | blueButton.setBounds(new Rectangle(0, 112, 34, 16));
|
---|
179 | blueButton.setBorder(BorderFactory.createLineBorder(Color.magenta, 2));
|
---|
180 | blueButton.setToolTipText(tr("Blue"));
|
---|
181 | }
|
---|
182 | return blueButton;
|
---|
183 | }
|
---|
184 |
|
---|
185 | private JRadioButton getVioletButton() {
|
---|
186 | if (violetButton == null) {
|
---|
187 | violetButton = new JRadioButton(new ImageIcon(getClass()
|
---|
188 | .getResource("/images/VioletButton.png")));
|
---|
189 | violetButton.setBounds(new Rectangle(0, 128, 34, 16));
|
---|
190 | violetButton.setBorder(BorderFactory.createLineBorder(Color.magenta, 2));
|
---|
191 | violetButton.setToolTipText(tr("Violet"));
|
---|
192 | }
|
---|
193 | return violetButton;
|
---|
194 | }
|
---|
195 |
|
---|
196 | private JRadioButton getBlackButton() {
|
---|
197 | if (blackButton == null) {
|
---|
198 | blackButton = new JRadioButton(new ImageIcon(getClass()
|
---|
199 | .getResource("/images/BlackButton.png")));
|
---|
200 | blackButton.setBounds(new Rectangle(0, 144, 34, 16));
|
---|
201 | blackButton.setBorder(BorderFactory.createLineBorder(Color.magenta, 2));
|
---|
202 | blackButton.setToolTipText(tr("Black"));
|
---|
203 | }
|
---|
204 | return blackButton;
|
---|
205 | }
|
---|
206 |
|
---|
207 | }
|
---|