Class Navigator
- java.lang.Object
-
- nl.siegmann.epublib.browsersupport.Navigator
-
- All Implemented Interfaces:
java.io.Serializable
public class Navigator extends java.lang.Object implements java.io.SerializableA helper class for epub browser applications. It helps moving from one resource to the other, from one resource to the other and keeping other elements of the application up-to-date by calling the NavigationEventListeners.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private Bookbookprivate java.lang.StringcurrentFragmentIdprivate intcurrentPagePosprivate ResourcecurrentResourceprivate intcurrentSpinePosprivate java.util.List<NavigationEventListener>eventListenersprivate static longserialVersionUID
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddNavigationEventListener(NavigationEventListener navigationEventListener)BookgetBook()java.lang.StringgetCurrentFragmentId()ResourcegetCurrentResource()intgetCurrentSectionPos()intgetCurrentSpinePos()The current position within the spine.voidgotoBook(Book book, java.lang.Object source)intgotoFirstSpineSection(java.lang.Object source)intgotoLastSpineSection(java.lang.Object source)intgotoNextSpineSection(java.lang.Object source)intgotoPreviousSpineSection(int pagePos, java.lang.Object source)intgotoPreviousSpineSection(java.lang.Object source)intgotoResource(java.lang.String resourceHref, java.lang.Object source)intgotoResource(Resource resource, int pagePos, java.lang.Object source)intgotoResource(Resource resource, int pagePos, java.lang.String fragmentId, java.lang.Object source)intgotoResource(Resource resource, java.lang.Object source)intgotoResource(Resource resource, java.lang.String fragmentId, java.lang.Object source)intgotoResourceId(java.lang.String resourceId, java.lang.Object source)intgotoSpineSection(int newSpinePos, int newPagePos, java.lang.Object source)Go to a specific section.intgotoSpineSection(int newSpinePos, java.lang.Object source)private voidhandleEventListeners(NavigationEvent navigationEvent)booleanhasNextSpineSection()booleanhasPreviousSpineSection()booleanremoveNavigationEventListener(NavigationEventListener navigationEventListener)intsetCurrentResource(Resource currentResource)Sets the current index and resource without calling the eventlisteners.voidsetCurrentSpinePos(int currentIndex)Sets the current index and resource without calling the eventlisteners.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
book
private Book book
-
currentSpinePos
private int currentSpinePos
-
currentResource
private Resource currentResource
-
currentPagePos
private int currentPagePos
-
currentFragmentId
private java.lang.String currentFragmentId
-
eventListeners
private java.util.List<NavigationEventListener> eventListeners
-
-
Constructor Detail
-
Navigator
public Navigator()
-
Navigator
public Navigator(Book book)
-
-
Method Detail
-
handleEventListeners
private void handleEventListeners(NavigationEvent navigationEvent)
-
addNavigationEventListener
public boolean addNavigationEventListener(NavigationEventListener navigationEventListener)
-
removeNavigationEventListener
public boolean removeNavigationEventListener(NavigationEventListener navigationEventListener)
-
gotoFirstSpineSection
public int gotoFirstSpineSection(java.lang.Object source)
-
gotoPreviousSpineSection
public int gotoPreviousSpineSection(java.lang.Object source)
-
gotoPreviousSpineSection
public int gotoPreviousSpineSection(int pagePos, java.lang.Object source)
-
hasNextSpineSection
public boolean hasNextSpineSection()
-
hasPreviousSpineSection
public boolean hasPreviousSpineSection()
-
gotoNextSpineSection
public int gotoNextSpineSection(java.lang.Object source)
-
gotoResource
public int gotoResource(java.lang.String resourceHref, java.lang.Object source)
-
gotoResource
public int gotoResource(Resource resource, java.lang.Object source)
-
gotoResource
public int gotoResource(Resource resource, java.lang.String fragmentId, java.lang.Object source)
-
gotoResource
public int gotoResource(Resource resource, int pagePos, java.lang.Object source)
-
gotoResource
public int gotoResource(Resource resource, int pagePos, java.lang.String fragmentId, java.lang.Object source)
-
gotoResourceId
public int gotoResourceId(java.lang.String resourceId, java.lang.Object source)
-
gotoSpineSection
public int gotoSpineSection(int newSpinePos, java.lang.Object source)
-
gotoSpineSection
public int gotoSpineSection(int newSpinePos, int newPagePos, java.lang.Object source)Go to a specific section. Illegal spine positions are silently ignored.- Parameters:
newSpinePos-source-- Returns:
- The current position within the spine
-
gotoLastSpineSection
public int gotoLastSpineSection(java.lang.Object source)
-
gotoBook
public void gotoBook(Book book, java.lang.Object source)
-
getCurrentSpinePos
public int getCurrentSpinePos()
The current position within the spine.- Returns:
- something < 0 if the current position is not within the spine.
-
getCurrentResource
public Resource getCurrentResource()
-
setCurrentSpinePos
public void setCurrentSpinePos(int currentIndex)
Sets the current index and resource without calling the eventlisteners. If you want the eventListeners called use gotoSection(index);- Parameters:
currentIndex-
-
getBook
public Book getBook()
-
setCurrentResource
public int setCurrentResource(Resource currentResource)
Sets the current index and resource without calling the eventlisteners. If you want the eventListeners called use gotoSection(index);
-
getCurrentFragmentId
public java.lang.String getCurrentFragmentId()
-
getCurrentSectionPos
public int getCurrentSectionPos()
-
-