altosui: remove un-used imports
[fw/altos] / altosui / Altos.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 libaltosJNI.*;
22
23 import org.altusmetrum.AltosLib.*;
24
25 public class Altos extends AltosLib {
26
27         static final int tab_elt_pad = 5;
28
29         static Font label_font;
30         static Font value_font;
31         static Font status_font;
32         static Font table_label_font;
33         static Font table_value_font;
34
35         final static int font_size_small = 1;
36         final static int font_size_medium = 2;
37         final static int font_size_large = 3;
38
39         static void set_fonts(int size) {
40                 int     brief_size;
41                 int     table_size;
42                 int     status_size;
43
44                 switch (size) {
45                 case font_size_small:
46                         brief_size = 16;
47                         status_size = 18;
48                         table_size = 11;
49                         break;
50                 default:
51                 case font_size_medium:
52                         brief_size = 22;
53                         status_size = 24;
54                         table_size = 14;
55                         break;
56                 case font_size_large:
57                         brief_size = 26;
58                         status_size = 30;
59                         table_size = 17;
60                         break;
61                 }
62                 label_font = new Font("Dialog", Font.PLAIN, brief_size);
63                 value_font = new Font("Monospaced", Font.PLAIN, brief_size);
64                 status_font = new Font("SansSerif", Font.BOLD, status_size);
65                 table_label_font = new Font("SansSerif", Font.PLAIN, table_size);
66                 table_value_font = new Font("Monospaced", Font.PLAIN, table_size);
67         }
68
69         static final int text_width = 20;
70
71         static public boolean initialized = false;
72         static public boolean loaded_library = false;
73
74         public static boolean load_library() {
75                 if (!initialized) {
76                         try {
77                                 System.loadLibrary("altos");
78                                 libaltos.altos_init();
79                                 loaded_library = true;
80                         } catch (UnsatisfiedLinkError e) {
81                                 try {
82                                         System.loadLibrary("altos64");
83                                         libaltos.altos_init();
84                                         loaded_library = true;
85                                 } catch (UnsatisfiedLinkError e2) {
86                                         loaded_library = false;
87                                 }
88                         }
89                         initialized = true;
90                 }
91                 return loaded_library;
92         }
93 }