X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FDesktop.java;h=471a40aa1e44d37c256ddfa7ab4b04e19cbe18ae;hb=c0adaae0693daad638b6b7db284eb17ea543f757;hp=77cf56f7fa555d4e53608d64d1ab03f018ccdcab;hpb=fbf08a1f5a164914fef4214778a24775891eead4;p=jalview.git diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 77cf56f..471a40a 100755 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -1,20 +1,19 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1) - * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5) + * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle * - * 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 file is part of Jalview. * - * 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. + * Jalview 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 3 of the License, or (at your option) any later version. * - * 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 + * Jalview 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 Jalview. If not, see . */ package jalview.gui; @@ -104,8 +103,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements desktop.setDesktopManager(new DefaultDesktopManager()); Rectangle dims = getLastKnownDimensions(""); - if (dims!=null) - { + if (dims != null) + { setBounds(dims); } else @@ -115,6 +114,16 @@ public class Desktop extends jalview.jbgui.GDesktop implements (int) (screenSize.height - 650) / 2, 900, 650); } jconsole = new Console(this); + // immediately output essential build information + System.out.println("Jalview Desktop " + + jalview.bin.Cache.getProperty("VERSION") + "\n" + + "Build Date: " + + jalview.bin.Cache.getDefault("BUILD_DATE", "unknown") + "\n" + + "Java version: " + System.getProperty("java.version") + "\n" + + System.getProperty("os.arch") + " " + + System.getProperty("os.name") + " " + + System.getProperty("os.version")); + showConsole(showjconsole); this.addWindowListener(new WindowAdapter() @@ -148,10 +157,26 @@ public class Desktop extends jalview.jbgui.GDesktop implements discoverer = new jalview.ws.Discoverer(); // Only gets started if gui is // displayed. + // Thread off a new instance of the file chooser - this reduces the time it + // takes to open it later on. + new Thread(new Runnable() + { + public void run() + { + Cache.log.debug("Filechooser init thread started."); + JalviewFileChooser chooser = new JalviewFileChooser( + jalview.bin.Cache.getProperty("LAST_DIRECTORY"), + jalview.io.AppletFormatAdapter.READABLE_EXTENSIONS, + jalview.io.AppletFormatAdapter.READABLE_FNAMES, + jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT")); + Cache.log.debug("Filechooser init thread finished."); + } + }).start(); } /** * recover the last known dimensions for a jalview window + * * @param windowName * - empty string is desktop, all other windows have unique prefix * @return null or last known dimensions scaled to current geometry (if last @@ -176,21 +201,22 @@ public class Desktop extends jalview.jbgui.GDesktop implements // attempt #1 - try to cope with change in screen geometry - this // version doesn't preserve original jv aspect ratio. // take ratio of current screen size vs original screen size. - double sw = ( (1f*screenSize.width) - / (1f*Integer.parseInt(jalview.bin.Cache - .getProperty("SCREENGEOMETRY_WIDTH")))) - ; - double sh = ( (1f*screenSize.height) - / (1f*Integer.parseInt(jalview.bin.Cache + double sw = ((1f * screenSize.width) / (1f * Integer + .parseInt(jalview.bin.Cache + .getProperty("SCREENGEOMETRY_WIDTH")))); + double sh = ((1f * screenSize.height) / (1f * Integer + .parseInt(jalview.bin.Cache .getProperty("SCREENGEOMETRY_HEIGHT")))); // rescale the bounds depending upon the current screen geometry. ix = (int) (ix * sw); iw = (int) (iw * sw); iy = (int) (iy * sh); ih = (int) (ih * sh); - jalview.bin.Cache.log.debug("Got last known dimensions for "+windowName+": x:"+ix + " y:"+iy + " width:"+iw+" height:"+ih); + jalview.bin.Cache.log.debug("Got last known dimensions for " + + windowName + ": x:" + ix + " y:" + iy + " width:" + iw + + " height:" + ih); } - // return dimensions for new instance + // return dimensions for new instance return new Rectangle(ix, iy, iw, ih); } return null; @@ -276,7 +302,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements } /** - * DOCUMENT ME! + * Adds and opens the given frame to the desktop * * @param frame * DOCUMENT ME! @@ -312,6 +338,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements boolean resizable) { + // TODO: allow callers to determine X and Y position of frame (eg. via + // bounds object). // TODO: consider fixing method to update entries in the window submenu with // the current window title @@ -668,11 +696,12 @@ public class Desktop extends jalview.jbgui.GDesktop implements .setProperty("SCREENGEOMETRY_WIDTH", screen.width + ""); jalview.bin.Cache.setProperty("SCREENGEOMETRY_HEIGHT", screen.height + ""); - storeLastKnownDimensions("",new Rectangle(getBounds().x,getBounds().y, getWidth(), getHeight())); + storeLastKnownDimensions("", new Rectangle(getBounds().x, + getBounds().y, getWidth(), getHeight())); if (jconsole != null) { - storeLastKnownDimensions("JAVA_CONSOLE_",jconsole.getBounds()); + storeLastKnownDimensions("JAVA_CONSOLE_", jconsole.getBounds()); jconsole.stopConsole(); } System.exit(0); @@ -680,13 +709,14 @@ public class Desktop extends jalview.jbgui.GDesktop implements private void storeLastKnownDimensions(String string, Rectangle jc) { - jalview.bin.Cache.log.debug("Storing last known dimensions for "+string+": x:"+jc.x + " y:"+jc.y + " width:"+jc.width+" height:"+jc.height); - - jalview.bin.Cache.setProperty(string+"SCREEN_X",jc.x + ""); - jalview.bin.Cache.setProperty(string+"SCREEN_Y", jc.y + ""); - jalview.bin.Cache.setProperty(string+"SCREEN_WIDTH", jc.width + ""); - jalview.bin.Cache.setProperty(string+"SCREEN_HEIGHT", jc.height - + ""); + jalview.bin.Cache.log.debug("Storing last known dimensions for " + + string + ": x:" + jc.x + " y:" + jc.y + " width:" + jc.width + + " height:" + jc.height); + + jalview.bin.Cache.setProperty(string + "SCREEN_X", jc.x + ""); + jalview.bin.Cache.setProperty(string + "SCREEN_Y", jc.y + ""); + jalview.bin.Cache.setProperty(string + "SCREEN_WIDTH", jc.width + ""); + jalview.bin.Cache.setProperty(string + "SCREEN_HEIGHT", jc.height + ""); } /** @@ -1651,11 +1681,12 @@ public class Desktop extends jalview.jbgui.GDesktop implements if (percentUsage < 20) g.setColor(Color.red); FontMetrics fm = g.getFontMetrics(); - if (fm!=null) - { g.drawString("Total Free Memory: " + df.format(totalFreeMemory) - + "MB; Max Memory: " + df.format(maxMemory) + "MB; " - + df.format(percentUsage) + "%", 10, getHeight() - - fm.getHeight()); + if (fm != null) + { + g.drawString("Total Free Memory: " + df.format(totalFreeMemory) + + "MB; Max Memory: " + df.format(maxMemory) + "MB; " + + df.format(percentUsage) + "%", 10, getHeight() + - fm.getHeight()); } } } @@ -1855,4 +1886,10 @@ public class Desktop extends jalview.jbgui.GDesktop implements return v_client; } + + public void startServiceDiscovery() + { + discoverer.start(); + new Thread(jalview.ws.jws2.Jws2Discoverer.getDiscoverer()).start(); + } }