Package diva.gui

Class MultipageModel


  • public class MultipageModel
    extends java.lang.Object
    A document that contains a linear sequence of Pages. This class is useful for documents which their data into logical pages. Generally this class is most useful for partitioned documents where all the partitions are stored together. For partitions that are stored separately, it is probably easiest to just use separate documents. Note that a page can contain any kind of data, and the interpretation and graphical representation of a list of page is up to the concrete document class and the corresponding application. Other than containing a sequence of pages, this class is used the same as AbstractDocument and provides the same abstract methods.
    Version:
    $Id$
    Author:
    John Reekie
    • Constructor Summary

      Constructors 
      Constructor Description
      MultipageModel()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addPage​(Page p)
      Add a page to the document and notify page listeners.
      void addPageListener​(javax.swing.event.ListDataListener listener)
      Add a page listener to this document.
      Page getCurrentPage()
      Get the current page.
      Page getPage​(int index)
      Get the page at the given index.
      Page getPage​(java.lang.String title)
      Get the page with the given title.
      int getPageCount()
      Get the number of pages in this document.
      java.lang.String getTitle()
      Return the title of this model
      int indexOf​(Page p)
      Get the index of the given page.
      void insertPage​(Page p, int index)
      Add a page to the document at the given index (between 0 and getPageCount()-1) and notify page listeners.
      java.util.Iterator pages()
      Return an iterator over all pages
      void removePage​(Page p)
      Remove the given page from this document and notify listeners.
      void removePageListener​(javax.swing.event.ListDataListener listener)
      Remove a page listener from this document.
      void setCurrentPage​(Page p)
      Set the current page.
      void setTitle​(java.lang.String title)
      Set the title of this model to the given title.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MultipageModel

        public MultipageModel()
    • Method Detail

      • addPage

        public void addPage​(Page p)
        Add a page to the document and notify page listeners.
      • insertPage

        public void insertPage​(Page p,
                               int index)
        Add a page to the document at the given index (between 0 and getPageCount()-1) and notify page listeners.
      • addPageListener

        public void addPageListener​(javax.swing.event.ListDataListener listener)
        Add a page listener to this document. The page listener is in fact a ListDataListener, which will be notified with intervalAdded() and intervalRemoved() events when pages are added or removed, and with a contentsChanged() event when the current page is changed.
      • getCurrentPage

        public Page getCurrentPage()
        Get the current page. Return null if there is no current page, which, provided the Document is implemented correctly, will only happen if the document contains no pages.
      • getPage

        public Page getPage​(int index)
        Get the page at the given index.
      • getPage

        public Page getPage​(java.lang.String title)
        Get the page with the given title.
      • getPageCount

        public int getPageCount()
        Get the number of pages in this document.
      • getTitle

        public java.lang.String getTitle()
        Return the title of this model
      • indexOf

        public int indexOf​(Page p)
        Get the index of the given page. -1 if it is not known.
      • pages

        public java.util.Iterator pages()
        Return an iterator over all pages
      • removePage

        public void removePage​(Page p)
        Remove the given page from this document and notify listeners. If the removed page is the current page, change the current page to the one after it, unless it was the last one, in which case changed it to the one before, unless this was the last page, in which case there is no selected page.
      • removePageListener

        public void removePageListener​(javax.swing.event.ListDataListener listener)
        Remove a page listener from this document.
      • setCurrentPage

        public void setCurrentPage​(Page p)
        Set the current page. Notify all page listeners with a contentsChanged() event. Throw an exception if the current page is not in the document.
      • setTitle

        public void setTitle​(java.lang.String title)
        Set the title of this model to the given title.