JAL-3403 Fit To Window menu item for Jmol
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 8 Aug 2019 15:07:21 +0000 (16:07 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 8 Aug 2019 15:07:21 +0000 (16:07 +0100)
src/jalview/ext/jmol/JalviewJmolBinding.java
src/jalview/gui/ChimeraViewFrame.java
src/jalview/gui/StructureViewerBase.java
src/jalview/jbgui/GStructureViewer.java
src/jalview/structures/models/AAStructureBindingModel.java

index 7acafd7..972f093 100644 (file)
@@ -1460,4 +1460,17 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
   {
     return String.valueOf(model + 1) + ".1";
   }
+
+  /**
+   * Sends a command to recentre the display
+   */
+  @Override
+  public void focusView()
+  {
+    /*
+     * don't use evalStateCommand because it ignores a command that is the same
+     * as the last command (why?); but user may have adjusted the display since
+     */
+    viewer.evalString("zoom 0");
+  }
 }
index 71e90d9..08cad53 100644 (file)
@@ -98,7 +98,6 @@ public class ChimeraViewFrame extends StructureViewerBase
 
     helpItem.setText(MessageManager.getString("label.chimera_help"));
     savemenu.setVisible(false); // not yet implemented
-    viewMenu.add(fitToWindow);
 
     JMenuItem writeFeatures = new JMenuItem(
             MessageManager.getString("label.create_chimera_attributes"));
@@ -787,12 +786,6 @@ public class ChimeraViewFrame extends StructureViewerBase
   }
 
   @Override
-  protected void fitToWindow_actionPerformed()
-  {
-    jmb.focusView();
-  }
-
-  @Override
   public ViewerType getViewerType()
   {
     return ViewerType.CHIMERA;
index e7e2967..b327176 100644 (file)
@@ -784,6 +784,7 @@ public abstract class StructureViewerBase extends GStructureViewer
       }
     });
     viewMenu.add(hideHiddenRegions);
+    viewMenu.add(fitToWindow);
 
     final ItemListener handler = new ItemListener()
     {
index a7a970f..7fc56d2 100644 (file)
@@ -161,7 +161,7 @@ public abstract class GStructureViewer extends JInternalFrame
       @Override
       public void actionPerformed(ActionEvent actionEvent)
       {
-        fitToWindow_actionPerformed();
+        getBinding().focusView();
       }
     });
 
@@ -215,10 +215,6 @@ public abstract class GStructureViewer extends JInternalFrame
     statusPanel.add(statusBar, null);
   }
 
-  protected void fitToWindow_actionPerformed()
-  {
-  }
-
   protected void highlightSelection_actionPerformed()
   {
   }
index 1dea2c6..af5fd0a 100644 (file)
@@ -1055,4 +1055,11 @@ public abstract class AAStructureBindingModel
   {
     return chainNames;
   }
+
+  /**
+   * Send a command to resize and/or centre the structure display
+   */
+  public void focusView()
+  {
+  }
 }