Merge branch 'develop' into features/JAL-3010ontologyFeatureSettings
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 24 May 2019 14:29:31 +0000 (15:29 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 24 May 2019 14:29:31 +0000 (15:29 +0100)
1  2 
resources/lang/Messages.properties
resources/lang/Messages_es.properties
src/jalview/bin/Jalview.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/FeatureSettings.java
src/jalview/gui/FeatureTypeSettings.java

@@@ -32,6 -32,7 +32,7 @@@ action.load_project = Load Projec
  action.save_project = Save Project
  action.save_project_as = Save Project as...
  action.quit = Quit
+ label.quit_jalview = Quit Jalview?
  action.expand_views = Expand Views
  action.gather_views = Gather Views
  action.page_setup = Page Setup...
@@@ -800,7 -801,6 +801,7 @@@ label.rest_client_submit = {0} using {1
  label.fetch_retrieve_from =Retrieve from {0}</html>
  label.fetch_retrieve_from_all_sources = Retrieve from all {0} sources in {1}<br>First is :{2}<html> 
  label.feature_settings_click_drag = Drag up or down to change render order.<br/>Double click to select columns containing feature.
 +label.feature_settings_select_columns = Double click to select columns containing feature
  label.transparency_tip = Adjust transparency to 'see through' feature colours.
  label.opt_and_params_further_details = see further details by right-clicking
  label.opt_and_params_show_brief_desc_image_link = <html>Click to show brief description<br><img src="{0}"/> Right click for further information.</html> 
@@@ -1314,6 -1314,7 +1315,7 @@@ label.numeric_required = The value shou
  label.filter = Filter
  label.filters = Filters
  label.join_conditions = Join conditions with
+ label.delete_condition = Delete this condition
  label.score = Score
  label.colour_by_label = Colour by label
  label.variable_colour = Variable colour...
@@@ -1338,10 -1339,6 +1340,10 @@@ label.most_bound_molecules = Most Boun
  label.most_polymer_residues = Most Polymer Residues
  label.cached_structures = Cached Structures
  label.free_text_search = Free Text Search
 +label.summary_view = Summary View
 +label.group_by_so = Group features by Sequence Ontology
 +label.apply_to_subtypes = Apply to features and sub-types of
 +label.apply_also_to = Apply also to:
  label.backupfiles_confirm_delete = Confirm delete
  label.backupfiles_confirm_delete_old_files = Delete the following older backup files? (see the Backups tab in Preferences for more options)
  label.backupfiles_confirm_save_file = Confirm save file
@@@ -32,6 -32,7 +32,7 @@@ action.load_project = Cargar proyect
  action.save_project = Guardar proyecto
  action.save_project_as = Guardar proyecto como...
  action.quit = Salir
+ label.quit_jalview = Salir de Jalview?
  action.expand_views = Expandir vistas
  action.gather_views = Capturar vistas
  action.page_setup = Configuración de la página
@@@ -725,8 -726,7 +726,8 @@@ label.services_at = Servicios en {0
  label.rest_client_submit = {0} utilizando {1}
  label.fetch_retrieve_from =Recuperar de {0}
  label.fetch_retrieve_from_all_sources = Recuperar de todas las fuentes {0} en {1}<br>La primera es :{2}
 -label.feature_settings_click_drag = Haga clic o arrastre los tipos de las características hacia arriba o hacia abajo para cambiar el orden de visualización.<br/>Haga doble clic para seleccionar las columnas que contienen las características del alineamiento/selección actual.<br/>
 +label.feature_settings_click_drag = Haga clic o arrastre los tipos de las características hacia arriba o hacia abajo para cambiar el orden de visualización.<br/>Haga doble clic para seleccionar las columnas que contienen las características del alineamiento/selección actual.
 +label.feature_settings_select_columns =Haga doble clic para seleccionar las columnas que contienen las características del alineamiento/selección actual
  label.opt_and_params_further_details = ver los detalles adicionales haciendo clic en el botón derecho
  label.opt_and_params_show_brief_desc_image_link = Haga clic para ver una descripción breve<br><img src="{0}"/>Haga clic en el botón derecho para obtener información adicional.
  label.opt_and_params_show_brief_desc = Haga clic para ver una descripción breve<br>
@@@ -1314,6 -1314,7 +1315,7 @@@ label.matchCondition_ge = >
  label.numeric_required = Valor numérico requerido
  label.filter = Filtro
  label.filters = Filtros
+ label.delete_condition = Borrar esta condición
  label.join_conditions = Combinar condiciones con
  label.score = Puntuación
  label.colour_by_label = Colorear por texto
@@@ -1339,10 -1340,6 +1341,10 @@@ label.most_bound_molecules = Más Molécu
  label.most_polymer_residues = Más Residuos de Polímeros
  label.cached_structures = Estructuras en Caché
  label.free_text_search = Búsqueda de texto libre
 +label.summary_view = Vista Resumida
 +label.group_by_so = Agrupar por términos de la Sequence Ontology
 +label.apply_to_subtypes = Aplicar también a características y subtipos de
 +label.apply_also_to = Aplicar también a:
  label.backupfiles_confirm_delete = Confirmar borrar
  label.backupfiles_confirm_delete_old_files = ¿Borrar los siguientes archivos? (ver la pestaña 'Copias' de la ventana de Preferencias para más opciones)
  label.backupfiles_confirm_save_file = Confirmar guardar archivo
@@@ -64,6 -64,8 +64,8 @@@ import java.util.Vector
  import javax.swing.LookAndFeel;
  import javax.swing.UIManager;
  
+ import com.threerings.getdown.util.LaunchUtil;
  import groovy.lang.Binding;
  import groovy.util.GroovyScriptEngine;
  
@@@ -105,7 -107,7 +107,7 @@@ public class Jalvie
          perms.add(new AllPermission());
          return (perms);
        }
+     
        @Override
        public void refresh()
        {
              + System.getProperty("os.name") + " "
              + System.getProperty("os.version"));
  
+     String appdirString = System.getProperty("getdownappdir");
+     if (appdirString != null && appdirString.length() > 0)
+     {
+       final File appdir = new File(appdirString);
+       new Thread()
+       {
+         @Override
+         public void run()
+         {
+           LaunchUtil.upgradeGetdown(
+                   new File(appdir, "getdown-launcher-old.jar"),
+                   new File(appdir, "getdown-launcher.jar"),
+                   new File(appdir, "getdown-launcher-new.jar"));
+         }
+       }.start();
+     }
      ArgsParser aparser = new ArgsParser(args);
      boolean headless = false;
  
       * configure 'full' SO model if preferences say to, 
       * else use the default (SO Lite)
       */
 -    if (Cache.getDefault("USE_FULL_SO", false))
 +    if (Cache.getDefault("USE_FULL_SO", true))
      {
        SequenceOntologyFactory.setInstance(new SequenceOntology());
      }
      {
        desktop = new Desktop();
        desktop.setInBatchMode(true); // indicate we are starting up
+       try
+       {
+         JalviewTaskbar.setTaskbar(this);
+       } catch (Exception e)
+       {
+         e.printStackTrace();
+       } catch (Throwable t)
+       {
+         t.printStackTrace();
+       }
        desktop.setVisible(true);
        desktop.startServiceDiscovery();
        if (!aparser.contains("nousagestats"))
      }
      try
      {
-       Map<String, Object> vbinding = new HashMap<>();
+       Map<String, java.lang.Object> vbinding = new HashMap<>();
        vbinding.put("Jalview", this);
        if (af != null)
        {
@@@ -1203,7 -1203,23 +1203,23 @@@ public class AlignFrame extends GAlignF
            PrintWriter out = new PrintWriter(
                    new FileWriter(backupfiles.getTempFilePath()));
  
+           // TESTING code here
+           boolean TESTING = true;
+           if (TESTING)
+           {
+             out.print("; TESTSTART\n");
+             int count = 20;
+             for (int i = 0; i < count; i++)
+             {
+               // Thread.sleep(1000);
+               out.println("; TEST: " + (count - 1 - i));
+             }
+           }
            out.print(output);
+           if (TESTING)
+           {
+             out.print("; TESTEND\n");
+           }
            out.close();
            this.setTitle(file);
            statusBar.setText(MessageManager.formatMessage(
                      newGraphGroups.add(q, null);
                    }
                    newGraphGroups.set(newann.graphGroup,
-                           new Integer(++fgroup));
+                           Integer.valueOf(++fgroup));
                  }
                  newann.graphGroup = newGraphGroups.get(newann.graphGroup)
                          .intValue();
                      newGraphGroups.add(q, null);
                    }
                    newGraphGroups.set(newann.graphGroup,
-                           new Integer(++fgroup));
+                           Integer.valueOf(++fgroup));
                  }
                  newann.graphGroup = newGraphGroups.get(newann.graphGroup)
                          .intValue();
              int assocfiles = 0;
              if (filesmatched.size() > 0)
              {
-               boolean autoAssociate = Cache.getDefault("AUTOASSOCIATE_PDBANDSEQS", false);
+               boolean autoAssociate = Cache
+                       .getDefault("AUTOASSOCIATE_PDBANDSEQS", false);
                if (!autoAssociate)
                {
                  String msg = MessageManager.formatMessage(
    }
  
    /**
 -   * Hides columns containing (or not containing) a specified feature, provided
 -   * that would not leave all columns hidden
 +   * Hides columns containing (or not containing) the specified feature(s),
 +   * provided that would not leave all columns hidden
     * 
 -   * @param featureType
     * @param columnsContaining
 +   * @param featureTypes
 +   * 
     * @return
     */
 -  public boolean hideFeatureColumns(String featureType,
 -          boolean columnsContaining)
 +  public boolean hideFeatureColumns(boolean columnsContaining,
 +          String... featureTypes)
    {
      boolean notForHiding = avc.markColumnsContainingFeatures(
 -            columnsContaining, false, false, featureType);
 +            columnsContaining, false, false, featureTypes);
      if (notForHiding)
      {
        if (avc.markColumnsContainingFeatures(!columnsContaining, false,
 -              false, featureType))
 +              false, featureTypes))
        {
          getViewport().hideSelectedColumns();
          return true;
@@@ -28,11 -28,9 +28,11 @@@ import jalview.datamodel.features.Featu
  import jalview.datamodel.features.FeatureMatcherI;
  import jalview.datamodel.features.FeatureMatcherSet;
  import jalview.datamodel.features.FeatureMatcherSetI;
 +import jalview.datamodel.ontology.OntologyI;
  import jalview.gui.Help.HelpId;
  import jalview.io.JalviewFileChooser;
  import jalview.io.JalviewFileView;
 +import jalview.io.gff.SequenceOntologyFactory;
  import jalview.schemes.FeatureColour;
  import jalview.util.MessageManager;
  import jalview.util.Platform;
@@@ -66,7 -64,6 +66,7 @@@ import java.io.FileOutputStream
  import java.io.InputStreamReader;
  import java.io.OutputStreamWriter;
  import java.io.PrintWriter;
 +import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.Comparator;
  import java.util.HashMap;
@@@ -95,7 -92,6 +95,7 @@@ import javax.swing.JScrollPane
  import javax.swing.JSlider;
  import javax.swing.JTable;
  import javax.swing.ListSelectionModel;
 +import javax.swing.RowFilter;
  import javax.swing.SwingConstants;
  import javax.swing.border.Border;
  import javax.swing.event.ChangeEvent;
@@@ -105,7 -101,6 +105,7 @@@ import javax.swing.table.JTableHeader
  import javax.swing.table.TableCellEditor;
  import javax.swing.table.TableCellRenderer;
  import javax.swing.table.TableColumn;
 +import javax.swing.table.TableRowSorter;
  import javax.xml.bind.JAXBContext;
  import javax.xml.bind.JAXBElement;
  import javax.xml.bind.Marshaller;
@@@ -115,8 -110,6 +115,8 @@@ import javax.xml.stream.XMLStreamReader
  public class FeatureSettings extends JPanel
          implements FeatureSettingsControllerI
  {
 +  private static final Font VERDANA_12 = new Font("Verdana", Font.PLAIN, 12);
 +
    private static final String SEQUENCE_FEATURE_COLOURS = MessageManager
            .getString("label.sequence_feature_colours");
  
     */
    Map<String, float[]> typeWidth = null;
  
 +  /*
 +   * if true, 'child' feature types are not displayed
 +   */
 +  JCheckBox summaryView;
 +
 +  /*
 +   * those feature types that do not have a parent feature type present
 +   * (as determined by an Ontology relationship)
 +   */
 +  List<String> topLevelTypes;
 +
    /**
     * Constructor
     * 
  
      originalFilters = new HashMap<>(fr.getFeatureFilters()); // shallow copy
  
 +    topLevelTypes = new ArrayList<>();
 +
      try
      {
        jbInit();
        ex.printStackTrace();
      }
  
 +    initTable();
 +
 +    scrollPane.setViewportView(table);
 +
 +    if (af.getViewport().isShowSequenceFeatures() || !fr.hasRenderOrder())
 +    {
 +      fr.findAllFeatures(true); // display everything!
 +    }
 +
 +    discoverAllFeatureData();
 +    final PropertyChangeListener change;
 +    final FeatureSettings fs = this;
 +    fr.addPropertyChangeListener(change = new PropertyChangeListener()
 +    {
 +      @Override
 +      public void propertyChange(PropertyChangeEvent evt)
 +      {
 +        if (!fs.resettingTable && !fs.handlingUpdate)
 +        {
 +          fs.handlingUpdate = true;
 +          fs.resetTable(null);
 +          // new groups may be added with new sequence feature types only
 +          fs.handlingUpdate = false;
 +        }
 +      }
 +    });
 +
 +    frame = new JInternalFrame();
 +    frame.setContentPane(this);
 +    if (Platform.isAMac())
 +    {
 +      Desktop.addInternalFrame(frame,
 +              MessageManager.getString("label.sequence_feature_settings"),
 +              600, 480);
 +    }
 +    else
 +    {
 +      Desktop.addInternalFrame(frame,
 +              MessageManager.getString("label.sequence_feature_settings"),
 +              600, 450);
 +    }
 +    frame.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT));
 +
 +    frame.addInternalFrameListener(
 +            new javax.swing.event.InternalFrameAdapter()
 +            {
 +              @Override
 +              public void internalFrameClosed(
 +                      javax.swing.event.InternalFrameEvent evt)
 +              {
 +                fr.removePropertyChangeListener(change);
 +              };
 +            });
 +    frame.setLayer(JLayeredPane.PALETTE_LAYER);
 +    inConstruction = false;
 +  }
 +
 +  /**
 +   * Constructs and configures the JTable which displays columns of data for
 +   * each feature type
 +   */
 +  protected void initTable()
 +  {
      table = new JTable()
      {
        @Override
          String tip = null;
          int column = table.columnAtPoint(e.getPoint());
          int row = table.rowAtPoint(e.getPoint());
          switch (column)
          {
          case TYPE_COLUMN:
 -          tip = JvSwingUtils.wrapTooltip(true, MessageManager
 +          /*
 +           * drag to reorder not enabled in Summary View
 +           */
 +          tip = summaryView.isSelected()
 +                  ? MessageManager.getString(
 +                          "label.feature_settings_select_columns")
 +                  : JvSwingUtils.wrapTooltip(true, MessageManager
                    .getString("label.feature_settings_click_drag"));
            break;
          case COLOUR_COLUMN:
          default:
            break;
          }
 -        
          return tip;
        }
  
          return loc;
        }
      };
 +
      JTableHeader tableHeader = table.getTableHeader();
 -    tableHeader.setFont(new Font("Verdana", Font.PLAIN, 12));
 +    tableHeader.setFont(VERDANA_12);
      tableHeader.setReorderingAllowed(false);
 -    table.setFont(new Font("Verdana", Font.PLAIN, 12));
 +    table.setFont(VERDANA_12);
  
      table.setDefaultEditor(FeatureColour.class, new ColorEditor(this));
      table.setDefaultRenderer(FeatureColour.class, new ColorRenderer());
          String type = (String) table.getValueAt(selectedRow, TYPE_COLUMN);
          if (evt.isPopupTrigger())
          {
 -          Object colour = table.getValueAt(selectedRow, COLOUR_COLUMN);
 -          popupSort(selectedRow, type, colour, fr.getMinMax(), evt.getX(),
 -                  evt.getY());
 +          popupMenu(selectedRow, type, evt.getX(), evt.getY());
          }
          else if (evt.getClickCount() == 2)
          {
            boolean invertSelection = evt.isAltDown();
            boolean toggleSelection = Platform.isControlDown(evt);
            boolean extendSelection = evt.isShiftDown();
 +          String[] terms = getTermsInScope(type);
            fr.ap.alignFrame.avc.markColumnsContainingFeatures(
 -                  invertSelection, extendSelection, toggleSelection, type);
 +                  invertSelection, extendSelection, toggleSelection, terms);
          }
        }
  
          if (evt.isPopupTrigger())
          {
            String type = (String) table.getValueAt(selectedRow, TYPE_COLUMN);
 -          Object colour = table.getValueAt(selectedRow, COLOUR_COLUMN);
 -          popupSort(selectedRow, type, colour, fr.getMinMax(), evt.getX(),
 -                  evt.getY());
 +          popupMenu(selectedRow, type, evt.getX(), evt.getY());
          }
        }
      });
        public void mouseDragged(MouseEvent evt)
        {
          int newRow = table.rowAtPoint(evt.getPoint());
 -        if (newRow != selectedRow && selectedRow != -1 && newRow != -1)
 -        {
 -          /*
 -           * reposition 'selectedRow' to 'newRow' (the dragged to location)
 -           * this could be more than one row away for a very fast drag action
 -           * so just swap it with adjacent rows until we get it there
 -           */
 -          Object[][] data = ((FeatureTableModel) table.getModel())
 -                  .getData();
 -          int direction = newRow < selectedRow ? -1 : 1;
 -          for (int i = selectedRow; i != newRow; i += direction)
 -          {
 -            Object[] temp = data[i];
 -            data[i] = data[i + direction];
 -            data[i + direction] = temp;
 -          }
 -          updateFeatureRenderer(data);
 -          table.repaint();
 -          selectedRow = newRow;
 -        }
 +        dragRow(newRow);
        }
      });
 -    // table.setToolTipText(JvSwingUtils.wrapTooltip(true,
 -    // MessageManager.getString("label.feature_settings_click_drag")));
 -    scrollPane.setViewportView(table);
 +  }
  
 -    if (af.getViewport().isShowSequenceFeatures() || !fr.hasRenderOrder())
 +  /**
 +   * Answers an array consisting of the given type, and also (if 'Summary View'
 +   * is selected), any feature types which are child terms of it in the Sequence
 +   * Ontology
 +   * 
 +   * @param type
 +   * @return
 +   */
 +  protected String[] getTermsInScope(String type)
 +  {
 +    if (!summaryView.isSelected())
      {
 -      fr.findAllFeatures(true); // display everything!
 +      return new String[] { type };
      }
  
 -    discoverAllFeatureData();
 -    final PropertyChangeListener change;
 -    final FeatureSettings fs = this;
 -    fr.addPropertyChangeListener(change = new PropertyChangeListener()
 -    {
 -      @Override
 -      public void propertyChange(PropertyChangeEvent evt)
 -      {
 -        if (!fs.resettingTable && !fs.handlingUpdate)
 -        {
 -          fs.handlingUpdate = true;
 -          fs.resetTable(null);
 -          // new groups may be added with new sequence feature types only
 -          fs.handlingUpdate = false;
 -        }
 -      }
 +    List<String> terms = new ArrayList<>();
 +    terms.add(type);
  
 -    });
 +    OntologyI so = SequenceOntologyFactory.getInstance();
  
 -    frame = new JInternalFrame();
 -    frame.setContentPane(this);
 -    if (Platform.isAMac())
 -    {
 -      Desktop.addInternalFrame(frame,
 -              MessageManager.getString("label.sequence_feature_settings"),
 -              600, 480);
 -    }
 -    else
 +    Object[][] data = ((FeatureTableModel) table.getModel()).getData();
 +    for (Object[] row : data)
      {
 -      Desktop.addInternalFrame(frame,
 -              MessageManager.getString("label.sequence_feature_settings"),
 -              600, 450);
 +      String type2 = (String) row[TYPE_COLUMN];
 +      if (!type2.equals(type) && so.isA(type2, type))
 +      {
 +        terms.add(type2);
 +      }
      }
 -    frame.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT));
 -
 -    frame.addInternalFrameListener(
 -            new javax.swing.event.InternalFrameAdapter()
 -            {
 -              @Override
 -              public void internalFrameClosed(
 -                      javax.swing.event.InternalFrameEvent evt)
 -              {
 -                fr.removePropertyChangeListener(change);
 -              };
 -            });
 -    frame.setLayer(JLayeredPane.PALETTE_LAYER);
 -    inConstruction = false;
 +    return terms.toArray(new String[terms.size()]);
    }
  
 -  protected void popupSort(final int rowSelected, final String type,
 -          final Object typeCol, final Map<String, float[][]> minmax, int x,
 +  protected void popupMenu(final int rowSelected, final String type, int x,
            int y)
    {
 -    final FeatureColourI featureColour = (FeatureColourI) typeCol;
 -
      JPopupMenu men = new JPopupMenu(MessageManager
              .formatMessage("label.settings_for_param", new String[]
              { type }));
      final FeatureSettings me = this;
      scr.addActionListener(new ActionListener()
      {
        @Override
        public void actionPerformed(ActionEvent e)
        {
 -        me.af.avc
 -                .sortAlignmentByFeatureScore(Arrays.asList(new String[]
 -                { type }));
 +        String[] types = getTermsInScope(type);
 +        me.af.avc.sortAlignmentByFeatureScore(Arrays.asList(types));
        }
 -
      });
      JMenuItem dens = new JMenuItem(
              MessageManager.getString("label.sort_by_density"));
      dens.addActionListener(new ActionListener()
      {
        @Override
        public void actionPerformed(ActionEvent e)
        {
 -        me.af.avc
 -                .sortAlignmentByFeatureDensity(Arrays.asList(new String[]
 -                { type }));
 +        String[] types = getTermsInScope(type);
 +        me.af.avc.sortAlignmentByFeatureDensity(Arrays.asList(types));
        }
 -
      });
      men.add(dens);
  
        @Override
        public void actionPerformed(ActionEvent arg0)
        {
 +        String[] types = getTermsInScope(type);
          fr.ap.alignFrame.avc.markColumnsContainingFeatures(false, false,
 -                false, type);
 +                false, types);
        }
      });
      JMenuItem clearCols = new JMenuItem(MessageManager
        @Override
        public void actionPerformed(ActionEvent arg0)
        {
 +        String[] types = getTermsInScope(type);
          fr.ap.alignFrame.avc.markColumnsContainingFeatures(true, false,
 -                false, type);
 +                false, types);
        }
      });
      JMenuItem hideCols = new JMenuItem(
        @Override
        public void actionPerformed(ActionEvent arg0)
        {
 -        fr.ap.alignFrame.hideFeatureColumns(type, true);
 +        String[] types = getTermsInScope(type);
 +        fr.ap.alignFrame.hideFeatureColumns(true, types);
        }
      });
      JMenuItem hideOtherCols = new JMenuItem(
        @Override
        public void actionPerformed(ActionEvent arg0)
        {
 -        fr.ap.alignFrame.hideFeatureColumns(type, false);
 +        String[] types = getTermsInScope(type);
 +        fr.ap.alignFrame.hideFeatureColumns(false, types);
        }
      });
      men.add(selCols);
         */
        Set<String> types = seq.getFeatures().getFeatureTypesForGroups(true,
                visibleGroups.toArray(new String[visibleGroups.size()]));
 +
        for (String type : types)
        {
          displayableTypes.add(type);
        }
      }
  
 +    /*
 +     * enable 'Summary View' if some types are sub-types of others
 +     */
 +    Set<String> parents = SequenceOntologyFactory.getInstance()
 +            .getParentTerms(displayableTypes);
 +    summaryView.setEnabled(parents.size() < displayableTypes.size());
 +
      Object[][] data = new Object[displayableTypes.size()][COLUMN_COUNT];
      int dataIndex = 0;
  
          {
            continue;
          }
 -
          data[dataIndex][TYPE_COLUMN] = type;
          data[dataIndex][COLOUR_COLUMN] = fr.getFeatureStyle(type);
          FeatureMatcherSetI featureFilter = fr.getFeatureFilter(type);
          data[dataIndex][FILTER_COLUMN] = featureFilter == null
                  ? new FeatureMatcherSet()
                  : featureFilter;
