java.awt.print.PrinterIOException#javax.print.attribute.standard.Sides源码实例Demo

下面列出了java.awt.print.PrinterIOException#javax.print.attribute.standard.Sides 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: gcs   文件: PageSetupPanel.java
private void createSidesCombo(PrintRequestAttributeSet set) {
    Sides[] sides = (Sides[]) mService.getSupportedAttributeValues(Sides.class, DocFlavor.SERVICE_FORMATTED.PRINTABLE, null);
    if (sides != null && sides.length > 0) {
        Set<Sides>           possible = new HashSet<>(Arrays.asList(sides));
        ArrayList<PageSides> choices  = new ArrayList<>();
        for (PageSides side : PageSides.values()) {
            if (possible.contains(side.getSides())) {
                choices.add(side);
            }
        }
        mSides = new JComboBox<>(choices.toArray(new PageSides[0]));
        mSides.setSelectedItem(PrintUtilities.getSides(mService, set));
        UIUtilities.setToPreferredSizeOnly(mSides);
        LinkedLabel label = new LinkedLabel(I18n.Text("Sides"), mSides);
        add(label, new PrecisionLayoutData().setEndHorizontalAlignment());
        add(mSides);
    } else {
        mSides = null;
    }
}
 
源代码2 项目: dragonwell8_jdk   文件: WPrinterJob.java
private void setSidesAttrib(Attribute attr) {
    if (attr == Sides.TWO_SIDED_LONG_EDGE) {
        mAttSides = 2; // DMDUP_VERTICAL
    } else if (attr == Sides.TWO_SIDED_SHORT_EDGE) {
        mAttSides = 3; // DMDUP_HORIZONTAL
    } else { // Sides.ONE_SIDED
        mAttSides = 1;
    }
}
 
源代码3 项目: TencentKona-8   文件: Win32PrintService.java
public Class<?>[] getSupportedAttributeCategories() {
    ArrayList categList = new ArrayList(otherAttrCats.length+3);
    for (int i=0; i < otherAttrCats.length; i++) {
        categList.add(otherAttrCats[i]);
    }

    int caps = getPrinterCapabilities();

    if ((caps & DEVCAP_DUPLEX) != 0) {
        categList.add(Sides.class);
    }

    if ((caps & DEVCAP_QUALITY) != 0) {
        int[] defaults = getDefaultPrinterSettings();
        // Added check: if supported, we should be able to get the default.
        if ((defaults[3] >= DMRES_HIGH) && (defaults[3] < 0)) {
            categList.add(PrintQuality.class);
        }
    }

    PrinterResolution[] supportedRes = getPrintResolutions();
    if ((supportedRes!=null) && (supportedRes.length>0)) {
        categList.add(PrinterResolution.class);
    }

    return (Class[])categList.toArray(new Class[categList.size()]);
}
 
源代码4 项目: TencentKona-8   文件: WPrinterJob.java
private void setSidesAttrib(Attribute attr) {
    if (attr == Sides.TWO_SIDED_LONG_EDGE) {
        mAttSides = 2; // DMDUP_VERTICAL
    } else if (attr == Sides.TWO_SIDED_SHORT_EDGE) {
        mAttSides = 3; // DMDUP_HORIZONTAL
    } else { // Sides.ONE_SIDED
        mAttSides = 1;
    }
}
 
源代码5 项目: jdk8u60   文件: Win32PrintService.java
public Class<?>[] getSupportedAttributeCategories() {
    ArrayList categList = new ArrayList(otherAttrCats.length+3);
    for (int i=0; i < otherAttrCats.length; i++) {
        categList.add(otherAttrCats[i]);
    }

    int caps = getPrinterCapabilities();

    if ((caps & DEVCAP_DUPLEX) != 0) {
        categList.add(Sides.class);
    }

    if ((caps & DEVCAP_QUALITY) != 0) {
        int[] defaults = getDefaultPrinterSettings();
        // Added check: if supported, we should be able to get the default.
        if ((defaults[3] >= DMRES_HIGH) && (defaults[3] < 0)) {
            categList.add(PrintQuality.class);
        }
    }

    PrinterResolution[] supportedRes = getPrintResolutions();
    if ((supportedRes!=null) && (supportedRes.length>0)) {
        categList.add(PrinterResolution.class);
    }

    return (Class[])categList.toArray(new Class[categList.size()]);
}
 
