Merge branch 'develop' into feature/JAL-2422ChimeraX
[jalview.git] / src / jalview / gui / StructureViewerBase.java
index c9607c6..6dd7d50 100644 (file)
@@ -22,9 +22,7 @@ package jalview.gui;
 
 import jalview.api.AlignmentViewPanel;
 import jalview.bin.Cache;
-import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentI;
-import jalview.datamodel.HiddenColumns;
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.SequenceI;
 import jalview.gui.StructureViewer.ViewerType;
@@ -560,8 +558,6 @@ public abstract class StructureViewerBase extends GStructureViewer
     }
   }
 
-  abstract void showSelectedChains();
-
   /**
    * Action on selecting one of Jalview's registered colour schemes
    */
@@ -572,7 +568,7 @@ public abstract class StructureViewerBase extends GStructureViewer
     ColourSchemeI cs = ColourSchemes.getInstance()
             .getColourScheme(colourSchemeName, getAlignmentPanel().av, al,
                     null);
-    getBinding().setJalviewColourScheme(cs);
+    getBinding().colourByJalviewColourScheme(cs);
   }
 
   /**
@@ -606,7 +602,7 @@ public abstract class StructureViewerBase extends GStructureViewer
       @Override
       public void actionPerformed(ActionEvent actionEvent)
       {
-        viewerColour_actionPerformed(actionEvent);
+        viewerColour_actionPerformed();
       }
     });
     colourMenu.add(viewerColour);
@@ -622,7 +618,7 @@ public abstract class StructureViewerBase extends GStructureViewer
       @Override
       public void actionPerformed(ActionEvent actionEvent)
       {
-        background_actionPerformed(actionEvent);
+        background_actionPerformed();
       }
     });
     colourMenu.add(backGround);
@@ -653,7 +649,7 @@ public abstract class StructureViewerBase extends GStructureViewer
       @Override
       public void actionPerformed(ActionEvent actionEvent)
       {
-        seqColour_actionPerformed(actionEvent);
+        seqColour_actionPerformed();
       }
     });
 
@@ -665,7 +661,7 @@ public abstract class StructureViewerBase extends GStructureViewer
       @Override
       public void actionPerformed(ActionEvent actionEvent)
       {
-        chainColour_actionPerformed(actionEvent);
+        chainColour_actionPerformed();
       }
     });
 
@@ -677,7 +673,7 @@ public abstract class StructureViewerBase extends GStructureViewer
       @Override
       public void actionPerformed(ActionEvent actionEvent)
       {
-        chargeColour_actionPerformed(actionEvent);
+        chargeColour_actionPerformed();
       }
     });
 
@@ -709,7 +705,7 @@ public abstract class StructureViewerBase extends GStructureViewer
                 else
                 {
                   // update the Chimera display now.
-                  seqColour_actionPerformed(null);
+                  seqColour_actionPerformed();
                 }
               }
             });
@@ -753,24 +749,13 @@ public abstract class StructureViewerBase extends GStructureViewer
     buildColourMenu();
   }
 
-  @Override
-  public void setJalviewColourScheme(ColourSchemeI cs)
-  {
-    getBinding().setJalviewColourScheme(cs);
-  }
-
   /**
    * Sends commands to the structure viewer to superimpose structures based on
    * currently associated alignments. May optionally return an error message for
    * the operation.
    */
   @Override
