}
}
+ @Override
+ public AlignmentAnnotation findOrCreateAnnotation(String name, boolean autoCalc,
+ SequenceI seqRef, SequenceGroup groupRef)
+ {
+ for (AlignmentAnnotation annot :
+ getAlignmentAnnotation())
+ {
+ if (annot.autoCalculated == autoCalc
+ && annot.getCalcId().equals(name)
+ && annot.sequenceRef == seqRef && annot.groupRef == groupRef)
+ {
+ return annot;
+ }
+ }
+ AlignmentAnnotation annot = new AlignmentAnnotation(name, name,
+ new Annotation[1], 0f, 0f, AlignmentAnnotation.BAR_GRAPH);
+ annot.hasText = false;
+ annot.setCalcId(new String(name));
+ annot.autoCalculated = autoCalc;
+ if (seqRef != null)
+ {
+ annot.setSequenceRef(seqRef);
+ }
+ annot.groupRef = groupRef;
+ addAnnotation(annot);
+
+ return annot;
+ }
+
+ @Override
+ public Iterable<AlignmentAnnotation> findAnnotation(String calcId)
+ {
+ ArrayList<AlignmentAnnotation> aa=new ArrayList<AlignmentAnnotation>();
+ for (AlignmentAnnotation a:getAlignmentAnnotation())
+ {
+ if (a.getCalcId()==calcId || (a.getCalcId()!=null && calcId!=null && a.getCalcId().equals(calcId)))
+ {
+ aa.add(a);
+ }
+ }
+ return aa;
+ }
+
}
* @param i
*/
public void addAnnotation(AlignmentAnnotation consensus, int i);
+
+ /**
+ * search for or create a specific annotation row on the alignment
+ *
+ * @param method - CalcId for the annotation (must match)
+ * @param autoCalc - value of autocalc flag for the annotation
+ * @param seqRef - null or specific sequence reference
+ * @param groupRef - null or specific group reference
+ * @return existing annotation matching the given attributes
+ */
+ public AlignmentAnnotation findOrCreateAnnotation(String name, boolean autoCalc,
+ SequenceI seqRef, SequenceGroup groupRef);
}
package jalview.datamodel;
-import java.util.List;
-
public interface AnnotatedCollectionI
{
*/
AlignmentAnnotation[] getAlignmentAnnotation();
+ Iterable<AlignmentAnnotation> findAnnotation(String calcId);
+
}
}
return annot.toArray(new AlignmentAnnotation[0]);
}
+ @Override
+ public Iterable<AlignmentAnnotation> findAnnotation(String calcId)
+ {
+ ArrayList<AlignmentAnnotation> aa=new ArrayList<AlignmentAnnotation>();
+ for (AlignmentAnnotation a:getAlignmentAnnotation())
+ {
+ if (a.getCalcId()==calcId)
+ {
+ aa.add(a);
+ }
+ }
+ return aa;
+ }
}
else
{
// simple annotation row
- annotation = findOrCreate(scr.getMethod(), true, null, null);
+ annotation = alignViewport.getAlignment().findOrCreateAnnotation(scr.getMethod(), true, null, null);
Annotation[] elm = new Annotation[alWidth];
if (alWidth == scr.getScores().size())
{
return seqs;
}
- protected AlignmentAnnotation findOrCreate(String name, boolean autoCalc,
- SequenceI seqRef, SequenceGroup groupRef)
- {
- for (AlignmentAnnotation annot : alignViewport.getAlignment()
- .getAlignmentAnnotation())
- {
- if (annot.autoCalculated == autoCalc
- && annot.getCalcId().equals(name)
- && annot.sequenceRef == seqRef && annot.groupRef == groupRef)
- {
- return annot;
- }
- }
- AlignmentAnnotation annot = new AlignmentAnnotation(name, name,
- new Annotation[1], 0f, 0f, AlignmentAnnotation.BAR_GRAPH);
- annot.hasText = false;
- annot.setCalcId(new String(name));
- annot.autoCalculated = autoCalc;
- if (seqRef != null)
- {
- annot.setSequenceRef(seqRef);
- }
- annot.groupRef = groupRef;
- alignViewport.getAlignment().addAnnotation(annot);
-
- return annot;
- }
-
/**
* notify manager that we have started, and wait for a free calculation slot
*