JAL-2808 pass FeatureSettings to controller as array of data bean
[jalview.git] / src / jalview / viewmodel / seqfeatures / FeatureRendererModel.java
index 4797675..8bdcad4 100644 (file)
@@ -50,16 +50,27 @@ public abstract class FeatureRendererModel
         implements jalview.api.FeatureRenderer
 {
   /*
-   * column indices of fields in Feature Settings table
-   * todo: transfer valuers as data beans instead of Object[][]
+   * a data bean to hold one row of feature settings from the gui
    */
-  public static final int TYPE_COLUMN = 0;
+  public static class FeatureSettingsBean
+  {
+    public final String featureType;
+
+    public final FeatureColourI featureColour;
 
-  public static final int COLOUR_COLUMN = 1;
+    public final KeyedMatcherSetI filter;
 
-  public static final int FILTER_COLUMN = 2;
+    public final Boolean show;
 
-  public static final int SHOW_COLUMN = 3;
+    public FeatureSettingsBean(String type, FeatureColourI colour,
+            KeyedMatcherSetI theFilter, Boolean isShown)
+    {
+      featureType = type;
+      featureColour = colour;
+      filter = theFilter;
+      show = isShown;
+    }
+  }
 
   /*
    * global transparency for feature
@@ -673,26 +684,27 @@ public abstract class FeatureRendererModel
    * Replace current ordering with new ordering
    * 
    * @param data
-   *          { String(Type), Colour(Type), Boolean(Displayed) }
+   *          an array of { Type, Colour, Filter, Boolean }
    * @return true if any visible features have been reordered, else false
    */
-  public boolean setFeaturePriority(Object[][] data)
+  public boolean setFeaturePriority(FeatureSettingsBean[] data)
   {
     return setFeaturePriority(data, true);
   }
 
   /**
-   * Sets the priority order for features, with the highest priority (displayed
-   * on top) at the start of the data array
+   * Sets the priority order for features, with the highest priority (displayed on
+   * top) at the start of the data array
    * 
    * @param data
-   *          { String(Type), Colour(Type), Boolean(Displayed) }
+   *          an array of { Type, Colour, Filter, Boolean }
    * @param visibleNew
    *          when true current featureDisplay list will be cleared
-   * @return true if any visible features have been reordered or recoloured,
-   *         else false (i.e. no need to repaint)
+   * @return true if any visible features have been reordered or recoloured, else
+   *         false (i.e. no need to repaint)
    */
-  public boolean setFeaturePriority(Object[][] data, boolean visibleNew)
+  public boolean setFeaturePriority(FeatureSettingsBean[] data,
+          boolean visibleNew)
   {
     /*
      * note visible feature ordering and colours before update
@@ -731,9 +743,9 @@ public abstract class FeatureRendererModel
     {
       for (int i = 0; i < data.length; i++)
       {
-        String type = data[i][TYPE_COLUMN].toString();
-        setColour(type, (FeatureColourI) data[i][COLOUR_COLUMN]);
-        if (((Boolean) data[i][SHOW_COLUMN]).booleanValue())
+        String type = data[i].featureType;
+        setColour(type, data[i].featureColour);
+        if (data[i].show)
         {
           av_featuresdisplayed.setVisible(type);
         }