Methods Summary |
---|
public java.lang.Object | clone()Makes a copy of this PageFormat with the same
contents as this PageFormat .
PageFormat newPage;
try {
newPage = (PageFormat) super.clone();
newPage.mPaper = (Paper)mPaper.clone();
} catch (CloneNotSupportedException e) {
e.printStackTrace();
newPage = null; // should never happen.
}
return newPage;
|
public double | getHeight()Returns the height, in 1/72nds of an inch, of the page.
This method takes into account the orientation of the
page when determining the height.
double height;
int orientation = getOrientation();
if (orientation == PORTRAIT) {
height = mPaper.getHeight();
} else {
height = mPaper.getWidth();
}
return height;
|
public double | getImageableHeight()Return the height, in 1/72nds of an inch, of the imageable
area of the page. This method takes into account the orientation
of the page.
double height;
if (getOrientation() == PORTRAIT) {
height = mPaper.getImageableHeight();
} else {
height = mPaper.getImageableWidth();
}
return height;
|
public double | getImageableWidth()Returns the width, in 1/72nds of an inch, of the imageable
area of the page. This method takes into account the orientation
of the page.
double width;
if (getOrientation() == PORTRAIT) {
width = mPaper.getImageableWidth();
} else {
width = mPaper.getImageableHeight();
}
return width;
|
public double | getImageableX()Returns the x coordinate of the upper left point of the
imageable area of the Paper object
associated with this PageFormat .
This method takes into account the
orientation of the page.
double x;
switch (getOrientation()) {
case LANDSCAPE:
x = mPaper.getHeight()
- (mPaper.getImageableY() + mPaper.getImageableHeight());
break;
case PORTRAIT:
x = mPaper.getImageableX();
break;
case REVERSE_LANDSCAPE:
x = mPaper.getImageableY();
break;
default:
/* This should never happen since it signifies that the
* PageFormat is in an invalid orientation.
*/
throw new InternalError("unrecognized orientation");
}
return x;
|
public double | getImageableY()Returns the y coordinate of the upper left point of the
imageable area of the Paper object
associated with this PageFormat .
This method takes into account the
orientation of the page.
double y;
switch (getOrientation()) {
case LANDSCAPE:
y = mPaper.getImageableX();
break;
case PORTRAIT:
y = mPaper.getImageableY();
break;
case REVERSE_LANDSCAPE:
y = mPaper.getWidth()
- (mPaper.getImageableX() + mPaper.getImageableWidth());
break;
default:
/* This should never happen since it signifies that the
* PageFormat is in an invalid orientation.
*/
throw new InternalError("unrecognized orientation");
}
return y;
|
public double[] | getMatrix()Returns a transformation matrix that translates user
space rendering to the requested orientation
of the page. The values are placed into the
array as
{ m00, m10, m01, m11, m02, m12} in
the form required by the {@link AffineTransform}
constructor.
double[] matrix = new double[6];
switch (mOrientation) {
case LANDSCAPE:
matrix[0] = 0; matrix[1] = -1;
matrix[2] = 1; matrix[3] = 0;
matrix[4] = 0; matrix[5] = mPaper.getHeight();
break;
case PORTRAIT:
matrix[0] = 1; matrix[1] = 0;
matrix[2] = 0; matrix[3] = 1;
matrix[4] = 0; matrix[5] = 0;
break;
case REVERSE_LANDSCAPE:
matrix[0] = 0; matrix[1] = 1;
matrix[2] = -1; matrix[3] = 0;
matrix[4] = mPaper.getWidth(); matrix[5] = 0;
break;
default:
throw new IllegalArgumentException();
}
return matrix;
|
public int | getOrientation()Returns the orientation of this PageFormat .
return mOrientation;
|
public java.awt.print.Paper | getPaper()Returns a copy of the {@link Paper} object associated
with this PageFormat . Changes made to the
Paper object returned from this method do not
affect the Paper object of this
PageFormat . To update the Paper
object of this PageFormat , create a new
Paper object and set it into this
PageFormat by using the {@link #setPaper(Paper)}
method.
return (Paper)mPaper.clone();
|
public double | getWidth()Returns the width, in 1/72nds of an inch, of the page.
This method takes into account the orientation of the
page when determining the width.
double width;
int orientation = getOrientation();
if (orientation == PORTRAIT) {
width = mPaper.getWidth();
} else {
width = mPaper.getHeight();
}
return width;
|
public void | setOrientation(int orientation)Sets the page orientation. orientation must be
one of the constants: PORTRAIT, LANDSCAPE,
or REVERSE_LANDSCAPE.
if (0 <= orientation && orientation <= REVERSE_LANDSCAPE) {
mOrientation = orientation;
} else {
throw new IllegalArgumentException();
}
|
public void | setPaper(java.awt.print.Paper paper)Sets the Paper object for this
PageFormat .
mPaper = (Paper)paper.clone();
|