JAL-3130 Lots of deprecation fixes. See utils/deprecation_auto_fixes.sh for commands...
[jalview.git] / src / jalview / appletgui / FeatureSettings.java
index 39a2747..489cbb1 100755 (executable)
  */
 package jalview.appletgui;
 
-import static jalview.viewmodel.seqfeatures.FeatureRendererModel.COLOUR_COLUMN;
-import static jalview.viewmodel.seqfeatures.FeatureRendererModel.SHOW_COLUMN;
-import static jalview.viewmodel.seqfeatures.FeatureRendererModel.TYPE_COLUMN;
-
 import jalview.api.FeatureColourI;
 import jalview.api.FeatureSettingsControllerI;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.SequenceI;
 import jalview.util.MessageManager;
+import jalview.viewmodel.seqfeatures.FeatureRendererModel.FeatureSettingsBean;
 
 import java.awt.BorderLayout;
 import java.awt.Button;
@@ -69,7 +66,7 @@ import java.util.Set;
 
 public class FeatureSettings extends Panel
         implements ItemListener, MouseListener, MouseMotionListener,
-        ActionListener, AdjustmentListener, FeatureSettingsControllerI
+        AdjustmentListener, FeatureSettingsControllerI
 {
   FeatureRenderer fr;
 
@@ -124,8 +121,17 @@ public class FeatureSettings extends Panel
       add(scrollPane, BorderLayout.CENTER);
     }
 
-    Button invert = new Button("Invert Selection");
-    invert.addActionListener(this);
+    Button invert = new Button(
+            MessageManager.getString("label.invert_selection"));
+    invert.addActionListener(new ActionListener()
+    {
+
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        invertSelection();
+      }
+    });
 
     Panel lowerPanel = new Panel(new GridLayout(2, 1, 5, 10));
     lowerPanel.add(invert);
@@ -549,8 +555,7 @@ public class FeatureSettings extends Panel
     }
   }
 
-  @Override
-  public void actionPerformed(ActionEvent evt)
+  protected void invertSelection()
   {
     for (int i = 0; i < featurePanel.getComponentCount(); i++)
     {
@@ -587,27 +592,19 @@ public class FeatureSettings extends Panel
   {
     Component[] comps = featurePanel.getComponents();
     int cSize = comps.length;
-
-    /*
-     * temporary! leave column[2] empty - used for Filter in
-     * gui.FeatureSettings
-     */
-    int columnCount = 4;
-    Object[][] tmp = new Object[cSize][columnCount];
-    int tmpSize = 0;
-    for (int i = 0; i < cSize; i++)
-    {
-      MyCheckbox check = (MyCheckbox) comps[i];
-      tmp[tmpSize][TYPE_COLUMN /* 0 */] = check.type;
-      tmp[tmpSize][COLOUR_COLUMN /* 1 */] = fr.getFeatureStyle(check.type);
-      tmp[tmpSize][SHOW_COLUMN /* 3 */] = new Boolean(check.getState());
-      tmpSize++;
+    FeatureSettingsBean[] rowData = new FeatureSettingsBean[cSize];
+    int i = 0;
+    for (Component comp : comps)
+    {
+      MyCheckbox check = (MyCheckbox) comp;
+      // feature filter set to null as not (yet) offered in applet
+      FeatureColourI colour = fr.getFeatureStyle(check.type);
+      rowData[i] = new FeatureSettingsBean(check.type, colour, null,
+              check.getState());
+      i++;
     }
 
-    Object[][] data = new Object[tmpSize][columnCount];
-    System.arraycopy(tmp, 0, data, 0, tmpSize);
-
-    fr.setFeaturePriority(data);
+    fr.setFeaturePriority(rowData);
 
     ap.paintAlignment(updateOverview, updateOverview);
   }
@@ -706,7 +703,7 @@ public class FeatureSettings extends Panel
   public void mouseClicked(MouseEvent evt)
   {
     MyCheckbox check = (MyCheckbox) evt.getSource();
-    if ((evt.getModifiers() & InputEvent.BUTTON3_MASK) != 0)
+    if ((evt.getModifiersEx() & InputEvent.BUTTON3_DOWN_MASK) != 0)
     {
       this.popupSort(check, fr.getMinMax(), evt.getX(), evt.getY());
     }