Java Reference
In-Depth Information
Argument Value
Description
PORTRA IT
The origin is at the top left corner of the page with the
positive x axis running from left to right and the positive y
axis from top to bottom. This is the Windows and Postscript
portrait definition.
LANDSCAPE
The origin is at the bottom left corner of the page with the
positive x axis running from bottom to top and the positive y
axis from left to right.
REVERSE _ LANDSCAPE
The origin is at the top right corner of the page with the
positive x axis running from top to bottom and the positive y
axis running from right to left. This is the Macintosh
landscape definition.
In each case the long side of the paper is in the same orientation as the y axis, but note that a Macintosh
landscape specification has the origin at the top right corner of the page rather than the top left or
bottom left.
Let's incorporate LANDSCAPE into the print() method in SketchView :
public int print(Graphics g, // Graphics context for printing
PageFormat pageFormat, // The page format
int pageIndex) // Index number of current page
throws PrinterException {
if(pageIndex>0)
return NO _ SUCH _ PAGE;
Graphics2D g2D = (Graphics2D) g;
// Get sketch bounds
Rectangle rect = theApp.getModel().getModelExtent();
// If the width is more than the height, set landscape
if(rect.width>rect.height) {
pageFormat.setOrientation(pageFormat.LANDSCAPE);
}
// Rest of the code as before...
}
Search WWH ::




Custom Search