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;
/**
* Colourscheme applied to group if any
*/
- public CollectionColourSchemeI cs;
+ public ResidueShaderI cs;
// start column (base 0)
int startRes = 0;
public SequenceGroup()
{
groupName = "JGroup:" + this.hashCode();
- cs = new CollectionColourScheme();
+ cs = new ResidueShader();
}
/**
this.displayBoxes = displayBoxes;
this.displayText = displayText;
this.colourText = colourText;
- this.cs = new CollectionColourScheme(scheme);
+ this.cs = new ResidueShader(scheme);
startRes = start;
endRes = end;
recalcConservation();
return aa;
}
- /**
- * Returns a list of annotations that match the specified sequenceRef, calcId
- * and label, ignoring null values.
- *
- * @return list of AlignmentAnnotation objects
- */
@Override
public Iterable<AlignmentAnnotation> findAnnotations(SequenceI seq,
String calcId, String label)
ArrayList<AlignmentAnnotation> aa = new ArrayList<AlignmentAnnotation>();
for (AlignmentAnnotation ann : getAlignmentAnnotation())
{
- if (ann.getCalcId() != null && ann.getCalcId().equals(calcId)
- && ann.sequenceRef != null && ann.sequenceRef == seq
- && ann.label != null && ann.label.equals(label))
+ if ((calcId == null || (ann.getCalcId() != null && ann.getCalcId()
+ .equals(calcId)))
+ && (seq == null || (ann.sequenceRef != null && ann.sequenceRef == seq))
+ && (label == null || (ann.label != null && ann.label
+ .equals(label))))
{
aa.add(ann);
}
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 || ref.getContext() == ctx)
+ {
+ throw new IllegalArgumentException(
+ "Circular reference in SequenceGroup.context");
+ }
+ ref = ref.getContext();
+ }
+ this.context = ctx;
}
/*
{
if (cs == null)
{
- cs = new CollectionColourScheme();
+ cs = new ResidueShader();
}
cs.setColourScheme(scheme);
}
- public void setGroupColourScheme(CollectionColourSchemeI scheme)
+ public void setGroupColourScheme(ResidueShaderI scheme)
{
cs = scheme;
}
return cs == null ? null : cs.getColourScheme();
}
- public CollectionColourSchemeI getGroupColourScheme()
+ public ResidueShaderI getGroupColourScheme()
{
return cs;
}
}
return false;
}
+
+ /**
+ * @param seq
+ * @return true if seq is a member of the group
+ */
+
+ public boolean contains(SequenceI seq1)
+ {
+ return sequences.contains(seq1);
+ }
+
+ /**
+ * @param seq
+ * @param apos
+ * @return true if startRes<=apos and endRes>=apos and seq is in the group
+ */
+ public boolean contains(SequenceI seq, int apos)
+ {
+ return (startRes <= apos && endRes >= apos) && sequences.contains(seq);
+ }
}