A bag of highlighted areas specified by their offsets in a document.
The highlighted areas (highlights) are determined by their starting and ending
offsets 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 this bag.
The OffsetsBag is designed to work over a single
document, which is passed in to the constructor. All offsets
accepted by various methods in this class must refer to positions within
this document. Therefore any offsets passed in to the methods in this class
have to be equal to or greater than zero and less than or equal to the document
size.
The OffsetsBag 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, which 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 |