/[classpath]/classpath/java/awt/print/Book.java
ViewVC logotype

Diff of /classpath/java/awt/print/Book.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by mkoch, Tue Nov 16 09:59:11 2004 UTC revision 1.6 by mkoch, Wed Dec 1 20:46:31 2004 UTC
# Line 1  Line 1 
1  /* Book.java -- A mixed group of pages to print.  /* Book.java -- A mixed group of pages to print.
2     Copyright (C) 1999 Free Software Foundation, Inc.     Copyright (C) 1999, 2004  Free Software Foundation, Inc.
3    
4  This file is part of GNU Classpath.  This file is part of GNU Classpath.
5    
# Line 41  package java.awt.print; Line 41  package java.awt.print;
41  import java.util.Vector;  import java.util.Vector;
42    
43  /**  /**
44    * This class allows documents to be created with different paper types,   * This class allows documents to be created with different paper types,
45    * page formatters, and painters.   * page formatters, and painters.
46    *   *
47    * @author Aaron M. Renn (arenn@urbanophile.com)   * @author Aaron M. Renn (arenn@urbanophile.com)
   */  
 public class Book implements Pageable  
 {  
   
 /*  
  * Instance Variables  
  */  
   
 // Painter objects for the book  
 Vector printables = new Vector();  
   
 // Page formats for the book  
 Vector page_formats = new Vector();  
   
 /*************************************************************************/  
   
 /*  
  * Constructors  
48   */   */
49    public class Book implements Pageable
 /**  
   * Initializes a new instance of <code>Book</code> that is empty.  
   */  
 public  
 Book()  
 {  
   ;  
 }  
   
 /*************************************************************************/  
   
 /**  
   * Returns the number of pages in this book.  
   *  
   * @return The number of pages in this book.  
   */  
 public int  
 getNumberOfPages()  
 {  
   return(printables.size());  
 }  
   
 /*************************************************************************/  
   
 /**  
   * This method returns the <code>PageFormat</code> object for the  
   * specified page.  
   *  
   * @param page_number The number of the page to get information for, where  
   * page numbers start at 0.  
   *  
   * @return The <code>PageFormat</code> object for the specified page.  
   *  
   * @exception IndexOutOfBoundsException If the page number is not valid.  
   */  
 public PageFormat  
 getPageFormat(int page_number)  
 {  
   return((PageFormat)page_formats.elementAt(page_number));  
 }  
   
 /*************************************************************************/  
   
 /**  
   * This method returns the <code>Printable</code> object for the  
   * specified page.  
   *  
   * @param page_number The number of the page to get information for, where  
   * page numbers start at 0.  
   *  
   * @return The <code>Printable</code> object for the specified page.  
   *  
   * @exception IndexOutOfBoundsException If the page number is not valid.  
   */  
 public Printable  
 getPrintable(int page_number)  
 {  
   return((Printable)printables.elementAt(page_number));  
 }  
   
 /*************************************************************************/  
   
 /**  
   * This method appends a page to the end of the book.  
   *  
   * @param printable The <code>Printable</code> for this page.  
   * @param page_format The <code>PageFormat</code> for this page.  
   *  
   * @exception NullPointerException If either argument is <code>null</code>.  
   */  
 public void  
 append(Printable printable, PageFormat page_format)  
 {  
   append(printable, page_format, 1);  
 }  
   
 /*************************************************************************/  
   
 /**  
   * This method appends the specified number of pages to the end of the book.  
   * Each one will be associated with the specified <code>Printable</code>  
   * and <code>PageFormat</code>.  
   *  
   * @param printable The <code>Printable</code> for this page.  
   * @param page_format The <code>PageFormat</code> for this page.  
   * @param num_pages The number of pages to append.  
   *  
   * @exception NullPointerException If any argument is <code>null</code>.  
   */  
 public void  
 append(Printable printable, PageFormat page_format, int num_pages)  
 {  
   for (int i = 0; i < num_pages; i++)  
     {  
       printables.addElement(printable);  
       page_formats.addElement(page_format);  
     }  
 }  
   
 /*************************************************************************/  
   
 /**  
   * This method changes the <code>Printable</code> and <code>PageFormat</code>  
   * for the specified page.  The page must already exist or an exception  
   * will be thrown.  
   *  
   * @param page_num The page number to alter.  
   * @param printable The new <code>Printable</code> for the page.  
   * @param page_format The new <code>PageFormat</code> for the page.  
   *  
   * @throws IndexOutOfBoundsException If the specified page does not exist.  
   */  
 public void  
 setPage(int page_num, Printable printable, PageFormat page_format)  
50  {  {
51    printables.setElementAt(printable, page_num);    /**
52    page_formats.setElementAt(page_format, page_num);     * Painter objects for the book.
53  }     */
54      Vector printables = new Vector();
55    
56      /**
57       * Page formats for the book.
58       */
59      Vector page_formats = new Vector();
60    
61      /**
62       * Initializes a new instance of <code>Book</code> that is empty.
63       */
64      public Book()
65      {
66      }
67    
68      /**
69       * Returns the number of pages in this book.
70       *
71       * @return The number of pages in this book.
72       */
73      public int getNumberOfPages()
74      {
75        return printables.size();
76      }
77    
78      /**
79       * This method returns the <code>PageFormat</code> object for the
80       * specified page.
81       *
82       * @param page_number The number of the page to get information for, where
83       * page numbers start at 0.
84       *
85       * @return The <code>PageFormat</code> object for the specified page.
86       *
87       * @exception IndexOutOfBoundsException If the page number is not valid.
88       */
89      public PageFormat getPageFormat(int page_number)
90      {
91        return (PageFormat) page_formats.elementAt(page_number);
92      }
93    
94      /**
95       * This method returns the <code>Printable</code> object for the
96       * specified page.
97       *
98       * @param page_number The number of the page to get information for, where
99       * page numbers start at 0.
100       *
101       * @return The <code>Printable</code> object for the specified page.
102       *
103       * @exception IndexOutOfBoundsException If the page number is not valid.
104       */
105      public Printable getPrintable(int page_number)
106      {
107        return (Printable) printables.elementAt(page_number);
108      }
109    
110      /**
111       * This method appends a page to the end of the book.
112       *
113       * @param printable The <code>Printable</code> for this page.
114       * @param page_format The <code>PageFormat</code> for this page.
115       *
116       * @exception NullPointerException If either argument is <code>null</code>.
117       */
118      public void append(Printable printable, PageFormat page_format)
119      {
120        append(printable, page_format, 1);
121      }
122    
123      /**
124       * This method appends the specified number of pages to the end of the book.
125       * Each one will be associated with the specified <code>Printable</code>
126       * and <code>PageFormat</code>.
127       *
128       * @param printable The <code>Printable</code> for this page.
129       * @param page_format The <code>PageFormat</code> for this page.
130       * @param num_pages The number of pages to append.
131       *
132       * @exception NullPointerException If any argument is <code>null</code>.
133       */
134      public void append(Printable printable, PageFormat page_format, int num_pages)
135      {
136        for (int i = 0; i < num_pages; i++)
137          {
138            printables.addElement(printable);
139            page_formats.addElement(page_format);
140          }
141      }
142    
143      /**
144       * This method changes the <code>Printable</code> and <code>PageFormat</code>
145       * for the specified page.  The page must already exist or an exception
146       * will be thrown.
147       *
148       * @param page_num The page number to alter.
149       * @param printable The new <code>Printable</code> for the page.
150       * @param page_format The new <code>PageFormat</code> for the page.
151       *
152       * @throws IndexOutOfBoundsException If the specified page does not exist.
153       */
154      public void setPage(int page_num, Printable printable, PageFormat page_format)
155      {
156        printables.setElementAt(printable, page_num);
157        page_formats.setElementAt(page_format, page_num);
158      }
159  }  }

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26