+ /**
+ * Builds a string hash of criteria for sorting, and if unchanged from last
+ * time, reverse the sort order
+ *
+ * @param method
+ * @param featureTypes
+ * @param groups
+ * @param startCol
+ * @param endCol
+ */
+ protected static void flipFeatureSortIfUnchanged(String method,
+ List<String> featureTypes, List<String> groups,
+ final int startCol, final int endCol)
+ {
+ StringBuilder sb = new StringBuilder(64);
+ sb.append(startCol).append(method).append(endCol);
+ if (featureTypes != null)
+ {
+ Collections.sort(featureTypes);
+ sb.append(featureTypes.toString());
+ }
+ if (groups != null)
+ {
+ Collections.sort(groups);
+ sb.append(groups.toString());
+ }
+ String scoreCriteria = sb.toString();
+
+ /*
+ * if resorting on the same criteria, toggle sort order
+ */
+ AlignmentSorter as = getInstance();
+ if (as.sortByFeatureCriteria == null
+ || !scoreCriteria.equals(as.sortByFeatureCriteria))
+ {
+ as.sortByFeatureAscending = true;
+ }
+ else
+ {
+ as.sortByFeatureAscending = !as.sortByFeatureAscending;
+ }
+ as.sortByFeatureCriteria = scoreCriteria;
+ }
+