/**
  * Get the level which is best for displaying the given range.
  *
  * @param levels list of levels to be checked
  * @param r the range to be displayed
  * @return
  */
 private Level getBestLevel(List<Level> levels, Range r) {
   for (int i = levels.size() - 1; i > 0; i--) {
     Level lev = levels.get(i);
     if (r.getLength() > lev.resolution * ContinuousFormatterHelper.NOTIONAL_SCREEN_SIZE / 2) {
       return lev;
     }
   }
   return levels.get(0);
 }
Ejemplo n.º 2
0
  /**
   * This function is equivalent to getSelectedFromList(URI uri, List<Record> data) but it uses
   * range to check whether anything has changed since the last request. If nothing has changed,
   * return the same list.
   */
  public List<Record> getSelectedFromList(String name, Range range, List<Record> data) {

    if (range.equals(rangeMap.get(name)) && currentMap.get(name) != null) {
      return currentMap.get(name);
    }

    rangeMap.put(name, range);
    List<Record> currentSelected = getSelectedFromList(name, data);
    currentMap.put(name, currentSelected);

    return currentSelected;
  }