-         data[dataIndex][SHOW_COLUMN] = new Boolean(
+         data[dataIndex][SHOW_COLUMN] = Boolean.valueOf(
                  af.getViewport().getFeaturesDisplayed().isVisible(type));
          dataIndex++;
          displayableTypes.remove(type);
        data[dataIndex][FILTER_COLUMN] = featureFilter == null
                ? new FeatureMatcherSet()
                : featureFilter;
-       data[dataIndex][SHOW_COLUMN] = new Boolean(true);
+       data[dataIndex][SHOW_COLUMN] = Boolean.valueOf(true);
        dataIndex++;
        displayableTypes.remove(type);
      }
        updateOriginalData(data);
      }
  
 -    table.setModel(new FeatureTableModel(data));
 +    /*
 +     * recreate the table model
 +     */
 +    FeatureTableModel dataModel = new FeatureTableModel(data);
 +    table.setModel(dataModel);
 +
 +    /*
 +     * we want to be able to filter out rows for sub-types, but not to sort 
 +     * rows, so have to add a RowFilter to a disabled TableRowSorter (!)
 +     */
 +    final TableRowSorter<FeatureTableModel> sorter = new TableRowSorter<>(
 +            dataModel);
 +    for (int i = 0; i < table.getColumnCount(); i++)
 +    {
 +      sorter.setSortable(i, false);
 +    }
 +
 +    /*
 +     * filter rows to only top-level Ontology types if requested
 +     */
 +    sorter.setRowFilter(new RowFilter<FeatureTableModel, Integer>()
 +    {
 +      @Override
 +      public boolean include(
 +              Entry<? extends FeatureTableModel, ? extends Integer> entry)
 +      {
 +        if (!summaryView.isSelected())
 +        {
 +          return true;
 +        }
 +        int row = entry.getIdentifier(); // this is model, not view, row number
 +        String featureType = (String) entry.getModel().getData()[row][TYPE_COLUMN];
 +        return parents.contains(featureType);
 +      }
 +    });
 +    table.setRowSorter(sorter);
 +
      table.getColumnModel().getColumn(0).setPreferredWidth(200);
  
      groupPanel.setLayout(
        }
      });
  
 +    summaryView = new JCheckBox(
 +            MessageManager.getString("label.summary_view"));
 +    summaryView
 +            .setToolTipText(
 +                    MessageManager.getString("label.group_by_so"));
 +    summaryView.addActionListener(new ActionListener()
 +    {
 +      @Override
 +      public void actionPerformed(ActionEvent e)
 +      {
 +        resetTable(null);
 +      }
 +    });
 +
      transparency.setMaximum(70);
      transparency.setToolTipText(
              MessageManager.getString("label.transparency_tip"));
  
 -    JPanel transPanel = new JPanel(new GridLayout(1, 2));
 -    bigPanel.add(transPanel, BorderLayout.SOUTH);
 +    JPanel lowerPanel = new JPanel(new GridLayout(1, 2));
 +    bigPanel.add(lowerPanel, BorderLayout.SOUTH);
  
      JPanel transbuttons = new JPanel(new GridLayout(5, 1));
      transbuttons.add(optimizeOrder);
      transbuttons.add(sortByScore);
      transbuttons.add(sortByDens);
      transbuttons.add(help);
 +    JPanel transPanel = new JPanel(new GridLayout(3, 1));
 +    transPanel.add(summaryView);
 +    transPanel.add(new JLabel(" Colour transparency" + ":"));
      transPanel.add(transparency);
 -    transPanel.add(transbuttons);
 +    lowerPanel.add(transPanel);
 +    lowerPanel.add(transbuttons);
  
      JPanel buttonPanel = new JPanel();
      buttonPanel.add(ok);
    }
  
    /**
 +   * Reorders features by 'dragging' selectedRow to 'newRow'
 +   * 
 +   * @param newRow
 +   */
 +  protected void dragRow(int newRow)
 +  {
 +    if (summaryView.isSelected())
 +    {
 +      // no drag while in summary view
 +      return;
 +    }
 +
 +    if (newRow != selectedRow && selectedRow != -1 && newRow != -1)
 +    {
 +      /*
 +       * reposition 'selectedRow' to 'newRow' (the dragged to location)
 +       * this could be more than one row away for a very fast drag action
 +       * so just swap it with adjacent rows until we get it there
 +       */
 +      Object[][] data = ((FeatureTableModel) table.getModel())
 +              .getData();
 +      int direction = newRow < selectedRow ? -1 : 1;
 +      for (int i = selectedRow; i != newRow; i += direction)
 +      {
 +        Object[] temp = data[i];
 +        data[i] = data[i + direction];
 +        data[i + direction] = temp;
 +      }
 +      updateFeatureRenderer(data);
 +      table.repaint();
 +      selectedRow = newRow;
 +    }
 +  }
 +
 +  protected void refreshTable()
 +  {
 +    Object[][] data = ((FeatureTableModel) table.getModel()).getData();
 +    for (Object[] row : data)
 +    {
 +      String type = (String) row[TYPE_COLUMN];
 +      FeatureColourI colour = fr.getFeatureColours().get(type);
 +      FeatureMatcherSetI filter = fr.getFeatureFilter(type);
 +      if (filter == null)
 +      {
 +        filter = new FeatureMatcherSet();
 +      }
 +      row[COLOUR_COLUMN] = colour;
 +      row[FILTER_COLUMN] = filter;
 +    }
 +    repaint();
 +  }
 +
 +  /*
     * Answers a suitable tooltip to show on the colour cell of the table
     * 
     * @param fcol
      }
  
      /**
 -     * Answers the class of the object in column c of the first row of the table
 +     * Answers the class of column c of the table
       */
      @Override
      public Class<?> getColumnClass(int c)
      {
 -      Object v = getValueAt(0, c);
 -      return v == null ? null : v.getClass();
 +      switch (c)
 +      {
 +      case TYPE_COLUMN:
 +        return String.class;
 +      case COLOUR_COLUMN:
 +        return FeatureColour.class;
 +      case FILTER_COLUMN:
 +        return FeatureMatcherSet.class;
 +      default:
 +        return Boolean.class;
 +      }
      }
  
 +    /**
 +     * Answers true for all columns except Feature Type
 +     */
      @Override
      public boolean isCellEditable(int row, int col)
      {
 -      return col == 0 ? false : true;
 +      return col != TYPE_COLUMN;
      }
  
 +    /**
 +     * Sets the value in the model for a given row and column. If Visibility
 +     * (Show/Hide) is being set, and the table is in Summary View, then it is
 +     * set also on any sub-types of the row's feature type.
 +     */
      @Override
      public void setValueAt(Object value, int row, int col)
      {
        data[row][col] = value;
        fireTableCellUpdated(row, col);
 +      if (summaryView.isSelected() && col == SHOW_COLUMN)
 +      {
 +        setSubtypesVisibility(row, (Boolean) value);
 +      }
        updateFeatureRenderer(data);
      }
  
 +    /**
 +     * Sets the visibility of any feature types which are sub-types of the type
 +     * in the given row of the table
 +     * 
 +     * @param row
 +     * @param value
 +     */
 +    protected void setSubtypesVisibility(int row, Boolean value)
 +    {
 +      String type = (String) data[row][TYPE_COLUMN];
 +      OntologyI so = SequenceOntologyFactory.getInstance();
 +
 +      for (int r = 0; r < data.length; r++)
 +      {
 +        if (r != row)
 +        {
 +          String type2 = (String) data[r][TYPE_COLUMN];
 +          if (so.isA(type2, type))
 +          {
 +            data[r][SHOW_COLUMN] = value;
 +            fireTableCellUpdated(r, SHOW_COLUMN);
 +          }
 +        }
 +      }
 +    }
    }
  
    class ColorRenderer extends JLabel implements TableCellRenderer
  
      String type;
  
 -    JButton button;
 +    JButton colourButton;
  
      JColorChooser colorChooser;
  
        // which is a button.
        // This button brings up the color chooser dialog,
        // which is the editor from the user's point of view.
 -      button = new JButton();
 -      button.setActionCommand(EDIT);
 -      button.addActionListener(this);
 -      button.setBorderPainted(false);
 +      colourButton = new JButton();
 +      colourButton.setActionCommand(EDIT);
 +      colourButton.addActionListener(this);
 +      colourButton.setBorderPainted(false);
        // Set up the dialog that the button brings up.
        colorChooser = new JColorChooser();
 -      dialog = JColorChooser.createDialog(button,
 +      dialog = JColorChooser.createDialog(colourButton,
                MessageManager.getString("label.select_colour"), true, // modal
                colorChooser, this, // OK button handler
                null); // no CANCEL button handler
          if (currentColor.isSimpleColour())
          {
            // bring up simple color chooser
 -          button.setBackground(currentColor.getColour());
 +          colourButton.setBackground(currentColor.getColour());
            colorChooser.setColor(currentColor.getColour());
            dialog.setVisible(true);
          }
          {
            // bring up graduated chooser.
            chooser = new FeatureTypeSettings(me.fr, type);
 -          /**
 -           * @j2sNative
 -           */
 -          {
 -            chooser.setRequestFocusEnabled(true);
 -            chooser.requestFocus();
 -          }
 +          chooser.setRequestFocusEnabled(true);
 +          chooser.requestFocus();
            chooser.addActionListener(this);
            // Make the renderer reappear.
            fireEditingStopped();
             * (or filters!) are already set in FeatureRenderer, so just
             * update table data without triggering updateFeatureRenderer
             */
 -          currentColor = fr.getFeatureColours().get(type);
 -          FeatureMatcherSetI currentFilter = me.fr.getFeatureFilter(type);
 -          if (currentFilter == null)
 -          {
 -            currentFilter = new FeatureMatcherSet();
 -          }
 -          Object[] data = ((FeatureTableModel) table.getModel())
 -                  .getData()[rowSelected];
 -          data[COLOUR_COLUMN] = currentColor;
 -          data[FILTER_COLUMN] = currentFilter;
 +          refreshTable();
          }
          fireEditingStopped();
          me.table.validate();
        currentColor = (FeatureColourI) value;
        this.rowSelected = row;
        type = me.table.getValueAt(row, TYPE_COLUMN).toString();
 -      button.setOpaque(true);
 -      button.setBackground(me.getBackground());
 +      colourButton.setOpaque(true);
 +      colourButton.setBackground(me.getBackground());
        if (!currentColor.isSimpleColour())
        {
          JLabel btn = new JLabel();
 -        btn.setSize(button.getSize());
 +        btn.setSize(colourButton.getSize());
          FeatureSettings.renderGraduatedColor(btn, currentColor);
 -        button.setBackground(btn.getBackground());
 -        button.setIcon(btn.getIcon());
 -        button.setText(btn.getText());
 +        colourButton.setBackground(btn.getBackground());
 +        colourButton.setIcon(btn.getIcon());
 +        colourButton.setText(btn.getText());
        }
        else
        {
 -        button.setText("");
 -        button.setIcon(null);
 -        button.setBackground(currentColor.getColour());
 +        colourButton.setText("");
 +        colourButton.setIcon(null);
 +        colourButton.setBackground(currentColor.getColour());
        }
 -      return button;
 +      return colourButton;
      }
    }
  
  
      String type;
  
 -    JButton button;
 +    JButton filterButton;
  
      protected static final String EDIT = "edit";
  
      public FilterEditor(FeatureSettings me)
      {
        this.me = me;
 -      button = new JButton();
 -      button.setActionCommand(EDIT);
 -      button.addActionListener(this);
 -      button.setBorderPainted(false);
 +      filterButton = new JButton();
 +      filterButton.setActionCommand(EDIT);
 +      filterButton.addActionListener(this);
 +      filterButton.setBorderPainted(false);
      }
  
      /**
      @Override
      public void actionPerformed(ActionEvent e)
      {
 -      if (button == e.getSource())
 +      if (filterButton == e.getSource())
        {
          FeatureTypeSettings chooser = new FeatureTypeSettings(me.fr, type);
          chooser.addActionListener(this);
        }
        else if (e.getSource() instanceof Component)
        {
 -
          /*
           * after OK in variable colour dialog, any changes to filter
           * (or colours!) are already set in FeatureRenderer, so just
           * update table data without triggering updateFeatureRenderer
           */
 -        FeatureColourI currentColor = fr.getFeatureColours().get(type);
 -        currentFilter = me.fr.getFeatureFilter(type);
 -        if (currentFilter == null)
 -        {
 -          currentFilter = new FeatureMatcherSet();
 -        }
 -        Object[] data = ((FeatureTableModel) table.getModel())
 -                .getData()[rowSelected];
 -        data[COLOUR_COLUMN] = currentColor;
 -        data[FILTER_COLUMN] = currentFilter;
 +        refreshTable();
          fireEditingStopped();
          me.table.validate();
        }
        currentFilter = (FeatureMatcherSetI) value;
        this.rowSelected = row;
        type = me.table.getValueAt(row, TYPE_COLUMN).toString();
 -      button.setOpaque(true);
 -      button.setBackground(me.getBackground());
 -      button.setText(currentFilter.toString());
 -      button.setIcon(null);
 -      return button;
 +      filterButton.setOpaque(true);
 +      filterButton.setBackground(me.getBackground());
 +      filterButton.setText(currentFilter.toString());
 +      filterButton.setToolTipText(currentFilter.toString());
 +      filterButton.setIcon(null);
 +      return filterButton;
      }
    }
  }
  
  class FeatureIcon implements Icon
  {
 +  private static final Font VERDANA_9 = new Font("Verdana", Font.PLAIN, 9);
 +
    FeatureColourI gcol;
  
    Color backg;
        // need an icon here.
        g.setColor(gcol.getMaxColour());
  
 -      g.setFont(new Font("Verdana", Font.PLAIN, 9));
 +      g.setFont(VERDANA_9);
  
        // g.setFont(g.getFont().deriveFont(
        // AffineTransform.getScaleInstance(
@@@ -29,8 -29,6 +29,8 @@@ import jalview.datamodel.features.Featu
  import jalview.datamodel.features.FeatureMatcherI;
  import jalview.datamodel.features.FeatureMatcherSet;
  import jalview.datamodel.features.FeatureMatcherSetI;
 +import jalview.io.gff.SequenceOntologyFactory;
 +import jalview.io.gff.SequenceOntologyI;
  import jalview.schemes.FeatureColour;
  import jalview.util.ColorUtils;
  import jalview.util.MessageManager;
@@@ -51,12 -49,7 +51,12 @@@ import java.awt.event.MouseAdapter
  import java.awt.event.MouseEvent;
  import java.text.DecimalFormat;
  import java.util.ArrayList;
 +import java.util.Collections;
 +import java.util.Comparator;
 +import java.util.HashMap;
  import java.util.List;
 +import java.util.Map;
 +import java.util.Map.Entry;
  
  import javax.swing.BorderFactory;
  import javax.swing.BoxLayout;
@@@ -70,11 -63,10 +70,10 @@@ import javax.swing.JPanel
  import javax.swing.JRadioButton;
  import javax.swing.JSlider;
  import javax.swing.JTextField;
- import javax.swing.SwingConstants;
+ import javax.swing.border.EmptyBorder;
  import javax.swing.border.LineBorder;
  import javax.swing.event.ChangeEvent;
  import javax.swing.event.ChangeListener;
- import javax.swing.plaf.basic.BasicArrowButton;
  
  /**
   * A dialog where the user can configure colour scheme, and any filters, for one
@@@ -125,11 -117,10 +124,11 @@@ public class FeatureTypeSettings extend
  
    /*
     * the colour and filters to reset to on Cancel
 +   * (including feature sub-types if modified)
     */
 -  private final FeatureColourI originalColour;
 +  private Map<String, FeatureColourI> originalColours;
  
 -  private final FeatureMatcherSetI originalFilter;
 +  private Map<String, FeatureMatcherSetI> originalFilters;
  
    /*
     * set flag to true when setting values programmatically,
  
    private JPanel chooseFiltersPanel;
  
 +  /*
 +   * the root Sequence Ontology terms (if any) that is a parent of
 +   * the current feature type
 +   */
 +  private String rootSOTerm;
 +
 +  /*
 +   * a map whose keys are Sequence Ontology terms - selected from the
 +   * current term and its parents in the SO - whose subterms include
 +   * additional feature types; the map entry is the list of additional
 +   * feature types that match the key or have it as a parent term; in
 +   * other words, distinct 'aggregations' that include the current feature type
 +   */
 +  private final Map<String, List<String>> relatedSoTerms;
 +
 +  /*
 +   * if true, filter or colour settings are also applied to 
 +   * any sub-types of parentTerm in the Sequence Ontology
 +   */
 +  private boolean applyFiltersToSubtypes;
 +
 +  private boolean applyColourToSubtypes;
 +
 +  private String parentSOTerm;
 +
    /**
     * Constructor
     * 
      this.fr = frender;
      this.featureType = theType;
      ap = fr.ap;
 -    originalFilter = fr.getFeatureFilter(theType);
 -    originalColour = fr.getFeatureColours().get(theType);
 -    
 +
 +    SequenceOntologyI so = SequenceOntologyFactory.getInstance();
 +    relatedSoTerms = so.findSequenceOntologyGroupings(
 +            this.featureType, fr.getRenderOrder());
 +
 +    /*
 +     * save original colours and filters for this feature type,
 +     * and any related types, to restore on Cancel
 +     */
 +    originalFilters = new HashMap<>();
 +    originalFilters.put(theType, fr.getFeatureFilter(theType));
 +    originalColours = new HashMap<>();
 +    originalColours.put(theType, fr.getFeatureColours().get(theType));
 +    for (List<String> related : relatedSoTerms.values())
 +    {
 +      for (String type : related)
 +      {
 +        originalFilters.put(type, fr.getFeatureFilter(type));
 +        originalColours.put(type, fr.getFeatureColours().get(type));
 +      }
 +    }
 +
      adjusting = true;
 -    
 +
      try
      {
        initialise();
        ex.printStackTrace();
        return;
      }
 -    
 +
      updateColoursTab();
 -    
 +
      updateFiltersTab();
 -    
 +
      adjusting = false;
 -    
 +
      colourChanged(false);
 -    
 +
      String title = MessageManager
              .formatMessage("label.display_settings_for", new String[]
              { theType });
    }
  
    /**
 +   * Answers a (possibly empty) map of any Sequence Ontology terms (the current
 +   * feature type and its parents) which incorporate additional known feature
 +   * types (the map entry).
 +   * <p>
 +   * For example if {@code stop_gained} and {@code stop_lost} are known feature
 +   * types, then SO term {@ nonsynonymous_variant} is the first common parent of
 +   * both terms
 +   * 
 +   * @param featureType
 +   *          the current feature type being configured
 +   * @param featureTypes
 +   *          all known feature types on the alignment
 +   * @return
 +   */
 +  protected static Map<String, List<String>> findSequenceOntologyGroupings(
 +          String featureType, List<String> featureTypes)
 +  {
 +    List<String> sortedTypes = new ArrayList<>(featureTypes);
 +    Collections.sort(sortedTypes);
 +
 +    Map<String, List<String>> parents = new HashMap<>();
 +
 +    /*
 +     * method: 
 +     * walk up featureType and all of its parents
 +     * find other feature types which are subsumed by each term
 +     * add each distinct aggregation of included feature types to the map
 +     */
 +    List<String> candidates = new ArrayList<>();
 +    SequenceOntologyI so = SequenceOntologyFactory.getInstance();
 +    candidates.add(featureType);
 +    while (!candidates.isEmpty())
 +    {
 +      String term = candidates.remove(0);
 +      List<String> includedFeatures = new ArrayList<>();
 +      for (String type : sortedTypes)
 +      {
 +        if (!type.equals(featureType) && so.isA(type, term))
 +        {
 +          includedFeatures.add(type);
 +        }
 +      }
 +      if (!includedFeatures.isEmpty()
 +              && !parents.containsValue(includedFeatures))
 +      {
 +        parents.put(term, includedFeatures);
 +      }
 +      candidates.addAll(so.getParents(term));
 +    }
 +    
 +    return parents;
 +  }
 +
 +  /**
     * Configures the widgets on the Colours tab according to the current feature
     * colour scheme
     */
       * if not set, default max colour to last plain colour,
       * and make min colour a pale version of max colour
       */
 +    FeatureColourI originalColour = originalColours.get(featureType);
      Color max = originalColour.getMaxColour();
      if (max == null)
      {
              MessageManager.getString("action.colour"), true);
  
      /*
 +     * option to apply colour to other selected types as well
 +     */
 +    if (!relatedSoTerms.isEmpty())
 +    {
 +      applyColourToSubtypes = false;
 +      colourByPanel.add(initSubtypesPanel(false));
 +    }
 +
 +    /*
       * simple colour radio button and colour picker
       */
      JPanel simpleColourPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
      singleColour.setFont(JvSwingUtils.getLabelFont());
      singleColour.setBorder(BorderFactory.createLineBorder(Color.black));
      singleColour.setPreferredSize(new Dimension(40, 20));
 -    // if (originalColour.isGraduatedColour())
 -    // {
 -    // singleColour.setBackground(originalColour.getMaxColour());
 -    // singleColour.setForeground(originalColour.getMaxColour());
 -    // }
 -    // else
 -    // {
 -      singleColour.setBackground(originalColour.getColour());
 -      singleColour.setForeground(originalColour.getColour());
 -    // }
 +    FeatureColourI originalColour = originalColours.get(featureType);
 +    singleColour.setBackground(originalColour.getColour());
 +    singleColour.setForeground(originalColour.getColour());
 +
      singleColour.addMouseListener(new MouseAdapter()
      {
        @Override
      return colourByPanel;
    }
  
 +  /**
 +   * Constructs and returns a panel with the option to apply any changes also to
 +   * sub-types of SO terms at or above the feature type
 +   * 
 +   * @return
 +   */
 +  protected JPanel initSubtypesPanel(final boolean forFilters)
 +  {
 +    JPanel toSubtypes = new JPanel(new FlowLayout(FlowLayout.LEFT));
 +    toSubtypes.setBackground(Color.WHITE);
 +
 +    /*
 +     * checkbox 'apply to sub-types of...'
 +     */
 +    JCheckBox applyToSubtypesCB = new JCheckBox(MessageManager
 +            .formatMessage("label.apply_to_subtypes", rootSOTerm));
 +    toSubtypes.add(applyToSubtypesCB);
 +    toSubtypes
 +            .setToolTipText(MessageManager.getString("label.group_by_so"));
 +
 +    /*
 +     * combobox to choose 'parent' of sub-types
 +     */
 +    List<String> soTerms = new ArrayList<>();
 +    for (String term : relatedSoTerms.keySet())
 +    {
 +      soTerms.add(term);
 +    }
 +    // sort from most restrictive to most inclusive
 +    Collections.sort(soTerms, new Comparator<String>()
 +    {
 +      @Override
 +      public int compare(String o1, String o2)
 +      {
 +        return Integer.compare(relatedSoTerms.get(o1).size(),
 +                relatedSoTerms.get(o2).size());
 +      }
 +    });
 +    List<String> tooltips = new ArrayList<>();
 +    for (String term : soTerms)
 +    {
 +      tooltips.add(getSOTermsTooltip(relatedSoTerms.get(term)));
 +    }
 +    JComboBox<String> parentType = JvSwingUtils
 +            .buildComboWithTooltips(soTerms, tooltips);
 +    toSubtypes.add(parentType);
 +
 +    /*
 +     * on toggle of checkbox, or change of parent SO term,
 +     * reset and then reapply filters to the selected scope
 +     */
 +    final ActionListener action = new ActionListener()
 +    {
 +      /*
 +       * reset and reapply settings on toggle of checkbox
 +       */
 +      @Override
 +      public void actionPerformed(ActionEvent e)
 +      {
 +        parentSOTerm = (String) parentType.getSelectedItem();
 +        if (forFilters)
 +        {
 +          applyFiltersToSubtypes = applyToSubtypesCB.isSelected();
 +          restoreOriginalFilters();
 +          filtersChanged();
 +        }
 +        else
 +        {
 +          applyColourToSubtypes = applyToSubtypesCB.isSelected();
 +          restoreOriginalColours();
 +          colourChanged(true);
 +        }
 +      }
 +    };
 +    applyToSubtypesCB.addActionListener(action);
 +    parentType.addActionListener(action);
 +
 +    return toSubtypes;
 +  }
 +
    private void showColourChooser(JPanel colourPanel, String key)
    {
      Color col = JColorChooser.showDialog(this,
      FeatureColourI acg = makeColourFromInputs();
  
      /*
 -     * save the colour, and repaint stuff
 +     * save the colour, and set on subtypes if selected
       */
      fr.setColour(featureType, acg);
 +    if (applyColourToSubtypes)
 +    {
 +      for (String child : relatedSoTerms.get(parentSOTerm))
 +      {
 +        fr.setColour(child, acg);
 +      }
 +    }
 +    refreshFeatureSettings();
      ap.paintAlignment(updateStructsAndOverview, updateStructsAndOverview);
  
      updateColoursTab();
    @Override
    protected void raiseClosed()
    {
 +    refreshFeatureSettings();
 +  }
 +
 +  protected void refreshFeatureSettings()
 +  {
      if (this.featureSettings != null)
      {
 -      featureSettings.actionPerformed(new ActionEvent(this, 0, "CLOSED"));
 +      featureSettings.actionPerformed(new ActionEvent(this, 0, "REFRESH"));
      }
    }
  
  
    /**
     * Action on Cancel is to restore colour scheme and filters as they were when
 -   * the dialog was opened
 +   * the dialog was opened (including any feature sub-types that may have been
 +   * changed)
     */
    @Override
    public void cancelPressed()
    {
 -    fr.setColour(featureType, originalColour);
 -    fr.setFeatureFilter(featureType, originalFilter);
 +    restoreOriginalColours();
 +    restoreOriginalFilters();
      ap.paintAlignment(true, true);
    }
  
    /**
 +   * Restores filters for all feature types to their values when the dialog was
 +   * opened
 +   */
 +  protected void restoreOriginalFilters()
 +  {
 +    for (Entry<String, FeatureMatcherSetI> entry : originalFilters
 +            .entrySet())
 +    {
 +      fr.setFeatureFilter(entry.getKey(), entry.getValue());
 +    }
 +  }
 +
 +  /**
 +   * Restores colours for all feature types to their values when the dialog was
 +   * opened
 +   */
 +  protected void restoreOriginalColours()
 +  {
 +    for (Entry<String, FeatureColourI> entry : originalColours.entrySet())
 +    {
 +      fr.setColour(entry.getKey(), entry.getValue());
 +    }
 +  }
 +
 +  /**
     * Action on text entry of a threshold value
     */
    protected void thresholdValue_actionPerformed()
         */
        adjusting = true;
        float f = Float.parseFloat(thresholdValue.getText());
 -      f = Float.max(f,  this.min);
 +      f = Float.max(f, this.min);
        f = Float.min(f, this.max);
        thresholdValue.setText(String.valueOf(f));
        slider.setValue((int) (f * scaleFactor));
    {
      filters = new ArrayList<>();
  
 +    JPanel outerPanel = new JPanel();
 +    outerPanel.setLayout(new BoxLayout(outerPanel, BoxLayout.Y_AXIS));
 +    outerPanel.setBackground(Color.white);
 +
 +    /*
 +     * option to apply colour to other selected types as well
 +     */
 +    if (!relatedSoTerms.isEmpty())
 +    {
 +      applyFiltersToSubtypes = false;
 +      outerPanel.add(initSubtypesPanel(true));
 +    }
 +
      JPanel filtersPanel = new JPanel();
      filtersPanel.setLayout(new BoxLayout(filtersPanel, BoxLayout.Y_AXIS));
      filtersPanel.setBackground(Color.white);
      JvSwingUtils.createTitledBorder(filtersPanel,
              MessageManager.getString("label.filters"), true);
 +    outerPanel.add(filtersPanel);
  
      JPanel andOrPanel = initialiseAndOrPanel();
      filtersPanel.add(andOrPanel);
      chooseFiltersPanel.setBackground(Color.white);
      filtersPanel.add(chooseFiltersPanel);
  
 -    return filtersPanel;
 +    return outerPanel;
    }
  
    /**
     */
    private JPanel initialiseAndOrPanel()
    {
 -    JPanel andOrPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
 +    JPanel andOrPanel = new JPanel(new BorderLayout());
      andOrPanel.setBackground(Color.white);
 +
      andFilters = new JRadioButton(MessageManager.getString("label.and"));
      orFilters = new JRadioButton(MessageManager.getString("label.or"));
      ActionListener actionListener = new ActionListener()
              new JLabel(MessageManager.getString("label.join_conditions")));
      andOrPanel.add(andFilters);
      andOrPanel.add(orFilters);
 +
      return andOrPanel;
    }
  
    /**
 +   * Builds a tooltip for the 'Apply also to...' combobox with a list of known
 +   * feature types (excluding the current type) which are sub-types of the
 +   * selected Sequence Ontology term
 +   * 
 +   * @param
 +   * @return
 +   */
 +  protected String getSOTermsTooltip(List<String> list)
 +  {
 +    StringBuilder sb = new StringBuilder(20 * relatedSoTerms.size());
 +    sb.append(MessageManager.getString("label.apply_also_to"));
 +    for (String child : list)
 +    {
 +      sb.append("<br>").append(child);
 +    }
 +    String tooltip = JvSwingUtils.wrapTooltip(true, sb.toString());
 +    return tooltip;
 +  }
 +
 +  /**
     * Refreshes the display to show any filters currently configured for the
     * selected feature type (editable, with 'remove' option), plus one extra row
     * for adding a condition. This should be called after a filter has been
      if (!patternField.isEnabled()
              || (pattern != null && pattern.trim().length() > 0))
      {
-       // todo: gif for button drawing '-' or 'x'
-       JButton removeCondition = new BasicArrowButton(SwingConstants.WEST);
-       removeCondition
-               .setToolTipText(MessageManager.getString("label.delete_row"));
+       JButton removeCondition = new JButton("\u2717"); // Dingbats cursive x
+       removeCondition.setToolTipText(
+               MessageManager.getString("label.delete_condition"));
+       removeCondition.setBorder(new EmptyBorder(0, 0, 0, 0));
        removeCondition.addActionListener(new ActionListener()
        {
          @Override
       * (note this might now be an empty filter with no conditions)
       */
      fr.setFeatureFilter(featureType, combined.isEmpty() ? null : combined);
 +    if (applyFiltersToSubtypes)
 +    {
 +      for (String child : relatedSoTerms.get(parentSOTerm))
 +      {
 +        fr.setFeatureFilter(child, combined.isEmpty() ? null : combined);
 +      }
 +    }
 +
 +    refreshFeatureSettings();
      ap.paintAlignment(true, true);
  
      updateFiltersTab();