Class NavigationHistory

    • Field Detail

      • DEFAULT_MAX_HISTORY_SIZE

        public static final int DEFAULT_MAX_HISTORY_SIZE
        See Also:
        Constant Field Values
      • DEFAULT_HISTORY_WAIT_TIME

        private static final long DEFAULT_HISTORY_WAIT_TIME
        See Also:
        Constant Field Values
      • lastUpdateTime

        private long lastUpdateTime
      • currentPos

        private int currentPos
      • currentSize

        private int currentSize
      • maxHistorySize

        private int maxHistorySize
      • historyWaitTime

        private long historyWaitTime
    • Constructor Detail

      • NavigationHistory

        public NavigationHistory​(Navigator navigator)
    • Method Detail

      • getCurrentPos

        public int getCurrentPos()
      • getCurrentSize

        public int getCurrentSize()
      • initBook

        public void initBook​(Book book)
      • getHistoryWaitTime

        public long getHistoryWaitTime()
        If the time between a navigation event is less than the historyWaitTime then the new location is not added to the history. When a user is rapidly viewing many pages using the slider we do not want all of them to be added to the history.
        Returns:
        the time we wait before adding the page to the history
      • setHistoryWaitTime

        public void setHistoryWaitTime​(long historyWaitTime)
      • addLocation

        public void addLocation​(Resource resource)
      • addLocation

        public void addLocation​(NavigationHistory.Location location)
        Adds the location after the current position. If the currentposition is not the end of the list then the elements between the current element and the end of the list will be discarded. Does nothing if the new location matches the current location.
        If this nr of locations becomes larger then the historySize then the first item(s) will be removed.
        Parameters:
        location -
      • checkHistorySize

        private void checkHistorySize()
        Removes all elements that are too much for the maxHistorySize out of the history.
      • addLocation

        public void addLocation​(java.lang.String href)
      • getLocationHref

        private java.lang.String getLocationHref​(int pos)
      • move

        public boolean move​(int delta)
        Moves the current positions delta positions. move(-1) to go one position back in history.
        move(1) to go one position forward.
        Parameters:
        delta -
        Returns:
        Whether we actually moved. If the requested value is illegal it will return false, true otherwise.
      • navigationPerformed

        public void navigationPerformed​(NavigationEvent navigationEvent)
        If this is not the source of the navigationEvent then the addLocation will be called with the href of the currentResource in the navigationEvent.
        Specified by:
        navigationPerformed in interface NavigationEventListener
      • getCurrentHref

        public java.lang.String getCurrentHref()
      • setMaxHistorySize

        public void setMaxHistorySize​(int maxHistorySize)
      • getMaxHistorySize

        public int getMaxHistorySize()