From af7469b223e0c6297f61c09c63c9416a16dba7da Mon Sep 17 00:00:00 2001 From: Renia Correya Date: Tue, 28 May 2024 15:37:13 +0100 Subject: [PATCH] JAL-4386 Fixed some identified bugs in recent changes --- src/jalview/analysis/AlignmentUtils.java | 2 +- src/jalview/gui/AlignFrame.java | 26 ++++++++++++++++++++------ src/jalview/gui/TreePanel.java | 5 ++--- src/jalview/jbgui/GAlignFrame.java | 6 +++--- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/jalview/analysis/AlignmentUtils.java b/src/jalview/analysis/AlignmentUtils.java index eec982b..7da3ee0 100644 --- a/src/jalview/analysis/AlignmentUtils.java +++ b/src/jalview/analysis/AlignmentUtils.java @@ -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)); diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 721b549..8dfc2e6 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -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; } } diff --git a/src/jalview/gui/TreePanel.java b/src/jalview/gui/TreePanel.java index a421850..24a5547 100755 --- a/src/jalview/gui/TreePanel.java +++ b/src/jalview/gui/TreePanel.java @@ -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); diff --git a/src/jalview/jbgui/GAlignFrame.java b/src/jalview/jbgui/GAlignFrame.java index 8bec4ae..c93c104 100755 --- a/src/jalview/jbgui/GAlignFrame.java +++ b/src/jalview/jbgui/GAlignFrame.java @@ -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 -- 1.7.10.2