源代码6 项目: jdk8u60   文件: WPrinterJob.java
private void setSidesAttrib(Attribute attr) {
    if (attr == Sides.TWO_SIDED_LONG_EDGE) {
        mAttSides = 2; // DMDUP_VERTICAL
    } else if (attr == Sides.TWO_SIDED_SHORT_EDGE) {
        mAttSides = 3; // DMDUP_HORIZONTAL
    } else { // Sides.ONE_SIDED
        mAttSides = 1;
    }
}
 
源代码7 项目: openjdk-jdk8u   文件: Win32PrintService.java
public Class<?>[] getSupportedAttributeCategories() {
    ArrayList categList = new ArrayList(otherAttrCats.length+3);
    for (int i=0; i < otherAttrCats.length; i++) {
        categList.add(otherAttrCats[i]);
    }

    int caps = getPrinterCapabilities();

    if ((caps & DEVCAP_DUPLEX) != 0) {
        categList.add(Sides.class);
    }

    if ((caps & DEVCAP_QUALITY) != 0) {
        int[] defaults = getDefaultPrinterSettings();
        // Added check: if supported, we should be able to get the default.
        if ((defaults[3] >= DMRES_HIGH) && (defaults[3] < 0)) {
            categList.add(PrintQuality.class);
        }
    }

    PrinterResolution[] supportedRes = getPrintResolutions();
    if ((supportedRes!=null) && (supportedRes.length>0)) {
        categList.add(PrinterResolution.class);
    }

    return (Class[])categList.toArray(new Class[categList.size()]);
}
 
源代码8 项目: openjdk-jdk8u   文件: WPrinterJob.java
private void setSidesAttrib(Attribute attr) {
    if (attr == Sides.TWO_SIDED_LONG_EDGE) {
        mAttSides = 2; // DMDUP_VERTICAL
    } else if (attr == Sides.TWO_SIDED_SHORT_EDGE) {
        mAttSides = 3; // DMDUP_HORIZONTAL
    } else { // Sides.ONE_SIDED
        mAttSides = 1;
    }
}
 
源代码9 项目: openjdk-jdk8u-backup   文件: Win32PrintService.java
public Class<?>[] getSupportedAttributeCategories() {
    ArrayList categList = new ArrayList(otherAttrCats.length+3);
    for (int i=0; i < otherAttrCats.length; i++) {
        categList.add(otherAttrCats[i]);
    }

    int caps = getPrinterCapabilities();

    if ((caps & DEVCAP_DUPLEX) != 0) {
        categList.add(Sides.class);
    }

    if ((caps & DEVCAP_QUALITY) != 0) {
        int[] defaults = getDefaultPrinterSettings();
        // Added check: if supported, we should be able to get the default.
        if ((defaults[3] >= DMRES_HIGH) && (defaults[3] < 0)) {
            categList.add(PrintQuality.class);
        }
    }

    PrinterResolution[] supportedRes = getPrintResolutions();
    if ((supportedRes!=null) && (supportedRes.length>0)) {
        categList.add(PrinterResolution.class);
    }

    return (Class[])categList.toArray(new Class[categList.size()]);
}
 
源代码10 项目: openjdk-jdk8u-backup   文件: WPrinterJob.java
private void setSidesAttrib(Attribute attr) {
    if (attr == Sides.TWO_SIDED_LONG_EDGE) {
        mAttSides = 2; // DMDUP_VERTICAL
    } else if (attr == Sides.TWO_SIDED_SHORT_EDGE) {
        mAttSides = 3; // DMDUP_HORIZONTAL
    } else { // Sides.ONE_SIDED
        mAttSides = 1;
    }
}
 
源代码11 项目: jdk8u_jdk   文件: WPrinterJob.java
private void setSidesAttrib(Attribute attr) {
    if (attr == Sides.TWO_SIDED_LONG_EDGE) {
        mAttSides = 2; // DMDUP_VERTICAL
    } else if (attr == Sides.TWO_SIDED_SHORT_EDGE) {
        mAttSides = 3; // DMDUP_HORIZONTAL
    } else { // Sides.ONE_SIDED
        mAttSides = 1;
    }
}
 
