treeMenuItem added, conservation sliders, finder top layer
authoramwaterhouse <Andrew Waterhouse>
Wed, 13 Apr 2005 16:32:55 +0000 (16:32 +0000)
committeramwaterhouse <Andrew Waterhouse>
Wed, 13 Apr 2005 16:32:55 +0000 (16:32 +0000)
src/jalview/gui/AlignFrame.java

index 3123184..3048b2c 100755 (executable)
@@ -30,8 +30,17 @@ public class AlignFrame extends GAlignFrame
 {\r
   final AlignmentPanel alignPanel;\r
   final AlignViewport viewport;\r
+  public static final int NEW_WINDOW_WIDTH = 700;\r
+  public static final int NEW_WINDOW_HEIGHT = 500;\r
+\r
   public AlignFrame(AlignmentI al)\r
   {\r
+    try{\r
+      String ip = java.net.InetAddress.getLocalHost().getHostAddress();\r
+      if( !ip.startsWith("10."))\r
+        alignMenu.setVisible(false);\r
+    }\r
+    catch(java.net.UnknownHostException e){}\r
     viewport = new AlignViewport(al,true,true,false);\r
 \r
     String fontName = jalview.bin.Cache.getProperty("FONT_NAME");\r
@@ -348,10 +357,7 @@ public class AlignFrame extends GAlignFrame
         SequenceI[] newSeqs = new SequenceI[seqs.size()];\r
         seqs.toArray(newSeqs);\r
         AlignFrame af = new AlignFrame(new Alignment(newSeqs));\r
-        int newHeight = newSeqs.length * af.viewport.getCharHeight() + 200;\r
-        if (newHeight > 500)\r
-          newHeight = 500;\r
-        Desktop.addInternalFrame(af, "Copied sequences", 700, 500);\r
+        Desktop.addInternalFrame(af, "Copied sequences", NEW_WINDOW_WIDTH, NEW_WINDOW_HEIGHT);\r
       }\r
       else\r
       {\r
@@ -560,10 +566,11 @@ public class AlignFrame extends GAlignFrame
 \r
   public void findMenuItem_actionPerformed(ActionEvent e)\r
   {\r
-      JInternalFrame frame = new JInternalFrame();\r
-      Finder finder = new Finder(viewport, alignPanel, frame);\r
-      frame.setContentPane(finder);\r
-     Desktop.addInternalFrame(frame, "Find", 340,110);\r
+    JInternalFrame frame = new JInternalFrame();\r
+    Finder finder = new Finder(viewport, alignPanel, frame);\r
+    frame.setContentPane(finder);\r
+    Desktop.addInternalFrame(frame, "Find", 340,110, false);\r
+    frame.setLayer(JLayeredPane.PALETTE_LAYER);\r
 \r
   }\r
 \r
@@ -786,16 +793,16 @@ public class AlignFrame extends GAlignFrame
     }\r
 \r
 \r
-    if ( viewport.getAbovePIDThreshold())\r
+    if ( viewport.getAbovePIDThreshold() )\r
     {\r
-      int threshold = 0;\r
-      threshold = Desktop.setPIDSliderSource(alignPanel, cs, "Background");\r
+ //     int threshold = 0;\r
+   //   threshold = Desktop.setPIDSliderSource(alignPanel, cs, "Background");\r
       Desktop.hideConservationSlider();\r
 \r
-      if (cs instanceof ResidueColourScheme)\r
-        ( (ResidueColourScheme) cs).setThreshold(threshold);\r
-      else if (cs instanceof ScoreColourScheme)\r
-        ( (ScoreColourScheme) cs).setThreshold(threshold);\r
+ //     if (cs instanceof ResidueColourScheme)\r
+ //       ( (ResidueColourScheme) cs).setThreshold(threshold);\r
+  //    else if (cs instanceof ScoreColourScheme)\r
+   //     ( (ScoreColourScheme) cs).setThreshold(threshold);\r
 \r
       viewport.setGlobalColourScheme(cs);\r
 \r
@@ -824,10 +831,9 @@ if ( viewport.getConservationSelected() )
 \r
    ccs = new ConservationColourScheme(c, cs);\r
 \r
-   int threshold = Desktop.setConservationSliderSource(alignPanel, ccs,\r
-       "Background");\r
+ //  int threshold = Desktop.setConservationSliderSource(alignPanel, ccs,    "Background");\r
 \r
-   ccs.inc = threshold;\r
+ //  ccs.inc = threshold;\r
 \r
    viewport.setGlobalColourScheme(ccs);\r
 \r
@@ -838,6 +844,16 @@ if ( viewport.getConservationSelected() )
     alignPanel.RefreshPanels();\r
   }\r
 \r
+  protected void modifyPID_actionPerformed(ActionEvent e)\r
+  {\r
+    Desktop.setPIDSliderSource(alignPanel, viewport.getGlobalColourScheme(), "Background");\r
+  }\r
+\r
+  protected void modifyConservation_actionPerformed(ActionEvent e)\r
+  {\r
+    Desktop.setConservationSliderSource(alignPanel, viewport.globalColourScheme,    "Background");\r
+  }\r
+\r
 \r
   protected  void conservationMenuItem_actionPerformed(ActionEvent e)\r
   {\r
@@ -895,10 +911,7 @@ if ( viewport.getConservationSelected() )
     JInternalFrame frame = new JInternalFrame();\r
     UserDefinedColours chooser = new UserDefinedColours( frame, alignPanel, null);\r
     frame.setContentPane(chooser);\r
-    Desktop.addInternalFrame(frame,"User defined colours", 450,540 );\r
-    frame.setResizable(false);\r
-    frame.setIconifiable(false);\r
-    frame.setMaximizable(false);\r
+    Desktop.addInternalFrame(frame,"User defined colours", 450,540, false );\r
   }\r
 \r
   public void PIDColour_actionPerformed(ActionEvent e)\r
@@ -936,24 +949,12 @@ if ( viewport.getConservationSelected() )
     alignPanel.RefreshPanels();\r
   }\r
 \r
