1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException {
if (pageIndex != 0) {
return NO_SUCH_PAGE;
Dimension dim = getSize();
double scaleX = pageFormat.getImageableWidth() / dim.width;
double scaleY = pageFormat.getImageableHeight() / dim.height;
double scale = Math.min(scaleX, scaleY);
Graphics2D g2D = (Graphics2D) graphics;
g2D.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
g2D.scale(scale, scale);
printAll(g2D);
g2D.dispose();
return PAGE_EXISTS;
} |
Partager