源代码12 项目: openjdk-8-source   文件: WPrinterJob.java
private void setSidesAttrib(Attribute attr) {
    if (attr == Sides.TWO_SIDED_LONG_EDGE) {
        mAttSides = 2; // DMDUP_VERTICAL
    } else if (attr == Sides.TWO_SIDED_SHORT_EDGE) {
        mAttSides = 3; // DMDUP_HORIZONTAL
    } else { // Sides.ONE_SIDED
        mAttSides = 1;
    }
}
 
源代码13 项目: jdk8u_jdk   文件: Win32PrintService.java
public Class<?>[] getSupportedAttributeCategories() {
    ArrayList categList = new ArrayList(otherAttrCats.length+3);
    for (int i=0; i < otherAttrCats.length; i++) {
        categList.add(otherAttrCats[i]);
    }

    int caps = getPrinterCapabilities();

    if ((caps & DEVCAP_DUPLEX) != 0) {
        categList.add(Sides.class);
    }

    if ((caps & DEVCAP_QUALITY) != 0) {
        int[] defaults = getDefaultPrinterSettings();
        // Added check: if supported, we should be able to get the default.
        if ((defaults[3] >= DMRES_HIGH) && (defaults[3] < 0)) {
            categList.add(PrintQuality.class);
        }
    }

    PrinterResolution[] supportedRes = getPrintResolutions();
    if ((supportedRes!=null) && (supportedRes.length>0)) {
        categList.add(PrinterResolution.class);
    }

    return (Class[])categList.toArray(new Class[categList.size()]);
}
 
源代码14 项目: openjdk-jdk9   文件: WPrinterJob.java
private void setSidesAttrib(Attribute attr) {
    if (attr == Sides.TWO_SIDED_LONG_EDGE) {
        mAttSides = 2; // DMDUP_VERTICAL
    } else if (attr == Sides.TWO_SIDED_SHORT_EDGE) {
        mAttSides = 3; // DMDUP_HORIZONTAL
    } else { // Sides.ONE_SIDED
        mAttSides = 1;
    }
}
 
源代码15 项目: openjdk-8   文件: WPrinterJob.java
private void setSidesAttrib(Attribute attr) {
    if (attr == Sides.TWO_SIDED_LONG_EDGE) {
        mAttSides = 2; // DMDUP_VERTICAL
    } else if (attr == Sides.TWO_SIDED_SHORT_EDGE) {
        mAttSides = 3; // DMDUP_HORIZONTAL
    } else { // Sides.ONE_SIDED
        mAttSides = 1;
    }
}
 
源代码16 项目: jdk8u-jdk   文件: Win32PrintService.java
public Class<?>[] getSupportedAttributeCategories() {
    ArrayList categList = new ArrayList(otherAttrCats.length+3);
    for (int i=0; i < otherAttrCats.length; i++) {
        categList.add(otherAttrCats[i]);
    }

    int caps = getPrinterCapabilities();

    if ((caps & DEVCAP_DUPLEX) != 0) {
        categList.add(Sides.class);
    }

    if ((caps & DEVCAP_QUALITY) != 0) {
        int[] defaults = getDefaultPrinterSettings();
        // Added check: if supported, we should be able to get the default.
        if ((defaults[3] >= DMRES_HIGH) && (defaults[3] < 0)) {
            categList.add(PrintQuality.class);
        }
    }

    PrinterResolution[] supportedRes = getPrintResolutions();
    if ((supportedRes!=null) && (supportedRes.length>0)) {
        categList.add(PrinterResolution.class);
    }

    return (Class[])categList.toArray(new Class[categList.size()]);
}
 
源代码17 项目: jdk8u-jdk   文件: WPrinterJob.java
private void setSidesAttrib(Attribute attr) {
    if (attr == Sides.TWO_SIDED_LONG_EDGE) {
        mAttSides = 2; // DMDUP_VERTICAL
    } else if (attr == Sides.TWO_SIDED_SHORT_EDGE) {
        mAttSides = 3; // DMDUP_HORIZONTAL
    } else { // Sides.ONE_SIDED
        mAttSides = 1;
    }
}
 
