SequenceI asq = alignment.getSequenceAt(i);
for (String group : asq.getFeatures().getFeatureGroups(true))
{
- if (group == null)
+ /*
+ * features in null group are always displayed; other groups
+ * keep their current visibility; new groups as 'newMadeVisible'
+ */
+ boolean groupDisplayed = true;
+ if (group != null)
{
- continue;
- }
- Boolean groupDisplayed = featureGroups.get(group);
- if (groupDisplayed == null)
- {
- groupDisplayed = Boolean.valueOf(newMadeVisible);
- featureGroups.put(group, groupDisplayed);
+ if (featureGroups.containsKey(group))
+ {
+ groupDisplayed = featureGroups.get(group);
+ }
+ else
+ {
+ groupDisplayed = newMadeVisible;
+ featureGroups.put(group, groupDisplayed);
+ }
}
if (groupDisplayed)
{
seqs.get(2).addSequenceFeature(
new SequenceFeature("Rfam", "Desc", 5, 9, Float.NaN,
"RfamGroup"));
+ // existing feature type with null group
seqs.get(3).addSequenceFeature(
new SequenceFeature("Rfam", "Desc", 5, 9, Float.NaN, null));
+ // new feature type with null group
+ seqs.get(3).addSequenceFeature(
+ new SequenceFeature("Scop", "Desc", 5, 9, Float.NaN, null));
// null value for type produces NullPointerException
fr.findAllFeatures(true);
types = fr.getRenderOrder();
groups = fr.getFeatureGroups();
- assertEquals(types.size(), 2);
+ assertEquals(types.size(), 3);
assertFalse(types.contains("Type"));
assertTrue(types.contains("Pfam"));
assertTrue(types.contains("Rfam"));
+ assertTrue(types.contains("Scop"));
assertEquals(groups.size(), 2);
assertFalse(groups.contains("Group"));
assertTrue(groups.contains("PfamGroup"));
* check render order (last is on top)
*/
List<String> renderOrder = fr.getRenderOrder();
- assertEquals(renderOrder, Arrays.asList("Rfam", "Pfam"));
+ assertEquals(renderOrder, Arrays.asList("Scop", "Rfam", "Pfam"));
/*
* change render order (todo: an easier way)
* nb here last comes first in the data array
*/
- Object[][] data = new Object[2][];
+ Object[][] data = new Object[3][];
FeatureColourI colour = new FeatureColour(Color.RED);
data[0] = new Object[] { "Rfam", colour, true };
data[1] = new Object[] { "Pfam", colour, false };
+ data[2] = new Object[] { "Scop", colour, false };
fr.setFeaturePriority(data);
- assertEquals(fr.getRenderOrder(), Arrays.asList("Pfam", "Rfam"));
+ assertEquals(fr.getRenderOrder(), Arrays.asList("Scop", "Pfam", "Rfam"));
assertEquals(fr.getDisplayedFeatureTypes(), Arrays.asList("Rfam"));
/*
new SequenceFeature("Metal", "Desc", 14, 22, 8f, "MetalGroup"));
fr.findAllFeatures(true);
assertEquals(fr.getRenderOrder(),
- Arrays.asList("Pfam", "Rfam", "Metal"));
+ Arrays.asList("Scop", "Pfam", "Rfam", "Metal"));
assertEquals(fr.getDisplayedFeatureTypes(),
Arrays.asList("Rfam", "Metal"));
}