telegps: Add graph display
[fw/altos] / altosuilib / AltosLed.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 org.altusmetrum.altosuilib_2;
19
20 import javax.swing.*;
21
22 public class AltosLed extends JLabel {
23         ImageIcon       on, off;
24
25         ImageIcon create_icon(String path) {
26                 java.net.URL imgURL = AltosUILib.class.getResource(path);
27                 if (imgURL != null)
28                         return new ImageIcon(imgURL);
29                 System.err.printf("Cannot find icon \"%s\"\n", path);
30                 return null;
31         }
32
33         public void set(boolean set) {
34                 if (set)
35                         setIcon(on);
36                 else
37                         setIcon(off);
38         }
39
40         public AltosLed(String on_path, String off_path) {
41                 on = create_icon(on_path);
42                 off = create_icon(off_path);
43                 setIcon(off);
44         }
45 }