源代码18 项目: hottub   文件: WPrinterJob.java
private void setSidesAttrib(Attribute attr) {
    if (attr == Sides.TWO_SIDED_LONG_EDGE) {
        mAttSides = 2; // DMDUP_VERTICAL
    } else if (attr == Sides.TWO_SIDED_SHORT_EDGE) {
        mAttSides = 3; // DMDUP_HORIZONTAL
    } else { // Sides.ONE_SIDED
        mAttSides = 1;
    }
}
 
源代码19 项目: jdk8u_jdk   文件: PrintJob2D.java
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);
}
 
源代码20 项目: dragonwell8_jdk   文件: PSStreamPrintService.java
public boolean isAttributeValueSupported(Attribute attr,
                                         DocFlavor flavor,
                                         AttributeSet attributes) {
    if (attr == null) {
        throw new NullPointerException("null attribute");
    }
    if (flavor != null && !isDocFlavorSupported(flavor)) {
        throw new IllegalArgumentException(flavor +
                                           " is an unsupported flavor");
    }
    Class category = attr.getCategory();
    if (!isAttributeCategorySupported(category)) {
        return false;
    }
    else if (attr.getCategory() == Chromaticity.class) {
        return attr == Chromaticity.COLOR;
    }
    else if (attr.getCategory() == Copies.class) {
        return isSupportedCopies((Copies)attr);
    } else if (attr.getCategory() == Media.class &&
               attr instanceof MediaSizeName) {
        return isSupportedMedia((MediaSizeName)attr);
    } else if (attr.getCategory() == OrientationRequested.class) {
        if (attr == OrientationRequested.REVERSE_PORTRAIT ||
            (flavor != null) &&
            !(flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) ||
            flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE))) {
            return false;
        }
    } else if (attr.getCategory() == PageRanges.class) {
        if (flavor != null &&
            !(flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) ||
            flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE))) {
            return false;
        }
    } else if (attr.getCategory() == SheetCollate.class) {
        if (flavor != null &&
            !(flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) ||
            flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE))) {
            return false;
        }
    } else if (attr.getCategory() == Sides.class) {
        if (flavor != null &&
            !(flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) ||
            flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE))) {
            return false;
        }
    }
    return true;
}
 
源代码21 项目: openjdk-8   文件: WPrinterJob.java
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);
    }
}
 
源代码22 项目: dragonwell8_jdk   文件: WPrinterJob.java
/**
 * copy the attributes to the native print job
 * Note that this method, and hence the re-initialisation
 * of the GDI values is done on each entry to the print dialog since
 * an app could redisplay the print dialog for the same job and
 * 1) the application may have changed attribute settings
 * 2) the application may have changed the printer.
 * In the event that the user changes the printer using the
  dialog, then it is up to GDI to report back all changed values.
 */
@Override
protected void setAttributes(PrintRequestAttributeSet attributes)
    throws PrinterException {

    // initialize attribute values
    initAttributeMembers();
    super.setAttributes(attributes);

    mAttCopies = getCopiesInt();
    mDestination = destinationAttr;

    if (attributes == null) {
        return; // now always use attributes, so this shouldn't happen.
    }
    Attribute[] attrs = attributes.toArray();
    for (int i=0; i< attrs.length; i++) {
        Attribute attr = attrs[i];
        try {
             if (attr.getCategory() == Sides.class) {
                setSidesAttrib(attr);
            }
            else if (attr.getCategory() == Chromaticity.class) {
                setColorAttrib(attr);
            }
            else if (attr.getCategory() == PrinterResolution.class) {
                setResolutionAttrib(attr);
            }
            else if (attr.getCategory() == PrintQuality.class) {
                setQualityAttrib(attr);
            }
            else if (attr.getCategory() == SheetCollate.class) {
                setCollateAttrib(attr);
            }  else if (attr.getCategory() == Media.class ||
                        attr.getCategory() == SunAlternateMedia.class) {
                /* SunAlternateMedia is used if its a tray, and
                 * any Media that is specified is not a tray.
                 */
                if (attr.getCategory() == SunAlternateMedia.class) {
                    Media media = (Media)attributes.get(Media.class);
                    if (media == null ||
                        !(media instanceof MediaTray)) {
                        attr = ((SunAlternateMedia)attr).getMedia();
                    }
                }
                if (attr instanceof MediaSizeName) {
                    setWin32MediaAttrib(attr);
                }
                if (attr instanceof MediaTray) {
                    setMediaTrayAttrib(attr);
                }
            }

        } catch (ClassCastException e) {
        }
    }
}
 
