Search in sources :

Example 1 with Sides

use of javax.print.attribute.standard.Sides in project jdk8u_jdk by JetBrains.

the class PSStreamPrintService method getSupportedAttributeValues.

public Object getSupportedAttributeValues(Class<? extends Attribute> category, DocFlavor flavor, AttributeSet attributes) {
    if (category == null) {
        throw new NullPointerException("null category");
    }
    if (!Attribute.class.isAssignableFrom(category)) {
        throw new IllegalArgumentException(category + " does not implement Attribute");
    }
    if (flavor != null && !isDocFlavorSupported(flavor)) {
        throw new IllegalArgumentException(flavor + " is an unsupported flavor");
    }
    if (!isAttributeCategorySupported(category)) {
        return null;
    }
    if (category == Chromaticity.class) {
        Chromaticity[] arr = new Chromaticity[1];
        arr[0] = Chromaticity.COLOR;
        //arr[1] = Chromaticity.MONOCHROME;
        return (arr);
    } else if (category == JobName.class) {
        return new JobName("", null);
    } else if (category == RequestingUserName.class) {
        return new RequestingUserName("", null);
    } else if (category == OrientationRequested.class) {
        if (flavor == null || flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) || flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE)) {
            OrientationRequested[] arr = new OrientationRequested[3];
            arr[0] = OrientationRequested.PORTRAIT;
            arr[1] = OrientationRequested.LANDSCAPE;
            arr[2] = OrientationRequested.REVERSE_LANDSCAPE;
            return arr;
        } else {
            return null;
        }
    } else if ((category == Copies.class) || (category == CopiesSupported.class)) {
        return new CopiesSupported(1, MAXCOPIES);
    } else if (category == Media.class) {
        Media[] arr = new Media[mediaSizes.length];
        System.arraycopy(mediaSizes, 0, arr, 0, mediaSizes.length);
        return arr;
    } else if (category == Fidelity.class) {
        Fidelity[] arr = new Fidelity[2];
        arr[0] = Fidelity.FIDELITY_FALSE;
        arr[1] = Fidelity.FIDELITY_TRUE;
        return arr;
    } else if (category == MediaPrintableArea.class) {
        if (attributes == null) {
            return null;
        }
        MediaSize mediaSize = (MediaSize) attributes.get(MediaSize.class);
        if (mediaSize == null) {
            Media media = (Media) attributes.get(Media.class);
            if (media != null && media instanceof MediaSizeName) {
                MediaSizeName msn = (MediaSizeName) media;
                mediaSize = MediaSize.getMediaSizeForName(msn);
            }
        }
        if (mediaSize == null) {
            return null;
        } else {
            MediaPrintableArea[] arr = new MediaPrintableArea[1];
            float w = mediaSize.getX(MediaSize.INCH);
            float h = mediaSize.getY(MediaSize.INCH);
            /* For dimensions >= 5 inches use 0.5 inch margins.
                 * For smaller dimensions, use 10% margins.
                 */
            float xmargin = 0.5f;
            float ymargin = 0.5f;
            if (w < 5f) {
                xmargin = w / 10;
            }
            if (h < 5f) {
                ymargin = h / 10;
            }
            arr[0] = new MediaPrintableArea(xmargin, ymargin, w - 2 * xmargin, h - 2 * ymargin, MediaSize.INCH);
            return arr;
        }
    } else if (category == PageRanges.class) {
        if (flavor == null || flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) || flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE)) {
            PageRanges[] arr = new PageRanges[1];
            arr[0] = new PageRanges(1, Integer.MAX_VALUE);
            return arr;
        } else {
            return null;
        }
    } else if (category == SheetCollate.class) {
        if (flavor == null || flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) || flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE)) {
            SheetCollate[] arr = new SheetCollate[2];
            arr[0] = SheetCollate.UNCOLLATED;
            arr[1] = SheetCollate.COLLATED;
            return arr;
        } else {
            SheetCollate[] arr = new SheetCollate[1];
            arr[0] = SheetCollate.UNCOLLATED;
            return arr;
        }
    } else if (category == Sides.class) {
        if (flavor == null || flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) || flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE)) {
            Sides[] arr = new Sides[3];
            arr[0] = Sides.ONE_SIDED;
            arr[1] = Sides.TWO_SIDED_LONG_EDGE;
            arr[2] = Sides.TWO_SIDED_SHORT_EDGE;
            return arr;
        } else {
            return null;
        }
    } else {
        return null;
    }
}
Also used : Fidelity(javax.print.attribute.standard.Fidelity) PageRanges(javax.print.attribute.standard.PageRanges) MediaSize(javax.print.attribute.standard.MediaSize) PrintServiceAttribute(javax.print.attribute.PrintServiceAttribute) Attribute(javax.print.attribute.Attribute) MediaSizeName(javax.print.attribute.standard.MediaSizeName) JobName(javax.print.attribute.standard.JobName) Media(javax.print.attribute.standard.Media) OrientationRequested(javax.print.attribute.standard.OrientationRequested) MediaPrintableArea(javax.print.attribute.standard.MediaPrintableArea) SheetCollate(javax.print.attribute.standard.SheetCollate) RequestingUserName(javax.print.attribute.standard.RequestingUserName) CopiesSupported(javax.print.attribute.standard.CopiesSupported) Chromaticity(javax.print.attribute.standard.Chromaticity) Sides(javax.print.attribute.standard.Sides)

