Merge branch 'features/r2_11_2_alphafold/JAL-629' into features/JAL-3858_PAEsInProjects
[jalview.git] / src / jalview / gui / FeatureSettings.java
index e636455..2c8f47a 100644 (file)
@@ -52,6 +52,7 @@ import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
 
@@ -61,7 +62,6 @@ import javax.swing.BorderFactory;
 import javax.swing.Icon;
 import javax.swing.JButton;
 import javax.swing.JCheckBox;
-import javax.swing.JCheckBoxMenuItem;
 import javax.swing.JInternalFrame;
 import javax.swing.JLabel;
 import javax.swing.JLayeredPane;
@@ -215,6 +215,7 @@ public class FeatureSettings extends JPanel
     transparency.setValue(100 - transparencyAsPercent);
     inConstruction = incon;
   }
+
   /**
    * Constructor
    * 
@@ -410,6 +411,7 @@ public class FeatureSettings extends JPanel
     {
       frame = new JInternalFrame();
       frame.setContentPane(this);
+      frame.setFrameIcon(null);
       Rectangle bounds = af.getFeatureSettingsGeometry();
       String title;
       if (af.getAlignPanels().size() > 1 || Desktop.getAlignmentPanels(
@@ -455,8 +457,8 @@ public class FeatureSettings extends JPanel
               });
       frame.setLayer(JLayeredPane.PALETTE_LAYER);
     }
-               inConstruction = false;
-       }
+    inConstruction = false;
+  }
 
   /**
    * Sets the state of buttons to show complement features from viewport
@@ -482,95 +484,21 @@ public class FeatureSettings extends JPanel
     change = null;
   }
 
-       /**
-        * Constructs and shows a popup menu of possible actions on the selected row and
-        * feature type
-        * 
-        * @param rowSelected
-        * @param type
-        * @param typeCol
-        * @param pt
-        */
-       protected void showPopupMenu(final int rowSelected, final String type, final Object typeCol, final Point pt)
+  /**
+   * Constructs and shows a popup menu of possible actions on the selected row
+   * and feature type
+   * 
+   * @param rowSelected
+   * @param type
+   * @param typeCol
+   * @param pt
+   */
+  protected void showPopupMenu(final int rowSelected, final String type,
+          final Object typeCol, final Point pt)
   {
     JPopupMenu men = new JPopupMenu(MessageManager
             .formatMessage("label.settings_for_param", new String[]
             { type }));
-    final FeatureColourI featureColour = (FeatureColourI) typeCol;
-
-    /*
-     * menu option to select (or deselect) variable colour
-     */
-    final JCheckBoxMenuItem variableColourCB = new JCheckBoxMenuItem(
-            MessageManager.getString("label.variable_colour"));
-    variableColourCB.setSelected(!featureColour.isSimpleColour());
-    men.add(variableColourCB);
-
-    /*
-     * checkbox action listener doubles up as listener to OK
-     * from the variable colour / filters dialog
-     */
-    variableColourCB.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        if (e.getSource() == variableColourCB)
-        {
-                                       // BH 2018 for JavaScript because this is a checkbox
-                                       men.setVisible(true);
-          men.setVisible(false);
-          if (featureColour.isSimpleColour())
-          {
-            /*
-             * toggle simple colour to variable colour - show dialog
-             */
-            FeatureTypeSettings fc = new FeatureTypeSettings(fr, type);
-            fc.addActionListener(this);
-          }
-          else
-          {
-            /*
-             * toggle variable to simple colour - show colour chooser
-             */
-            String title = MessageManager
-                    .formatMessage("label.select_colour_for", type);
-            ColourChooserListener listener = new ColourChooserListener()
-            {
-              @Override
-              public void colourSelected(Color c)
-              {
-                table.setValueAt(new FeatureColour(c), rowSelected,
-                        COLOUR_COLUMN);
-                table.validate();
-                updateFeatureRenderer(
-                        ((FeatureTableModel) table.getModel()).getData(),
-                        false);
-              }
-            };
-            JalviewColourChooser.showColourChooser(FeatureSettings.this,
-                    title, featureColour.getMaxColour(), listener);
-          }
-        }
-        else
-        {
-          if (e.getSource() instanceof FeatureTypeSettings)
-          {
-            /*
-             * update after OK in feature colour dialog; the updated
-             * colour will have already been set in the FeatureRenderer
-             */
-            FeatureColourI fci = fr.getFeatureColours().get(type);
-            table.setValueAt(fci, rowSelected, COLOUR_COLUMN);
-            // BH 2018 setting a table value does not invalidate it.
-            // System.out.println("FeatureSettings is valied" +
-            // table.validate();
-          }
-        }
-      }
-    });
-
-    men.addSeparator();
 
     JMenuItem scr = new JMenuItem(
             MessageManager.getString("label.sort_by_score"));
