altos: product defines are always in ao_product.h
[fw/altos] / altosui / AltosLights.java
1 /*
2  * Copyright © 2010 Keith Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 2 of the License.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write to the Free Software Foundation, Inc.,
15  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
16  */
17
18 package altosui;
19
20 import java.awt.*;
21 import java.awt.event.*;
22 import javax.swing.*;
23 import javax.swing.filechooser.FileNameExtensionFilter;
24 import javax.swing.table.*;
25 import java.io.*;
26 import java.util.*;
27 import java.text.*;
28 import java.util.prefs.*;
29 import java.util.concurrent.LinkedBlockingQueue;
30
31 public class AltosLights extends JComponent {
32
33         GridBagLayout   gridbag;
34
35         AltosLed        red, green;
36
37         ImageIcon create_icon(String path, String description) {
38                 java.net.URL imgURL = AltosUI.class.getResource(path);
39                 if (imgURL != null)
40                         return new ImageIcon(imgURL, description);
41                 System.err.printf("Cannot find icon \"%s\"\n", path);
42                 return null;
43         }
44
45         public void set (boolean on) {
46                 if (on) {
47                         red.set(false);
48                         green.set(true);
49                 } else {
50                         red.set(true);
51                         green.set(false);
52                 }
53         }
54
55         public AltosLights() {
56                 GridBagConstraints c;
57                 gridbag = new GridBagLayout();
58                 setLayout(gridbag);
59
60                 c = new GridBagConstraints();
61                 red = new AltosLed("/redled.png", "/grayled.png");
62                 c.gridx = 0; c.gridy = 0;
63                 c.insets = new Insets (0, 5, 0, 5);
64                 gridbag.setConstraints(red, c);
65                 add(red);
66                 red.set(true);
67                 green = new AltosLed("/greenled.png", "/grayled.png");
68                 c.gridx = 1; c.gridy = 0;
69                 gridbag.setConstraints(green, c);
70                 add(green);
71                 green.set(false);
72         }
73 }