source: trunk/gcc/libjava/java/awt/print/Book.java

Last change on this file was 1389, checked in by bird, 21 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 5.5 KB
Line 
1/* Book.java -- A mixed group of pages to print.
2 Copyright (C) 1999 Free Software Foundation, Inc.
3
4This file is part of GNU Classpath.
5
6GNU Classpath is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GNU Classpath is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Classpath; see the file COPYING. If not, write to the
18Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
1902111-1307 USA.
20
21Linking this library statically or dynamically with other modules is
22making a combined work based on this library. Thus, the terms and
23conditions of the GNU General Public License cover the whole
24combination.
25
26As a special exception, the copyright holders of this library give you
27permission to link this library with independent modules to produce an
28executable, regardless of the license terms of these independent
29modules, and to copy and distribute the resulting executable under
30terms of your choice, provided that you also meet, for each linked
31independent module, the terms and conditions of the license of that
32module. An independent module is a module which is not derived from
33or based on this library. If you modify this library, you may extend
34this exception to your version of the library, but you are not
35obligated to do so. If you do not wish to do so, delete this
36exception statement from your version. */
37
38
39package java.awt.print;
40
41import java.util.Vector;
42
43/**
44 * This class allows documents to be created with different paper types,
45 * page formatters, and painters.
46 *
47 * @author Aaron M. Renn (arenn@urbanophile.com)
48 */
49public class Book implements Pageable
50{
51
52/*
53 * Instance Variables
54 */
55
56// Painter objects for the book
57Vector printables = new Vector();
58
59// Page formats for the book
60Vector page_formats = new Vector();
61
62/*************************************************************************/
63
64/*
65 * Constructors
66 */
67
68/**
69 * Initializes a new instance of <code>Book</code> that is empty.
70 */
71public
72Book()
73{
74 ;
75}
76
77/*************************************************************************/
78
79/**
80 * Returns the number of pages in this book.
81 *
82 * @return The number of pages in this book.
83 */
84public int
85getNumberOfPages()
86{
87 return(printables.size());
88}
89
90/*************************************************************************/
91
92/**
93 * This method returns the <code>PageFormat</code> object for the
94 * specified page.
95 *
96 * @param page_numbers The number of the page to get information for, where
97 * page numbers start at 0.
98 *
99 * @return The <code>PageFormat</code> object for the specified page.
100 *
101 * @exception IndexOutOfBoundsException If the page number is not valid.
102 */
103public PageFormat
104getPageFormat(int page_number)
105{
106 return((PageFormat)page_formats.elementAt(page_number));
107}
108
109/*************************************************************************/
110
111/**
112 * This method returns the <code>Printable</code> object for the
113 * specified page.
114 *
115 * @param page_numbers The number of the page to get information for, where
116 * page numbers start at 0.
117 *
118 * @return The <code>Printable</code> object for the specified page.
119 *
120 * @exception IndexOutOfBoundsException If the page number is not valid.
121 */
122public Printable
123getPrintable(int page_number)
124{
125 return((Printable)printables.elementAt(page_number));
126}
127
128/*************************************************************************/
129
130/**
131 * This method appends a page to the end of the book.
132 *
133 * @param printable The <code>Printable</code> for this page.
134 * @param page_format The <code>PageFormat</code> for this page.
135 *
136 * @exception NullPointerException If either argument is <code>null</code>.
137 */
138public void
139append(Printable printable, PageFormat page_format)
140{
141 append(printable, page_format, 1);
142}
143
144/*************************************************************************/
145
146/**
147 * This method appends the specified number of pages to the end of the book.
148 * Each one will be associated with the specified <code>Printable</code>
149 * and <code>PageFormat</code>.
150 *
151 * @param printable The <code>Printable</code> for this page.
152 * @param page_format The <code>PageFormat</code> for this page.
153 * @param num_pages The number of pages to append.
154 *
155 * @exception NullPointerException If any argument is <code>null</code>.
156 */
157public void
158append(Printable painter, PageFormat page_format, int num_pages)
159{
160 for (int i = 0; i < num_pages; i++)
161 {
162 printables.addElement(painter);
163 page_formats.addElement(page_format);
164 }
165}
166
167/*************************************************************************/
168
169/**
170 * This method changes the <code>Printable</code> and <code>PageFormat</code>
171 * for the specified page. The page must already exist or an exception
172 * will be thrown.
173 *
174 * @param page_num The page number to alter.
175 * @param printable The new <code>Printable</code> for the page.
176 * @param page_format The new <code>PageFormat</code> for the page.
177 *
178 * @param IndexOutOfBoundsException If the specified page does not exist.
179 */
180public void
181setPage(int page_num, Printable printable, PageFormat page_format)
182{
183 printables.setElementAt(printable, page_num);
184 page_formats.setElementAt(page_format, page_num);
185}
186
187} // class Book
188
Note: See TracBrowser for help on using the repository browser.