X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FSequenceGroup.java;h=4f9d530fb317cc9ca16adc8319dbd5650f3b3491;hb=ff8c06845590fd9fd423aa59809dcce9610ab295;hp=8218ba7729231f689da37d187688d614164cb988;hpb=244520d01226040ec02eb8560bf0b181932797cf;p=jalview.git diff --git a/src/jalview/datamodel/SequenceGroup.java b/src/jalview/datamodel/SequenceGroup.java index 8218ba7..4f9d530 100755 --- a/src/jalview/datamodel/SequenceGroup.java +++ b/src/jalview/datamodel/SequenceGroup.java @@ -22,8 +22,8 @@ package jalview.datamodel; import jalview.analysis.AAFrequency; import jalview.analysis.Conservation; -import jalview.schemes.CollectionColourScheme; -import jalview.schemes.CollectionColourSchemeI; +import jalview.renderer.ResidueShader; +import jalview.renderer.ResidueShaderI; import jalview.schemes.ColourSchemeI; import java.awt.Color; @@ -71,7 +71,7 @@ public class SequenceGroup implements AnnotatedCollectionI /** * Colourscheme applied to group if any */ - public CollectionColourSchemeI cs; + public ResidueShaderI cs; // start column (base 0) int startRes = 0; @@ -118,7 +118,7 @@ public class SequenceGroup implements AnnotatedCollectionI public SequenceGroup() { groupName = "JGroup:" + this.hashCode(); - cs = new CollectionColourScheme(); + cs = new ResidueShader(); } /** @@ -145,7 +145,7 @@ public class SequenceGroup implements AnnotatedCollectionI this.displayBoxes = displayBoxes; this.displayText = displayText; this.colourText = colourText; - this.cs = new CollectionColourScheme(scheme); + this.cs = new ResidueShader(scheme); startRes = start; endRes = end; recalcConservation(); @@ -1347,13 +1347,25 @@ public class SequenceGroup implements AnnotatedCollectionI private AnnotatedCollectionI context; /** - * set the alignment or group context for this group + * Sets the alignment or group context for this group * - * @param context + * @param ctx + * @throws IllegalArgumentException + * if setting the context would result in a circular reference chain */ - public void setContext(AnnotatedCollectionI context) + public void setContext(AnnotatedCollectionI ctx) { - this.context = context; + AnnotatedCollectionI ref = ctx; + while (ref != null) + { + if (ref == this) + { + throw new IllegalArgumentException( + "Circular reference in SequenceGroup.context"); + } + ref = ref.getContext(); + } + this.context = ctx; } /* @@ -1371,12 +1383,12 @@ public class SequenceGroup implements AnnotatedCollectionI { if (cs == null) { - cs = new CollectionColourScheme(); + cs = new ResidueShader(); } cs.setColourScheme(scheme); } - public void setGroupColourScheme(CollectionColourSchemeI scheme) + public void setGroupColourScheme(ResidueShaderI scheme) { cs = scheme; } @@ -1386,7 +1398,7 @@ public class SequenceGroup implements AnnotatedCollectionI return cs == null ? null : cs.getColourScheme(); } - public CollectionColourSchemeI getGroupColourScheme() + public ResidueShaderI getGroupColourScheme() { return cs; } @@ -1394,9 +1406,8 @@ public class SequenceGroup implements AnnotatedCollectionI @Override public boolean isNucleotide() { - if (context != null && context instanceof AlignmentI) - { - return ((AlignmentI) context).isNucleotide(); + if (context != null) { + return context.isNucleotide(); } return false; }