1 /*
2 * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
537 }
538
539 OrientationRequested orient = (OrientationRequested)
540 attSet.get(OrientationRequested.class);
541 if (orient == null) {
542 orient = (OrientationRequested)
543 service.getDefaultAttributeValue(OrientationRequested.class);
544 }
545 if (orient == OrientationRequested.REVERSE_LANDSCAPE) {
546 page.setOrientation(PageFormat.REVERSE_LANDSCAPE);
547 } else if (orient == OrientationRequested.LANDSCAPE) {
548 page.setOrientation(PageFormat.LANDSCAPE);
549 } else {
550 page.setOrientation(PageFormat.PORTRAIT);
551 }
552
553 Media media = (Media)attSet.get(Media.class);
554 MediaSize size = getMediaSize(media, service, page);
555
556 Paper paper = new Paper();
557 float dim[] = size.getSize(1); //units == 1 to avoid FP error
558 double w = Math.rint((dim[0]*72.0)/Size2DSyntax.INCH);
559 double h = Math.rint((dim[1]*72.0)/Size2DSyntax.INCH);
560 paper.setSize(w, h);
561 MediaPrintableArea area =
562 (MediaPrintableArea)
563 attSet.get(MediaPrintableArea.class);
564 if (area == null) {
565 area = getDefaultPrintableArea(page, w, h);
566 }
567
568 double ix, iw, iy, ih;
569 // Should pass in same unit as updatePageAttributes
570 // to avoid rounding off errors.
571 ix = Math.rint(
572 area.getX(MediaPrintableArea.INCH) * DPI);
573 iy = Math.rint(
574 area.getY(MediaPrintableArea.INCH) * DPI);
575 iw = Math.rint(
576 area.getWidth(MediaPrintableArea.INCH) * DPI);
577 ih = Math.rint(
|
1 /*
2 * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
537 }
538
539 OrientationRequested orient = (OrientationRequested)
540 attSet.get(OrientationRequested.class);
541 if (orient == null) {
542 orient = (OrientationRequested)
543 service.getDefaultAttributeValue(OrientationRequested.class);
544 }
545 if (orient == OrientationRequested.REVERSE_LANDSCAPE) {
546 page.setOrientation(PageFormat.REVERSE_LANDSCAPE);
547 } else if (orient == OrientationRequested.LANDSCAPE) {
548 page.setOrientation(PageFormat.LANDSCAPE);
549 } else {
550 page.setOrientation(PageFormat.PORTRAIT);
551 }
552
553 Media media = (Media)attSet.get(Media.class);
554 MediaSize size = getMediaSize(media, service, page);
555
556 Paper paper = new Paper();
557 float[] dim = size.getSize(1); //units == 1 to avoid FP error
558 double w = Math.rint((dim[0]*72.0)/Size2DSyntax.INCH);
559 double h = Math.rint((dim[1]*72.0)/Size2DSyntax.INCH);
560 paper.setSize(w, h);
561 MediaPrintableArea area =
562 (MediaPrintableArea)
563 attSet.get(MediaPrintableArea.class);
564 if (area == null) {
565 area = getDefaultPrintableArea(page, w, h);
566 }
567
568 double ix, iw, iy, ih;
569 // Should pass in same unit as updatePageAttributes
570 // to avoid rounding off errors.
571 ix = Math.rint(
572 area.getX(MediaPrintableArea.INCH) * DPI);
573 iy = Math.rint(
574 area.getY(MediaPrintableArea.INCH) * DPI);
575 iw = Math.rint(
576 area.getWidth(MediaPrintableArea.INCH) * DPI);
577 ih = Math.rint(
|