@@ -1020,14 +948,10 @@ public class FeatureSettings extends JPanel
     chooser.setDialogTitle(
             MessageManager.getString("label.load_feature_colours"));
     chooser.setToolTipText(MessageManager.getString("action.load"));
-    chooser.setResponseHandler(0, new Runnable()
-    {
-      @Override
-      public void run()
-      {
-        File file = chooser.getSelectedFile();
-        load(file);
-      }
+    chooser.setResponseHandler(0, () -> {
+      File file = chooser.getSelectedFile();
+      load(file);
+      return null;
     });
     chooser.showOpenDialog(this);
   }
@@ -1274,8 +1198,8 @@ public class FeatureSettings extends JPanel
   }
 
   /**
-   * close ourselves but leave any existing UI handlers (e.g a CDS/Protein tabbed
-   * feature settings dialog) intact
+   * close ourselves but leave any existing UI handlers (e.g a CDS/Protein
+   * tabbed feature settings dialog) intact
    */
   public void closeOldSettings()
   {
@@ -1391,7 +1315,8 @@ public class FeatureSettings extends JPanel
       }
     });
 
-    final String byScoreLabel = MessageManager.getString("label.seq_sort_by_score");
+    final String byScoreLabel = MessageManager
+            .getString("label.seq_sort_by_score");
     JButton sortByScore = new JButton(byScoreLabel);
     sortByScore.setFont(JvSwingUtils.getLabelFont());
     sortByScore.addActionListener(new ActionListener()
@@ -1405,7 +1330,8 @@ public class FeatureSettings extends JPanel
         }
       }
     });
-    final String byDensityLabel = MessageManager.getString("label.sequence_sort_by_density");
+    final String byDensityLabel = MessageManager
+            .getString("label.sequence_sort_by_density");
     JButton sortByDens = new JButton(byDensityLabel);
     sortByDens.setFont(JvSwingUtils.getLabelFont());
     sortByDens.addActionListener(new ActionListener()
@@ -1436,7 +1362,8 @@ public class FeatureSettings extends JPanel
         }
       }
     });
-    // Cancel for a SplitFrame should just revert changes to the currently displayed
+    // Cancel for a SplitFrame should just revert changes to the currently
+    // displayed
     // settings. May want to do this for either or both - so need a splitview
     // feature settings cancel/OK.
     JButton cancel = new JButton(MessageManager
@@ -1526,11 +1453,12 @@ public class FeatureSettings extends JPanel
             MessageManager.getString("label.transparency_tip"));
 
     boolean nucleotide = af.getViewport().getAlignment().isNucleotide();
-    String text = MessageManager.formatMessage("label.show_linked_features",
-            nucleotide
-                    ? MessageManager.getString("label.protein")
-                            .toLowerCase()
-                    : "CDS");
+    String text = MessageManager
+            .formatMessage("label.show_linked_features",
+                    nucleotide
+                            ? MessageManager.getString("label.protein")
+                                    .toLowerCase(Locale.ROOT)
+                            : "CDS");
     showComplement = new JCheckBox(text);
     showComplement.addActionListener(new ActionListener()
     {
@@ -1614,7 +1542,7 @@ public class FeatureSettings extends JPanel
    * 
    * @param fcol
    * @param withHint
-   *                   if true include 'click to edit' and similar text
+   *          if true include 'click to edit' and similar text
    * @return
    */
   public static String getColorTooltip(FeatureColourI fcol,