Here you can find the source of getResolution(PrintService service, PrintRequestAttributeSet set, boolean tryDefaultIfNull)
Parameter | Description |
---|---|
service | The PrintService to use. |
set | The PrintRequestAttributeSet to use. |
tryDefaultIfNull | Whether to ask for the default if no value is present in the set. |
public static PrinterResolution getResolution(PrintService service, PrintRequestAttributeSet set, boolean tryDefaultIfNull)
//package com.java2s; /*/*from w w w . j a v a 2 s. c o m*/ * Copyright (c) 1998-2017 by Richard A. Wilkes. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, version 2.0. If a copy of the MPL was not distributed with * this file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This Source Code Form is "Incompatible With Secondary Licenses", as * defined by the Mozilla Public License, version 2.0. */ import javax.print.PrintService; import javax.print.attribute.Attribute; import javax.print.attribute.PrintRequestAttributeSet; import javax.print.attribute.standard.PrinterResolution; public class Main { /** * @param service The {@link PrintService} to use. * @param set The {@link PrintRequestAttributeSet} to use. * @param tryDefaultIfNull Whether to ask for the default if no value is present in the set. * @return The print resolution. */ public static PrinterResolution getResolution(PrintService service, PrintRequestAttributeSet set, boolean tryDefaultIfNull) { return (PrinterResolution) getSetting(service, set, PrinterResolution.class, tryDefaultIfNull); } /** * Extracts a setting from the specified {@link PrintRequestAttributeSet} or looks up a default * value from the specified {@link PrintService} if the set doesn't contain it. * * @param service The {@link PrintService} to use. * @param set The {@link PrintRequestAttributeSet} to use. * @param type The setting type to extract. * @param tryDefaultIfNull Whether to ask for the default if no value is present in the set. * @return The value for the setting, or <code>null</code> if neither the set or the service has * a value for it. */ public static Attribute getSetting(PrintService service, PrintRequestAttributeSet set, Class<? extends Attribute> type, boolean tryDefaultIfNull) { Attribute attribute = set.get(type); if (tryDefaultIfNull && attribute == null && service != null) { attribute = (Attribute) service.getDefaultAttributeValue(type); } return attribute; } }