From fac8703b72442854d4b91fd71483455058b41e2b Mon Sep 17 00:00:00 2001 From: gmungoc Date: Thu, 16 Nov 2017 14:23:00 +0000 Subject: [PATCH] JAL-2069 fix minor bugs in variable setting --- src/jalview/gui/FeatureColourChooser.java | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/jalview/gui/FeatureColourChooser.java b/src/jalview/gui/FeatureColourChooser.java index da3819c..d3d9e1a 100644 --- a/src/jalview/gui/FeatureColourChooser.java +++ b/src/jalview/gui/FeatureColourChooser.java @@ -263,7 +263,7 @@ public class FeatureColourChooser extends JalviewDialog textAttributeCombo.setEnabled(true); String[] attributeName = cs.getAttributeName(); textAttributeCombo - .setSelectedItem(String.join(COLON, attributeName)); + .setSelectedItem(toAttributeDisplayName(attributeName)); } else { @@ -278,7 +278,7 @@ public class FeatureColourChooser extends JalviewDialog byAttributeValue.setSelected(true); String[] attributeName = cs.getAttributeName(); valueAttributeCombo - .setSelectedItem(String.join(COLON, attributeName)); + .setSelectedItem(toAttributeDisplayName(attributeName)); valueAttributeCombo.setEnabled(true); updateMinMax(); } @@ -393,7 +393,7 @@ public class FeatureColourChooser extends JalviewDialog else if (byAttributeValue.isSelected()) { String attName = (String) valueAttributeCombo.getSelectedItem(); - String[] attNames = attName.split(COLON); + String[] attNames = fromAttributeDisplayName(attName); minMax = FeatureAttributes.getInstance().getMinMax(type, attNames); } if (minMax != null) @@ -740,17 +740,17 @@ public class FeatureColourChooser extends JalviewDialog { attribute = (String) textAttributeCombo.getSelectedItem(); textAttributeCombo.setEnabled(true); - acg.setAttributeName(attribute.split(COLON)); + acg.setAttributeName(fromAttributeDisplayName(attribute)); } else if (byAttributeValue.isSelected()) { attribute = (String) valueAttributeCombo.getSelectedItem(); valueAttributeCombo.setEnabled(true); - acg.setAttributeName(attribute.split(COLON)); + acg.setAttributeName(fromAttributeDisplayName(attribute)); } else { - acg.setAttributeName((String) null); + acg.setAttributeName((String[]) null); } if (!hasThreshold) @@ -839,6 +839,11 @@ public class FeatureColourChooser extends JalviewDialog ap.paintAlignment(updateStructsAndOverview, updateStructsAndOverview); } + private String[] fromAttributeDisplayName(String attribute) + { + return attribute == null ? null : attribute.split(COLON); + } + @Override protected void raiseClosed() { @@ -972,7 +977,7 @@ public class FeatureColourChooser extends JalviewDialog continue; } } - validAtts.add(String.join(COLON, attName)); + validAtts.add(toAttributeDisplayName(attName)); String desc = fa.getDescription(featureType, attName); if (desc != null && desc.length() > MAX_TOOLTIP_LENGTH) { @@ -1003,4 +1008,9 @@ public class FeatureColourChooser extends JalviewDialog return attCombo; } + private String toAttributeDisplayName(String[] attName) + { + return attName == null ? "" : String.join(COLON, attName); + } + } -- 1.7.10.2