源代码23 项目: dragonwell8_jdk   文件: WPrinterJob.java
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);
    }
}
 
源代码24 项目: dragonwell8_jdk   文件: WPrinterJob.java
private final void setJobAttributes(PrintRequestAttributeSet attributes,
                                    int fields, int values,
                                    short copies,
                                    short dmPaperSize,
                                    short dmPaperWidth,
                                    short dmPaperLength,
                                    short dmDefaultSource,
                                    short xRes,
                                    short yRes) {

    if (attributes == null) {
        return;
    }

    if ((fields & DM_COPIES) != 0) {
        attributes.add(new Copies(copies));
    }

    if ((fields & DM_COLLATE) != 0) {
        if ((values & SET_COLLATED) != 0) {
            attributes.add(SheetCollate.COLLATED);
        } else {
            attributes.add(SheetCollate.UNCOLLATED);
        }
    }

    if ((fields & DM_ORIENTATION) != 0) {
        if ((values & SET_ORIENTATION) != 0) {
            attributes.add(OrientationRequested.LANDSCAPE);
        } else {
            attributes.add(OrientationRequested.PORTRAIT);
        }
    }

    if ((fields & DM_COLOR) != 0) {
        if ((values & SET_COLOR) != 0) {
            attributes.add(Chromaticity.COLOR);
        } else {
            attributes.add(Chromaticity.MONOCHROME);
        }
    }

    if ((fields & DM_PRINTQUALITY) != 0) {
        /* value < 0 indicates quality setting.
         * value > 0 indicates X resolution. In that case
         * hopefully we will also find y-resolution specified.
         * If its not, assume its the same as x-res.
         * Maybe Java code should try to reconcile this against
         * the printers claimed set of supported resolutions.
         */
        if (xRes < 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;
            }
            attributes.add(quality);
        } else if (xRes > 0 && yRes > 0) {
            attributes.add(
                new PrinterResolution(xRes, yRes, PrinterResolution.DPI));
        }
    }

    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;
        }
        attributes.add(sides);
    }

    if ((fields & DM_PAPERSIZE) != 0) {
        addPaperSize(attributes, dmPaperSize, dmPaperWidth, dmPaperLength);
    }

    if ((fields & DM_DEFAULTSOURCE) != 0) {
        MediaTray tray =
            ((Win32PrintService)myService).findMediaTray(dmDefaultSource);
        attributes.add(new SunAlternateMedia(tray));
    }
}
 
