X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FSequenceGroup.java;h=4f9d530fb317cc9ca16adc8319dbd5650f3b3491;hb=ff8c06845590fd9fd423aa59809dcce9610ab295;hp=da47a8981783b8a68c62eeb1c31b14cbdd49cb44;hpb=06775313266c93eba687d73df794eba606145048;p=jalview.git diff --git a/src/jalview/datamodel/SequenceGroup.java b/src/jalview/datamodel/SequenceGroup.java index da47a89..4f9d530 100755 --- a/src/jalview/datamodel/SequenceGroup.java +++ b/src/jalview/datamodel/SequenceGroup.java @@ -22,6 +22,8 @@ package jalview.datamodel; import jalview.analysis.AAFrequency; import jalview.analysis.Conservation; +import jalview.renderer.ResidueShader; +import jalview.renderer.ResidueShaderI; import jalview.schemes.ColourSchemeI; import java.awt.Color; @@ -69,7 +71,7 @@ public class SequenceGroup implements AnnotatedCollectionI /** * Colourscheme applied to group if any */ - public ColourSchemeI cs; + public ResidueShaderI cs; // start column (base 0) int startRes = 0; @@ -116,6 +118,7 @@ public class SequenceGroup implements AnnotatedCollectionI public SequenceGroup() { groupName = "JGroup:" + this.hashCode(); + cs = new ResidueShader(); } /** @@ -136,12 +139,13 @@ public class SequenceGroup implements AnnotatedCollectionI ColourSchemeI scheme, boolean displayBoxes, boolean displayText, boolean colourText, int start, int end) { + this(); this.sequences = sequences; this.groupName = groupName; this.displayBoxes = displayBoxes; this.displayText = displayText; this.colourText = colourText; - this.cs = scheme; + this.cs = new ResidueShader(scheme); startRes = start; endRes = end; recalcConservation(); @@ -154,6 +158,7 @@ public class SequenceGroup implements AnnotatedCollectionI */ public SequenceGroup(SequenceGroup seqsel) { + this(); if (seqsel != null) { sequences = new ArrayList(); @@ -1342,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; } /* @@ -1361,4 +1378,37 @@ public class SequenceGroup implements AnnotatedCollectionI { return context; } + + public void setColourScheme(ColourSchemeI scheme) + { + if (cs == null) + { + cs = new ResidueShader(); + } + cs.setColourScheme(scheme); + } + + public void setGroupColourScheme(ResidueShaderI scheme) + { + cs = scheme; + } + + public ColourSchemeI getColourScheme() + { + return cs == null ? null : cs.getColourScheme(); + } + + public ResidueShaderI getGroupColourScheme() + { + return cs; + } + + @Override + public boolean isNucleotide() + { + if (context != null) { + return context.isNucleotide(); + } + return false; + } }