Example 2 with Sides

use of javax.print.attribute.standard.Sides in project jdk8u_jdk by JetBrains.

the class PrintJob2D method updateAttributes.

private void updateAttributes() {
    Copies c = (Copies) attributes.get(Copies.class);
    jobAttributes.setCopies(c.getValue());
    SunPageSelection sel = (SunPageSelection) attributes.get(SunPageSelection.class);
    if (sel == SunPageSelection.RANGE) {
        jobAttributes.setDefaultSelection(DefaultSelectionType.RANGE);
    } else if (sel == SunPageSelection.SELECTION) {
        jobAttributes.setDefaultSelection(DefaultSelectionType.SELECTION);
    } else {
        jobAttributes.setDefaultSelection(DefaultSelectionType.ALL);
    }
    Destination dest = (Destination) attributes.get(Destination.class);
    if (dest != null) {
        jobAttributes.setDestination(DestinationType.FILE);
        jobAttributes.setFileName(dest.getURI().getPath());
    } else {
        jobAttributes.setDestination(DestinationType.PRINTER);
    }
    PrintService serv = printerJob.getPrintService();
    if (serv != null) {
        jobAttributes.setPrinter(serv.getName());
    }
    PageRanges range = (PageRanges) attributes.get(PageRanges.class);
    int[][] members = range.getMembers();
    jobAttributes.setPageRanges(members);
    SheetCollate collation = (SheetCollate) attributes.get(SheetCollate.class);
    if (collation == SheetCollate.COLLATED) {
        jobAttributes.setMultipleDocumentHandling(MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_COLLATED_COPIES);
    } else {
        jobAttributes.setMultipleDocumentHandling(MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES);
    }
    Sides sides = (Sides) attributes.get(Sides.class);
    if (sides == Sides.TWO_SIDED_LONG_EDGE) {
        jobAttributes.setSides(SidesType.TWO_SIDED_LONG_EDGE);
    } else if (sides == Sides.TWO_SIDED_SHORT_EDGE) {
        jobAttributes.setSides(SidesType.TWO_SIDED_SHORT_EDGE);
    } else {
        jobAttributes.setSides(SidesType.ONE_SIDED);
    }
    // PageAttributes
    Chromaticity color = (Chromaticity) attributes.get(Chromaticity.class);
    if (color == Chromaticity.COLOR) {
        pageAttributes.setColor(ColorType.COLOR);
    } else {
        pageAttributes.setColor(ColorType.MONOCHROME);
    }
    OrientationRequested orient = (OrientationRequested) attributes.get(OrientationRequested.class);
    if (orient == OrientationRequested.LANDSCAPE) {
        pageAttributes.setOrientationRequested(OrientationRequestedType.LANDSCAPE);
    } else {
        pageAttributes.setOrientationRequested(OrientationRequestedType.PORTRAIT);
    }
    PrintQuality qual = (PrintQuality) attributes.get(PrintQuality.class);
    if (qual == PrintQuality.DRAFT) {
        pageAttributes.setPrintQuality(PrintQualityType.DRAFT);
    } else if (qual == PrintQuality.HIGH) {
        pageAttributes.setPrintQuality(PrintQualityType.HIGH);
    } else {
        // NORMAL
        pageAttributes.setPrintQuality(PrintQualityType.NORMAL);
    }
    Media msn = (Media) attributes.get(Media.class);
    if (msn != null && msn instanceof MediaSizeName) {
        MediaType mType = unMapMedia((MediaSizeName) msn);
        if (mType != null) {
            pageAttributes.setMedia(mType);
        }
    }
    debugPrintAttributes(false, false);
}
Also used : Destination(javax.print.attribute.standard.Destination) PageRanges(javax.print.attribute.standard.PageRanges) MediaSizeName(javax.print.attribute.standard.MediaSizeName) PrintQuality(javax.print.attribute.standard.PrintQuality) Media(javax.print.attribute.standard.Media) OrientationRequested(javax.print.attribute.standard.OrientationRequested) PrintService(javax.print.PrintService) SheetCollate(javax.print.attribute.standard.SheetCollate) Copies(javax.print.attribute.standard.Copies) SunPageSelection(sun.print.SunPageSelection) Chromaticity(javax.print.attribute.standard.Chromaticity) Sides(javax.print.attribute.standard.Sides)

