Package javax.print.attribute.standard

Examples of javax.print.attribute.standard.PrinterResolution


            int[] resolutions = getResolutionsSupported(serviceName);
            if (resolutions != null && resolutions.length > 1) {
                PrinterResolution[] res =
                    new PrinterResolution[resolutions.length / 2];
                for (int i = 0; i < resolutions.length / 2; i++) {
                    res[i] = new PrinterResolution(resolutions[i * 2],
                            resolutions[i * 2 + 1], PrinterResolution.DPI);
                }
                return res;
            }
        } else if (category.equals(SheetCollate.class)) {
View Full Code Here


                } 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) {
View Full Code Here

        if (resolutions==null)
            return new String[]{"Default"};

        String[] names = new String[resolutions.length];
        for (int i=0; i<resolutions.length; i++) {
            PrinterResolution res = resolutions[i];
            names[i] = res.getCrossFeedResolution(PrinterResolution.DPI)+"x"+res.getFeedResolution(PrinterResolution.DPI)+" dpi";
        }

        return names;
    }
View Full Code Here

        //find nearest resolution
        int minDiff = Integer.MAX_VALUE;
        int indexToUse = 0;
        for (int i=0; i<resolutions.length; i++) {
            PrinterResolution res = resolutions[i];
            int cfDiff = res.getCrossFeedResolution(PrinterResolution.DPI)-defaultResolution;
            if (cfDiff < 0)
                cfDiff = -cfDiff;
            int fDiff = res.getFeedResolution(PrinterResolution.DPI)-defaultResolution;
            if (fDiff < 0)
                fDiff = -fDiff;

            if (cfDiff+fDiff < minDiff) {
                minDiff = cfDiff+fDiff;
View Full Code Here

                printRes = new PrinterResolution[0];
            } else {
                int nRes = prnRes.length/2;

                ArrayList arrList = new ArrayList();
                PrinterResolution pr;

                for (int i=0; i<nRes; i++) {
                  try {
                        pr = new PrinterResolution(prnRes[i*2],
                                       prnRes[i*2+1], PrinterResolution.DPI);
                        arrList.add(pr);
                    } catch (IllegalArgumentException e) {
                    }
                }
View Full Code Here

            int yRes = defYRes;
            int xRes = defQuality;
            if ((xRes < 0) || (yRes < 0)) {
                int res = (yRes > xRes) ? yRes : xRes;
                if (res > 0) {
                 return new PrinterResolution(res, res, PrinterResolution.DPI);
                }
            }
            else {
               return new PrinterResolution(xRes, yRes, PrinterResolution.DPI);
            }
        } else if (category == ColorSupported.class) {
            int caps = getPrinterCapabilities();
            if ((caps & DEVCAP_COLOR) != 0) {
                return ColorSupported.SUPPORTED;
View Full Code Here


    /* Printer Resolution. See also getXRes() and getYRes() */
    private final void setResolutionDPI(int xres, int yres) {
        if (attributes != null) {
            PrinterResolution res =
                new PrinterResolution(xres, yres, PrinterResolution.DPI);
            attributes.add(res);
        }
        mAttXRes = xres;
        mAttYRes = yres;
    }
View Full Code Here

        mAttXRes = xres;
        mAttYRes = yres;
    }

    private void setResolutionAttrib(Attribute attr) {
        PrinterResolution pr = (PrinterResolution)attr;
        mAttXRes = pr.getCrossFeedResolution(PrinterResolution.DPI);
        mAttYRes = pr.getFeedResolution(PrinterResolution.DPI);
    }
View Full Code Here

    public PrinterResolution getPrinterResolution() {
        final int x = getDmPrintQuality(structPtr);
        final int y = getDmYResolution(structPtr);

        if (y > 0) {
            return new PrinterResolution(x > 0 ? x : y, y, ResolutionSyntax.DPI);
        }

        return null;
    }
View Full Code Here

    }

    public <T extends AttributeSet> T getAttributes(final T attrs) {
        final long flags = getDmFields();
        final Paper p = getPaper();
        final PrinterResolution res = getPrinterResolution();

        if (p != null) {
            attrs.add(p.getSize());
            attrs.add(p.getSize().getMediaSizeName());
        }
View Full Code Here

TOP

Related Classes of javax.print.attribute.standard.PrinterResolution

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.