2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
19 package jalview.bin;
\r
21 import jalview.gui.*;
\r
23 import jalview.io.*;
\r
25 import org.apache.log4j.*;
\r
27 import java.awt.event.*;
\r
29 import javax.swing.*;
\r
32 public class Jalview extends JApplet {
\r
33 public static JApplet applet;
\r
36 public void init() {
\r
38 Cache.loadProperties();
\r
39 jalview.gui.Preferences.initPreferences();
\r
41 frame = new Desktop();
\r
42 frame.setResizable(true);
\r
43 frame.setVisible(true);
\r
44 frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
\r
45 frame.addWindowListener(new WindowAdapter() {
\r
46 public void windowClosing(WindowEvent e) {
\r
52 String file = getParameter("alignment");
\r
55 jalview.bin.Cache.setProperty("LAST_DIRECTORY", file);
\r
57 String protocol = "File";
\r
59 if (file.indexOf("http:") > -1) {
\r
63 String format = jalview.io.IdentifyFile.Identify(file, protocol);
\r
65 frame.LoadFile(file, protocol, format);
\r
69 public void destroy() {
\r
70 if (applet != null) {
\r
76 frame.setVisible(false);
\r
79 private static void initLogger() {
\r
80 Logger laxis = Logger.getLogger("org.apache.axis");
\r
81 Logger lcastor = Logger.getLogger("org.exolab.castor");
\r
82 if (Cache.getProperty("logs.Axis.Level") == null) {
\r
83 Cache.setProperty("logs.Axis.Level", Level.INFO.toString());
\r
85 if (Cache.getProperty("logs.Castor.Level") == null) {
\r
86 Cache.setProperty("logs.Castor.Level", Level.INFO.toString());
\r
89 laxis.setLevel(Level.toLevel(Cache.getProperty("logs.Axis.Level")));
\r
90 lcastor.setLevel(Level.toLevel(Cache.getProperty("logs.Castor.Level")));
\r
92 ConsoleAppender ap = new ConsoleAppender(new SimpleLayout(),
\r
94 ap.setName("JalviewLogger");
\r
95 laxis.addAppender(ap);
\r
96 lcastor.addAppender(ap);
\r
99 public static void main(String[] args) {
\r
100 Cache.loadProperties();
\r
101 jalview.gui.Preferences.initPreferences();
\r
105 } catch (Exception e) {
\r
106 System.err.println("Problems initializing the log4j system\n");
\r
107 e.printStackTrace();
\r
111 UIManager.setLookAndFeel(
\r
112 // "javax.swing.plaf.metal.MetalLookAndFeel"
\r
113 // "javax.swing.plaf.multi.MultiLookAndFeel"
\r
114 UIManager.getSystemLookAndFeelClassName());
\r
115 } catch (Exception ex) {
\r
118 Desktop frame = new Desktop();
\r
119 frame.setResizable(true);
\r
120 frame.setVisible(true);
\r
122 if ((args != null) && (args.length > 0)) {
\r
123 String file = null;
\r
125 if (args[0].equals("-open")) {
\r
131 String protocol = "File";
\r
133 if (file.indexOf("http:") > -1) {
\r
137 String format = jalview.io.IdentifyFile.Identify(file, protocol);
\r
139 frame.LoadFile(file, protocol, format);
\r
142 if (jalview.gui.Preferences.showStartupFile &&
\r
143 (jalview.gui.Preferences.startupFile != null)) {
\r
144 String file = jalview.gui.Preferences.startupFile;
\r
145 String protocol = "File";
\r
147 if (file.indexOf("http:") > -1) {
\r
151 if (file.endsWith(".jar")) {
\r
152 Jalview2XML.LoadJalviewAlign(file);
\r
154 String format = jalview.io.IdentifyFile.Identify(file, protocol);
\r
155 frame.LoadFile(file, protocol, format);
\r