Java Code Examples for java.awt.print.Pageable#getPageFormat()
The following examples show how to use
java.awt.print.Pageable#getPageFormat() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RasterPrinterJob.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
protected PageFormat getPageFormatFromAttributes() { Pageable pageable = null; if (attributes == null || attributes.isEmpty() || !((pageable = getPageable()) instanceof OpenBook)) { return null; } PageFormat newPf = attributeToPageFormat( getPrintService(), attributes); PageFormat oldPf = null; if ((oldPf = pageable.getPageFormat(0)) != null) { // If orientation, media, imageable area attributes are not in // "attributes" set, then use respective values of the existing // page format "oldPf". if (attributes.get(OrientationRequested.class) == null) { newPf.setOrientation(oldPf.getOrientation()); } Paper newPaper = newPf.getPaper(); Paper oldPaper = oldPf.getPaper(); boolean oldPaperValWasSet = false; if (attributes.get(MediaSizeName.class) == null) { newPaper.setSize(oldPaper.getWidth(), oldPaper.getHeight()); oldPaperValWasSet = true; } if (attributes.get(MediaPrintableArea.class) == null) { newPaper.setImageableArea( oldPaper.getImageableX(), oldPaper.getImageableY(), oldPaper.getImageableWidth(), oldPaper.getImageableHeight()); oldPaperValWasSet = true; } if (oldPaperValWasSet) { newPf.setPaper(newPaper); } } return newPf; }
Example 2
Source File: RasterPrinterJob.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
protected PageFormat getPageFormatFromAttributes() { Pageable pageable = null; if (attributes == null || attributes.isEmpty() || !((pageable = getPageable()) instanceof OpenBook)) { return null; } PageFormat newPf = attributeToPageFormat( getPrintService(), attributes); PageFormat oldPf = null; if ((oldPf = pageable.getPageFormat(0)) != null) { // If orientation, media, imageable area attributes are not in // "attributes" set, then use respective values of the existing // page format "oldPf". if (attributes.get(OrientationRequested.class) == null) { newPf.setOrientation(oldPf.getOrientation()); } Paper newPaper = newPf.getPaper(); Paper oldPaper = oldPf.getPaper(); boolean oldPaperValWasSet = false; if (attributes.get(MediaSizeName.class) == null) { newPaper.setSize(oldPaper.getWidth(), oldPaper.getHeight()); oldPaperValWasSet = true; } if (attributes.get(MediaPrintableArea.class) == null) { newPaper.setImageableArea( oldPaper.getImageableX(), oldPaper.getImageableY(), oldPaper.getImageableWidth(), oldPaper.getImageableHeight()); oldPaperValWasSet = true; } if (oldPaperValWasSet) { newPf.setPaper(newPaper); } } return newPf; }
Example 3
Source File: RasterPrinterJob.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
protected PageFormat getPageFormatFromAttributes() { Pageable pageable = null; if (attributes == null || attributes.isEmpty() || !((pageable = getPageable()) instanceof OpenBook)) { return null; } PageFormat newPf = attributeToPageFormat( getPrintService(), attributes); PageFormat oldPf = null; if ((oldPf = pageable.getPageFormat(0)) != null) { // If orientation, media, imageable area attributes are not in // "attributes" set, then use respective values of the existing // page format "oldPf". if (attributes.get(OrientationRequested.class) == null) { newPf.setOrientation(oldPf.getOrientation()); } Paper newPaper = newPf.getPaper(); Paper oldPaper = oldPf.getPaper(); boolean oldPaperValWasSet = false; if (attributes.get(MediaSizeName.class) == null) { newPaper.setSize(oldPaper.getWidth(), oldPaper.getHeight()); oldPaperValWasSet = true; } if (attributes.get(MediaPrintableArea.class) == null) { newPaper.setImageableArea( oldPaper.getImageableX(), oldPaper.getImageableY(), oldPaper.getImageableWidth(), oldPaper.getImageableHeight()); oldPaperValWasSet = true; } if (oldPaperValWasSet) { newPf.setPaper(newPaper); } } return newPf; }
Example 4
Source File: RasterPrinterJob.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
protected PageFormat getPageFormatFromAttributes() { if (attributes == null || attributes.isEmpty()) { return null; } PageFormat newPf = attributeToPageFormat( getPrintService(), attributes); PageFormat oldPf = null; Pageable pageable = getPageable(); if ((pageable != null) && (pageable instanceof OpenBook) && ((oldPf = pageable.getPageFormat(0)) != null)) { // If orientation, media, imageable area attributes are not in // "attributes" set, then use respective values of the existing // page format "oldPf". if (attributes.get(OrientationRequested.class) == null) { newPf.setOrientation(oldPf.getOrientation()); } Paper newPaper = newPf.getPaper(); Paper oldPaper = oldPf.getPaper(); boolean oldPaperValWasSet = false; if (attributes.get(MediaSizeName.class) == null) { newPaper.setSize(oldPaper.getWidth(), oldPaper.getHeight()); oldPaperValWasSet = true; } if (attributes.get(MediaPrintableArea.class) == null) { newPaper.setImageableArea( oldPaper.getImageableX(), oldPaper.getImageableY(), oldPaper.getImageableWidth(), oldPaper.getImageableHeight()); oldPaperValWasSet = true; } if (oldPaperValWasSet) { newPf.setPaper(newPaper); } } return newPf; }
Example 5
Source File: RasterPrinterJob.java From Bytecoder with Apache License 2.0 | 5 votes |
protected PageFormat getPageFormatFromAttributes() { Pageable pageable = null; if (attributes == null || attributes.isEmpty() || !((pageable = getPageable()) instanceof OpenBook)) { return null; } PageFormat newPf = attributeToPageFormat( getPrintService(), attributes); PageFormat oldPf = null; if ((oldPf = pageable.getPageFormat(0)) != null) { // If orientation, media, imageable area attributes are not in // "attributes" set, then use respective values of the existing // page format "oldPf". if (attributes.get(OrientationRequested.class) == null) { newPf.setOrientation(oldPf.getOrientation()); } Paper newPaper = newPf.getPaper(); Paper oldPaper = oldPf.getPaper(); boolean oldPaperValWasSet = false; if (attributes.get(MediaSizeName.class) == null) { newPaper.setSize(oldPaper.getWidth(), oldPaper.getHeight()); oldPaperValWasSet = true; } if (attributes.get(MediaPrintableArea.class) == null) { newPaper.setImageableArea( oldPaper.getImageableX(), oldPaper.getImageableY(), oldPaper.getImageableWidth(), oldPaper.getImageableHeight()); oldPaperValWasSet = true; } if (oldPaperValWasSet) { newPf.setPaper(newPaper); } } return newPf; }
Example 6
Source File: RasterPrinterJob.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
protected PageFormat getPageFormatFromAttributes() { Pageable pageable = null; if (attributes == null || attributes.isEmpty() || !((pageable = getPageable()) instanceof OpenBook)) { return null; } PageFormat newPf = attributeToPageFormat( getPrintService(), attributes); PageFormat oldPf = null; if ((oldPf = pageable.getPageFormat(0)) != null) { // If orientation, media, imageable area attributes are not in // "attributes" set, then use respective values of the existing // page format "oldPf". if (attributes.get(OrientationRequested.class) == null) { newPf.setOrientation(oldPf.getOrientation()); } Paper newPaper = newPf.getPaper(); Paper oldPaper = oldPf.getPaper(); boolean oldPaperValWasSet = false; if (attributes.get(MediaSizeName.class) == null) { newPaper.setSize(oldPaper.getWidth(), oldPaper.getHeight()); oldPaperValWasSet = true; } if (attributes.get(MediaPrintableArea.class) == null) { newPaper.setImageableArea( oldPaper.getImageableX(), oldPaper.getImageableY(), oldPaper.getImageableWidth(), oldPaper.getImageableHeight()); oldPaperValWasSet = true; } if (oldPaperValWasSet) { newPf.setPaper(newPaper); } } return newPf; }