JAL-3509 coerce RESNUM to hidden (really) after fetching from PDB - resolved conflict...
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 6 Feb 2020 14:44:38 +0000 (14:44 +0000)
committerJim Procter <j.procter@dundee.ac.uk>
Thu, 2 Sep 2021 13:08:32 +0000 (14:08 +0100)
src/jalview/api/FeatureRenderer.java
src/jalview/api/FeatureSettingsModelI.java
src/jalview/api/FeaturesDisplayedI.java
src/jalview/ext/jmol/JalviewJmolBinding.java
src/jalview/gui/AlignViewport.java
src/jalview/gui/ChimeraViewFrame.java
src/jalview/io/PDBFeatureSettings.java
src/jalview/schemes/FeatureSettingsAdapter.java
src/jalview/structures/models/AAStructureBindingModel.java
src/jalview/viewmodel/seqfeatures/FeatureRendererModel.java
src/jalview/viewmodel/seqfeatures/FeaturesDisplayed.java

index 8aa2858..fff3b38 100644 (file)
@@ -297,4 +297,11 @@ public interface FeatureRenderer
    * @return
    */
   MappedFeatures findComplementFeaturesAtResidue(SequenceI sequence, int pos);
+
+  /**
+   * Sends a message to let any registered parties know that something about
+   * feature rendering has changed
+   */
+  void notifyFeaturesChanged();
+
 }
index c0fc523..c8a835a 100644 (file)
@@ -35,7 +35,8 @@ public interface FeatureSettingsModelI extends Comparator<String>
   // interface, simplifying instantiating classes
 
   /**
-   * Answers true if the specified feature type is displayed
+   * Answers true if the specified feature type is to be displayed, false if no
+   * preference
    * 
    * @param type
    * @return
@@ -43,6 +44,15 @@ public interface FeatureSettingsModelI extends Comparator<String>
   boolean isFeatureDisplayed(String type);
 
   /**
+   * Answers true if the specified feature type is to be hidden, false if no
+   * preference
+   * 
+   * @param type
+   * @return
+   */
+  boolean isFeatureHidden(String type);
+
+  /**
    * Answers true if the specified feature group is displayed
    * 
    * @param group
index e69785f..9387e3f 100644 (file)
@@ -39,6 +39,8 @@ public interface FeaturesDisplayedI
 
   void setVisible(String featureType);
 
+  void setHidden(String featureType);
+
   /**
    * Sets all the specified feature types to visible. Visibility of other
    * feature types is not changed.
index eee48df..8a7cd23 100644 (file)
@@ -20,6 +20,7 @@
  */
 package jalview.ext.jmol;
 
+import java.awt.Color;
 import java.awt.Container;
 import java.awt.event.ComponentEvent;
 import java.awt.event.ComponentListener;
@@ -41,10 +42,12 @@ import org.jmol.viewer.Viewer;
 
 import jalview.api.AlignmentViewPanel;
 import jalview.api.FeatureRenderer;
+import jalview.api.FeatureSettingsModelI;
 import jalview.api.SequenceRenderer;
 import jalview.bin.Cache;
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.SequenceI;
+import jalview.gui.AppJmol;
 import jalview.gui.IProgressIndicator;
 import jalview.gui.StructureViewer.ViewerType;
 import jalview.io.DataSourceType;
@@ -54,6 +57,7 @@ import jalview.structure.StructureCommand;
 import jalview.structure.StructureCommandI;
 import jalview.structure.StructureSelectionManager;
 import jalview.structures.models.AAStructureBindingModel;
+import jalview.ws.dbsources.Pdb;
 import javajs.util.BS;
 
 public abstract class JalviewJmolBinding extends AAStructureBindingModel
@@ -745,7 +749,14 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
       FeatureRenderer fr = getFeatureRenderer(null);
       if (fr != null)
       {
+        // JAL-1842 ensure FeatureRenderer knows about RESNUM
         fr.featuresAdded();
+        // ... apply feature settings (e.g. to hide RESNUM)
+        FeatureSettingsModelI colours = new Pdb().getFeatureColourScheme();
+        ((AppJmol) getViewer()).getAlignmentPanel().av
+                .applyFeaturesStyle(colours);
+        // ... and refresh again to ensure FeatureSettings is in synch!
+        fr.notifyFeaturesChanged();
       }
       refreshGUI();
       loadNotifiesHandled++;
index 0125f0d..3c520e3 100644 (file)
@@ -1022,8 +1022,8 @@ public class AlignViewport extends AlignmentViewport
     
     FeatureRenderer fr = getAlignPanel().getSeqPanel().seqCanvas
             .getFeatureRenderer();
-    List<String> origRenderOrder = new ArrayList(),
-            origGroups = new ArrayList();
+    List<String> origRenderOrder = new ArrayList<>();
+    List<String> origGroups = new ArrayList<>();
     // preserve original render order - allows differentiation between user configured colours and autogenerated ones
     origRenderOrder.addAll(fr.getRenderOrder());
     origGroups.addAll(fr.getFeatureGroups());
