Merge branch 'features/JAL-4034_improve_3dbeacons_button_and_ux' into develop
[jalview.git] / src / jalview / gui / AnnotationChooser.java
index 33c4992..791421d 100644 (file)
@@ -1,3 +1,23 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
 package jalview.gui;
 
 import jalview.datamodel.AlignmentAnnotation;
@@ -36,7 +56,8 @@ import javax.swing.JPanel;
 public class AnnotationChooser extends JPanel
 {
 
-  private static final Font CHECKBOX_FONT = new Font("Serif", Font.BOLD, 12);
+  private static final Font CHECKBOX_FONT = new Font("Serif", Font.BOLD,
+          12);
 
   private static final int MY_FRAME_WIDTH = 600;
 
@@ -61,8 +82,8 @@ public class AnnotationChooser extends JPanel
   private boolean applyToUnselectedSequences;
 
   // currently selected 'annotation type' checkboxes
-  private Map<String, String> selectedTypes = new HashMap<String, String>();
-  
+  private Map<String, String> selectedTypes = new HashMap<>();
+
   /**
    * Constructor.
    * 
@@ -174,14 +195,7 @@ public class AnnotationChooser extends JPanel
   {
     setAnnotationVisibility(true);
 
-    // copied from AnnotationLabel.actionPerformed (after show/hide row)...
-    // TODO should drive this functionality into AlignmentPanel
     ap.updateAnnotation();
-    // this.ap.annotationPanel.adjustPanelHeight();
-    // this.ap.alabels.setSize(this.ap.alabels.getSize().width,
-    // this.ap.annotationPanel.getSize().height);
-    // this.ap.validate();
-    this.ap.paintAlignment(true);
   }
 
   /**
@@ -208,11 +222,6 @@ public class AnnotationChooser extends JPanel
       }
     }
     ap.updateAnnotation();
-    // // this.ap.annotationPanel.adjustPanelHeight();
-    // this.ap.alabels.setSize(this.ap.alabels.getSize().width,
-    // this.ap.annotationPanel.getSize().height);
-    // this.ap.validate();
-    this.ap.paintAlignment(true);
   }
 
   /**
@@ -222,15 +231,13 @@ public class AnnotationChooser extends JPanel
    * type which are in the application scope (all, selected or unselected
    * sequences).
    * 
-   * @param type
+   * @param dataSourceType
    */
   protected void changeShowHide_actionPerformed()
   {
     setAnnotationVisibility(false);
 
-    this.ap.updateAnnotation();
-    // this.ap.annotationPanel.adjustPanelHeight();
-    this.ap.paintAlignment(true);
+    ap.updateAnnotation();
   }
 
   /**
@@ -335,7 +342,7 @@ public class AnnotationChooser extends JPanel
   public static List<String> getAnnotationTypes(AlignmentI alignment,
           boolean sequenceSpecificOnly)
   {
-    List<String> result = new ArrayList<String>();
+    List<String> result = new ArrayList<>();
     for (AlignmentAnnotation aa : alignment.getAlignmentAnnotation())
     {
       if (!sequenceSpecificOnly || aa.sequenceRef != null)
@@ -388,7 +395,7 @@ public class AnnotationChooser extends JPanel
     final boolean wholeAlignment = this.sg == null;
     JPanel applyToOptions = new JPanel(new FlowLayout(FlowLayout.LEFT));
     CheckboxGroup actingOn = new CheckboxGroup();
-    
+
     String forAll = MessageManager.getString("label.all_sequences");
     final Checkbox allSequences = new Checkbox(forAll, actingOn,
             wholeAlignment);
@@ -397,7 +404,8 @@ public class AnnotationChooser extends JPanel
       @Override
       public void itemStateChanged(ItemEvent evt)
       {
-        if (evt.getStateChange() == ItemEvent.SELECTED) {
+        if (evt.getStateChange() == ItemEvent.SELECTED)
+        {
           AnnotationChooser.this.setApplyToSelectedSequences(true);
           AnnotationChooser.this.setApplyToUnselectedSequences(true);
           AnnotationChooser.this.changeApplyTo_actionPerformed();
@@ -405,7 +413,7 @@ public class AnnotationChooser extends JPanel
       }
     });
     applyToOptions.add(allSequences);
-    
+
     String forSelected = MessageManager
             .getString("label.selected_sequences");
     final Checkbox selectedSequences = new Checkbox(forSelected, actingOn,
@@ -425,10 +433,11 @@ public class AnnotationChooser extends JPanel
       }
     });
     applyToOptions.add(selectedSequences);
-    
+
     String exceptSelected = MessageManager
             .getString("label.except_selected_sequences");
-    final Checkbox unselectedSequences = new Checkbox(exceptSelected, actingOn, false);
+    final Checkbox unselectedSequences = new Checkbox(exceptSelected,
+            actingOn, false);
     unselectedSequences.setEnabled(!wholeAlignment);
     unselectedSequences.addItemListener(new ItemListener()
     {
@@ -444,7 +453,7 @@ public class AnnotationChooser extends JPanel
       }
     });
     applyToOptions.add(unselectedSequences);
-    
+
     // set member variables to match the initial selection state
     this.applyToSelectedSequences = selectedSequences.getState()
             || allSequences.getState();
@@ -476,7 +485,8 @@ public class AnnotationChooser extends JPanel
       @Override
       public void itemStateChanged(ItemEvent evt)
       {
-        if (evt.getStateChange() == ItemEvent.SELECTED) {
+        if (evt.getStateChange() == ItemEvent.SELECTED)
+        {
           AnnotationChooser.this.setShowSelected(true);
           AnnotationChooser.this.changeShowHide_actionPerformed();
         }
@@ -521,7 +531,7 @@ public class AnnotationChooser extends JPanel
   {
     JPanel jp = new JPanel();
     final Font labelFont = JvSwingUtils.getLabelFont();
-    
+
     JButton ok = new JButton(MessageManager.getString("action.ok"));
     ok.setFont(labelFont);
     ok.addActionListener(new ActionListener()
@@ -533,7 +543,7 @@ public class AnnotationChooser extends JPanel
       }
     });
     jp.add(ok);
-    
+
     JButton cancel = new JButton(MessageManager.getString("action.cancel"));
     cancel.setFont(labelFont);
     cancel.addActionListener(new ActionListener()