import java.util.Arrays;
import java.util.Deque;
import java.util.Enumeration;
+import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Locale;
+import java.util.Map;
import java.util.Vector;
import javax.swing.ButtonGroup;
import jalview.schemes.ColourSchemes;
import jalview.schemes.ResidueColourScheme;
import jalview.schemes.TCoffeeColourScheme;
+import jalview.util.Constants;
import jalview.util.HttpUtils;
import jalview.util.ImageMaker.TYPE;
import jalview.util.MessageManager;
}
ap.av.updateConservation(ap);
ap.av.updateConsensus(ap);
+ ap.av.updateSecondaryStructureConsensus(ap);
ap.av.updateStrucConsensus(ap);
}
}
viewport.setShowUnconserved(showNonconservedMenuItem.getState());
alignPanel.paintAlignment(false, false);
}
+
+ @Override
+ protected void updateShowSecondaryStructureMenu(JMenu showSS, ButtonGroup ssButtonGroup){
+
+ List<String> ssSources = new ArrayList<String>();
+ AlignmentAnnotation[] anns = alignPanel.getAlignment()
+ .getAlignmentAnnotation();
+ Map<String, JCheckBoxMenuItem> checkboxMap = getCheckboxesInMenu(showSS);
+
+ ssSources = AlignmentUtils.extractSSSourceInAlignmentAnnotation(anns);
+
+ if(ssSources == null) {
+ showSS.removeAll();
+ ssButtonGroup.clearSelection();
+ return;
+ }
+
+ List<String> selectedCheckBoxes = getSelectedOptions(checkboxMap);
+
+ // Add checkboxes for categories
+ for (String ssSource : ssSources) {
+
+ if(checkboxMap.get(ssSource)== null) {
+ JCheckBoxMenuItem checkBox = new JCheckBoxMenuItem(ssSource);
+ checkBox.setSelected(false);
+
+ checkBox.addItemListener(e -> {
+ if (e.getStateChange() == ItemEvent.SELECTED) {
+
+ showOrHideSecondaryStructureForSource(ssSource, true);
+
+ } else {
+
+ showOrHideSecondaryStructureForSource(ssSource, false);
+
+ }
+ });
+ showSS.add(checkBox);
+ }
+ }
+ // Iterate over the keys of checkboxMap
+ for (String key : checkboxMap.keySet()) {
+ // Check if the key is not in ssSources
+ if (!ssSources.contains(key)) {
+ showSS.remove(checkboxMap.get(key));
+ checkboxMap.remove(key);
+ selectedCheckBoxes.remove(key);
+ }
+ if(selectedCheckBoxes.contains(key)){
+ checkboxMap.get(key).setSelected(true);
+ }
+ else {
+ checkboxMap.get(key).setSelected(false);
+ }
+
+ ssButtonGroup.clearSelection();
+ }
+
+ }
+
+ private List<String> getSelectedOptions(Map<String, JCheckBoxMenuItem> checkboxMap) {
+ List<String> selectedOptions = new ArrayList<>();
+ for (String key : checkboxMap.keySet()) {
+ JCheckBoxMenuItem checkbox = checkboxMap.get(key);
+ if (checkbox.isSelected()) {
+ selectedOptions.add(key);
+ }
+ }
+ return selectedOptions;
+ }
+
+ private Map<String, JCheckBoxMenuItem> getCheckboxesInMenu(JMenu menu) {
+ Map<String, JCheckBoxMenuItem> checkboxMap = new HashMap<>();
+ for (Component component : menu.getMenuComponents()) {
+ if (component instanceof JCheckBoxMenuItem) {
+ JCheckBoxMenuItem checkbox = (JCheckBoxMenuItem) component;
+ checkboxMap.put(checkbox.getText(), checkbox);
+ }
+ }
+ 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) {
+
+ 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()) {
+
+ if (label.equals(aa.label)) {
+
+ String ssSource = AlignmentUtils.extractSSSourceFromAnnotationDescription(aa);
+
+ if(ssSource != null && (ssSource.equals(ssSourceSelection) || ssSourceSelection.equals(noneOption))) {
+ aa.visible = visible;
+ }
+ }
+ }
+
+ }
+
+ PaintRefresher.Refresh(this, viewport.getSequenceSetId());
+ alignPanel.updateAnnotation();
+ alignPanel.paintAlignment(true, true);
+
+ }
+
+ protected void showSSConsensus_actionPerformed(ActionEvent e)
+ {
+ viewport.setShowSSConsensus(showSSConsensus.getState());
+ alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
+
+ }
+
/*
* (non-Javadoc)
}
+ @Override
+ protected void showGroupSSConsensus_actionPerformed(ActionEvent e)
+ {
+ viewport.setShowGroupSSConsensus(showGroupSSConsensus.getState());
+ alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
+
+ }
/*
* (non-Javadoc)
*
viewport.setShowConsensusHistogram(showConsensusHistogram.getState());
alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
}
-
+
/*
* (non-Javadoc)
*