Paperpublic class Paper extends Object implements CloneableThe 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.
|
Fields Summary |
---|
private static final int | INCH | private static final double | LETTER_WIDTH | private static final double | LETTER_HEIGHT | private double | mHeightThe 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 | mWidthThe width of the physical page in 1/72nds
of an inch. | private Rectangle2D | mImageableAreaThe 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.Object | clone()Creates a copy of this Paper with the same contents
as 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 double | getHeight()Returns the height of the page in 1/72nds of an inch.
return mHeight;
| public double | getImageableHeight()Returns the height of this Paper object's imageable
area.
return mImageableArea.getHeight();
| public double | getImageableWidth()Returns the width of this Paper object's imageable
area.
return mImageableArea.getWidth();
| public double | getImageableX()Returns the x coordinate of the upper-left corner of this
Paper object's imageable area.
return mImageableArea.getX();
| public double | getImageableY()Returns the y coordinate of the upper-left corner of this
Paper object's imageable area.
return mImageableArea.getY();
| public double | getWidth()Returns the width of the page in 1/72nds
of an inch.
return mWidth;
| public void | setImageableArea(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.
mImageableArea = new Rectangle2D.Double(x, y, width,height);
| public void | setSize(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.
mWidth = width;
mHeight = height;
|
|