2 * Copyright © 2010 Keith Packard <keithp@keithp.com>
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.
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.
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.
18 package org.altusmetrum.altosuilib_9;
23 import org.altusmetrum.altoslib_9.*;
25 public class AltosUILib extends AltosLib {
27 public static final int tab_elt_pad = 5;
29 public static Font label_font;
30 public static Font value_font;
31 public static Font status_font;
32 public static Font table_label_font;
33 public static Font table_value_font;
35 final public static int font_size_small = 1;
36 final public static int font_size_medium = 2;
37 final public static int font_size_large = 3;
39 final public static int position_top_left = 0;
40 final public static int position_top = 1;
41 final public static int position_top_right = 2;
42 final public static int position_left = 3;
43 final public static int position_center = 4;
44 final public static int position_right = 5;
45 final public static int position_bottom_left = 6;
46 final public static int position_bottom = 7;
47 final public static int position_bottom_right = 8;
49 public static void set_fonts(int size) {
61 case font_size_medium:
72 label_font = new Font("Dialog", Font.PLAIN, brief_size);
73 value_font = new Font("Monospaced", Font.PLAIN, brief_size);
74 status_font = new Font("SansSerif", Font.BOLD, status_size);
75 table_label_font = new Font("SansSerif", Font.PLAIN, table_size);
76 table_value_font = new Font("Monospaced", Font.PLAIN, table_size);
79 static public final int text_width = 20;
81 static public boolean initialized = false;
82 static public boolean loaded_library = false;
83 static public boolean has_bluetooth = false;
85 static final String[] library_names_32 = { "altos", "altos32", "altos64" };
86 static final String[] library_names_64 = { "altos", "altos64", "altos32" };
88 public static boolean load_library() {
90 String model = System.getProperty("sun.arch.data.model", "missing");
91 boolean is_64 = false;
92 if (model.equals("64")) {
94 } else if (model.equals("32")) {
97 String arch = System.getProperty("os.arch", "missing");
98 if (arch.endsWith("64"))
101 for (String name : is_64 ? library_names_64 : library_names_32) {
103 System.loadLibrary(name);
104 libaltos.altos_init();
105 loaded_library = true;
107 } catch (UnsatisfiedLinkError e) {
108 System.out.printf("Link error %s\n", e.getMessage());
109 loaded_library = false;
113 String OS = System.getProperty("os.name");
115 if (OS.startsWith("Linux")) {
116 has_bluetooth = true;
121 return loaded_library;