Debian Codegraph @

src/dr/app/bss/BeagleSequenceSimulatorApp.java

raw symbols SCIP
1 /*
2 * BeagleSequenceSimulatorApp.java
3 *
4 * Copyright (c) 2002-2015 Alexei Drummond, Andrew Rambaut and Marc Suchard
5 *
6 * This file is part of BEAST.
7 * See the NOTICE file distributed with this work for additional
8 * information regarding copyright ownership and licensing.
9 *
10 * BEAST is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as
12 * published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * BEAST is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with BEAST; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 * Boston, MA 02110-1301 USA
24 */
25
26 package dr.app.bss;
27
28 import jam.framework.SingleDocApplication;
29
30 import java.awt.Font;
31 import java.awt.Image;
32 import java.awt.Toolkit;
33 import java.net.URL;
34 import java.util.Locale;
35
36 import javax.swing.ImageIcon;
37 import javax.swing.UIManager;
38 import javax.swing.UnsupportedLookAndFeelException;
39
40 /**
41 * @author Filip Bielejec
42 * @version $Id$
43 */
44 public class BeagleSequenceSimulatorApp {
45
46 public static final boolean DEBUG = false;
47 public static final boolean VERBOSE = true;
48
49 // Share those if neccessary
50 public static final String SHORT_NAME = "\u03C0BUSS";
51 public static final String LONG_NAME = "Parallel BEAST/BEAGLE Utility for Sequence Simulation";
52 public static final String VERSION = "1.4";
53 public static final String DATE = "2018";
54
55 // Icons
56 private Image beagleSequenceSimulatorImage;
57
58 public BeagleSequenceSimulatorApp() throws ClassNotFoundException,
59 InstantiationException, IllegalAccessException,
60 UnsupportedLookAndFeelException {
61
62 boolean lafLoaded = false;
63
64 // Setup Look & Feel
65 if (System.getProperty("os.name").toLowerCase().startsWith("mac os x")) {
66
67 // Mac stuff
68 System.setProperty("apple.awt.showGrowBox", "true");
69 System.setProperty("apple.awt.brushMetalLook", "true");
70 System.setProperty("apple.laf.useScreenMenuBar", "true");
71
72 System.setProperty("apple.awt.graphics.UseQuartz", "true");
73 System.setProperty("apple.awt.antialiasing", "true");
74 System.setProperty("apple.awt.rendering", "VALUE_RENDER_QUALITY");
75
76 System.setProperty("apple.laf.useScreenMenuBar", "true");
77 System.setProperty("apple.awt.draggableWindowBackground", "true");
78 System.setProperty("apple.awt.showGrowBox", "true");
79
80 UIManager.put("SystemFont", new Font("Lucida Grande", Font.PLAIN,
81 13));
82 UIManager.put("SmallSystemFont", new Font("Lucida Grande",
83 Font.PLAIN, 11));
84
85 try {
86
87 // UIManager.setLookAndFeel(UIManager
88 // .getSystemLookAndFeelClassName());
89
90 UIManager
91 .setLookAndFeel("ch.randelshofer.quaqua.QuaquaLookAndFeel");
92 lafLoaded = true;
93
94 } catch (Exception e) {
95 //
96 }
97
98 } else {
99
100 try {
101
102 // UIManager.setLookAndFeel(UIManager
103 // .getSystemLookAndFeelClassName());
104
105 UIManager
106 .setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
107 lafLoaded = true;
108
109 } catch (Exception e) {
110 //
111 }
112
113 }
114
115 if (!lafLoaded) {
116
117 try {
118
119 UIManager.setLookAndFeel(UIManager
120 .getSystemLookAndFeelClassName());
121 System.out
122 .println("Specified l&f not found. Loading system default l&f");
123
124 } catch (Exception e) {
125
126 e.printStackTrace();
127
128 }
129 }
130
131 ImageIcon bssIcon = Utils.createImageIcon(Utils.BSS_ICON);
132 SingleDocApplication app = new SingleDocApplication(new MenuBarFactory(), //
133 LONG_NAME, //
134 VERSION.concat(" ").concat(
135 DATE), //
136 bssIcon //
137 );
138
139 beagleSequenceSimulatorImage = CreateImage(Utils.BSS_ICON);
140 MainFrame frame = new MainFrame(SHORT_NAME + " " + VERSION);
141 frame.setIconImage(beagleSequenceSimulatorImage);
142 app.setDocumentFrame(frame);
143
144 }// END: Constructor
145
146 public static void main(String args[]) {
147
148 Locale.setDefault(Locale.US);
149
150 if (args.length > 0) {
151
152 try {
153
154 BeagleSequenceSimulatorConsoleApp app = new BeagleSequenceSimulatorConsoleApp();
155 app.simulate(args);
156
157 } catch (UnsupportedClassVersionError e) {
158
159 Utils.handleException(e, "Your Java Runtime Environment is too old. Please update");
160
161 }//END: try-catch block
162
163 } else {
164
165 try {
166
167 Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler());
168 new BeagleSequenceSimulatorApp();
169
170 // sub-title for a software note
171 System.out.println("Do the evolution baby!");
172
173 } catch (UnsupportedClassVersionError e) {
174
175 Utils.handleException(e, "Your Java Runtime Environment is too old. Please update");
176
177 } catch (ClassNotFoundException e) {
178 Utils.handleException(e, e.getMessage());
179 } catch (InstantiationException e) {
180 Utils.handleException(e, e.getMessage());
181 } catch (IllegalAccessException e) {
182 Utils.handleException(e, e.getMessage());
183 } catch (UnsupportedLookAndFeelException e) {
184 Utils.handleException(e, e.getMessage());
185 }// END: try catch block
186
187 }// END: command line check
188
189 }// END: main
190
191 private Image CreateImage(String path) {
192 URL imgURL = this.getClass().getResource(path);
193 Toolkit kit = Toolkit.getDefaultToolkit();
194 Image img = kit.createImage(imgURL);
195
196 if (img != null) {
197 return img;
198 } else {
199 System.out.println("Couldn't find file: " + path + "\n");
200 return null;
201 }
202
203 }// END: CreateImage
204
205 }// END: class
206