A bag of highlighted areas specified by their document Position s.
The highlighted areas (highlights) are determined by their starting and ending
positions in a document and the set of attributes that should be used for rendering
that area. The highlights can be arbitrarily added to and remove from the bag.
The PositionsBag is designed to work over a single
document, which is passed in to the constructor. All the Position s
accepted by various methods in this class must refer to positions within
this document. Since there is no way how this could be checked it is up to
the users of this class to make sure that Position s they pass in
to the bag are from the same Document , which they used for creating
the bag.
The PositionsBag can operate in two modes depending on a
value passed in its construtor. The mode determines how the bag will treat
newly added highlights that overlap with existing highlights in the bag.
Trimming mode:
In the trimming mode the bag will trim any existing highlights that
would overlap with a newly added highlight. In this mode the newly
added highlights always replace the existing highlights if they overlap.
Merging mode:
In the merging mode the bag will merge attributes of the overlapping highlights.
The area where the new highlight overlaps with some existing highlights will
then constitute a new highlight and its attributes will be a composition of
the attributes of both the new and existing highlight. Should there be attributes
with the same name the attribute values from the newly added highlight will take
precedence.
author: Vita Stejskal |