selection removed, now SelectionGroup does same job as id select and residue select
[jalview.git] / src / jalview / gui / Desktop.java
index 7a75379..efa283c 100755 (executable)
@@ -12,6 +12,7 @@ package jalview.gui;
 import jalview.gui.*;\r
 import jalview.io.*;\r
 import jalview.datamodel.*;\r
+import jalview.schemes.*;\r
 import javax.swing.*;\r
 import java.awt.*;\r
 import java.awt.event.*;\r
@@ -22,13 +23,12 @@ public class Desktop extends jalview.jbgui.GDesktop
   public static JDesktopPane desktop;\r
   static int openFrameCount = 0;\r
   static final int xOffset = 30, yOffset = 30;\r
-  static boolean splashScreenVisible = false;\r
 \r
   public Desktop()\r
   {\r
     Image image =null;\r
     try{\r
-      java.net.URL url = getClass().getResource("/BartonGroupBanner.gif");\r
+      java.net.URL url = getClass().getResource("/images/BartonGroupBanner.gif");\r
       if(url!=null)\r
       {\r
         image = java.awt.Toolkit.getDefaultToolkit().createImage(url);\r
@@ -48,7 +48,7 @@ public class Desktop extends jalview.jbgui.GDesktop
     desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);\r
 \r
     Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();\r
-    int width = 1200, height = 800;\r
+    int width = 900, height = 650;\r
     if(screenSize.getWidth()<width)\r
       width = screenSize.width;\r
     if(screenSize.getHeight()<height)\r
@@ -65,23 +65,29 @@ public class Desktop extends jalview.jbgui.GDesktop
 \r
     SplashScreen splash = new SplashScreen(frame, image);\r
     frame.setContentPane(splash);\r
-    addInternalFrame(frame, "",845,200);\r
-    splashScreenVisible = true;\r
-\r
+    desktop.add(frame);\r
+    frame.setVisible(true);\r
+    openFrameCount++;\r
+    try\r
+    {\r
+      frame.setSelected(true);\r
+    }\r
+    catch (java.beans.PropertyVetoException e)\r
+    {}\r
+    frame.setResizable(true);\r
+    frame.setSize(845, 200);\r
     frame.setLocation( (int)((getWidth()-845) /2), (int)((getHeight()-240) /2));\r
     frame.setClosable(false);\r
     frame.setIconifiable(false);\r
     frame.setMaximizable(false);\r
     frame.setFrameIcon(null);\r
-    splashScreenVisible = false;\r
 \r
   }\r
 \r
   public static void addInternalFrame(final JInternalFrame frame, String title, int w, int h)\r
   {\r
-   if(!splashScreenVisible)\r
-      frame.setVisible(true); //necessary as of 1.3\r
    desktop.add(frame);\r
+   frame.setVisible(true);\r
    openFrameCount++;\r
    try {\r
        frame.setSelected(true);\r
@@ -119,14 +125,15 @@ public class Desktop extends jalview.jbgui.GDesktop
 \r
  public void inputLocalFileMenuItem_actionPerformed(ActionEvent e)\r
  {\r
-   JFileChooser chooser = new JFileChooser(jalview.bin.Cache.LAST_DIRECTORY);\r
+   JFileChooser chooser = new JFileChooser(jalview.bin.Cache.getProperty("LAST_DIRECTORY"));\r
+   chooser.setFileView(new JalviewFileView());\r
    chooser.setDialogTitle("Open local file");\r
    chooser.setToolTipText("Open");\r
    int value = chooser.showOpenDialog(this);\r
    if(value == JFileChooser.APPROVE_OPTION)\r
    {\r
      String choice =  chooser.getSelectedFile().getPath();\r
-     jalview.bin.Cache.LAST_DIRECTORY = choice;\r
+     jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);\r
      String format = IdentifyFile.Identify(choice, "File");\r
      LoadFile(choice, "File", format);\r
    }\r
@@ -148,7 +155,7 @@ public class Desktop extends jalview.jbgui.GDesktop
 \r
    }\r
    else\r
-     JOptionPane.showInternalMessageDialog(this,  "Couldn't open file.\n"\r
+     JOptionPane.showInternalMessageDialog(Desktop.desktop,  "Couldn't open file.\n"\r
                           + "Formats currently supported are\n"\r
                           + "Fasta, MSF, Clustal, BLC, PIR, MSP or PFAM"\r
                           ,"Error loading file",\r
@@ -158,7 +165,7 @@ public class Desktop extends jalview.jbgui.GDesktop
 \r
  public void inputURLMenuItem_actionPerformed(ActionEvent e)\r
  {\r
-   String url = JOptionPane.showInternalInputDialog(this,"Enter url of input file",\r
+   String url = JOptionPane.showInternalInputDialog(Desktop.desktop,"Enter url of input file",\r
                                             "Input alignment from URL",\r
                                             JOptionPane.QUESTION_MESSAGE);\r
    if (url == null)\r
@@ -169,7 +176,7 @@ public class Desktop extends jalview.jbgui.GDesktop
    System.out.println(format +" format");\r
    if (format.equals("URL NOT FOUND"))\r
    {\r
-     JOptionPane.showInternalMessageDialog(this,"Couldn't locate " + url,\r
+     JOptionPane.showInternalMessageDialog(Desktop.desktop,"Couldn't locate " + url,\r
                                    "URL not found",\r
                                    JOptionPane.WARNING_MESSAGE);\r
      return;\r
@@ -181,7 +188,7 @@ public class Desktop extends jalview.jbgui.GDesktop
  public void inputTextboxMenuItem_actionPerformed(ActionEvent e)\r
  {\r
    CutAndPasteTransfer cap = new CutAndPasteTransfer(true);\r
-   int accept =  JOptionPane.showInternalOptionDialog(desktop, cap, "Cut & paste Alignment File",\r
+   int accept =  JOptionPane.showInternalOptionDialog(Desktop.desktop, cap, "Cut & paste Alignment File",\r
                                        JOptionPane.YES_NO_CANCEL_OPTION,\r
                                        JOptionPane.PLAIN_MESSAGE,\r
                                        null,\r
@@ -204,12 +211,11 @@ public class Desktop extends jalview.jbgui.GDesktop
         af.statusBar.setText("Successfully pasted alignment file");\r
       }\r
       else\r
-        JOptionPane.showInternalMessageDialog(this, "Couldn't read the pasted text.\n"\r
+        JOptionPane.showInternalMessageDialog(Desktop.desktop, "Couldn't read the pasted text.\n"\r
                                       +"Formats currently supported are\n"\r
                                       +"Fasta, MSF, Clustal, BLC, PIR, MSP or PFAM",\r
                                       "Error parsing text", JOptionPane.WARNING_MESSAGE);\r
 \r
-\r
    }\r
  }\r
 \r
@@ -218,23 +224,19 @@ public class Desktop extends jalview.jbgui.GDesktop
 */\r
  public void quit_actionPerformed(ActionEvent e)\r
  {\r
-   this.setVisible(false);\r
-   System.exit(0);\r
+   if(jalview.bin.Jalview.applet!=null)\r
+     jalview.bin.Jalview.applet.destroy();\r
+    else\r
+      System.exit(0);\r
  }\r
 \r
 \r
- protected void colourIndexMenuItem_actionPerformed(ActionEvent e)\r
- {\r
-   ColourKey colourKey = new ColourKey(null);\r
-   addInternalFrame(colourKey, "Colour scheme key", 400, 320);\r
- }\r
-\r
 \r
  public void aboutMenuItem_actionPerformed(ActionEvent e)\r
  {\r
-   JOptionPane.showInternalMessageDialog(desktop,\r
+   JOptionPane.showInternalMessageDialog(Desktop.desktop,\r
                                          "JalView 2005"\r
-                                       +"\nAuthors:  Michele Clamp, James Cuff, Steve Searle, Andrew Waterhouse and Geoff Barton."\r
+                                       +"\nAuthors:  Michele Clamp, James Cuff, Steve Searle, Andrew Waterhouse, Jim Procter & Geoff Barton."\r
                                        +"\nCurrent development managed by Andrew Waterhouse; Barton Group, University of Dundee."\r
                                        +"\nIf  you use JalView, please cite:  \"Clamp, M., Cuff, J., Searle, S. M. and Barton, G. J. (2004), The Jalview Java Alignment Editor\"",\r
                                          "About Jalview",\r
@@ -243,10 +245,104 @@ public class Desktop extends jalview.jbgui.GDesktop
 \r
  public void documentationMenuItem_actionPerformed(ActionEvent e)\r
  {\r
+   try\r
+   {\r
+      ClassLoader cl = jalview.gui.Desktop.class.getClassLoader();\r
+      java.net.URL url = javax.help.HelpSet.findHelpSet(cl,"help/help");\r
+      javax.help.HelpSet hs = new javax.help.HelpSet(cl,url);\r
+\r
+      javax.help.HelpBroker hb = hs.createHelpBroker();\r
+      hb.setLocation(new Point(200, 50));\r
+      hb.setSize(new Dimension(800,700));\r
+      hb.setCurrentID("home");\r
+      hb.setDisplayed(true);\r
+   }\r
+   catch (Exception ex)\r
+   {\r
+     ex.printStackTrace();\r
+   }\r
+ }\r
+\r
+ static JInternalFrame conservationSlider;\r
+ static JInternalFrame PIDSlider;\r
+ public static int setConservationSliderSource(AlignmentPanel ap, ColourSchemeI cs, String source)\r
+ {\r
+   SliderPanel sp = null;\r
+\r
+   if(conservationSlider == null)\r
+   {\r
+     sp = new SliderPanel(ap, 30, true, cs);\r
+     conservationSlider = new JInternalFrame();\r
+     conservationSlider.setContentPane(sp);\r
+     conservationSlider.setResizable(false);\r
+     addInternalFrame(conservationSlider, "Conservation Colour Increment  ("+source+")", 420, 90);\r
+     conservationSlider.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()\r
+                  {\r
+                    public void internalFrameClosed(javax.swing.event.InternalFrameEvent e)\r
+                    {\r
+                      conservationSlider = null;\r
+                    }\r
+                  });\r
+   }\r
+   else\r
+   {\r
+       conservationSlider.setTitle("Conservation Colour Increment  ("+source+")");\r
+       sp = (SliderPanel)conservationSlider.getContentPane();\r
+       sp.cs = cs;\r
+   }\r
+\r
+   if(ap.av.alignment.getGroups()!=null)\r
+     sp.setAllGroupsCheckEnabled( true );\r
+   else\r
+     sp.setAllGroupsCheckEnabled( false);\r
+\r
+   return sp.getValue();\r
+\r
+ }\r
+\r
+ public static void hideConservationSlider()\r
+ {\r
+  try{\r
+    conservationSlider.setClosed(true);\r
+    conservationSlider = null;\r
+  }catch(Exception ex){}\r
+}\r
+\r
+\r
+ public static void hidePIDSlider()\r
+ {\r
    try{\r
-     jalview.util.BrowserLauncher.openURL("http://jalview.org/documentation.html");\r
+     PIDSlider.setClosed(true);\r
+     PIDSlider = null;\r
    }catch(Exception ex){}\r
  }\r
 \r
+ public static int setPIDSliderSource(AlignmentPanel ap, ColourSchemeI cs, String source)\r
+ {\r
+   SliderPanel pid = null;\r
+   if(PIDSlider == null)\r
+   {\r
+     pid = new SliderPanel(ap, 50, false, cs);\r
+     PIDSlider = new JInternalFrame();\r
+     PIDSlider.setContentPane(pid);\r
+     PIDSlider.setResizable(false);\r
+     addInternalFrame(PIDSlider, "Percentage Identity Threshold ("+source+")", 420, 90);\r
+   }\r
+   else\r
+   {\r
+       PIDSlider.setTitle("Percentage Identity Threshold ("+source+")");\r
+       pid = (SliderPanel)PIDSlider.getContentPane();\r
+       pid.cs = cs;\r
+   }\r
+\r
+   if (ap.av.alignment.getGroups() != null)\r
+     pid.setAllGroupsCheckEnabled(true);\r
+   else\r
+     pid.setAllGroupsCheckEnabled(false);\r
+\r
+\r
+   return pid.getValue();\r
+\r
+ }\r
 \r
 }\r