From 1f029391e9e263b132a62eaefcc2fe68badacfd6 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Thu, 6 Feb 2020 14:44:38 +0000 Subject: [PATCH] JAL-3509 coerce RESNUM to hidden (really) after fetching from PDB - resolved conflicts for 2.11.2 --- src/jalview/api/FeatureRenderer.java | 7 +++++++ src/jalview/api/FeatureSettingsModelI.java | 12 +++++++++++- src/jalview/api/FeaturesDisplayedI.java | 2 ++ src/jalview/ext/jmol/JalviewJmolBinding.java | 11 +++++++++++ src/jalview/gui/AlignViewport.java | 10 +++++++--- src/jalview/gui/ChimeraViewFrame.java | 3 ++- src/jalview/io/PDBFeatureSettings.java | 5 ++--- src/jalview/schemes/FeatureSettingsAdapter.java | 6 ++++++ .../structures/models/AAStructureBindingModel.java | 7 ++----- .../viewmodel/seqfeatures/FeatureRendererModel.java | 14 ++++++++++---- src/jalview/viewmodel/seqfeatures/FeaturesDisplayed.java | 11 +++++++++-- 11 files changed, 69 insertions(+), 19 deletions(-) diff --git a/src/jalview/api/FeatureRenderer.java b/src/jalview/api/FeatureRenderer.java index 8aa2858..fff3b38 100644 --- a/src/jalview/api/FeatureRenderer.java +++ b/src/jalview/api/FeatureRenderer.java @@ -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(); + } diff --git a/src/jalview/api/FeatureSettingsModelI.java b/src/jalview/api/FeatureSettingsModelI.java index c0fc523..c8a835a 100644 --- a/src/jalview/api/FeatureSettingsModelI.java +++ b/src/jalview/api/FeatureSettingsModelI.java @@ -35,7 +35,8 @@ public interface FeatureSettingsModelI extends Comparator // 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 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 diff --git a/src/jalview/api/FeaturesDisplayedI.java b/src/jalview/api/FeaturesDisplayedI.java index e69785f..9387e3f 100644 --- a/src/jalview/api/FeaturesDisplayedI.java +++ b/src/jalview/api/FeaturesDisplayedI.java @@ -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. diff --git a/src/jalview/ext/jmol/JalviewJmolBinding.java b/src/jalview/ext/jmol/JalviewJmolBinding.java index eee48df..8a7cd23 100644 --- a/src/jalview/ext/jmol/JalviewJmolBinding.java +++ b/src/jalview/ext/jmol/JalviewJmolBinding.java @@ -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++; diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 0125f0d..3c520e3 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -1022,8 +1022,8 @@ public class AlignViewport extends AlignmentViewport FeatureRenderer fr = getAlignPanel().getSeqPanel().seqCanvas .getFeatureRenderer(); - List origRenderOrder = new ArrayList(), - origGroups = new ArrayList(); + List origRenderOrder = new ArrayList<>(); + List 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); + } } } diff --git a/src/jalview/gui/ChimeraViewFrame.java b/src/jalview/gui/ChimeraViewFrame.java index 810f40d..e3c65da 100644 --- a/src/jalview/gui/ChimeraViewFrame.java +++ b/src/jalview/gui/ChimeraViewFrame.java @@ -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) diff --git a/src/jalview/io/PDBFeatureSettings.java b/src/jalview/io/PDBFeatureSettings.java index 01610a1..6b09cd1 100644 --- a/src/jalview/io/PDBFeatureSettings.java +++ b/src/jalview/io/PDBFeatureSettings.java @@ -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 diff --git a/src/jalview/schemes/FeatureSettingsAdapter.java b/src/jalview/schemes/FeatureSettingsAdapter.java index b15e4cf..6e8554f 100644 --- a/src/jalview/schemes/FeatureSettingsAdapter.java +++ b/src/jalview/schemes/FeatureSettingsAdapter.java @@ -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; diff --git a/src/jalview/structures/models/AAStructureBindingModel.java b/src/jalview/structures/models/AAStructureBindingModel.java index 16dd96c..da86ca5 100644 --- a/src/jalview/structures/models/AAStructureBindingModel.java +++ b/src/jalview/structures/models/AAStructureBindingModel.java @@ -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) diff --git a/src/jalview/viewmodel/seqfeatures/FeatureRendererModel.java b/src/jalview/viewmodel/seqfeatures/FeatureRendererModel.java index 3608626..853bc3b 100644 --- a/src/jalview/viewmodel/seqfeatures/FeatureRendererModel.java +++ b/src/jalview/viewmodel/seqfeatures/FeatureRendererModel.java @@ -104,11 +104,11 @@ public abstract class FeatureRendererModel Map 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 findFeaturesAtColumn(SequenceI sequence, int column) { /* diff --git a/src/jalview/viewmodel/seqfeatures/FeaturesDisplayed.java b/src/jalview/viewmodel/seqfeatures/FeaturesDisplayed.java index f44a2d1..d7da519 100644 --- a/src/jalview/viewmodel/seqfeatures/FeaturesDisplayed.java +++ b/src/jalview/viewmodel/seqfeatures/FeaturesDisplayed.java @@ -29,9 +29,9 @@ import java.util.Set; public class FeaturesDisplayed implements FeaturesDisplayedI { - private Set featuresDisplayed = new HashSet(); + private Set featuresDisplayed = new HashSet<>(); - private Set featuresRegistered = new HashSet(); + private Set 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); -- 1.7.10.2