@@ -1034,7 +1034,7 @@ public class AlignViewport extends AlignmentViewport
     if (!mergeOnly)
     {
       // only clear displayed features if we are mergeing
-      displayed.clear();
+      // displayed.clear();
     }
     // TODO this clears displayed.featuresRegistered - do we care?
     //
@@ -1066,6 +1066,10 @@ public class AlignViewport extends AlignmentViewport
         {
           displayed.setVisible(type);
         }
+        else if (featureSettings.isFeatureHidden(type))
+        {
+          displayed.setHidden(type);
+        }
       }
     }
 
index 810f40d..e3c65da 100644 (file)
@@ -491,7 +491,8 @@ public class ChimeraViewFrame extends StructureViewerBase
 
       /*
        * ensure that any newly discovered features (e.g. RESNUM)
-       * are added to any open feature settings dialog
+       * are notified to the FeatureRenderer (and added to any 
+       * open feature settings dialog)
        */
       FeatureRenderer fr = getBinding().getFeatureRenderer(null);
       if (fr != null)
index 01610a1..6b09cd1 100644 (file)
@@ -36,10 +36,9 @@ public class PDBFeatureSettings extends FeatureSettingsAdapter
   private static final String FEATURE_RES_NUM = PDBChain.RESNUM_FEATURE;
 
   @Override
-  public boolean isFeatureDisplayed(String type)
+  public boolean isFeatureHidden(String type)
   {
-    return type.equalsIgnoreCase(FEATURE_INSERTION)
-            || type.equalsIgnoreCase(FEATURE_RES_NUM);
+    return type.equalsIgnoreCase(FEATURE_RES_NUM);
   }
 
   @Override
index b15e4cf..6e8554f 100644 (file)
@@ -36,6 +36,12 @@ public class FeatureSettingsAdapter implements FeatureSettingsModelI
   }
 
   @Override
+  public boolean isFeatureHidden(String type)
+  {
+    return false;
+  }
+
+  @Override
   public boolean isGroupDisplayed(String group)
   {
     return true;
index 16dd96c..da86ca5 100644 (file)
@@ -1213,8 +1213,7 @@ public abstract class AAStructureBindingModel
   }
 
   /**
-   * Returns the FeatureRenderer for the given alignment view, or null if
-   * feature display is turned off in the view.
+   * Returns the FeatureRenderer for the given alignment view
    * 
    * @param avp
    * @return
@@ -1227,9 +1226,7 @@ public abstract class AAStructureBindingModel
     {
       return null;
     }
-    return ap.getAlignViewport().isShowSequenceFeatures()
-            ? ap.getFeatureRenderer()
-            : null;
+    return ap.getFeatureRenderer();
   }
 
   protected void setStructureCommands(StructureCommandsI cmd)
index 3608626..853bc3b 100644 (file)
@@ -104,11 +104,11 @@ public abstract class FeatureRendererModel
 
   Map<String, Float> featureOrder = null;
 
-  protected PropertyChangeSupport changeSupport = new PropertyChangeSupport(
-          this);
-
   protected AlignViewportI av;
 
+  private PropertyChangeSupport changeSupport = new PropertyChangeSupport(
+          this);
+
   @Override
   public AlignViewportI getViewport()
   {
@@ -301,13 +301,19 @@ public abstract class FeatureRendererModel
       {
         firing = Boolean.TRUE;
         findAllFeatures(true); // add all new features as visible
-        changeSupport.firePropertyChange("changeSupport", null, null);
+        notifyFeaturesChanged();
         firing = Boolean.FALSE;
       }
     }
   }
 
   @Override
+  public void notifyFeaturesChanged()
+  {
+    changeSupport.firePropertyChange("changeSupport", null, null);
+  }
+
+  @Override
   public List<SequenceFeature> findFeaturesAtColumn(SequenceI sequence, int column)
   {
     /*
index f44a2d1..d7da519 100644 (file)
@@ -29,9 +29,9 @@ import java.util.Set;
 
 public class FeaturesDisplayed implements FeaturesDisplayedI
 {
-  private Set<String> featuresDisplayed = new HashSet<String>();
+  private Set<String> featuresDisplayed = new HashSet<>();
 
-  private Set<String> featuresRegistered = new HashSet<String>();
+  private Set<String> featuresRegistered = new HashSet<>();
 
   public FeaturesDisplayed(FeaturesDisplayedI featuresDisplayed2)
   {
@@ -93,6 +93,13 @@ public class FeaturesDisplayed implements FeaturesDisplayedI
   }
 
   @Override
+  public void setHidden(String featureType)
+  {
+    featuresDisplayed.remove(featureType);
+    featuresRegistered.add(featureType);
+  }
+
+  @Override
   public boolean isRegistered(String type)
   {
     return featuresRegistered.contains(type);