Class Navigator

  • All Implemented Interfaces:
    java.io.Serializable

    public class Navigator
    extends java.lang.Object
    implements java.io.Serializable
    A 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 Detail

      • book

        private Book book
      • currentSpinePos

        private int currentSpinePos
      • currentResource

        private Resource currentResource
      • currentPagePos

        private int currentPagePos
      • currentFragmentId

        private java.lang.String currentFragmentId
    • 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()