Example 3 with Sides

use of javax.print.attribute.standard.Sides in project jdk8u_jdk by JetBrains.

the class Win32MediaSize method getSupportedAttributeValues.

public Object getSupportedAttributeValues(Class<? extends Attribute> category, DocFlavor flavor, AttributeSet attributes) {
    if (category == null) {
        throw new NullPointerException("null category");
    }
    if (!Attribute.class.isAssignableFrom(category)) {
        throw new IllegalArgumentException(category + " does not implement Attribute");
    }
    if (flavor != null) {
        if (!isDocFlavorSupported(flavor)) {
            throw new IllegalArgumentException(flavor + " is an unsupported flavor");
        // if postscript & category is already specified within the
        //  PostScript data we return null
        } else if (isAutoSense(flavor) || (isPostScriptFlavor(flavor) && (isPSDocAttr(category)))) {
            return null;
        }
    }
    if (!isAttributeCategorySupported(category)) {
        return null;
    }
    if (category == JobName.class) {
        return new JobName("Java Printing", null);
    } else if (category == RequestingUserName.class) {
        String userName = "";
        try {
            userName = System.getProperty("user.name", "");
        } catch (SecurityException se) {
        }
        return new RequestingUserName(userName, null);
    } else if (category == ColorSupported.class) {
        int caps = getPrinterCapabilities();
        if ((caps & DEVCAP_COLOR) != 0) {
            return ColorSupported.SUPPORTED;
        } else {
            return ColorSupported.NOT_SUPPORTED;
        }
    } else if (category == Chromaticity.class) {
        if (flavor == null || flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) || flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE) || flavor.equals(DocFlavor.BYTE_ARRAY.GIF) || flavor.equals(DocFlavor.INPUT_STREAM.GIF) || flavor.equals(DocFlavor.URL.GIF) || flavor.equals(DocFlavor.BYTE_ARRAY.JPEG) || flavor.equals(DocFlavor.INPUT_STREAM.JPEG) || flavor.equals(DocFlavor.URL.JPEG) || flavor.equals(DocFlavor.BYTE_ARRAY.PNG) || flavor.equals(DocFlavor.INPUT_STREAM.PNG) || flavor.equals(DocFlavor.URL.PNG)) {
            int caps = getPrinterCapabilities();
            if ((caps & DEVCAP_COLOR) == 0) {
                Chromaticity[] arr = new Chromaticity[1];
                arr[0] = Chromaticity.MONOCHROME;
                return (arr);
            } else {
                Chromaticity[] arr = new Chromaticity[2];
                arr[0] = Chromaticity.MONOCHROME;
                arr[1] = Chromaticity.COLOR;
                return (arr);
            }
        } else {
            return null;
        }
    } else if (category == Destination.class) {
        try {
            return new Destination((new File("out.prn")).toURI());
        } catch (SecurityException se) {
            try {
                return new Destination(new URI("file:out.prn"));
            } catch (URISyntaxException e) {
                return null;
            }
        }
    } else if (category == OrientationRequested.class) {
        if (flavor == null || flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) || flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE) || flavor.equals(DocFlavor.INPUT_STREAM.GIF) || flavor.equals(DocFlavor.INPUT_STREAM.JPEG) || flavor.equals(DocFlavor.INPUT_STREAM.PNG) || flavor.equals(DocFlavor.BYTE_ARRAY.GIF) || flavor.equals(DocFlavor.BYTE_ARRAY.JPEG) || flavor.equals(DocFlavor.BYTE_ARRAY.PNG) || flavor.equals(DocFlavor.URL.GIF) || flavor.equals(DocFlavor.URL.JPEG) || flavor.equals(DocFlavor.URL.PNG)) {
            OrientationRequested[] arr = new OrientationRequested[3];
            arr[0] = OrientationRequested.PORTRAIT;
            arr[1] = OrientationRequested.LANDSCAPE;
            arr[2] = OrientationRequested.REVERSE_LANDSCAPE;
            return arr;
        } else {
            return null;
        }
    } else if ((category == Copies.class) || (category == CopiesSupported.class)) {
        synchronized (this) {
            if (gotCopies == false) {
                nCopies = getCopiesSupported(printer, getPort());
                gotCopies = true;
            }
        }
        return new CopiesSupported(1, nCopies);
    } else if (category == Media.class) {
        initMedia();
        int len = (mediaSizeNames == null) ? 0 : mediaSizeNames.length;
        MediaTray[] trays = getMediaTrays();
        len += (trays == null) ? 0 : trays.length;
        Media[] arr = new Media[len];
        if (mediaSizeNames != null) {
            System.arraycopy(mediaSizeNames, 0, arr, 0, mediaSizeNames.length);
        }
        if (trays != null) {
            System.arraycopy(trays, 0, arr, len - trays.length, trays.length);
        }
        return arr;
    } else if (category == MediaPrintableArea.class) {
        // if getting printable area for a specific media size
        Media mediaName = null;
        if ((attributes != null) && ((mediaName = (Media) attributes.get(Media.class)) != null)) {
            if (!(mediaName instanceof MediaSizeName)) {
                // if an instance of MediaTray, fall thru returning
                // all MediaPrintableAreas
                mediaName = null;
            }
        }
        MediaPrintableArea[] mpas = getMediaPrintables((MediaSizeName) mediaName);
        if (mpas != null) {
            MediaPrintableArea[] arr = new MediaPrintableArea[mpas.length];
            System.arraycopy(mpas, 0, arr, 0, mpas.length);
            return arr;
        } else {
            return null;
        }
    } else if (category == SunAlternateMedia.class) {
        return new SunAlternateMedia((Media) getDefaultAttributeValue(Media.class));
    } else if (category == PageRanges.class) {
        if (flavor == null || flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) || flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE)) {
            PageRanges[] arr = new PageRanges[1];
            arr[0] = new PageRanges(1, Integer.MAX_VALUE);
            return arr;
        } else {
            return null;
        }
    } else if (category == PrinterResolution.class) {
        PrinterResolution[] supportedRes = getPrintResolutions();
        if (supportedRes == null) {
            return null;
        }
        PrinterResolution[] arr = new PrinterResolution[supportedRes.length];
        System.arraycopy(supportedRes, 0, arr, 0, supportedRes.length);
        return arr;
    } else if (category == Sides.class) {
        if (flavor == null || flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) || flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE)) {
            Sides[] arr = new Sides[3];
            arr[0] = Sides.ONE_SIDED;
            arr[1] = Sides.TWO_SIDED_LONG_EDGE;
            arr[2] = Sides.TWO_SIDED_SHORT_EDGE;
            return arr;
        } else {
            return null;
        }
    } else if (category == PrintQuality.class) {
        PrintQuality[] arr = new PrintQuality[3];
        arr[0] = PrintQuality.DRAFT;
        arr[1] = PrintQuality.HIGH;
        arr[2] = PrintQuality.NORMAL;
        return arr;
    } else if (category == SheetCollate.class) {
        if (flavor == null || (flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) || flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE))) {
            SheetCollate[] arr = new SheetCollate[2];
            arr[0] = SheetCollate.COLLATED;
            arr[1] = SheetCollate.UNCOLLATED;
            return arr;
        } else {
            return null;
        }
    } else if (category == Fidelity.class) {
        Fidelity[] arr = new Fidelity[2];
        arr[0] = Fidelity.FIDELITY_FALSE;
        arr[1] = Fidelity.FIDELITY_TRUE;
        return arr;
    } else {
        return null;
    }
}
Also used : Destination(javax.print.attribute.standard.Destination) Fidelity(javax.print.attribute.standard.Fidelity) PrintServiceAttribute(javax.print.attribute.PrintServiceAttribute) Attribute(javax.print.attribute.Attribute) PrintQuality(javax.print.attribute.standard.PrintQuality) JobName(javax.print.attribute.standard.JobName) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) OrientationRequested(javax.print.attribute.standard.OrientationRequested) MediaPrintableArea(javax.print.attribute.standard.MediaPrintableArea) PrinterResolution(javax.print.attribute.standard.PrinterResolution) Sides(javax.print.attribute.standard.Sides) PageRanges(javax.print.attribute.standard.PageRanges) MediaSizeName(javax.print.attribute.standard.MediaSizeName) Media(javax.print.attribute.standard.Media) SheetCollate(javax.print.attribute.standard.SheetCollate) RequestingUserName(javax.print.attribute.standard.RequestingUserName) CopiesSupported(javax.print.attribute.standard.CopiesSupported) Chromaticity(javax.print.attribute.standard.Chromaticity) File(java.io.File)