-  protected String alignStructs_actionPerformed(ActionEvent actionEvent)
-  {
-    return alignStructs_withAllAlignPanels();
-  }
-
-  protected String alignStructs_withAllAlignPanels()
+  protected String alignStructsWithAllAlignPanels()
   {
     if (getAlignmentPanel() == null)
     {
@@ -785,19 +770,8 @@ public abstract class StructureViewerBase extends GStructureViewer
     String reply = null;
     try
     {
-      AlignmentI[] als = new Alignment[_alignwith.size()];
-      HiddenColumns[] alc = new HiddenColumns[_alignwith.size()];
-      int[] alm = new int[_alignwith.size()];
-      int a = 0;
-
-      for (AlignmentViewPanel alignPanel : _alignwith)
-      {
-        als[a] = alignPanel.getAlignment();
-        alm[a] = -1;
-        alc[a++] = alignPanel.getAlignment().getHiddenColumns();
-      }
-      reply = getBinding().superposeStructures(als, alm, alc);
-      if (reply != null)
+      reply = getBinding().superposeStructures(_alignwith);
+      if (reply != null && !reply.isEmpty())
       {
         String text = MessageManager
                 .formatMessage("error.superposition_failed", reply);
@@ -817,7 +791,7 @@ public abstract class StructureViewerBase extends GStructureViewer
   }
 
   @Override
-  public void background_actionPerformed(ActionEvent actionEvent)
+  public void background_actionPerformed()
   {
     Color col = JColorChooser.showDialog(this,
             MessageManager.getString("label.select_background_colour"),
@@ -829,7 +803,7 @@ public abstract class StructureViewerBase extends GStructureViewer
   }
 
   @Override
-  public void viewerColour_actionPerformed(ActionEvent actionEvent)
+  public void viewerColour_actionPerformed()
   {
     if (viewerColour.isSelected())
     {
@@ -839,21 +813,21 @@ public abstract class StructureViewerBase extends GStructureViewer
   }
 
   @Override
-  public void chainColour_actionPerformed(ActionEvent actionEvent)
+  public void chainColour_actionPerformed()
   {
     chainColour.setSelected(true);
     getBinding().colourByChain();
   }
 
   @Override
-  public void chargeColour_actionPerformed(ActionEvent actionEvent)
+  public void chargeColour_actionPerformed()
   {
     chargeColour.setSelected(true);
     getBinding().colourByCharge();
   }
 
   @Override
-  public void seqColour_actionPerformed(ActionEvent actionEvent)
+  public void seqColour_actionPerformed()
   {
     AAStructureBindingModel binding = getBinding();
     binding.setColourBySequence(seqColour.isSelected());
@@ -881,7 +855,7 @@ public abstract class StructureViewerBase extends GStructureViewer
   }
 
   @Override
-  public void pdbFile_actionPerformed(ActionEvent actionEvent)
+  public void pdbFile_actionPerformed()
   {
     JalviewFileChooser chooser = new JalviewFileChooser(
             Cache.getProperty("LAST_DIRECTORY"));
@@ -932,7 +906,7 @@ public abstract class StructureViewerBase extends GStructureViewer
   }
 
   @Override
-  public void viewMapping_actionPerformed(ActionEvent actionEvent)
+  public void viewMapping_actionPerformed()
   {
     CutAndPasteTransfer cap = new CutAndPasteTransfer();
     try
@@ -994,7 +968,7 @@ public abstract class StructureViewerBase extends GStructureViewer
 
     if (!binding.isLoadingFromArchive())
     {
-      seqColour_actionPerformed(null);
+      seqColour_actionPerformed();
     }
   }
 
@@ -1060,13 +1034,7 @@ public abstract class StructureViewerBase extends GStructureViewer
     return tm;
   }
 
-  /**
-   * End the progress bar with the specified handle, leaving a message (if not
-   * null) on the status bar
-   * 
-   * @param msg
-   * @param handle
-   */
+  @Override
   public void stopProgressBar(String msg, long handle)
   {
     if (progressBar != null)
@@ -1075,11 +1043,6 @@ public abstract class StructureViewerBase extends GStructureViewer
     }
   }
 
-  @Override
-  public void stopProgressBar(Object object, long handle)
-  {
-  }
-
   protected IProgressIndicator getProgressIndicator()
   {
     return progressBar;
@@ -1104,4 +1067,24 @@ public abstract class StructureViewerBase extends GStructureViewer
     // default does nothing
   }
 
+  /**
+   * Show only the selected chain(s) in the viewer
+   */
+  protected void showSelectedChains()
+  {
+    List<String> toshow = new ArrayList<>();
+    for (int i = 0; i < chainMenu.getItemCount(); i++)
+    {
+      if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
+      {
+        JCheckBoxMenuItem item = (JCheckBoxMenuItem) chainMenu.getItem(i);
+        if (item.isSelected())
+        {
+          toshow.add(item.getText());
+        }
+      }
+    }
+    getBinding().showChains(toshow);
+  }
+
 }