+
+ @Override
+ public String toString()
+ {
+ return "Sort by label and sequence";
+ }
+ };
+
+ /**
+ * noSort leaves sort order unchanged, within sequence- and autocalculated
+ * annotations, but may switch the ordering of these groups. Note this is
+ * guaranteed (at least in Java 7) as Arrays.sort() is guaranteed to be
+ * 'stable' (not change ordering of equal items).
+ */
+ private Comparator<? super AlignmentAnnotation> noSort = new Comparator<AlignmentAnnotation>()
+ {
+ @Override
+ public int compare(AlignmentAnnotation o1, AlignmentAnnotation o2)
+ {
+ // TODO how to treat sequence-related autocalculated annotation
+ boolean o1auto = o1.autoCalculated && o1.sequenceRef == null;
+ boolean o2auto = o2.autoCalculated && o2.sequenceRef == null;
+ // TODO skip this test to allow customised ordering of all annotations
+ // - needs a third option: place autocalculated first / last / none
+ if (o1 != null && o2 != null)
+ {
+ if (o1auto && !o2auto)
+ {
+ return showAutocalcAbove ? -1 : 1;
+ }
+ if (!o1auto && o2auto)
+ {
+ return showAutocalcAbove ? 1 : -1;
+ }
+ }
+ return 0;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "No sort";
+ }