1 /* Paper.java -- Information about a paper type.
2 Copyright (C) 1999 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package java
.awt
.print
;
42 * This class describes a particular type of paper.
44 * @author Aaron M. Renn (arenn@urbanophile.com)
46 public class Paper
implements Cloneable
53 // Height of the paper
54 private double height
;
59 // Upper left imageable X coordinate
60 private double imageableX
;
62 // Upper left imageable Y coordinate
63 private double imageableY
;
65 // Imageable width of the page
66 private double imageableWidth
;
68 // Imageable height of the page
69 private double imageableHeight
;
71 /*************************************************************************/
78 * This method creates a letter sized paper with one inch margins
87 imageableWidth
= width
- (2 * 72);
88 imageableHeight
= height
- (2 * 72);
91 /*************************************************************************/
94 * This method returns the height of the paper in 1/72nds of an inch.
96 * @return The height of the paper in 1/72nds of an inch.
104 /*************************************************************************/
107 * Returns the width of the paper in 1/72nds of an inch.
109 * @return The width of the paper in 1/72nds of an inch.
117 /*************************************************************************/
120 * This method returns the X coordinate of the upper left hand corner
121 * of the imageable area of the paper.
123 * @return The X coordinate of the upper left hand corner of the imageable
132 /*************************************************************************/
135 * This method returns the Y coordinate of the upper left hand corner
136 * of the imageable area of the paper.
138 * @return The Y coordinate of the upper left hand corner of the imageable
147 /*************************************************************************/
150 * Returns the width of the imageable area of the paper.
152 * @return The width of the imageable area of the paper.
157 return(imageableWidth
);
160 /*************************************************************************/
163 * Returns the height of the imageable area of the paper.
165 * @return The height of the imageable area of the paper.
170 return(imageableHeight
);
173 /*************************************************************************/
176 * This method sets the size of the paper to the specified width and
177 * height, which are specified in 1/72nds of an inch.
179 * @param width The width of the paper in 1/72nds of an inch.
180 * @param height The height of the paper in 1/72nds of an inch.
183 setSize(double width
, double height
)
186 this.height
= height
;
189 /*************************************************************************/
192 * This method sets the imageable area of the paper by specifying the
193 * coordinates of the upper left hand corner of that area, and its
194 * length and height. All values are in 1/72nds of an inch.
196 * @param imageableX The X coordinate of the upper left hand corner of
197 * the imageable area, in 1/72nds of an inch.
198 * @param imageableY The Y coordinate of the upper left hand corner of
199 * the imageable area, in 1/72nds of an inch.
200 * @param imageableWidth The width of the imageable area of the paper,
201 * in 1/72nds of an inch.
202 * @param imageableHeight The heigth of the imageable area of the paper,
203 * in 1/72nds of an inch.
206 setImageableArea(double imageableX
, double imageableY
,
207 double imageableWidth
, double imageableHeight
)
209 this.imageableX
= imageableX
;
210 this.imageableY
= imageableY
;
211 this.imageableWidth
= imageableWidth
;
212 this.imageableHeight
= imageableHeight
;
215 /*************************************************************************/
218 * This method creates a copy of this object.
220 * @return A copy of this object.
227 return(super.clone());
229 catch(CloneNotSupportedException e
)