コード例 #1
0
  /**
   * Sorts the list of interaction partners. Alphabetical sorting is the default, but can be set to
   * sort by number of occurrences in {@link PreferenceDialog}.
   *
   * @param map The interactions to sort
   * @return The sorted interactions
   */
  private Map<Xref, Interaction> sortXrefs(Map<Xref, Interaction> map) {
    Map<Xref, Interaction> sorted = new LinkedHashMap<Xref, Interaction>();
    if (RegIntPreferences.getPreferences().getSort()
        == RegIntPreferences.BY_NUMBER_OF_OCCURRENCES) {
      List<ObjectsToSort> list = new ArrayList<ObjectsToSort>();

      for (Xref xref : map.keySet()) {
        ObjectsToSort obj = new ObjectsToSort(xref, map.get(xref).getFiles().size());
        list.add(obj);
      }

      Collections.sort(list);

      for (ObjectsToSort obj : list) {
        sorted.put(obj.getXref(), map.get(obj.getXref()));
      }
    } else {
      sorted = new TreeMap<Xref, Interaction>(map); // alphabetical sorting
      // as default
    }
    return sorted;
  }
コード例 #2
0
 @Override
 public int compareTo(ObjectsToSort o) {
   return o.getFiles().compareTo(files);
 }