源代码25 项目: dragonwell8_jdk   文件: UnixPrintJob.java
private void getAttributeValues(DocFlavor flavor) throws PrintException {
    Attribute attr;
    Class category;

    if (reqAttrSet.get(Fidelity.class) == Fidelity.FIDELITY_TRUE) {
        fidelity = true;
    } else {
        fidelity = false;
    }

    Attribute []attrs = reqAttrSet.toArray();
    for (int i=0; i<attrs.length; i++) {
        attr = attrs[i];
        category = attr.getCategory();
        if (fidelity == true) {
            if (!service.isAttributeCategorySupported(category)) {
                notifyEvent(PrintJobEvent.JOB_FAILED);
                throw new PrintJobAttributeException(
                    "unsupported category: " + category, category, null);
            } else if
                (!service.isAttributeValueSupported(attr, flavor, null)) {
                notifyEvent(PrintJobEvent.JOB_FAILED);
                throw new PrintJobAttributeException(
                    "unsupported attribute: " + attr, null, attr);
            }
        }
        if (category == Destination.class) {
            URI uri = ((Destination)attr).getURI();
            if (!"file".equals(uri.getScheme())) {
                notifyEvent(PrintJobEvent.JOB_FAILED);
                throw new PrintException("Not a file: URI");
            } else {
                try {
                    mDestType = DESTFILE;
                    mDestination = (new File(uri)).getPath();
                } catch (Exception e) {
                    throw new PrintException(e);
                }
                // check write access
                SecurityManager security = System.getSecurityManager();
                if (security != null) {
                  try {
                    security.checkWrite(mDestination);
                  } catch (SecurityException se) {
                    notifyEvent(PrintJobEvent.JOB_FAILED);
                    throw new PrintException(se);
                  }
                }
            }
        } else if (category == JobSheets.class) {
            if ((JobSheets)attr == JobSheets.NONE) {
               mNoJobSheet = true;
            }
        } else if (category == JobName.class) {
            jobName = ((JobName)attr).getValue();
        } else if (category == Copies.class) {
            copies = ((Copies)attr).getValue();
        } else if (category == Media.class) {
            if (attr instanceof MediaSizeName) {
                mediaName = (MediaSizeName)attr;
                IPPPrintService.debug_println(debugPrefix+
                                              "mediaName "+mediaName);
            if (!service.isAttributeValueSupported(attr, null, null)) {
                mediaSize = MediaSize.getMediaSizeForName(mediaName);
            }
          } else if (attr instanceof CustomMediaTray) {
              customTray = (CustomMediaTray)attr;
          }
        } else if (category == OrientationRequested.class) {
            orient = (OrientationRequested)attr;
        } else if (category == NumberUp.class) {
            nUp = (NumberUp)attr;
        } else if (category == Sides.class) {
            sides = (Sides)attr;
        }
    }
}
 
源代码26 项目: dragonwell8_jdk   文件: UnixPrintService.java
public boolean isAttributeValueSupported(Attribute attr,
                                         DocFlavor flavor,
                                         AttributeSet attributes) {
    if (attr == null) {
        throw new NullPointerException("null attribute");
    }
    if (flavor != null) {
        if (!isDocFlavorSupported(flavor)) {
            throw new IllegalArgumentException(flavor +
                                           " is an unsupported flavor");
        } else if (isAutoSense(flavor)) {
            return false;
        }
    }
    Class category = attr.getCategory();
    if (!isAttributeCategorySupported(category)) {
        return false;
    }
    else if (attr.getCategory() == Chromaticity.class) {
        if (flavor == null || isServiceFormattedFlavor(flavor)) {
            return attr == Chromaticity.COLOR;
        } else {
            return false;
        }
    }
    else if (attr.getCategory() == Copies.class) {
        return (flavor == null ||
               !(flavor.equals(DocFlavor.INPUT_STREAM.POSTSCRIPT) ||
                 flavor.equals(DocFlavor.URL.POSTSCRIPT) ||
                 flavor.equals(DocFlavor.BYTE_ARRAY.POSTSCRIPT))) &&
            isSupportedCopies((Copies)attr);
    } else if (attr.getCategory() == Destination.class) {
        URI uri = ((Destination)attr).getURI();
            if ("file".equals(uri.getScheme()) &&
                !(uri.getSchemeSpecificPart().equals(""))) {
            return true;
        } else {
        return false;
        }
    } else if (attr.getCategory() == Media.class) {
        if (attr instanceof MediaSizeName) {
            return isSupportedMedia((MediaSizeName)attr);
        } else {
            return false;
        }
    } else if (attr.getCategory() == OrientationRequested.class) {
        if (attr == OrientationRequested.REVERSE_PORTRAIT ||
            (flavor != null) &&
            !isServiceFormattedFlavor(flavor)) {
            return false;
        }
    } else if (attr.getCategory() == PageRanges.class) {
        if (flavor != null &&
            !(flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) ||
            flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE))) {
            return false;
        }
    } else if (attr.getCategory() == SheetCollate.class) {
        if (flavor != null &&
            !(flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) ||
            flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE))) {
            return false;
        }
    } else if (attr.getCategory() == Sides.class) {
        if (flavor != null &&
            !(flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) ||
            flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE))) {
            return false;
        }
    }
    return true;
}
 
