Java Printer Usage validateDPI(int dpi)

Here you can find the source of validateDPI(int dpi)

Description

Validates the dpi value.

License

Open Source License

Parameter

Parameter Description
dpi the dpi value

Return

the validated dpi value

Declaration

private static int validateDPI(int dpi) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2004 Actuate Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:/*from   w w w  . j av  a 2  s . c o m*/
 *  Actuate Corporation  - initial API and implementation
 *******************************************************************************/

import javax.print.attribute.ResolutionSyntax;

public class Main {
    /**
     * The default DPI value.
     */
    private static final int DEFAULT_DPI = 96;

    /**
     * Validates the dpi value. If the value is invalid, try to use the JVM
     * defined value and model defined default value.
     * 
     * @param dpi
     *            the dpi value
     * @return the validated dpi value
     */
    private static int validateDPI(int dpi) {
        if (dpi <= 0)
            // Try to use JVM defined value if the dpi value is invalid.
            dpi = ResolutionSyntax.DPI;
        if (dpi <= 0)
            // Use the default value if the JVM defined is invalid.
            dpi = DEFAULT_DPI;
        return dpi;
    }
}

Related

  1. notInArray(PrintService key, PrintService[] array)
  2. print(PrintService printService, byte[] pdf)
  3. refreshPrinterList()
  4. showAttributes(PrintRequestAttributeSet aset)
  5. testSPS()