JAL-4386 Fixed some identified bugs in recent changes
authorRenia Correya <rcorreya001@dundee.ac.uk>
Tue, 28 May 2024 14:37:13 +0000 (15:37 +0100)
committerRenia Correya <rcorreya001@dundee.ac.uk>
Tue, 28 May 2024 14:37:13 +0000 (15:37 +0100)
src/jalview/analysis/AlignmentUtils.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/TreePanel.java
src/jalview/jbgui/GAlignFrame.java

index eec982b..7da3ee0 100644 (file)
@@ -2996,7 +2996,7 @@ public class AlignmentUtils
 
         // For input with secondary structure
         if (aa.label.equals(Constants.SS_ANNOTATION_LABEL)
-                && aa.description.equals(Constants.SS_ANNOTATION_LABEL))
+                && aa.description != null && aa.description.equals(Constants.SS_ANNOTATION_LABEL))
         {
 
           return (Constants.SECONDARY_STRUCTURE_LABELS.get(aa.label));
index 721b549..8dfc2e6 100644 (file)
@@ -5699,10 +5699,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
                 
               showOrHideSecondaryStructureForSource(ssSource, true);
               
-            } else {
-                
+            } else {                
 
               showOrHideSecondaryStructureForSource(ssSource, false);
+              
             }
         });
         showSS.add(checkBox);
@@ -5750,16 +5750,30 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     return checkboxMap;
 }
   
-  
+  @Override
   protected void showOrHideSecondaryStructureForSource(String ssSourceSelection, boolean visible){
     
+    String noneOption = MessageManager.getString("option.ss_providers_none");
+    String allOption = MessageManager.getString("option.ss_providers_all");
+    
     AlignmentAnnotation[] annotations = alignPanel.getAlignment()
             .getAlignmentAnnotation();
     
     for (AlignmentAnnotation aa: annotations) {
       
-      if(aa.label.startsWith(MessageManager.getString("label.ssconsensus_label")) && aa.description.startsWith(ssSourceSelection)) {
-        aa.visible  = visible;
+      boolean isSSConsensus = aa.label.startsWith(MessageManager.getString("label.ssconsensus_label"));
+      boolean matchesSSSourceSelection = aa.description.startsWith(ssSourceSelection);
+      
+      if(isSSConsensus && (matchesSSSourceSelection || ssSourceSelection.equals(noneOption))) {
+        
+        if (ssSourceSelection.equals(allOption)) {
+          aa.visible  = true;
+          break;
+        }
+        
+        if(!aa.description.startsWith(allOption))
+          aa.visible  = visible;
+
       }
       
       for (String label : Constants.SECONDARY_STRUCTURE_LABELS.keySet()) {
@@ -5767,7 +5781,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
         if (label.equals(aa.label)) { 
 
             String ssSource = AlignmentUtils.extractSSSourceFromAnnotationDescription(aa);
-            if(ssSource.equals(ssSourceSelection)) {
+            if(ssSource.equals(ssSourceSelection) || ssSourceSelection.equals(noneOption)) {
               aa.visible = visible;
             }           
         }
index a421850..24a5547 100755 (executable)
@@ -190,13 +190,12 @@ public class TreePanel extends GTreePanel
     treeCanvas = new TreeCanvas(this, ap, scrollPane);
     scrollPane.setViewportView(treeCanvas);
     
-    if(this.similarityParams.getSecondaryStructureSource()!=null ) {
+    if(this.similarityParams!=null)
+      if(this.similarityParams.getSecondaryStructureSource()!=null ) {
     
-      // Initialize the subtitle label
       subtitleLabel = new JLabel(" Secondary Structure Provider : " 
                 + this.similarityParams.getSecondaryStructureSource(), SwingConstants.LEFT);
   
-      // Create a new panel to hold the label and treeCanvas
       JPanel panel = new JPanel(new BorderLayout());
       panel.add(subtitleLabel, BorderLayout.NORTH);
       panel.add(scrollPane, BorderLayout.CENTER);
index 8bec4ae..c93c104 100755 (executable)
@@ -1815,7 +1815,7 @@ public class GAlignFrame extends JInternalFrame
     radioButtonAllSS.addActionListener(new ActionListener() {
       @Override
       public void actionPerformed(ActionEvent e) {
-          showSS_actionPerformed(MessageManager.getString("option.ss_providers_all"));
+          showOrHideSecondaryStructureForSource(MessageManager.getString("option.ss_providers_all"), true);
           // Select all checkboxes if "All" is selected
           Component[] components = showSS.getMenuComponents();
           for (Component component : components) {
@@ -1832,7 +1832,7 @@ public class GAlignFrame extends JInternalFrame
     radioButtonNoneSS.addActionListener(new ActionListener() {
       @Override
       public void actionPerformed(ActionEvent e) {
-          showSS_actionPerformed(MessageManager.getString("option.ss_providers_none"));
+          showOrHideSecondaryStructureForSource(MessageManager.getString("option.ss_providers_none"), false);
           // Remove selection of all checkboxes if "None" is selected
           Component[] components = showSS.getMenuComponents();
           for (Component component : components) {
@@ -2868,7 +2868,7 @@ public class GAlignFrame extends JInternalFrame
     return null;
   }
 
-  protected void showSS_actionPerformed(String ssSourceSelection)
+  protected void showOrHideSecondaryStructureForSource(String ssSourceSelection, boolean visible)
   {
     // TODO Auto-generated method stub