Example 4 with Sides

use of javax.print.attribute.standard.Sides in project jdk8u_jdk by JetBrains.

the class WPrinterJob method setNativeAttributes.

private final void setNativeAttributes(int flags, int fields, int values) {
    if (attributes == null) {
        return;
    }
    if ((flags & PD_PRINTTOFILE) != 0) {
        Destination destPrn = (Destination) attributes.get(Destination.class);
        if (destPrn == null) {
            try {
                attributes.add(new Destination(new File("./out.prn").toURI()));
            } catch (SecurityException se) {
                try {
                    attributes.add(new Destination(new URI("file:out.prn")));
                } catch (URISyntaxException e) {
                }
            }
        }
    } else {
        attributes.remove(Destination.class);
    }
    if ((flags & PD_COLLATE) != 0) {
        setCollateAttrib(SheetCollate.COLLATED, attributes);
    } else {
        setCollateAttrib(SheetCollate.UNCOLLATED, attributes);
    }
    if ((flags & PD_PAGENUMS) != 0) {
        attributes.add(SunPageSelection.RANGE);
    } else if ((flags & PD_SELECTION) != 0) {
        attributes.add(SunPageSelection.SELECTION);
    } else {
        attributes.add(SunPageSelection.ALL);
    }
    if ((fields & DM_ORIENTATION) != 0) {
        if ((values & SET_ORIENTATION) != 0) {
            setOrientAttrib(OrientationRequested.LANDSCAPE, attributes);
        } else {
            setOrientAttrib(OrientationRequested.PORTRAIT, attributes);
        }
    }
    if ((fields & DM_COLOR) != 0) {
        if ((values & SET_COLOR) != 0) {
            setColorAttrib(Chromaticity.COLOR, attributes);
        } else {
            setColorAttrib(Chromaticity.MONOCHROME, attributes);
        }
    }
    if ((fields & DM_PRINTQUALITY) != 0) {
        PrintQuality quality;
        if ((values & SET_RES_LOW) != 0) {
            quality = PrintQuality.DRAFT;
        } else if ((fields & SET_RES_HIGH) != 0) {
            quality = PrintQuality.HIGH;
        } else {
            quality = PrintQuality.NORMAL;
        }
        setQualityAttrib(quality, attributes);
    }
    if ((fields & DM_DUPLEX) != 0) {
        Sides sides;
        if ((values & SET_DUP_VERTICAL) != 0) {
            sides = Sides.TWO_SIDED_LONG_EDGE;
        } else if ((values & SET_DUP_HORIZONTAL) != 0) {
            sides = Sides.TWO_SIDED_SHORT_EDGE;
        } else {
            sides = Sides.ONE_SIDED;
        }
        setSidesAttrib(sides, attributes);
    }
}
Also used : Destination(javax.print.attribute.standard.Destination) PrintQuality(javax.print.attribute.standard.PrintQuality) URISyntaxException(java.net.URISyntaxException) File(java.io.File) URI(java.net.URI) Sides(javax.print.attribute.standard.Sides)

