Java Printer Usage getJobPriority(int pages, int copies, boolean withDialog)

Here you can find the source of getJobPriority(int pages, int copies, boolean withDialog)

Description

Get Job Priority based on pages printed.

License

Open Source License

Parameter

Parameter Description
pages number of pages
copies number of copies
withDialog dialog gets lower priority than direct print

Return

Job Priority

Declaration

static public JobPriority getJobPriority(int pages, int copies,
        boolean withDialog) 

Method Source Code

//package com.java2s;
/******************************************************************************
 * Product: Adempiere ERP & CRM Smart Business Solution                       *
 * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved.                *
 * This program is free software; you can redistribute it and/or modify it    *
 * under the terms version 2 of the GNU General Public License as published   *
 * by the Free Software Foundation. This program is distributed in the hope   *
 * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.           *
 * See the GNU General Public License for more details.                       *
 * You should have received a copy of the GNU General Public License along    *
 * with this program; if not, write to the Free Software Foundation, Inc.,    *
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.                     *
 * For the text or an alternative of this public license, you may reach us    *
 * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA        *
 * or via info@compiere.org or http://www.compiere.org/license.html           *
 *****************************************************************************/

import javax.print.attribute.standard.JobPriority;

public class Main {
    /**/*from   w  ww .j  ava 2  s  .  co m*/
     *    Get Job Priority based on pages printed.
     *  The more pages, the lower the priority
     *    @param pages number of pages
     *  @param copies number of copies
     *  @param withDialog dialog gets lower priority than direct print
     *    @return Job Priority
     */
    static public JobPriority getJobPriority(int pages, int copies,
            boolean withDialog) {
        //   Set priority (the more pages, the lower the priority)
        int priority = copies * pages;
        if (withDialog) //    prefer direct print
            priority *= 2;
        priority = 100 - priority; //   convert to 1-100 supported range
        if (priority < 10)
            priority = 10;
        else if (priority > 100)
            priority = 100;
        return new JobPriority(priority);
    }
}

Related

  1. getDefaultPrinterName()
  2. getDefaultPrinterName()
  3. getDefaultPrintRequestAttributes()
  4. getEnumAttribute(String name, Object value)
  5. getIntegerAttribute(String name, int value)
  6. getOrientationRequested(int value)
  7. getPaperTraysArray(PrintService ps)
  8. getPrinterAttributes(PrintService printer)
  9. getPrinterJobProperties(PrintService ps)