Java 类java.awt.print.Pageable 实例源码
项目:OpenJSharp
文件:RasterPrinterJob.java
protected final int getMaxPageAttrib() {
if (attributes != null) {
SunMinMaxPage s =
(SunMinMaxPage)attributes.get(SunMinMaxPage.class);
if (s != null) {
return s.getMax();
}
}
Pageable pageable = getPageable();
if (pageable != null) {
int numPages = pageable.getNumberOfPages();
if (numPages <= Pageable.UNKNOWN_NUMBER_OF_PAGES) {
numPages = MAX_UNKNOWN_PAGES;
}
return ((numPages == 0) ? 1 : numPages);
}
return Integer.MAX_VALUE;
}
项目:jdk8u-jdk
文件:RasterPrinterJob.java
protected final int getMaxPageAttrib() {
if (attributes != null) {
SunMinMaxPage s =
(SunMinMaxPage)attributes.get(SunMinMaxPage.class);
if (s != null) {
return s.getMax();
}
}
Pageable pageable = getPageable();
if (pageable != null) {
int numPages = pageable.getNumberOfPages();
if (numPages <= Pageable.UNKNOWN_NUMBER_OF_PAGES) {
numPages = MAX_UNKNOWN_PAGES;
}
return ((numPages == 0) ? 1 : numPages);
}
return Integer.MAX_VALUE;
}
项目:openjdk-jdk10
文件:RasterPrinterJob.java
protected final int getMaxPageAttrib() {
if (attributes != null) {
SunMinMaxPage s =
(SunMinMaxPage)attributes.get(SunMinMaxPage.class);
if (s != null) {
return s.getMax();
}
}
Pageable pageable = getPageable();
if (pageable != null) {
int numPages = pageable.getNumberOfPages();
if (numPages <= Pageable.UNKNOWN_NUMBER_OF_PAGES) {
numPages = MAX_UNKNOWN_PAGES;
}
return ((numPages == 0) ? 1 : numPages);
}
return Integer.MAX_VALUE;
}
项目:openjdk-jdk10
文件:UnixPrintJob.java
public void pageableJob(Pageable pageable) throws PrintException {
try {
synchronized(this) {
if (job != null) { // shouldn't happen
throw new PrintException("already printing");
} else {
job = new PSPrinterJob();
}
}
job.setPrintService(getPrintService());
job.setCopies(copies);
job.setJobName(jobName);
job.setPageable(pageable);
job.print(reqAttrSet);
notifyEvent(PrintJobEvent.DATA_TRANSFER_COMPLETE);
return;
} catch (PrinterException pe) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintException(pe);
} finally {
printReturned = true;
notifyEvent(PrintJobEvent.NO_MORE_EVENTS);
}
}
项目:openjdk9
文件:RasterPrinterJob.java
protected final int getMaxPageAttrib() {
if (attributes != null) {
SunMinMaxPage s =
(SunMinMaxPage)attributes.get(SunMinMaxPage.class);
if (s != null) {
return s.getMax();
}
}
Pageable pageable = getPageable();
if (pageable != null) {
int numPages = pageable.getNumberOfPages();
if (numPages <= Pageable.UNKNOWN_NUMBER_OF_PAGES) {
numPages = MAX_UNKNOWN_PAGES;
}
return ((numPages == 0) ? 1 : numPages);
}
return Integer.MAX_VALUE;
}
项目:jdk8u_jdk
文件:RasterPrinterJob.java
protected final int getMaxPageAttrib() {
if (attributes != null) {
SunMinMaxPage s =
(SunMinMaxPage)attributes.get(SunMinMaxPage.class);
if (s != null) {
return s.getMax();
}
}
Pageable pageable = getPageable();
if (pageable != null) {
int numPages = pageable.getNumberOfPages();
if (numPages <= Pageable.UNKNOWN_NUMBER_OF_PAGES) {
numPages = MAX_UNKNOWN_PAGES;
}
return ((numPages == 0) ? 1 : numPages);
}
return Integer.MAX_VALUE;
}
项目:lookaside_java-1.8.0-openjdk
文件:RasterPrinterJob.java
protected final int getMaxPageAttrib() {
if (attributes != null) {
SunMinMaxPage s =
(SunMinMaxPage)attributes.get(SunMinMaxPage.class);
if (s != null) {
return s.getMax();
}
}
Pageable pageable = getPageable();
if (pageable != null) {
int numPages = pageable.getNumberOfPages();
if (numPages <= Pageable.UNKNOWN_NUMBER_OF_PAGES) {
numPages = MAX_UNKNOWN_PAGES;
}
return ((numPages == 0) ? 1 : numPages);
}
return Integer.MAX_VALUE;
}
项目:icedtea-web
文件:XPrintService.java
public boolean print(Pageable document) {
if (pj != null) {
pj.setPageable(document);
if (pj.printDialog()) {
try {
pj.print();
return true;
} catch (PrinterException pe) {
OutputController.getLogger().log(OutputController.Level.ERROR_ALL, "Could not print: " + pe);
OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, pe);
return false;
}
}
} else
showWarning();
return false;
}
项目:metasfresh
文件:PrintUtil.java
/**
* Print (async)
* @param printerName optional printer name
* @param jobName optional printer job name
* @param pageable pageable
* @param copies number of copies
* @param withDialog if true, shows printer dialog
*/
static public void print (Pageable pageable, String printerName, String jobName,
int copies, boolean withDialog)
{
if (pageable == null)
return;
String name = "Adempiere_";
if (jobName != null)
name += jobName;
//
PrinterJob job = CPrinter.getPrinterJob(printerName);
job.setJobName (name);
job.setPageable (pageable);
// Attributes
HashPrintRequestAttributeSet prats = new HashPrintRequestAttributeSet();
prats.add(new Copies(copies));
// Set Orientation
if (pageable.getPageFormat(0).getOrientation() == PageFormat.PORTRAIT)
prats.add(OrientationRequested.PORTRAIT);
else
prats.add(OrientationRequested.LANDSCAPE);
prats.add(new JobName(name, Language.getLoginLanguage().getLocale()));
prats.add(getJobPriority(pageable.getNumberOfPages(), copies, withDialog));
//
print (job, prats, withDialog, false);
}
项目:infobip-open-jdk-8
文件:RasterPrinterJob.java
protected final int getMaxPageAttrib() {
if (attributes != null) {
SunMinMaxPage s =
(SunMinMaxPage)attributes.get(SunMinMaxPage.class);
if (s != null) {
return s.getMax();
}
}
Pageable pageable = getPageable();
if (pageable != null) {
int numPages = pageable.getNumberOfPages();
if (numPages <= Pageable.UNKNOWN_NUMBER_OF_PAGES) {
numPages = MAX_UNKNOWN_PAGES;
}
return ((numPages == 0) ? 1 : numPages);
}
return Integer.MAX_VALUE;
}
项目:jdk8u-dev-jdk
文件:RasterPrinterJob.java
protected final int getMaxPageAttrib() {
if (attributes != null) {
SunMinMaxPage s =
(SunMinMaxPage)attributes.get(SunMinMaxPage.class);
if (s != null) {
return s.getMax();
}
}
Pageable pageable = getPageable();
if (pageable != null) {
int numPages = pageable.getNumberOfPages();
if (numPages <= Pageable.UNKNOWN_NUMBER_OF_PAGES) {
numPages = MAX_UNKNOWN_PAGES;
}
return ((numPages == 0) ? 1 : numPages);
}
return Integer.MAX_VALUE;
}
项目:jdk7-jdk
文件:WPrinterJob.java
private final int getMaxPageAttrib() {
if (attributes != null) {
SunMinMaxPage s =
(SunMinMaxPage)attributes.get(SunMinMaxPage.class);
if (s != null) {
return s.getMax();
}
}
Pageable pageable = getPageable();
if (pageable != null) {
int numPages = pageable.getNumberOfPages();
if (numPages <= Pageable.UNKNOWN_NUMBER_OF_PAGES) {
numPages = MAX_UNKNOWN_PAGES;
}
return ((numPages == 0) ? 1 : numPages);
}
return Integer.MAX_VALUE;
}
项目:openjdk-source-code-learn
文件:WPrinterJob.java
private final int getMaxPageAttrib() {
if (attributes != null) {
SunMinMaxPage s =
(SunMinMaxPage)attributes.get(SunMinMaxPage.class);
if (s != null) {
return s.getMax();
}
}
Pageable pageable = getPageable();
if (pageable != null) {
int numPages = pageable.getNumberOfPages();
if (numPages <= Pageable.UNKNOWN_NUMBER_OF_PAGES) {
numPages = MAX_UNKNOWN_PAGES;
}
return ((numPages == 0) ? 1 : numPages);
}
return Integer.MAX_VALUE;
}
项目:OLD-OpenJDK8
文件:RasterPrinterJob.java
protected final int getMaxPageAttrib() {
if (attributes != null) {
SunMinMaxPage s =
(SunMinMaxPage)attributes.get(SunMinMaxPage.class);
if (s != null) {
return s.getMax();
}
}
Pageable pageable = getPageable();
if (pageable != null) {
int numPages = pageable.getNumberOfPages();
if (numPages <= Pageable.UNKNOWN_NUMBER_OF_PAGES) {
numPages = MAX_UNKNOWN_PAGES;
}
return ((numPages == 0) ? 1 : numPages);
}
return Integer.MAX_VALUE;
}
项目:openjdk-jdk7u-jdk
文件:WPrinterJob.java
private final int getMaxPageAttrib() {
if (attributes != null) {
SunMinMaxPage s =
(SunMinMaxPage)attributes.get(SunMinMaxPage.class);
if (s != null) {
return s.getMax();
}
}
Pageable pageable = getPageable();
if (pageable != null) {
int numPages = pageable.getNumberOfPages();
if (numPages <= Pageable.UNKNOWN_NUMBER_OF_PAGES) {
numPages = MAX_UNKNOWN_PAGES;
}
return ((numPages == 0) ? 1 : numPages);
}
return Integer.MAX_VALUE;
}
项目:openjdk-icedtea7
文件:WPrinterJob.java
private final int getMaxPageAttrib() {
if (attributes != null) {
SunMinMaxPage s =
(SunMinMaxPage)attributes.get(SunMinMaxPage.class);
if (s != null) {
return s.getMax();
}
}
Pageable pageable = getPageable();
if (pageable != null) {
int numPages = pageable.getNumberOfPages();
if (numPages <= Pageable.UNKNOWN_NUMBER_OF_PAGES) {
numPages = MAX_UNKNOWN_PAGES;
}
return ((numPages == 0) ? 1 : numPages);
}
return Integer.MAX_VALUE;
}
项目:OpenJSharp
文件:RasterPrinterJob.java
/**
* Set the range of pages from a Book to be printed.
* Both 'firstPage' and 'lastPage' are zero based
* page indices. If either parameter is less than
* zero then the page range is set to be from the
* first page to the last.
*/
protected void setPageRange(int firstPage, int lastPage) {
if(firstPage >= 0 && lastPage >= 0) {
mFirstPage = firstPage;
mLastPage = lastPage;
if(mLastPage < mFirstPage) mLastPage = mFirstPage;
} else {
mFirstPage = Pageable.UNKNOWN_NUMBER_OF_PAGES;
mLastPage = Pageable.UNKNOWN_NUMBER_OF_PAGES;
}
}
项目:OpenJSharp
文件:Win32PrintJob.java
public void pageableJob(Pageable pageable) throws PrintException {
// a general hint for this code here: The PrintJob implementation (WPrinterJob) in the Oracle
// JRE implements SunPrinterJobService - which we don't here. Unfortunately this is used as a hint
// to distinguish between the build-in printer service and custom printer services. So for the RasterPrinterJob
// this implementation of the Win32PrintJob is a custom print job! That's why several methods of
// RasterPrintJob(which only apply to the SunPrinterJobService otherwise) had to be moved here.
// This includes the attribute resolving and the media patch for instance.
try {
PrintDocument printDocument = createPrintDocument( );
pageable = patchMedia( pageable );
printDocument.add_QueryPageSettings(new QueryPageSettingsEventHandler(new QueryPage( pageable, printColor, mediaTray ) ) );
printDocument.add_PrintPage(new PrintPageEventHandler(new PrintPage(pageable)));
printDocument.Print();
if(printerException != null){
throw printerException;
}
//TODO throw exception on Cancel
notifyEvent(PrintJobEvent.DATA_TRANSFER_COMPLETE);
return;
} catch (PrinterException pe) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintException(pe);
} finally {
printReturned = true;
notifyEvent(PrintJobEvent.NO_MORE_EVENTS);
}
}
项目:jdk8u-jdk
文件:RasterPrinterJob.java
/**
* Set the range of pages from a Book to be printed.
* Both 'firstPage' and 'lastPage' are zero based
* page indices. If either parameter is less than
* zero then the page range is set to be from the
* first page to the last.
*/
protected void setPageRange(int firstPage, int lastPage) {
if(firstPage >= 0 && lastPage >= 0) {
mFirstPage = firstPage;
mLastPage = lastPage;
if(mLastPage < mFirstPage) mLastPage = mFirstPage;
} else {
mFirstPage = Pageable.UNKNOWN_NUMBER_OF_PAGES;
mLastPage = Pageable.UNKNOWN_NUMBER_OF_PAGES;
}
}
项目:openjdk-jdk10
文件:RasterPrinterJob.java
/**
* Set the range of pages from a Book to be printed.
* Both 'firstPage' and 'lastPage' are zero based
* page indices. If either parameter is less than
* zero then the page range is set to be from the
* first page to the last.
*/
protected void setPageRange(int firstPage, int lastPage) {
if(firstPage >= 0 && lastPage >= 0) {
mFirstPage = firstPage;
mLastPage = lastPage;
if(mLastPage < mFirstPage) mLastPage = mFirstPage;
} else {
mFirstPage = Pageable.UNKNOWN_NUMBER_OF_PAGES;
mLastPage = Pageable.UNKNOWN_NUMBER_OF_PAGES;
}
}
项目:openjdk9
文件:RasterPrinterJob.java
/**
* Set the range of pages from a Book to be printed.
* Both 'firstPage' and 'lastPage' are zero based
* page indices. If either parameter is less than
* zero then the page range is set to be from the
* first page to the last.
*/
protected void setPageRange(int firstPage, int lastPage) {
if(firstPage >= 0 && lastPage >= 0) {
mFirstPage = firstPage;
mLastPage = lastPage;
if(mLastPage < mFirstPage) mLastPage = mFirstPage;
} else {
mFirstPage = Pageable.UNKNOWN_NUMBER_OF_PAGES;
mLastPage = Pageable.UNKNOWN_NUMBER_OF_PAGES;
}
}
项目:jdk8u_jdk
文件:RasterPrinterJob.java
/**
* Set the range of pages from a Book to be printed.
* Both 'firstPage' and 'lastPage' are zero based
* page indices. If either parameter is less than
* zero then the page range is set to be from the
* first page to the last.
*/
protected void setPageRange(int firstPage, int lastPage) {
if(firstPage >= 0 && lastPage >= 0) {
mFirstPage = firstPage;
mLastPage = lastPage;
if(mLastPage < mFirstPage) mLastPage = mFirstPage;
} else {
mFirstPage = Pageable.UNKNOWN_NUMBER_OF_PAGES;
mLastPage = Pageable.UNKNOWN_NUMBER_OF_PAGES;
}
}
项目:lookaside_java-1.8.0-openjdk
文件:RasterPrinterJob.java
/**
* Set the range of pages from a Book to be printed.
* Both 'firstPage' and 'lastPage' are zero based
* page indices. If either parameter is less than
* zero then the page range is set to be from the
* first page to the last.
*/
protected void setPageRange(int firstPage, int lastPage) {
if(firstPage >= 0 && lastPage >= 0) {
mFirstPage = firstPage;
mLastPage = lastPage;
if(mLastPage < mFirstPage) mLastPage = mFirstPage;
} else {
mFirstPage = Pageable.UNKNOWN_NUMBER_OF_PAGES;
mLastPage = Pageable.UNKNOWN_NUMBER_OF_PAGES;
}
}
项目:javify
文件:JavaPrinterJob.java
/**
* This sets the pages that are to be printed.
*
* @param pageable The pages to be printed, which may not be <code>null</code>.
*/
public void setPageable(Pageable pageable)
{
if( pageable == null )
throw new NullPointerException("Pageable cannot be null.");
this.pageable = pageable;
}
项目:jvm-stm
文件:JavaPrinterJob.java
/**
* This sets the pages that are to be printed.
*
* @param pageable The pages to be printed, which may not be <code>null</code>.
*/
public void setPageable(Pageable pageable)
{
if( pageable == null )
throw new NullPointerException("Pageable cannot be null.");
this.pageable = pageable;
}
项目:metasfresh
文件:ArchiveEngine.java
/**
* Can we archive the document?
* @param layout layout
* @return true if can be archived
*/
public static boolean isValid (LayoutEngine layout)
{
return (layout != null
&& Document.isValid((Pageable)layout)
&& layout.getNumberOfPages() > 0);
}
项目:metasfresh
文件:PrintUtil.java
/**
* Print Async
* @param pageable pageable
* @param prats print attribure set
*/
static public void print (Pageable pageable, PrintRequestAttributeSet prats)
{
PrinterJob job = CPrinter.getPrinterJob();
job.setPageable(pageable);
print (job, prats, true, false);
}
项目:metasfresh
文件:Document.java
public static File getPDFAsFile(String filename, Pageable pageable) {
final File result = new File(filename);
try {
writePDF(pageable, new FileOutputStream(result));
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
项目:metasfresh
文件:Document.java
public static byte[] getPDFAsArray(Pageable pageable) {
try {
ByteArrayOutputStream output = new ByteArrayOutputStream(10240);
writePDF(pageable, output);
return output.toByteArray();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
项目:infobip-open-jdk-8
文件:RasterPrinterJob.java
/**
* Set the range of pages from a Book to be printed.
* Both 'firstPage' and 'lastPage' are zero based
* page indices. If either parameter is less than
* zero then the page range is set to be from the
* first page to the last.
*/
protected void setPageRange(int firstPage, int lastPage) {
if(firstPage >= 0 && lastPage >= 0) {
mFirstPage = firstPage;
mLastPage = lastPage;
if(mLastPage < mFirstPage) mLastPage = mFirstPage;
} else {
mFirstPage = Pageable.UNKNOWN_NUMBER_OF_PAGES;
mLastPage = Pageable.UNKNOWN_NUMBER_OF_PAGES;
}
}
项目:jdk8u-dev-jdk
文件:RasterPrinterJob.java
/**
* Set the range of pages from a Book to be printed.
* Both 'firstPage' and 'lastPage' are zero based
* page indices. If either parameter is less than
* zero then the page range is set to be from the
* first page to the last.
*/
protected void setPageRange(int firstPage, int lastPage) {
if(firstPage >= 0 && lastPage >= 0) {
mFirstPage = firstPage;
mLastPage = lastPage;
if(mLastPage < mFirstPage) mLastPage = mFirstPage;
} else {
mFirstPage = Pageable.UNKNOWN_NUMBER_OF_PAGES;
mLastPage = Pageable.UNKNOWN_NUMBER_OF_PAGES;
}
}
项目:jdk7-jdk
文件:RasterPrinterJob.java
/**
* Set the range of pages from a Book to be printed.
* Both 'firstPage' and 'lastPage' are zero based
* page indices. If either parameter is less than
* zero then the page range is set to be from the
* first page to the last.
*/
protected void setPageRange(int firstPage, int lastPage) {
if(firstPage >= 0 && lastPage >= 0) {
mFirstPage = firstPage;
mLastPage = lastPage;
if(mLastPage < mFirstPage) mLastPage = mFirstPage;
} else {
mFirstPage = Pageable.UNKNOWN_NUMBER_OF_PAGES;
mLastPage = Pageable.UNKNOWN_NUMBER_OF_PAGES;
}
}
项目:openjdk-source-code-learn
文件:RasterPrinterJob.java
/**
* Set the range of pages from a Book to be printed.
* Both 'firstPage' and 'lastPage' are zero based
* page indices. If either parameter is less than
* zero then the page range is set to be from the
* first page to the last.
*/
protected void setPageRange(int firstPage, int lastPage) {
if(firstPage >= 0 && lastPage >= 0) {
mFirstPage = firstPage;
mLastPage = lastPage;
if(mLastPage < mFirstPage) mLastPage = mFirstPage;
} else {
mFirstPage = Pageable.UNKNOWN_NUMBER_OF_PAGES;
mLastPage = Pageable.UNKNOWN_NUMBER_OF_PAGES;
}
}
项目:OLD-OpenJDK8
文件:RasterPrinterJob.java
/**
* Set the range of pages from a Book to be printed.
* Both 'firstPage' and 'lastPage' are zero based
* page indices. If either parameter is less than
* zero then the page range is set to be from the
* first page to the last.
*/
protected void setPageRange(int firstPage, int lastPage) {
if(firstPage >= 0 && lastPage >= 0) {
mFirstPage = firstPage;
mLastPage = lastPage;
if(mLastPage < mFirstPage) mLastPage = mFirstPage;
} else {
mFirstPage = Pageable.UNKNOWN_NUMBER_OF_PAGES;
mLastPage = Pageable.UNKNOWN_NUMBER_OF_PAGES;
}
}
项目:jpexs-decompiler
文件:PDFPrinterJob.java
@Override
public void setPageable(Pageable document) throws NullPointerException {
if (document == null) {
throw new NullPointerException("Pageable cannot be null.");
}
this.pageable = document;
}
项目:JamVM-PH
文件:JavaPrinterJob.java
/**
* This sets the pages that are to be printed.
*
* @param pageable The pages to be printed, which may not be <code>null</code>.
*/
public void setPageable(Pageable pageable)
{
if( pageable == null )
throw new NullPointerException("Pageable cannot be null.");
this.pageable = pageable;
}
项目:openjdk-jdk7u-jdk
文件:RasterPrinterJob.java
/**
* Set the range of pages from a Book to be printed.
* Both 'firstPage' and 'lastPage' are zero based
* page indices. If either parameter is less than
* zero then the page range is set to be from the
* first page to the last.
*/
protected void setPageRange(int firstPage, int lastPage) {
if(firstPage >= 0 && lastPage >= 0) {
mFirstPage = firstPage;
mLastPage = lastPage;
if(mLastPage < mFirstPage) mLastPage = mFirstPage;
} else {
mFirstPage = Pageable.UNKNOWN_NUMBER_OF_PAGES;
mLastPage = Pageable.UNKNOWN_NUMBER_OF_PAGES;
}
}
项目:classpath
文件:JavaPrinterJob.java
/**
* This sets the pages that are to be printed.
*
* @param pageable The pages to be printed, which may not be <code>null</code>.
*/
public void setPageable(Pageable pageable)
{
if( pageable == null )
throw new NullPointerException("Pageable cannot be null.");
this.pageable = pageable;
}
项目:openjdk-icedtea7
文件:RasterPrinterJob.java
/**
* Set the range of pages from a Book to be printed.
* Both 'firstPage' and 'lastPage' are zero based
* page indices. If either parameter is less than
* zero then the page range is set to be from the
* first page to the last.
*/
protected void setPageRange(int firstPage, int lastPage) {
if(firstPage >= 0 && lastPage >= 0) {
mFirstPage = firstPage;
mLastPage = lastPage;
if(mLastPage < mFirstPage) mLastPage = mFirstPage;
} else {
mFirstPage = Pageable.UNKNOWN_NUMBER_OF_PAGES;
mLastPage = Pageable.UNKNOWN_NUMBER_OF_PAGES;
}
}
项目:OpenJSharp
文件:RasterPrinterJob.java
/**
* Return the Pageable describing the pages to be printed.
*/
protected Pageable getPageable() {
return mDocument;
}