public class

SearchResultHighlighter

extends PdfDrawableProvider
java.lang.Object
   ↳ com.pspdfkit.ui.drawable.PdfDrawableProvider
     ↳ com.pspdfkit.ui.search.SearchResultHighlighter

Class Overview

PdfDrawableProvider creating highlights based on a list of SearchResult instances.

Summary

[Expand]
Inherited Fields
From class com.pspdfkit.ui.drawable.PdfDrawableProvider
Public Constructors
SearchResultHighlighter(Context context)
Creates the search result highlighter.
Public Methods
synchronized void addSearchResults(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(Context context, PdfDocument document, int pageIndex)
Returns all drawables for the given document and pageIndex.
synchronized int getSearchResultAnimationPadding()
Returns padding of the highlighted search result used when pop-out animating the currently selected search result.
synchronized int getSearchResultAnnotationPadding()
Returns padding of the highlighted search result used when highlighting annotations.
synchronized int getSearchResultBackgroundColor()
Returns color of the highlighted search result.
synchronized int getSearchResultBorderColor()
Returns border color of the highlighted search result.
synchronized int getSearchResultBorderWidth()
Returns border width of the highlighted search result.
synchronized float getSearchResultCornerRadiusToHeightRatio()
Returns ratio between corner radius of the search result rectangle and its height.
synchronized int getSearchResultMaxCornerRadius()
Returns maximal corner radius of the highlighted search result.
synchronized int getSearchResultMinCornerRadius()
Returns minimal corner radius of the highlighted search result.
synchronized int getSearchResultPadding()
Returns padding of the the highlighted search result used when highlighting document text.
synchronized void setSearchResultAnimationPadding(int searchResultAnimationPadding)
Sets padding of the highlighted search result used when pop-out animating the currently selected search result.
synchronized void setSearchResultAnnotationPadding(int searchResultAnnotationPadding)
Sets padding of the highlighted search result used when highlighting annotations.
synchronized void setSearchResultBackgroundColor(int searchResultBackgroundColor)
Sets color of the highlighted search result.
synchronized void setSearchResultBorderColor(int searchResultBorderColor)
Sets border color of the highlighted search result.
synchronized void setSearchResultBorderWidth(int searchResultBorderWidth)
Sets border width of the highlighted search result.
synchronized void setSearchResultCornerRadiusToHeightRatio(float searchResultCornerRadiusToHeightRatio)
Sets ratio between corner radius of the search result rectangle and its height.
synchronized void setSearchResultMaxCornerRadius(int searchResultMaxCornerRadius)
Sets maximal corner radius of the highlighted search result.
synchronized void setSearchResultMinCornerRadius(int searchResultMinCornerRadius)
Sets minimal corner radius of the highlighted search result.
synchronized void setSearchResultPadding(int searchResultPadding)
Sets padding of the the highlighted search result used when highlighting document text.
synchronized void setSearchResults(List<SearchResult> results)
Sets new search results.
synchronized void setSelectedSearchResult(SearchResult newSelectedSearchResult)
Marks a single search results as selected, deselecting any previously selected search result.
[Expand]
Inherited Methods
From class com.pspdfkit.ui.drawable.PdfDrawableProvider
From class java.lang.Object

Public Constructors

public SearchResultHighlighter (Context context)

Creates the search result highlighter.

Parameters
context Context used for pulling theme attributes set for the search result highlights.

Public Methods

public synchronized void addSearchResults (List<SearchResult> results)

Adds the given results to the set of previously added results. In contrast to setSearchResults(List) 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.

public synchronized void clearSearchResults ()

Clears all previously selected search results.

public synchronized List<PdfDrawable> getDrawablesForPage (Context context, PdfDocument document, int pageIndex)

Returns all drawables for the given document and pageIndex. 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.

public 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).

public 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).

public synchronized int getSearchResultBackgroundColor ()

Returns color of the highlighted search result. This defaults to R.color#pspdf__color_highlight.

Returns
  • Search result background color.

public 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.

public 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).

public 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.

public 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).

public 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).

public 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).

public synchronized void setSearchResultAnimationPadding (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(Context, PdfDocument, int) 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).

public synchronized void setSearchResultAnnotationPadding (int searchResultAnnotationPadding)

Sets padding of the highlighted search result used when highlighting annotations. Once you've set this property, you need to call getDrawablesForPage(Context, PdfDocument, int) 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).

public synchronized void setSearchResultBackgroundColor (int searchResultBackgroundColor)

Sets color of the highlighted search result. Once you've set this property, you need to call getDrawablesForPage(Context, PdfDocument, int) in order to get search highlight drawables with latest properties applied.

Parameters
searchResultBackgroundColor Search result background color.

public synchronized void setSearchResultBorderColor (int searchResultBorderColor)

Sets border color of the highlighted search result. Once you've set this property, you need to call getDrawablesForPage(Context, PdfDocument, int) in order to get search highlight drawables with latest properties applied.

Parameters
searchResultBorderColor Search result border color.

public synchronized void setSearchResultBorderWidth (int searchResultBorderWidth)

Sets border width of the highlighted search result. Once you've set this property, you need to call getDrawablesForPage(Context, PdfDocument, int) in order to get search highlight drawables with latest properties applied.

Parameters
searchResultBorderWidth Search result rectangle border width (in pixels).

public synchronized void setSearchResultCornerRadiusToHeightRatio (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(Context, PdfDocument, int) in order to get search highlight drawables with latest properties applied.

Parameters
searchResultCornerRadiusToHeightRatio Search result corner radius to search result height ratio.

public synchronized void setSearchResultMaxCornerRadius (int searchResultMaxCornerRadius)

Sets maximal corner radius of the highlighted search result. Once you've set this property, you need to call getDrawablesForPage(Context, PdfDocument, int) in order to get search highlight drawables with latest properties applied.

Parameters
searchResultMaxCornerRadius Maximal corner radius (in pixels).

public synchronized void setSearchResultMinCornerRadius (int searchResultMinCornerRadius)

Sets minimal corner radius of the highlighted search result. Once you've set this property, you need to call getDrawablesForPage(Context, PdfDocument, int) in order to get search highlight drawables with latest properties applied.

Parameters
searchResultMinCornerRadius Minimal corner radius (in pixels).

public synchronized void setSearchResultPadding (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(Context, PdfDocument, int) 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).

public synchronized void setSearchResults (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.

public synchronized void setSelectedSearchResult (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(List) or an exception will be thrown.

Parameters
newSelectedSearchResult A search result that should be highlighted as selected.