From: gmungoc Date: Sun, 3 Jun 2018 10:14:04 +0000 (+0100) Subject: JAL-3010 option to apply colour to all ontology sub-types X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=9597d6affdf8f30580b1915beeba4a2516a81777;p=jalview.git JAL-3010 option to apply colour to all ontology sub-types --- diff --git a/src/jalview/gui/FeatureSettings.java b/src/jalview/gui/FeatureSettings.java index fe905c0..0c90646 100644 --- a/src/jalview/gui/FeatureSettings.java +++ b/src/jalview/gui/FeatureSettings.java @@ -1759,9 +1759,9 @@ public class FeatureSettings extends JPanel for (int r = 0; r < data.length; r++) { - String type2 = (String) data[r][TYPE_COLUMN]; - if (!type2.equals(type)) + if (r != row) { + String type2 = (String) data[r][TYPE_COLUMN]; if (so.isA(type2, type)) { data[r][SHOW_COLUMN] = value; diff --git a/src/jalview/gui/FeatureTypeSettings.java b/src/jalview/gui/FeatureTypeSettings.java index 201ec44..e412274 100644 --- a/src/jalview/gui/FeatureTypeSettings.java +++ b/src/jalview/gui/FeatureTypeSettings.java @@ -228,7 +228,7 @@ public class FeatureTypeSettings extends JalviewDialog * if selected, colour settings are also applied to any * feature sub-types in the Sequence Ontology */ - private JCheckBox applyColourToChildren; + private JCheckBox applyColourToSubtypes; /** * Constructor @@ -783,6 +783,19 @@ public class FeatureTypeSettings extends JalviewDialog colourByPanel.setLayout(new BoxLayout(colourByPanel, BoxLayout.Y_AXIS)); /* + * option to apply colour to sub-types as well (if there are any) + */ + if (!subTypes.isEmpty()) + { + JPanel toSubtypes = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + toSubtypes.setBackground(Color.WHITE); + applyColourToSubtypes = new JCheckBox("Apply also to child terms"); + applyColourToSubtypes.setToolTipText(getSubtypesTooltip()); + toSubtypes.add(applyColourToSubtypes); + colourByPanel.add(toSubtypes); + } + + /* * simple colour radio button and colour picker */ JPanel simpleColourPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); @@ -918,9 +931,16 @@ public class FeatureTypeSettings extends JalviewDialog FeatureColourI acg = makeColourFromInputs(); /* - * save the colour, and repaint stuff + * save the colour, and set on subtypes if selected */ fr.setColour(featureType, acg); + if (applyColourToSubtypes.isSelected()) + { + for (String child : subTypes) + { + fr.setColour(child, acg); + } + } refreshFeatureSettings(); ap.paintAlignment(updateStructsAndOverview, updateStructsAndOverview); @@ -1281,13 +1301,7 @@ public class FeatureTypeSettings extends JalviewDialog JPanel panel2 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); panel2.setBackground(Color.white); andOrPanel.add(panel2, BorderLayout.EAST); - StringBuilder sb = new StringBuilder(20 * subTypes.size()); - sb.append("Apply filters also to child terms" + ":"); // todo i18n - for (String child : subTypes) - { - sb.append("
").append(child); - } - String tooltip = JvSwingUtils.wrapTooltip(true, sb.toString()); + String tooltip = getSubtypesTooltip(); applyFiltersToSubtypes.setToolTipText(tooltip); panel2.add(applyFiltersToSubtypes); } @@ -1296,6 +1310,24 @@ public class FeatureTypeSettings extends JalviewDialog } /** + * Builds a tooltip for the 'Apply to subtypes' checkbox with a list of + * subtypes of this feature type + * + * @return + */ + protected String getSubtypesTooltip() + { + StringBuilder sb = new StringBuilder(20 * subTypes.size()); + sb.append("Apply filters also to child terms" + ":"); // todo i18n + for (String child : subTypes) + { + sb.append("
").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