Exemple #1
0
 @Override
 public TextPosition getPreTranslationPosition(TextPosition source) {
   // find the most recent change to the offset and add it to the
   // position
   Offset offset = null;
   if (offsetMap.containsKey(source)) { // offset change starts at the specified position
     offset = offsetMap.get(source);
   } else {
     SortedMap<TextPosition, Offset> headMap = offsetMap.headMap(source);
     if (headMap.isEmpty()) { // no offset change occurs before the position
       offset = new Offset(0, 0);
     } else { // offset change strictly precedes the position
       offset = headMap.get(headMap.lastKey());
     }
   }
   return offset.forwardOffset(source);
 }