-  public void sortTreeOrderMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-    addHistoryItem("sort");\r
-    if(viewport.getCurrentTree()==null)\r
-      return;\r
-\r
-    AlignmentSorter.sortByTree(viewport.getAlignment(), viewport.getCurrentTree());\r
-    alignPanel.RefreshPanels();\r
-  }\r
-\r
   public void removeRedundancyMenuItem_actionPerformed(ActionEvent e)\r
   {\r
     RedundancyPanel sp = new RedundancyPanel(alignPanel);\r
     JInternalFrame frame = new JInternalFrame();\r
     frame.setContentPane(sp);\r
-    Desktop.addInternalFrame(frame, "Redundancy threshold selection", 400, 100);\r
-    frame.setMaximizable(false);\r
-    frame.setResizable(false);\r
+    Desktop.addInternalFrame(frame, "Redundancy threshold selection", 400, 100, false);\r
 \r
   }\r
 \r
@@ -1027,22 +1028,48 @@ if ( viewport.getConservationSelected() )
       return;\r
     }\r
 \r
-    TreePanel tp=null;\r
-   if (viewport.getSelectionGroup() != null && viewport.getSelectionGroup().getSize() > 3)\r
-   {\r
-     tp = new TreePanel(viewport, viewport.getSelectionGroup().sequences,type, pwType,\r
+    final TreePanel tp;\r
+    if (viewport.getSelectionGroup() != null &&\r
+        viewport.getSelectionGroup().getSize() > 3)\r
+    {\r
+      tp = new TreePanel(viewport, viewport.getSelectionGroup().sequences, type,\r
+                         pwType,\r
                          0, viewport.alignment.getWidth());\r
-   }\r
-   else\r
-   {\r
-     tp = new TreePanel(viewport, viewport.getAlignment().getSequences(),\r
-                         type, pwType,  0, viewport.alignment.getWidth());\r
-   }\r
+    }\r
+    else\r
+    {\r
+      tp = new TreePanel(viewport, viewport.getAlignment().getSequences(),\r
+                         type, pwType, 0, viewport.alignment.getWidth());\r
+    }\r
+\r
+   addTreeMenuItem(tp, title);\r
 \r
    Desktop.addInternalFrame(tp, title, 600, 500);\r
   }\r
 \r
+  void addTreeMenuItem(final TreePanel treePanel, String title)\r
+  {\r
+    final JMenuItem item = new JMenuItem(title);\r
+    sortByTreeMenu.add(item);\r
+    item.addActionListener(new java.awt.event.ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent e)\r
+      {\r
+        addHistoryItem("sort");\r
+        AlignmentSorter.sortByTree(viewport.getAlignment(), treePanel.getTree());\r
+        alignPanel.RefreshPanels();\r
+      }\r
+    });\r
+\r
+    treePanel.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()\r
+    {\r
+      public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt)\r
+      {\r
+        sortByTreeMenu.remove(item);\r
+      };\r
+    });\r
 \r
+  }\r
 \r
 \r
   public void clustalAlignMenuItem_actionPerformed(ActionEvent e)\r
@@ -1052,7 +1079,7 @@ if ( viewport.getConservationSelected() )
     Thread t = new Thread(ct);\r
     t.start();\r
     frame.setContentPane(ct);\r
-     Desktop.addInternalFrame(frame, title, 300, 80);\r
+     Desktop.addInternalFrame(frame, title, 320, 90);\r
 \r
   }\r
 \r
@@ -1123,10 +1150,9 @@ if ( viewport.getConservationSelected() )
          if (alignment != null)\r
          {\r
            AlignFrame af = new AlignFrame(new Alignment(alignment));\r
-          af.clustalColour.setSelected(true);\r
-          af.clustalColour_actionPerformed(null);\r
-           Desktop.addInternalFrame(af, getTitle().concat(" - ClustalW Alignment"),\r
-                                    700, 500); // JBPNote - is there a new window geom. property ?\r
+           Desktop.addInternalFrame(af, getTitle().concat(" - ClustalW Alignment"),NEW_WINDOW_WIDTH, NEW_WINDOW_HEIGHT);\r
+           af.clustalColour_actionPerformed(null);\r
+           af.clustalColour.setSelected(true);\r
          }\r
          else\r
            JOptionPane.showMessageDialog(Desktop.desktop, "Problem obtaining clustal alignment", "Web service error",\r
@@ -1229,6 +1255,7 @@ if ( viewport.getConservationSelected() )
           tp = new TreePanel(viewport, viewport.getAlignment().getSequences(),\r
                              fin, "FromFile", choice);\r
           Desktop.addInternalFrame(tp, title, 600, 500);\r
+          addTreeMenuItem(tp, title);\r
         }\r
       }\r
       catch (Exception ex)\r