Package com.inet.pdfc.results
Class ResultModel
java.lang.Object
com.inet.pdfc.results.ResultModel
- All Implemented Interfaces:
Closeable
,Serializable
,AutoCloseable
This class is the central model to access the results of a comparison and to make the result available to any
listener and presenter.
A ResultModel wraps an instance of
Beyond that, a ResultModel handles several runtime aspects of the comparison result, for example filtering the presentation according to given settings. In general, it makes the comparison result available to listeners which can manipulate or update the result.
A ResultModel wraps an instance of
ResultModelData
where the persistable data
of the comparison result are stored. It is that instance can be used to serialize the result and save it across
sessions. Beyond that, a ResultModel handles several runtime aspects of the comparison result, for example filtering the presentation according to given settings. In general, it makes the comparison result available to listeners which can manipulate or update the result.
- Since:
- 3.0
- See Also:
-
ResultModelData
- Serialized Form
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Event object with a page range for both documents where the differences data has changedstatic interface
Defines a listener for the result modelstatic enum
Defines the type of model change in an update event -
Constructor Summary
ConstructorDescriptionCreates the instance and sets allDiffGroup.GroupType
s to visible.ResultModel
(com.inet.pdfc.results.ResultModelData data) Creates the instance, sets allDiffGroup.GroupType
s to visible and sets the data. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds aResultModelChangeListener
to this model.void
clear()
Completely clears the model including the page images.void
close()
Clears all in memory and cached data of thisResultModel
.
It's highly recommended to call this method before releasing the instance!Returns the static data for the current comparison.getDifferences
(boolean filtered) Returns either all or only the visible differences in this mode, depending on theDiffGroup.GroupType
visibility settings.int
getDifferences
(Modification.ModificationType type, boolean filtered) Count all differences with the specified modification type.int
getDifferencesCount
(boolean filtered) Returns the number of differences held by this model.getHighlightData
(String key) Return the highlight overlay data for a certain filter or type.getHighlightsForPage
(int pageNr, boolean firstDocument) Returns the highlights for a page.getPage
(int pageIndex, boolean first) Returns a page info object for a certain page.Returns the page at the specified location ornull
if there is no page at the specified location.int
getPageCount
(boolean first) Returns the number of pages CURRENTLY AVAILABLE for one of the documents.com.inet.pdfc.generator.rendercache.PageImageCache
Returns the page image cache.Returns a copy of the current settings.boolean
isEmpty()
Returns whether the list of page info objects is emptyboolean
Deprecated.boolean
isVisible
(VisibilitySetting setting) Returns whether differences of a certainVisibilitySetting
is shown / used in the presentation of this result model.void
Removes aResultModelChangeListener
from this model.void
setHighlightVisibile
(String key, boolean visible) Deprecated.As of i-net PDFC 4.3, usesetSetting(Settings)
insteadvoid
setSetting
(Settings settings) Set setting for this model.void
setTypeVisible
(DiffGroup.GroupType t, boolean visible) Deprecated.As of i-net PDFC 4.1, usesetSetting(Settings)
insteadvoid
setVisible
(boolean isVisible, VisibilitySetting... visibles) Deprecated.As of i-net PDFC 4.3, usesetSetting(Settings)
instead
-
Constructor Details
-
ResultModel
public ResultModel()Creates the instance and sets allDiffGroup.GroupType
s to visible.- Since:
- 3.0
-
ResultModel
public ResultModel(com.inet.pdfc.results.ResultModelData data) Creates the instance, sets allDiffGroup.GroupType
s to visible and sets the data.- Parameters:
data
- the data for this result model- Since:
- 4.0
-
-
Method Details
-
addChangeListener
Adds aResultModelChangeListener
to this model. This listener will be notified whenever the model is cleared, new differences are added, the comparison has finished or the filter has changed.- Parameters:
l
- theResultModelChangeListener
to add (not null)- Since:
- 3.0
- See Also:
-
clear
public void clear()Completely clears the model including the page images. Fires a change result of typeResultModel.STATE_CHANGE_TYPE.CLEARED
- Since:
- 3.0
-
close
public void close()Clears all in memory and cached data of thisResultModel
.
It's highly recommended to call this method before releasing the instance!
Not calling close() may result on a notable performance decline since the caching process and memory usage will persist until the next garbage collection cycle.
Since there is no 'closed' state for theResultModel
the instance will just be empty when this call returns.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Since:
- 4.1
-
getComparisonParameters
Returns the static data for the current comparison. This includes the source PDF references as well as the configuration of the comparison- Returns:
- the comparison static data
- Since:
- 3.0
-
getDifferences
Returns either all or only the visible differences in this mode, depending on theDiffGroup.GroupType
visibility settings.- Parameters:
filtered
- iftrue
, only the type which are visible will be returned, iffalse
all differences known to this model will be returned.- Returns:
- a list of differences, never
null
but may be empty - Since:
- 3.0
-
getDifferences
Count all differences with the specified modification type.- Parameters:
type
- the modification type that should be countedfiltered
- iftrue
, only the types which are visible will be returned, iffalse
all differences known to this model will be returned.- Returns:
- the differences for a
Modification.ModificationType
- Since:
- 5.0
-
getDifferencesCount
public int getDifferencesCount(boolean filtered) Returns the number of differences held by this model. This number is an approximation to how many changes where done in the documents. It's neither the number of elements which are somehow affected nor the number ofDiffGroup
s in the model. E.G. aDiffGroup
of typeDiffGroup.GroupType.AddedOrRemoved
contains an add and a remove modification, this will be counted as two differences here.- Parameters:
filtered
- iftrue
, only the type which are visible as byisVisible(VisibilitySetting)
will be counted, iffalse
all differences known to this model will be counted.- Returns:
- the number of differences to be displayed to the user or presenter
- Since:
- 3.0
-
getHighlightData
Return the highlight overlay data for a certain filter or type.- Parameters:
key
- type to get the Highlight data for- Returns:
- the highlight overlay data or
null
, if there is no such filter currently active - Since:
- 4.0
-
getHighlightsForPage
Returns the highlights for a page. Highlights are either annotations of the PDF file itself or created by filter to outline filtered elements.- Parameters:
pageNr
- the zero-based page numberfirstDocument
- true if the first document is references, false for the second one- Returns:
- the highlights for this page, may be
null
or empty - Since:
- 3.0
-
getPageCount
public int getPageCount(boolean first) Returns the number of pages CURRENTLY AVAILABLE for one of the documents. This number may increase as new pages are appended to the model.- Parameters:
first
-true
if the first document is references,false
for the second one- Returns:
- the maximum number of pages
- Since:
- 4.0
-
getPage
Returns a page info object for a certain page. This info object contains all informations about the page except the differences on this page sinceDiffGroup
s may span several pages. If you'd like to get all differences for a page, please usegetDifferences(boolean)
and filter all differences with a y-location inside the bounds of a page.- Parameters:
pageIndex
- the zero-based index of the pagefirst
-true
to get a page of the first document,false
to get a page for the second document- Returns:
- the requested page object, may be a dummy if there is no such page in this document, or
null
if the index below zero or larger thangetPageCount(boolean)
- Since:
- 3.0
-
getPageAt
Returns the page at the specified location ornull
if there is no page at the specified location.- Parameters:
pos
- the locationleft
- flag indicating the left side document- Returns:
- the page
- Since:
- 3.0
-
getPageImageCache
public com.inet.pdfc.generator.rendercache.PageImageCache getPageImageCache()Returns the page image cache. This is is used by the parser to store the pares pages to. Use this as a source for rendered pages when exporting the result.- Returns:
- the page image cache
- Since:
- 3.0
-
isEmpty
public boolean isEmpty()Returns whether the list of page info objects is empty- Returns:
- whether the list of page info objects is empty
- Since:
- 3.0
-
isTypeVisible
Deprecated.As of i-net PDFC 4.1, useisVisible(VisibilitySetting)
insteadReturns whether differences of a certainDiffGroup.GroupType
is shown / used in the presentation of this result model.- Parameters:
t
- the type to check for- Returns:
- true, if the type is visible
- Since:
- 3.0
-
isVisible
Returns whether differences of a certainVisibilitySetting
is shown / used in the presentation of this result model.- Parameters:
setting
- the type to check for- Returns:
- true, if the type is visible
- Since:
- 4.1
-
removeChangeListener
Removes aResultModelChangeListener
from this model.- Parameters:
l
- theResultModelChangeListener
to remove (not null)- Since:
- 3.0
- See Also:
-
setHighlightVisibile
Deprecated.As of i-net PDFC 4.3, usesetSetting(Settings)
insteadSets a certain type of highlight to visible or hidden. This does not modify the model but will cause theResultPage.getHighlights()
to be filtered according to this setting.- Parameters:
key
- the key of the filter to plugin to show the highlights forvisible
-true
for visible,false
to hide- Since:
- 4.0
-
setTypeVisible
Deprecated.As of i-net PDFC 4.1, usesetSetting(Settings)
insteadDefines a difference type as visible or invisible.
This can be called outside the Event Dispatching Thread. To inform any listeners about the change, the caller must explicitly call the fireStateChange method from inside the EDT- Parameters:
t
- the type to setvisible
- true for visible- Since:
- 3.0
-
setSetting
Set setting for this model. With the setting can be change the color and the visibility of GroupTypes.- Parameters:
settings
- the new setting- Since:
- 4.1
-
setVisible
Deprecated.As of i-net PDFC 4.3, usesetSetting(Settings)
insteadDefines a difference type as visible or invisible.
This can be called outside the Event Dispatching Thread. To inform any listeners about the change, the caller must explicitly call the fireStateChange method from inside the EDT- Parameters:
isVisible
- true for visiblevisibles
- the type to set- Since:
- 4.1
-
getSettings
Returns a copy of the current settings. So, on order to modify the settings you'll have to callsetSetting(Settings)
afterwards.- Returns:
- a copy of the current settings
- Since:
- 5.0
-
isVisible(VisibilitySetting)
instead