X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FDesktop.java;h=9d58c7badef5f205da54936e314b68d820a49115;hb=174230b4233d9ce80f94527768d2cd2f76da11ab;hp=889227f99df0c7848699de2a80c0c2cd89651ae2;hpb=d9b5411f1f2cd0acf62eab94188428a754094926;p=jalview.git diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 889227f..9d58c7b 100755 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -1,252 +1,669 @@ -/******************** - * 2004 Jalview Reengineered - * Barton Group - * Dundee University +/* + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * - * AM Waterhouse - *******************/ - - + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ package jalview.gui; -import jalview.gui.*; import jalview.io.*; -import jalview.datamodel.*; -import javax.swing.*; + import java.awt.*; +import java.awt.datatransfer.*; +import java.awt.dnd.*; import java.awt.event.*; +import java.util.*; + +import javax.swing.*; +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ public class Desktop extends jalview.jbgui.GDesktop + implements DropTargetListener, ClipboardOwner { - public static JDesktopPane desktop; - static int openFrameCount = 0; - static final int xOffset = 30, yOffset = 30; - static boolean splashScreenVisible = false; - - public Desktop() - { - Image image =null; - try{ - java.net.URL url = getClass().getResource("/BartonGroupBanner.gif"); - if(url!=null) + /** DOCUMENT ME!! */ + public static Desktop instance; + public static JDesktopPane desktop; + static int openFrameCount = 0; + static final int xOffset = 30; + static final int yOffset = 30; + public static jalview.ws.Discoverer discoverer; + + public static Object [] jalviewClipboard; + + static int fileLoadingCount= 0; + + /** + * Creates a new Desktop object. + */ + public Desktop() + { + instance = this; + + Image image = null; + + try + { + java.net.URL url = getClass().getResource("/images/logo.gif"); + + if (url != null) + { + image = java.awt.Toolkit.getDefaultToolkit().createImage(url); + + MediaTracker mt = new MediaTracker(this); + mt.addImage(image, 0); + mt.waitForID(0); + setIconImage(image); + } + } + catch (Exception ex) + { + } + + setTitle("Jalview "+jalview.bin.Cache.getProperty("VERSION")); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + desktop = new JDesktopPane(); + desktop.setBackground(Color.white); + getContentPane().setLayout(new BorderLayout()); + getContentPane().add(desktop, BorderLayout.CENTER); + desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE); + + // This line prevents Windows Look&Feel resizing all new windows to maximum + // if previous window was maximised + desktop.setDesktopManager(new DefaultDesktopManager()); + + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + String x = jalview.bin.Cache.getProperty("SCREEN_X"); + String y = jalview.bin.Cache.getProperty("SCREEN_Y"); + String width = jalview.bin.Cache.getProperty("SCREEN_WIDTH"); + String height = jalview.bin.Cache.getProperty("SCREEN_HEIGHT"); + + if ((x != null) && (y != null) && (width != null) && (height != null)) + { + setBounds(Integer.parseInt(x), Integer.parseInt(y), + Integer.parseInt(width), Integer.parseInt(height)); + } + else + { + setBounds((int) (screenSize.width - 900) / 2, + (int) (screenSize.height - 650) / 2, 900, 650); + } + + this.addWindowListener(new WindowAdapter() + { + public void windowClosing(WindowEvent evt) + { + quit(); + } + }); + + this.setDropTarget(new java.awt.dnd.DropTarget(desktop, this)); + + /////////Add a splashscreen on startup + /////////Add a splashscreen on startup + JInternalFrame frame = new JInternalFrame(); + + SplashScreen splash = new SplashScreen(frame, image); + frame.setContentPane(splash); + frame.setLayer(JLayeredPane.PALETTE_LAYER); + frame.setLocation((int) ((getWidth() - 750) / 2), + (int) ((getHeight() - 160) / 2)); + + addInternalFrame(frame, "", 750, 160, false); + + discoverer=new jalview.ws.Discoverer(); // Only gets started if gui is displayed. + + } + + /** + * DOCUMENT ME! + * + * @param frame DOCUMENT ME! + * @param title DOCUMENT ME! + * @param w DOCUMENT ME! + * @param h DOCUMENT ME! + */ + public static synchronized void addInternalFrame(final JInternalFrame frame, + String title, int w, int h) + { + addInternalFrame(frame, title, w, h, true); + } + + /** + * DOCUMENT ME! + * + * @param frame DOCUMENT ME! + * @param title DOCUMENT ME! + * @param w DOCUMENT ME! + * @param h DOCUMENT ME! + * @param resizable DOCUMENT ME! + */ + public static synchronized void addInternalFrame(final JInternalFrame frame, + String title, int w, int h, boolean resizable) + { + + frame.setTitle(title); + if(frame.getWidth()<1 || frame.getHeight()<1) + { + frame.setSize(w, h); + } + // THIS IS A PUBLIC STATIC METHOD, SO IT MAY BE CALLED EVEN IN + // A HEADLESS STATE WHEN NO DESKTOP EXISTS. MUST RETURN + // IF JALVIEW IS RUNNING HEADLESS + ///////////////////////////////////////////////// + if (System.getProperty("java.awt.headless") != null + && System.getProperty("java.awt.headless").equals("true")) { - image = java.awt.Toolkit.getDefaultToolkit().createImage(url); - MediaTracker mt = new MediaTracker(this); - mt.addImage(image, 0); - mt.waitForID(0); - setIconImage(image); + return; } - }catch(Exception ex){} - - setTitle("Jalview 2005"); - setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - setVisible(true); - desktop = new JDesktopPane(); - setContentPane(desktop); - desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE); - - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - int width = 1200, height = 800; - if(screenSize.getWidth()