use of gate.event.AnnotationSetEvent in project gate-core by GateNLP.
the class AnnotationSetImpl method remove.
/**
* Remove an element from this set.
*/
@Override
public boolean remove(Object o) throws ClassCastException {
Annotation a = (Annotation) o;
boolean wasPresent = removeFromIdIndex(a);
if (wasPresent) {
removeFromTypeIndex(a);
removeFromOffsetIndex(a);
}
// fire the event
fireAnnotationRemoved(new AnnotationSetEvent(AnnotationSetImpl.this, AnnotationSetEvent.ANNOTATION_REMOVED, getDocument(), a));
return wasPresent;
}
use of gate.event.AnnotationSetEvent in project gate-core by GateNLP.
the class AnnotationSetImpl method add.
// add(Node, Node, String, FeatureMap)
/**
* Add an existing annotation. Returns true when the set is modified.
*/
@Override
public boolean add(Annotation a) throws ClassCastException {
Annotation oldValue = annotsById.put(a.getId(), a);
if (oldValue != null) {
if (annotsByType != null)
removeFromTypeIndex(oldValue);
if (annotsByStartNode != null)
removeFromOffsetIndex(oldValue);
}
if (annotsByType != null)
addToTypeIndex(a);
if (annotsByStartNode != null)
addToStartOffsetIndex(a);
AnnotationSetEvent evt = new AnnotationSetEvent(this, AnnotationSetEvent.ANNOTATION_ADDED, doc, a);
fireAnnotationAdded(evt);
fireGateEvent(evt);
return oldValue != a;
}
Aggregations