Java Reference
In-Depth Information
Origin was moved by
-rect.x
-rect.y
in the x direction
and
in the y direction
The Paper
rect.x,rect.y
0.0
The Printable
Area on the Page
The Sketch
New Position of Paper Coordinates
Thus a translation of the origin to the point (- rect.x,-rect.y ) does the trick.
We have the sketch in the right place on the page, but it won't necessarily fit into the space available on
the paper. We must scale the sketch so that it doesn't hang out beyond the right side or below the
bottom of the printable page area.
Scaling the Sketch to Fit
We saw earlier that we can get the width and height of the printable area on a page by calling the
getImageableWidth() and getImageableHeight() methods for the PageFormat object that is
passed to the print() method. We also have the width and height of the rectangle that encloses the
entire sketch. This gives the information that we need to scale the sketch to fit on the page. There are a
couple of tricky aspects that we need to think about though.
Scaling up by a factor of 2
x
2
4
6
Original
4
7
12
8
Scaled by 2
14
y
Search WWH ::




Custom Search