源代码27 项目: TencentKona-8   文件: PrintJob2D.java
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);
}
 
源代码28 项目: TencentKona-8   文件: PSStreamPrintService.java
public boolean isAttributeValueSupported(Attribute attr,
                                         DocFlavor flavor,
                                         AttributeSet attributes) {
    if (attr == null) {
        throw new NullPointerException("null attribute");
    }
    if (flavor != null && !isDocFlavorSupported(flavor)) {
        throw new IllegalArgumentException(flavor +
                                           " is an unsupported flavor");
    }
    Class category = attr.getCategory();
    if (!isAttributeCategorySupported(category)) {
        return false;
    }
    else if (attr.getCategory() == Chromaticity.class) {
        return attr == Chromaticity.COLOR;
    }
    else if (attr.getCategory() == Copies.class) {
        return isSupportedCopies((Copies)attr);
    } else if (attr.getCategory() == Media.class &&
               attr instanceof MediaSizeName) {
        return isSupportedMedia((MediaSizeName)attr);
    } else if (attr.getCategory() == OrientationRequested.class) {
        if (attr == OrientationRequested.REVERSE_PORTRAIT ||
            (flavor != null) &&
            !(flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) ||
            flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE))) {
            return false;
        }
    } else if (attr.getCategory() == PageRanges.class) {
        if (flavor != null &&
            !(flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) ||
            flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE))) {
            return false;
        }
    } else if (attr.getCategory() == SheetCollate.class) {
        if (flavor != null &&
            !(flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) ||
            flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE))) {
            return false;
        }
    } else if (attr.getCategory() == Sides.class) {
        if (flavor != null &&
            !(flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) ||
            flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE))) {
            return false;
        }
    }
    return true;
}
 
源代码29 项目: TencentKona-8   文件: WPrinterJob.java
/**
 * copy the attributes to the native print job
 * Note that this method, and hence the re-initialisation
 * of the GDI values is done on each entry to the print dialog since
 * an app could redisplay the print dialog for the same job and
 * 1) the application may have changed attribute settings
 * 2) the application may have changed the printer.
 * In the event that the user changes the printer using the
  dialog, then it is up to GDI to report back all changed values.
 */
@Override
protected void setAttributes(PrintRequestAttributeSet attributes)
    throws PrinterException {

    // initialize attribute values
    initAttributeMembers();
    super.setAttributes(attributes);

    mAttCopies = getCopiesInt();
    mDestination = destinationAttr;

    if (attributes == null) {
        return; // now always use attributes, so this shouldn't happen.
    }
    Attribute[] attrs = attributes.toArray();
    for (int i=0; i< attrs.length; i++) {
        Attribute attr = attrs[i];
        try {
             if (attr.getCategory() == Sides.class) {
                setSidesAttrib(attr);
            }
            else if (attr.getCategory() == Chromaticity.class) {
                setColorAttrib(attr);
            }
            else if (attr.getCategory() == PrinterResolution.class) {
                setResolutionAttrib(attr);
            }
            else if (attr.getCategory() == PrintQuality.class) {
                setQualityAttrib(attr);
            }
            else if (attr.getCategory() == SheetCollate.class) {
                setCollateAttrib(attr);
            }  else if (attr.getCategory() == Media.class ||
                        attr.getCategory() == SunAlternateMedia.class) {
                /* SunAlternateMedia is used if its a tray, and
                 * any Media that is specified is not a tray.
                 */
                if (attr.getCategory() == SunAlternateMedia.class) {
                    Media media = (Media)attributes.get(Media.class);
                    if (media == null ||
                        !(media instanceof MediaTray)) {
                        attr = ((SunAlternateMedia)attr).getMedia();
                    }
                }
                if (attr instanceof MediaSizeName) {
                    setWin32MediaAttrib(attr);
                }
                if (attr instanceof MediaTray) {
                    setMediaTrayAttrib(attr);
                }
            }

        } catch (ClassCastException e) {
        }
    }
}
 
源代码30 项目: TencentKona-8   文件: WPrinterJob.java
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);
    }
}