Example 5 with Sides

use of javax.print.attribute.standard.Sides in project jdk8u_jdk by JetBrains.

the class WPrinterJob method getDevModeValues.

private void getDevModeValues(PrintRequestAttributeSet aset, DevModeValues info) {
    Copies c = (Copies) aset.get(Copies.class);
    if (c != null) {
        info.dmFields |= DM_COPIES;
        info.copies = (short) c.getValue();
    }
    SheetCollate sc = (SheetCollate) aset.get(SheetCollate.class);
    if (sc != null) {
        info.dmFields |= DM_COLLATE;
        info.collate = (sc == SheetCollate.COLLATED) ? DMCOLLATE_TRUE : DMCOLLATE_FALSE;
    }
    Chromaticity ch = (Chromaticity) aset.get(Chromaticity.class);
    if (ch != null) {
        info.dmFields |= DM_COLOR;
        if (ch == Chromaticity.COLOR) {
            info.color = DMCOLOR_COLOR;
        } else {
            info.color = DMCOLOR_MONOCHROME;
        }
    }
    Sides s = (Sides) aset.get(Sides.class);
    if (s != null) {
        info.dmFields |= DM_DUPLEX;
        if (s == Sides.TWO_SIDED_LONG_EDGE) {
            info.duplex = DMDUP_VERTICAL;
        } else if (s == Sides.TWO_SIDED_SHORT_EDGE) {
            info.duplex = DMDUP_HORIZONTAL;
        } else {
            // Sides.ONE_SIDED
            info.duplex = DMDUP_SIMPLEX;
        }
    }
    OrientationRequested or = (OrientationRequested) aset.get(OrientationRequested.class);
    if (or != null) {
        info.dmFields |= DM_ORIENTATION;
        info.orient = (or == OrientationRequested.LANDSCAPE) ? DMORIENT_LANDSCAPE : DMORIENT_PORTRAIT;
    }
    Media m = (Media) aset.get(Media.class);
    if (m instanceof MediaSizeName) {
        info.dmFields |= DM_PAPERSIZE;
        MediaSizeName msn = (MediaSizeName) m;
        info.paper = (short) ((Win32PrintService) myService).findPaperID(msn);
    }
    MediaTray mt = null;
    if (m instanceof MediaTray) {
        mt = (MediaTray) m;
    }
    if (mt == null) {
        SunAlternateMedia sam = (SunAlternateMedia) aset.get(SunAlternateMedia.class);
        if (sam != null && (sam.getMedia() instanceof MediaTray)) {
            mt = (MediaTray) sam.getMedia();
        }
    }
    if (mt != null) {
        info.dmFields |= DM_DEFAULTSOURCE;
        info.bin = (short) (((Win32PrintService) myService).findTrayID(mt));
    }
    PrintQuality q = (PrintQuality) aset.get(PrintQuality.class);
    if (q != null) {
        info.dmFields |= DM_PRINTQUALITY;
        if (q == PrintQuality.DRAFT) {
            info.xres_quality = DMRES_DRAFT;
        } else if (q == PrintQuality.HIGH) {
            info.xres_quality = DMRES_HIGH;
        } else {
            info.xres_quality = DMRES_MEDIUM;
        }
    }
    PrinterResolution r = (PrinterResolution) aset.get(PrinterResolution.class);
    if (r != null) {
        info.dmFields |= DM_PRINTQUALITY | DM_YRESOLUTION;
        info.xres_quality = (short) r.getCrossFeedResolution(PrinterResolution.DPI);
        info.yres = (short) r.getFeedResolution(PrinterResolution.DPI);
    }
}
Also used : Win32PrintService(sun.print.Win32PrintService) PrinterResolution(javax.print.attribute.standard.PrinterResolution) SheetCollate(javax.print.attribute.standard.SheetCollate) MediaSizeName(javax.print.attribute.standard.MediaSizeName) Copies(javax.print.attribute.standard.Copies) PrintQuality(javax.print.attribute.standard.PrintQuality) Media(javax.print.attribute.standard.Media) SunAlternateMedia(sun.print.SunAlternateMedia) Chromaticity(javax.print.attribute.standard.Chromaticity) SunAlternateMedia(sun.print.SunAlternateMedia) Win32MediaTray(sun.print.Win32MediaTray) MediaTray(javax.print.attribute.standard.MediaTray) Sides(javax.print.attribute.standard.Sides) OrientationRequested(javax.print.attribute.standard.OrientationRequested)

Aggregations

Sides (javax.print.attribute.standard.Sides)8 MediaSizeName (javax.print.attribute.standard.MediaSizeName)6 OrientationRequested (javax.print.attribute.standard.OrientationRequested)6 Chromaticity (javax.print.attribute.standard.Chromaticity)5 Destination (javax.print.attribute.standard.Destination)5 Media (javax.print.attribute.standard.Media)5 PrintQuality (javax.print.attribute.standard.PrintQuality)5 SheetCollate (javax.print.attribute.standard.SheetCollate)5 File (java.io.File)4 URI (java.net.URI)4 Attribute (javax.print.attribute.Attribute)4 Copies (javax.print.attribute.standard.Copies)4 Fidelity (javax.print.attribute.standard.Fidelity)4 PageRanges (javax.print.attribute.standard.PageRanges)4 URISyntaxException (java.net.URISyntaxException)3 PrintServiceAttribute (javax.print.attribute.PrintServiceAttribute)3 CopiesSupported (javax.print.attribute.standard.CopiesSupported)3 JobName (javax.print.attribute.standard.JobName)3 MediaPrintableArea (javax.print.attribute.standard.MediaPrintableArea)3 PrinterResolution (javax.print.attribute.standard.PrinterResolution)3