当前位置: 首页>>代码示例>>Java>>正文


Java Copies.getValue方法代码示例

本文整理汇总了Java中javax.print.attribute.standard.Copies.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java Copies.getValue方法的具体用法?Java Copies.getValue怎么用?Java Copies.getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.print.attribute.standard.Copies的用法示例。


在下文中一共展示了Copies.getValue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isSupportedCopies

import javax.print.attribute.standard.Copies; //导入方法依赖的package包/类
private boolean isSupportedCopies(Copies copies) {
    synchronized (this) {
        if (gotCopies == false) {
            nCopies = getCopiesSupported(printer, getPort());
            gotCopies = true;
        }
    }
    int numCopies = copies.getValue();
    return (numCopies > 0 && numCopies <= nCopies);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:Win32PrintService.java

示例2: pageableJob

import javax.print.attribute.standard.Copies; //导入方法依赖的package包/类
public void pageableJob(Pageable pageable) throws PrintException {
    try {
        synchronized(this) {
            if (job != null) { // shouldn't happen
                throw new PrintException("already printing");
            } else {
                job = new sun.awt.windows.WPrinterJob();
            }
        }
        PrintService svc = getPrintService();
        job.setPrintService(svc);
        if (copies == 0) {
            Copies c = (Copies)svc.getDefaultAttributeValue(Copies.class);
            copies = c.getValue();
        }
        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);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:30,代码来源:Win32PrintJob.java

示例3: isSupportedCopies

import javax.print.attribute.standard.Copies; //导入方法依赖的package包/类
private boolean isSupportedCopies(Copies copies) {
    int numCopies = copies.getValue();
    return (numCopies > 0 && numCopies < MAXCOPIES);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:PSStreamPrintService.java

示例4: print

import javax.print.attribute.standard.Copies; //导入方法依赖的package包/类
private void print(
		final PrintPackage printPackage,
		final PrintPackageInfo printPackageInfo,
		final PrintablePDF printable) throws PrinterException
{
	logger.log(Level.FINE, "Printing {}", printPackageInfo);

	final PrintPackageRequest printRequest = new PrintPackageRequest(printPackage, printPackageInfo);
	printRequest.setPrintJobName("adempiere-job-" + printPackageInfo.toString());
	printRequest.setPrintable(printable);
	printRequest.setNumPages(printable.getNumPages());
	//
	// Attribute: Page Range
	printRequest.getAttributes().add(new PageRanges(printPackageInfo.getPageFrom(), printPackageInfo.getPageTo()));

	// task 08958: !not! discarding our local printer settings, but *also* using the preset from the print package package
	final Copies copies = (Copies)printRequest.getAttributes().get(Copies.class);
	if (copies != null && copies.getValue() != 1)
	{
		logger.log(Level.INFO, "Local printer setting: {} = {} ", new Object[] { copies.getName(), copies.getValue() });
		// printRequest.getAttributes().add(new Copies(1)); don't discard the local printer setting because this is just what the user might want.
	}

	//
	// Attribute: Redirect to file
	if (isRedirectToFile())
	{
		final Destination destination = new Destination(mkTmpPrintFile(printRequest).toURI());
		printRequest.getAttributes().add(destination);
	}

	// task 09832: retry on error
	final Context context = Context.getContext();
	final int retryCount = context.getPropertyAsInt(Context.CTX_Engine_RetryCount, Context.DEFAULT_RetryCount);
	final int retryIntervalMS = context.getPropertyAsInt(Context.CTX_Engine_RetryIntervalMS, Context.DEFAULT_RetryIntervalMS);

	for (int i = 0; i <= retryCount; i++)
	{
		try
		{
			// these might also throw an exception if the printer is not available temporarily. In this case we might also want to retry.
			resolvePrintService(printRequest);
			resolveMediaTray(printRequest);

			print(printRequest);

			break; // if we get here, we did the print and can stop retrying.
		}
		catch (final PrinterException e)
		{
			final int retriesLeft = retryCount - i;
			if (retriesLeft <= 0)
			{
				throw e; // we exhausted our retries
			}
			logger.log(Level.WARNING, "Caught PrinterException while trying to print. " + retriesLeft + " retries left. Waiting " + retryIntervalMS + " millisseconds for the next retry", e);
			sleep(retryIntervalMS);
		}
	}
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:61,代码来源:PrintingEngine.java

示例5: convertAttributes

import javax.print.attribute.standard.Copies; //导入方法依赖的package包/类
int[] convertAttributes(PrintRequestAttributeSet attrs, DocFlavor flavor)
        throws PrintException {
    PrintRequestAttributeSet attributes = null;
    if (attrs == null ||
        flavor.equals(DocFlavor.INPUT_STREAM.AUTOSENSE) ||
        flavor.equals(DocFlavor.BYTE_ARRAY.AUTOSENSE) ||
        flavor.equals(DocFlavor.URL.AUTOSENSE)) {
        int[] defaultValues = {-1, -1, -1, -1, -1, -1, -1, -1}; 
        return defaultValues;
    } else {
        attributes = attrs;
    }
    Attribute[] requestAttrs = attributes.toArray();
    int[] printAttributes = new int[ATTRIBUTES_ARRAY_SIZE];
    Arrays.fill(printAttributes, -1);
    for (int i = 0; i < requestAttrs.length; i++) {
        Class category = requestAttrs[i].getCategory();
        if (!isAttributeValueSupported(requestAttrs[i], flavor, attrs)) {
            // Do nothing or throw PrintException if Fidelity supported.
        } else if (category.equals(Copies.class)) {
            Copies copies = (Copies)requestAttrs[i];
            printAttributes[COPIES_INDEX] = copies.getValue();
        } else if (category.equals(Sides.class)) {
            Sides sides = (Sides)requestAttrs[i];
            printAttributes[SIDES_INDEX] = 1;
            if (sides.equals(Sides.DUPLEX) ||
                sides.equals(Sides.TWO_SIDED_LONG_EDGE)) {
                printAttributes[SIDES_INDEX] = 2;
            } else if (sides.equals(Sides.TUMBLE) ||
                       sides.equals(Sides.TWO_SIDED_SHORT_EDGE)) {
                printAttributes[SIDES_INDEX] = 3;
            }
        } else if (category.equals(Media.class)) {
            if (medias.containsKey(requestAttrs[i])) {
                Integer id = (Integer)medias.get(requestAttrs[i]);
                printAttributes[PAPER_ID_INDEX] = id.intValue();
            }
        } else if (category.equals(Chromaticity.class)) {
            if (requestAttrs[i].equals(Chromaticity.MONOCHROME)) {
                printAttributes[CHROMATICITY_INDEX] = 1;
            } else if (requestAttrs[i].equals(Chromaticity.COLOR)) {
                printAttributes[CHROMATICITY_INDEX] = 2;
            }
        } else if (category.equals(OrientationRequested.class)) {
            if (requestAttrs[i].equals(OrientationRequested.PORTRAIT)) {
                printAttributes[ORIENTATION_INDEX] = 1;
            } else
              if (requestAttrs[i].equals(OrientationRequested.LANDSCAPE)) {
                printAttributes[ORIENTATION_INDEX] = 2;
            }
        } else if (category.equals(PrinterResolution.class)) {
            PrinterResolution res = (PrinterResolution)requestAttrs[i];
            int xres = res.getCrossFeedResolution(PrinterResolution.DPI);
            int yres = res.getFeedResolution(PrinterResolution.DPI);
            printAttributes[XRESOLUTION_INDEX] = xres;
            printAttributes[YRESOLUTION_INDEX] = yres;
        } else if (category.equals(SheetCollate.class)) {
            SheetCollate collate = (SheetCollate)requestAttrs[i];
            if (collate == SheetCollate.COLLATED) {
                printAttributes[COLLATE_INDEX] = 1;
            } else if (collate == SheetCollate.UNCOLLATED) {
                printAttributes[COLLATE_INDEX] = 0;
            }
        }
    }
    return printAttributes;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:68,代码来源:GDIClient.java

示例6: getCopies

import javax.print.attribute.standard.Copies; //导入方法依赖的package包/类
@Override
public int getCopies() {
    final Copies c = (Copies) attributes.get(Copies.class);
    return c != null ? c.getValue() : 1;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:6,代码来源:PrinterJobImpl.java

示例7: getCopies

import javax.print.attribute.standard.Copies; //导入方法依赖的package包/类
/**
 * @param service The {@link PrintService} to use.
 * @param set The {@link PrintRequestAttributeSet} to use.
 * @return The copies to print.
 */
public static int getCopies(PrintService service, PrintRequestAttributeSet set) {
	Copies copies = (Copies) PrintUtilities.getSetting(service, set, Copies.class, false);
	return copies == null ? 1 : copies.getValue();
}
 
开发者ID:Ayutac,项目名称:toolkit,代码行数:10,代码来源:PrintUtilities.java


注:本文中的javax.print.attribute.standard.Copies.getValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。