public final class PageLayout
extends java.lang.Object
Printers usually have hardware margins where they cannot print. A PageLayout instance obtained from a PrinterJob in the context of a specific printer will be correctly set up to print over the whole of that area. If an application adjusts the printable area outside of this bounds, rendering to those areas will be clipped by the device.
Within those hardware margins, the application may define any printable area it needs. The resulting printable area will define the effective dimensions of the page available to the application at printing time.
Applying a PageLayout configured based on one printer, to a job on a different printer may not work correctly, as the second printer may not support the same margins, and may not even support the same Paper. In such a case, the PageLayout must be validated against the new printer.
A PageLayout is immutable.
Modifier and Type | Field and Description |
---|---|
private double |
bMargin |
private double |
lMargin |
private PageOrientation |
orient |
private Paper |
paper |
private double |
rMargin |
private double |
tMargin |
Constructor and Description |
---|
PageLayout(Paper paper,
PageOrientation orient)
Create a PageLayout using the specified Paper size and orientation.
|
PageLayout(Paper paper,
PageOrientation orient,
double leftMargin,
double rightMargin,
double topMargin,
double bottomMargin)
Note that the margins are to be specified as applying after
the rotation due to the orientation.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object o) |
double |
getBottomMargin()
Returns the bottom margin of the page layout in points.
|
double |
getLeftMargin()
Returns the left margin of the page layout in points.
|
PageOrientation |
getPageOrientation() |
Paper |
getPaper()
The paper used.
|
double |
getPrintableHeight()
Returns the height dimension of the printable area of the page,
in 1/72 of an inch, taking into account the orientation.
|
double |
getPrintableWidth()
Returns the width dimension of the printable area of the page,
in 1/72 of an inch points, taking into account the orientation.
|
double |
getRightMargin()
Returns the right margin of the page layout in points.
|
double |
getTopMargin()
Returns the top margin of the page layout in points.
|
int |
hashCode() |
java.lang.String |
toString() |
private PageOrientation orient
private Paper paper
private double lMargin
private double rMargin
private double tMargin
private double bMargin
PageLayout(Paper paper, PageOrientation orient)
paper
- the paper to useorient
- orientation of the layoutjava.lang.IllegalArgumentException
- if paper or orient is null.PageLayout(Paper paper, PageOrientation orient, double leftMargin, double rightMargin, double topMargin, double bottomMargin)
paper
- the paper to useorient
- orientation of the layoutleftMargin
- the left margin in points.rightMargin
- the left margin in points.topMargin
- the top margin in points.bottomMargin
- the bottom margin in points.java.lang.IllegalArgumentException
- if the margins exceed the
corresponding paper dimension, or are negative, or if
paper or orient is null.public PageOrientation getPageOrientation()
public Paper getPaper()
PageLayout
.public double getPrintableWidth()
The printable area is width or height reduced by the requested margins on each side. If the requested margins are smaller than the the hardware margins, rendering may be clipped by the device.
Since the returned value accounts for orientation, this means if if the orientation is LANDSCAPE or REVERSE_LANDSCAPE, then the left and right margins are subtracted from the height of the underlying paper, since it is rotated 90 degrees.
public double getPrintableHeight()
The printable area is width or height reduced by the requested margins on each side. If the requested margins are smaller than the the hardware margins, rendering may be clipped by the device.
Since the returned value accounts for orientation, this means if if the orientation is LANDSCAPE or REVERSE_LANDSCAPE, then the top and bottom margins are subtracted from the height of the underlying paper, since it is rotated 90 degrees.
public double getLeftMargin()
public double getRightMargin()
public double getTopMargin()
public double getBottomMargin()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object