JAL-1847 superpose checkbox in structure chooser
authorJim Procter <jprocter@issues.jalview.org>
Mon, 9 Apr 2018 09:14:57 +0000 (10:14 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Mon, 9 Apr 2018 09:14:57 +0000 (10:14 +0100)
src/jalview/gui/StructureChooser.java
src/jalview/jbgui/GStructureChooser.java

index 1c99f02..1b69989 100644 (file)
@@ -22,6 +22,7 @@
 package jalview.gui;
 
 import jalview.api.structures.JalviewStructureDisplayI;
+import jalview.bin.Cache;
 import jalview.bin.Jalview;
 import jalview.datamodel.DBRefEntry;
 import jalview.datamodel.DBRefSource;
@@ -108,6 +109,8 @@ public class StructureChooser extends GStructureChooser
       progressBar = new ProgressBar(this.statusPanel, this.statusBar);
     }
 
+    chk_superpose.setSelected(Cache.getDefault("AUTOSUPERIMPOSE", true));
+
     // ensure a filter option is in force for search
     populateFilterComboBox(true, cachedPDBExists);
     Thread discoverPDBStructuresThread = new Thread(new Runnable()
@@ -999,17 +1002,24 @@ public class StructureChooser extends GStructureChooser
     return foundEntry;
   }
 
+  /**
+   * @param ssm
+   * @return targetted structure view (new or existing) configured according to
+   *         superpose checkbox
+   */
   public StructureViewer getTargetedStructureViewer(
           StructureSelectionManager ssm)
   {
     Object _sv = targetView.getSelectedItem();
-
+    StructureViewer sv;
     if (_sv == null)
     {
-      return new StructureViewer(ssm);
+      sv = new StructureViewer(ssm);
     } else {
-      return (StructureViewer) _sv;
+      sv = (StructureViewer) _sv;
     }
+    sv.setSuperpose(chk_superpose.isSelected());
+    return sv;
   }
   private StructureViewer launchStructureViewer(
           StructureSelectionManager ssm,
@@ -1020,6 +1030,7 @@ public class StructureChooser extends GStructureChooser
     setProgressBar(MessageManager
             .getString("status.launching_3d_structure_viewer"), progressId);
     final StructureViewer sViewer = getTargetedStructureViewer(ssm);
+    sViewer.setSuperpose(chk_superpose.isSelected());
 
     setProgressBar(null, progressId);
     if (SiftsSettings.isMapWithSifts())
index 9c7ba6d..810813b 100644 (file)
@@ -109,6 +109,9 @@ public abstract class GStructureChooser extends JPanel
 
   protected JButton btn_pdbFromFile = new JButton();
 
+  protected JCheckBox chk_superpose = new JCheckBox(
+          MessageManager.getString("label.superpose_structures"));
+
   protected JTextField txt_search = new JTextField(14);
 
   private JPanel pnl_actions = new JPanel(new MigLayout());
@@ -524,6 +527,7 @@ public abstract class GStructureChooser extends JPanel
     pnl_actions.add(chk_rememberSettings);
     pnl_actions.add(btn_view);
     pnl_actions.add(btn_cancel);
+    pnl_actions.add(chk_superpose, "left");
 
     // pnl_filter.add(lbl_result);
     pnl_main.add(cmb_filterOption);