Class SearchResultHighlighter
-
- All Implemented Interfaces:
-
com.pspdfkit.ui.PageObjectProvider
public class SearchResultHighlighter extends PdfDrawableProvider
PdfDrawableProvider creating highlights based on a list of SearchResult instances.
-
-
Constructor Summary
Constructors Constructor Description SearchResultHighlighter(Context context)
Creates the search result highlighter.
-
Method Summary
Modifier and Type Method Description synchronized void
addSearchResults(@NonNull() List<SearchResult> results)
Adds the given results
to the set of previously added results.synchronized void
clearSearchResults()
Clears all previously selected search results. synchronized List<PdfDrawable>
getDrawablesForPage(@NonNull() Context context, @NonNull() PdfDocument document, @IntRange(from = 0) int pageIndex)
Returns all drawables for the given document
andpageIndex
.synchronized int
getSearchResultBackgroundColor()
Returns color of the highlighted search result. synchronized void
setSearchResultBackgroundColor(@ColorInt() int searchResultBackgroundColor)
Sets color of the highlighted search result. synchronized int
getSearchResultBorderColor()
Returns border color of the highlighted search result. synchronized void
setSearchResultBorderColor(@ColorInt() int searchResultBorderColor)
Sets border color of the highlighted search result. synchronized int
getSearchResultBorderWidth()
Returns border width of the highlighted search result. synchronized void
setSearchResultBorderWidth(@IntRange(from = 0) int searchResultBorderWidth)
Sets border width of the highlighted search result. synchronized int
getSearchResultPadding()
Returns padding of the the highlighted search result used when highlighting document text. synchronized void
setSearchResultPadding(@IntRange(from = 0) int searchResultPadding)
Sets padding of the the highlighted search result used when highlighting document text. synchronized int
getSearchResultAnnotationPadding()
Returns padding of the highlighted search result used when highlighting annotations. synchronized void
setSearchResultAnnotationPadding(@IntRange(from = 0) int searchResultAnnotationPadding)
Sets padding of the highlighted search result used when highlighting annotations. synchronized int
getSearchResultAnimationPadding()
Returns padding of the highlighted search result used when pop-out animating the currently selected search result. synchronized void
setSearchResultAnimationPadding(@IntRange(from = 0) int searchResultAnimationPadding)
Sets padding of the highlighted search result used when pop-out animating the currently selected search result. synchronized float
getSearchResultCornerRadiusToHeightRatio()
Returns ratio between corner radius of the search result rectangle and its height. synchronized void
setSearchResultCornerRadiusToHeightRatio(@FloatRange(from = 0) float searchResultCornerRadiusToHeightRatio)
Sets ratio between corner radius of the search result rectangle and its height. synchronized int
getSearchResultMinCornerRadius()
Returns minimal corner radius of the highlighted search result. synchronized void
setSearchResultMinCornerRadius(@IntRange(from = 0) int searchResultMinCornerRadius)
Sets minimal corner radius of the highlighted search result. synchronized int
getSearchResultMaxCornerRadius()
Returns maximal corner radius of the highlighted search result. synchronized void
setSearchResultMaxCornerRadius(@IntRange(from = 0) int searchResultMaxCornerRadius)
Sets maximal corner radius of the highlighted search result. synchronized void
setSearchResults(@NonNull() List<SearchResult> results)
Sets new search results. synchronized void
setSelectedSearchResult(@Nullable() SearchResult newSelectedSearchResult)
Marks a single search results as selected, deselecting any previously selected search result. -
-
Constructor Detail
-
SearchResultHighlighter
SearchResultHighlighter(Context context)
Creates the search result highlighter.- Parameters:
context
- Context used for pulling theme attributes set for the search result highlights.
-
-
Method Detail
-
addSearchResults
synchronized void addSearchResults(@NonNull() List<SearchResult> results)
Adds the given
results
to the set of previously added results. In contrast to setSearchResults a call to this will not clear previously set results. Also any previously selected search result will not be cleared.- Parameters:
results
- List of search results to add to highlighting.
-
clearSearchResults
synchronized void clearSearchResults()
Clears all previously selected search results.
-
getDrawablesForPage
@Nullable() synchronized List<PdfDrawable> getDrawablesForPage(@NonNull() Context context, @NonNull() PdfDocument document, @IntRange(from = 0) int pageIndex)
Returns all drawables for the given
document
andpageIndex
. The framework may call this method on any thread.- Parameters:
context
- Context for resource resolution.document
- The currently loaded PdfDocument.pageIndex
- Number of the page for which the drawables should be returned.- Returns:
A list of all drawables for the given document and page.
-
getSearchResultBackgroundColor
@ColorInt() synchronized int getSearchResultBackgroundColor()
Returns color of the highlighted search result. This defaults to
R.color#pspdf__color_highlight
.- Returns:
Search result background color.
-
setSearchResultBackgroundColor
synchronized void setSearchResultBackgroundColor(@ColorInt() int searchResultBackgroundColor)
Sets color of the highlighted search result. Once you've set this property, you need to call getDrawablesForPage in order to get search highlight drawables with latest properties applied.
- Parameters:
searchResultBackgroundColor
- Search result background color.
-
getSearchResultBorderColor
@ColorInt() synchronized int getSearchResultBorderColor()
Returns border color of the highlighted search result. This defaults to
R.color#pspdf__border_color_highlight
.- Returns:
Search result border color.
-
setSearchResultBorderColor
synchronized void setSearchResultBorderColor(@ColorInt() int searchResultBorderColor)
Sets border color of the highlighted search result. Once you've set this property, you need to call getDrawablesForPage in order to get search highlight drawables with latest properties applied.
- Parameters:
searchResultBorderColor
- Search result border color.
-
getSearchResultBorderWidth
@IntRange(from = 0) synchronized int getSearchResultBorderWidth()
Returns border width of the highlighted search result. This defaults to
R.dimen#pspdf__search_result_border_width
.- Returns:
Search result rectangle border width (in pixels).
-
setSearchResultBorderWidth
synchronized void setSearchResultBorderWidth(@IntRange(from = 0) int searchResultBorderWidth)
Sets border width of the highlighted search result. Once you've set this property, you need to call getDrawablesForPage in order to get search highlight drawables with latest properties applied.
- Parameters:
searchResultBorderWidth
- Search result rectangle border width (in pixels).
-
getSearchResultPadding
@IntRange(from = 0) synchronized int getSearchResultPadding()
Returns padding of the the highlighted search result used when highlighting document text. This defaults to
R.dimen#pspdf__search_result_padding
.- Returns:
Padding of the highlighted search result used for text results (in pixels).
-
setSearchResultPadding
synchronized void setSearchResultPadding(@IntRange(from = 0) int searchResultPadding)
Sets padding of the the highlighted search result used when highlighting document text. Once you've set this property, you need to call getDrawablesForPage in order to get search highlight drawables with latest properties applied.
- Parameters:
searchResultPadding
- Padding of the highlighted search result used for text results (in pixels).
-
getSearchResultAnnotationPadding
@IntRange(from = 0) synchronized int getSearchResultAnnotationPadding()
Returns padding of the highlighted search result used when highlighting annotations. This defaults to pspdf__search_result_annotation_padding.
- Returns:
Padding of the highlighted search result used for annotation results (in pixels).
-
setSearchResultAnnotationPadding
synchronized void setSearchResultAnnotationPadding(@IntRange(from = 0) int searchResultAnnotationPadding)
Sets padding of the highlighted search result used when highlighting annotations. Once you've set this property, you need to call getDrawablesForPage in order to get search highlight drawables with latest properties applied.
- Parameters:
searchResultAnnotationPadding
- Padding of the highlighted search result used for annotation results (in pixels).
-
getSearchResultAnimationPadding
@IntRange(from = 0) synchronized int getSearchResultAnimationPadding()
Returns padding of the highlighted search result used when pop-out animating the currently selected search result. This defaults to pspdf__search_result_animation_padding.
- Returns:
Padding of the highlighted search result used when pop-out animating the currently selected search result (in pixels).
-
setSearchResultAnimationPadding
synchronized void setSearchResultAnimationPadding(@IntRange(from = 0) int searchResultAnimationPadding)
Sets padding of the highlighted search result used when pop-out animating the currently selected search result. Once you've set this property, you need to call getDrawablesForPage in order to get search highlight drawables with latest properties applied.
- Parameters:
searchResultAnimationPadding
- Padding of the highlighted search result used when pop-out animating the currently selected search result (in pixels).
-
getSearchResultCornerRadiusToHeightRatio
@FloatRange(from = 0) synchronized float getSearchResultCornerRadiusToHeightRatio()
Returns ratio between corner radius of the search result rectangle and its height. This defaults to
0.1f
.- Returns:
Search result corner radius to search result height ratio.
-
setSearchResultCornerRadiusToHeightRatio
synchronized void setSearchResultCornerRadiusToHeightRatio(@FloatRange(from = 0) float searchResultCornerRadiusToHeightRatio)
Sets ratio between corner radius of the search result rectangle and its height. Once you've set this property, you need to call getDrawablesForPage in order to get search highlight drawables with latest properties applied.
- Parameters:
searchResultCornerRadiusToHeightRatio
- Search result corner radius to search result height ratio.
-
getSearchResultMinCornerRadius
@IntRange(from = 0) synchronized int getSearchResultMinCornerRadius()
Returns minimal corner radius of the highlighted search result. This defaults to pspdf__search_result_min_corner_radius.
- Returns:
Minimal corner radius (in pixels).
-
setSearchResultMinCornerRadius
synchronized void setSearchResultMinCornerRadius(@IntRange(from = 0) int searchResultMinCornerRadius)
Sets minimal corner radius of the highlighted search result. Once you've set this property, you need to call getDrawablesForPage in order to get search highlight drawables with latest properties applied.
- Parameters:
searchResultMinCornerRadius
- Minimal corner radius (in pixels).
-
getSearchResultMaxCornerRadius
@IntRange(from = 0) synchronized int getSearchResultMaxCornerRadius()
Returns maximal corner radius of the highlighted search result. This defaults to pspdf__search_result_max_corner_radius.
- Returns:
Maximal corner radius (in pixels).
-
setSearchResultMaxCornerRadius
synchronized void setSearchResultMaxCornerRadius(@IntRange(from = 0) int searchResultMaxCornerRadius)
Sets maximal corner radius of the highlighted search result. Once you've set this property, you need to call getDrawablesForPage in order to get search highlight drawables with latest properties applied.
- Parameters:
searchResultMaxCornerRadius
- Maximal corner radius (in pixels).
-
setSearchResults
synchronized void setSearchResults(@NonNull() List<SearchResult> results)
Sets new search results. Calling this will replace any previously set search results and also clear the currently selected search result.
- Parameters:
results
- List of search results to highlight.
-
setSelectedSearchResult
synchronized void setSelectedSearchResult(@Nullable() SearchResult newSelectedSearchResult)
Marks a single search results as selected, deselecting any previously selected search result. Callers must ensure that the selected search results has been set previously using setSearchResults or an exception will be thrown.
- Parameters:
newSelectedSearchResult
- A search result that should be highlighted as selected.
-
-
-
-