JAL-2852 merged the EPS button adding from main branch into interfaces
authorkjvdheide <kjvanderheide@dundee.ac.uk>
Fri, 15 Dec 2017 16:07:57 +0000 (16:07 +0000)
committerkjvdheide <kjvanderheide@dundee.ac.uk>
Fri, 15 Dec 2017 16:07:57 +0000 (16:07 +0000)
src/jalview/ext/archaeopteryx/AptxFrame.java

index b00b24d..c105c25 100644 (file)
@@ -13,6 +13,8 @@ import java.awt.Event;
 import java.awt.Font;
 import java.awt.Image;
 import java.awt.MenuComponent;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
 
 import javax.accessibility.AccessibleContext;
 import javax.swing.JLayeredPane;
@@ -54,45 +56,90 @@ public class AptxFrame implements ExternalTreeFrame
   private void adaptAptxGui(MainFrame aptxFrame)
   {
     JMenuBar frameBar = aptxFrame.getJMenuBar();
-
-    for (int i = 0; i < frameBar.getMenuCount(); i++)
-    {
+    boolean epsAdded = false;
+    for (int i = 0; i < frameBar.getMenuCount();i++) {
       JMenu menu = frameBar.getMenu(i);
+      int menuCount = menu.getMenuComponentCount();
 
-      if (menu.getText().startsWith("File"))
+      if (menu.getText().contains("File"))
       {
         // hide all "Read from ..." and "New" menu items and any Separators that
         // come directly after them
-        Component previousMenuItem = null;
-        for (Component menuItem : menu.getMenuComponents())
+        Component previousComp = null;
+        for (int x = 0; x < menuCount; x++)
         {
-          if (previousMenuItem instanceof JMenuItem)
+          Component menuItem = menu.getMenuComponent(x);
+          if (previousComp instanceof JMenuItem)
           {
-            if (((JMenuItem) previousMenuItem).getText().startsWith("Read")
-                    || ((JMenuItem) previousMenuItem).getText()
-                            .startsWith("New"))
+            JMenuItem previousMenuItem = (JMenuItem) previousComp;
+            if (previousMenuItem.getText().startsWith("Read")
+                    || previousMenuItem.getText()
+                            .startsWith("New")
+                    || previousMenuItem.getText()
+                            .startsWith("Close Tab"))
             {
-              previousMenuItem.setVisible(false);
+              previousComp.setVisible(false);
 
               if (menuItem instanceof JSeparator)
               {
                 menuItem.setVisible(false);
               }
+
+            }
+
+            if ((!epsAdded) && previousMenuItem.getText()
+                    .startsWith("Export to"))
+            {
+              JMenuItem exportEps = new JMenuItem("Export to EPS file...");
+              menu.add(exportEps, x);
+              exportEps.addActionListener(new ActionListener()
+              {
+
+                @Override
+                public void actionPerformed(ActionEvent e)
+                {
+                  // TODO Auto-generated method stub
+
+                }
+                
+              });
+              epsAdded = true;
+
             }
           }
-          previousMenuItem = menuItem;
+          previousComp = menuItem;
         }
       }
-      else if (menu.getText().startsWith("Inference"))
+      else if (menu.getText().contains("Inference"))
       {
         menu.setVisible(false);
       }
-      else if (menu.getText().startsWith("View"))
+      else if (menu.getText().contains("View"))
       {
         menu.addSeparator();
-        JMenuItem sortMenuItem = new JMenuItem("Sort alignment by tree");
-        sortMenuItem.setVisible(false);
-        menu.add(sortMenuItem);
+        JMenuItem sortByTree = new JMenuItem("Sort alignment by tree");
+        JMenuItem refreshJalview = new JMenuItem(
+                "Filter alignment to show only currently visible sequences");
+
+        refreshJalview.setFont(menu.getFont());
+
+        menu.add(sortByTree);
+        menu.add(refreshJalview);
+
+        sortByTree.setFont(menu.getFont());
+        refreshJalview.addActionListener(new ActionListener()
+        {
+
+          @Override
+          public void actionPerformed(ActionEvent e)
+          {
+            // TODO Auto-generated method stub
+
+          }
+
+        });
+
+
       }
 
     }