@Override
 protected void removeAllAnnotations(boolean fireModelChanged) {
   super.removeAllAnnotations(fireModelChanged);
   synchronized (getLockObject()) {
     fReverseMap.clear();
   }
 }
 @Override
 @SuppressWarnings({"unchecked"})
 protected void removeAnnotation(Annotation annotation, boolean fireModelChanged) {
   Position position = getPosition(annotation);
   synchronized (getLockObject()) {
     Object cached = fReverseMap.get(position);
     if (cached instanceof List) {
       List<Annotation> list = (List<Annotation>) cached;
       list.remove(annotation);
       if (list.size() == 1) {
         fReverseMap.put(position, list.get(0));
         list.clear();
       }
     } else if (cached instanceof Annotation) {
       fReverseMap.remove(position);
     }
   }
   super.removeAnnotation(annotation, fireModelChanged);
 }
    @Override
    @SuppressWarnings({"unchecked"})
    protected void addAnnotation(Annotation annotation, Position position, boolean fireModelChanged)
        throws BadLocationException {
      super.addAnnotation(annotation, position, fireModelChanged);

      synchronized (getLockObject()) {
        Object cached = fReverseMap.get(position);
        if (cached == null) fReverseMap.put(position, annotation);
        else if (cached instanceof List) {
          List<Annotation> list = (List<Annotation>) cached;
          list.add(annotation);
        } else if (cached instanceof Annotation) {
          List<Annotation> list = new ArrayList<Annotation>(2);
          list.add((Annotation) cached);
          list.add(annotation);
          fReverseMap.put(position, list);
        }
      }
    }