FileDocCategorySizeDatePackage
Paper.javaAPI DocJava SE 5 API5409Fri Aug 26 14:56:56 BST 2005java.awt.print

Paper

public class Paper extends Object implements Cloneable
The Paper class describes the physical characteristics of a piece of paper.

When creating a Paper object, it is the application's responsibility to ensure that the paper size and the imageable area are compatible. For example, if the paper size is changed from 11 x 17 to 8.5 x 11, the application might need to reduce the imageable area so that whatever is printed fits on the page.

see
#setSize(double, double)
see
#setImageableArea(double, double, double, double)

Fields Summary
private static final int
INCH
private static final double
LETTER_WIDTH
private static final double
LETTER_HEIGHT
private double
mHeight
The height of the physical page in 1/72nds of an inch. The number is stored as a floating point value rather than as an integer to facilitate the conversion from metric units to 1/72nds of an inch and then back. (This may or may not be a good enough reason for a float).
private double
mWidth
The width of the physical page in 1/72nds of an inch.
private Rectangle2D
mImageableArea
The area of the page on which drawing will be visable. The area outside of this rectangle but on the Page generally reflects the printer's hardware margins. The origin of the physical page is at (0, 0) with this rectangle provided in that coordinate system.
Constructors Summary
public Paper()
Creates a letter sized piece of paper with one inch margins.


 /* Constructors */

                    
      
	mHeight = LETTER_HEIGHT;
	mWidth = LETTER_WIDTH;
	mImageableArea = new Rectangle2D.Double(INCH, INCH,
						mWidth - 2 * INCH,
						mHeight - 2 * INCH);
    
Methods Summary
public java.lang.Objectclone()
Creates a copy of this Paper with the same contents as this Paper.

return
a copy of this Paper.


	Paper newPaper;

	try {
	    /* It's okay to copy the reference to the imageable
	     * area into the clone since we always return a copy
	     * of the imageable area when asked for it.
	     */
	    newPaper = (Paper) super.clone();

	} catch (CloneNotSupportedException e) {
	    e.printStackTrace();
	    newPaper = null;	// should never happen.
	}

	return newPaper;
    
public doublegetHeight()
Returns the height of the page in 1/72nds of an inch.

return
the height of the page described by this Paper.

	return mHeight;
    
public doublegetImageableHeight()
Returns the height of this Paper object's imageable area.

return
the height of the imageable area.

	return mImageableArea.getHeight();
    
public doublegetImageableWidth()
Returns the width of this Paper object's imageable area.

return
the width of the imageable area.

	return mImageableArea.getWidth();
    
public doublegetImageableX()
Returns the x coordinate of the upper-left corner of this Paper object's imageable area.

return
the x coordinate of the imageable area.

	return mImageableArea.getX();
    
public doublegetImageableY()
Returns the y coordinate of the upper-left corner of this Paper object's imageable area.

return
the y coordinate of the imageable area.

	return mImageableArea.getY();
    
public doublegetWidth()
Returns the width of the page in 1/72nds of an inch.

return
the width of the page described by this Paper.

	return mWidth;
    
public voidsetImageableArea(double x, double y, double width, double height)
Sets the imageable area of this Paper. The imageable area is the area on the page in which printing occurs.

param
x, y the coordinates to which to set the upper-left corner of the imageable area of this Paper
param
width the value to which to set the width of the imageable area of this Paper
param
height the value to which to set the height of the imageable area of this Paper

	mImageableArea = new Rectangle2D.Double(x, y, width,height);
    
public voidsetSize(double width, double height)
Sets the width and height of this Paper object, which represents the properties of the page onto which printing occurs. The dimensions are supplied in 1/72nds of an inch.

param
width the value to which to set this Paper object's width
param
height the value to which to set this Paper object's height

	mWidth = width;
	mHeight = height;