Package nl.siegmann.epublib.viewer
Class HTMLDocumentFactory
java.lang.Object
nl.siegmann.epublib.viewer.HTMLDocumentFactory
- All Implemented Interfaces:
NavigationEventListener
Creates swing HTML documents from resources.
Between books the init(Book) function needs to be called in order for images to appear correctly.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ReentrantReadWriteLockprivate Lockprivate Lockstatic final intprivate Map<String, HTMLDocument> private MyHtmlEditorKitprivate ImageLoaderCacheprivate static final org.slf4j.Logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate HTMLDocumentcreateDocument(Resource resource) Creates a swing HTMLDocument from the given resource.getDocument(Resource resource) Get the HTMLDocument representation of the resource.voidprivate voidinitDocumentCache(Book book) voidnavigationPerformed(NavigationEvent navigationEvent) Called whenever the user navigates to another position in the book.private voidputDocument(Resource resource, HTMLDocument document) private static StringremoveControlTags(String input) Quick and dirty stripper of all <?...> and <!...> tags as these confuse the html viewer.private String
-
Field Details
-
log
private static final org.slf4j.Logger log -
DOCUMENT_CACHE_INDEXER_WAIT_TIME
public static final int DOCUMENT_CACHE_INDEXER_WAIT_TIME- See Also:
-
imageLoaderCache
-
cacheLock
-
cacheReadLock
-
cacheWriteLock
-
documentCache
-
editorKit
-
-
Constructor Details
-
Method Details
-
init
-
putDocument
-
getDocument
Get the HTMLDocument representation of the resource. If the resource is not an XHTML resource then it returns null. It first tries to get the document from the cache. If the document is not in the cache it creates a document from the resource and adds it to the cache.- Parameters:
resource-- Returns:
- the HTMLDocument representation of the resource.
-
stripHtml
-
removeControlTags
Quick and dirty stripper of all <?...> and <!...> tags as these confuse the html viewer.- Parameters:
input-- Returns:
- the input stripped of control characters
-
createDocument
Creates a swing HTMLDocument from the given resource. If the resources is not of type XHTML then null is returned.- Parameters:
resource-- Returns:
- a swing HTMLDocument created from the given resource.
-
initDocumentCache
-