+ if (refSeq != null)\r
+ {\r
+ annotation.belowAlignment = false;\r
+ // make a copy of refSeq so we can find other matches in the alignment\r
+ SequenceI referedSeq = refSeq;\r
+ do\r
+ {\r
+ // copy before we do any mapping business.\r
+ // TODO: verify that undo/redo with 1:many sequence associated\r
+ // annotations can be undone correctly\r
+ AlignmentAnnotation ann = new AlignmentAnnotation(annotation);\r
+ annotation\r
+ .createSequenceMapping(referedSeq, refSeqIndex, false);\r
+ annotation.adjustForAlignment();\r
+ referedSeq.addAlignmentAnnotation(annotation);\r
+ al.addAnnotation(annotation);\r
+ al.setAnnotationIndex(annotation,\r
+ al.getAlignmentAnnotation().length\r
+ - existingAnnotations - 1);\r
+ // and recover our virgin copy to use again if necessary.\r
+ annotation = ann;\r
+\r
+ } while (refSeqId != null\r
+ && (referedSeq = al.findName(referedSeq, refSeqId, true)) != null);\r
+ }\r
+ else\r
+ {\r
+ al.addAnnotation(annotation);\r
+ al.setAnnotationIndex(annotation,\r
+ al.getAlignmentAnnotation().length - existingAnnotations\r
+ - 1);\r
+ }\r