JAL-2852 added EPS export button to File menu
authorkjvdheide <kjvanderheide@dundee.ac.uk>
Fri, 15 Dec 2017 14:53:35 +0000 (14:53 +0000)
committerkjvdheide <kjvanderheide@dundee.ac.uk>
Fri, 15 Dec 2017 14:53:35 +0000 (14:53 +0000)
src/jalview/ext/archaeopteryx/AptxInit.java

index 9d248d0..fe5f16e 100644 (file)
@@ -11,6 +11,8 @@ import jalview.viewmodel.AlignmentViewport;
 
 import java.awt.Component;
 import java.awt.Dimension;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
@@ -559,31 +561,58 @@ public final class AptxInit
   private static void adaptAptxGui(MainFrame aptxFrame)
   {
     JMenuBar frameBar = aptxFrame.getJMenuBar();
-
+    boolean epsAdded = false;
     for (int i = 0; i < frameBar.getMenuCount();i++) {
       JMenu menu = frameBar.getMenu(i);
+      int menuCount = menu.getMenuComponentCount();
 
       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()) {
-          if (previousMenuItem instanceof JMenuItem)
+        Component previousComp = null;
+        for (int x = 0; x < menuCount; x++)
+        {
+          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().contains("Inference"))
@@ -603,9 +632,6 @@ public final class AptxInit
         menu.add(refreshJalview);
 
         sortByTree.setFont(menu.getFont());
-        sortByTree.setVisible(false); // don't show unless it's actually
-        // possible
-
         refreshJalview.addActionListener(activeAptx.get(aptxFrame));