private boolean advanceApiBetweenOrLater(TreeSet<AreaPanelInfo> sortedApiTree,AreaPanelInfo api,int minTime,int maxTime,int endTime){
  sortedApiTree.remove(api);
  AreaPanel ap=api.ap();
  TimeTree rootTt=ap.getTimeTree();
  TimeTree tt=rootTt.getEncompassigTimeTreeOrMaxTimeTreeBeforeTime(maxTime,true);
  if (tt == null || tt.getMinTimeSecs() < minTime) {
    tt=rootTt.getEncompassigTimeTreeOrMinTimeTreeAfterTime(maxTime,true);
    if (api.setTt(tt,endTime)) {
      sortedApiTree.add(api);
    }
    return false;
  }
 else {
    if (api.setTt(tt,endTime))     sortedApiTree.add(api);
    return true;
  }
}

private boolean advanceApiBetweenOrLater ( TreeSet < AreaPanelInfo > sortedApiTree , AreaPanelInfo api , int minTime , int maxTime , int endTime ) { sortedApiTree . remove ( api ) ; AreaPanel ap = api . ap ( ) ; TimeTree rootTt = ap . getTimeTree ( ) ; TimeTree tt = rootTt . getEncompassigTimeTreeOrMaxTimeTreeBeforeTime ( maxTime , true ) ; if ( tt == null || tt . getMinTimeSecs ( ) < minTime ) { tt = rootTt . getEncompassigTimeTreeOrMinTimeTreeAfterTime ( maxTime , true ) ; if ( api . setTt ( tt , endTime ) ) { sortedApiTree . add ( api ) ; } return false ; } else { if ( api . setTt ( tt , endTime ) ) sortedApiTree . add ( api ) ; return true ; } }
advances the api to the latest time tree that is > = mintime and < = maxtime . if this is not possible , will advance even further to the earliest time after maxtime
