Search in sources :

Example 11 with MediaTray

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

the class WPrinterJob method setAttributes.

/**
     * 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) {
        // now always use attributes, so this shouldn't happen.
        return;
    }
    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) {
        }
    }
}
Also used : Attribute(javax.print.attribute.Attribute) MediaSizeName(javax.print.attribute.standard.MediaSizeName) 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)

Example 12 with MediaTray

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

the class Win32MediaTray method getEnumValueTable.

protected EnumSyntax[] getEnumValueTable() {
    ArrayList completeList = new ArrayList();
    for (int i = 0; i < myEnumValueTable.length; i++) {
        completeList.add(myEnumValueTable[i]);
    }
    completeList.addAll(winEnumTable);
    MediaTray[] enumTable = new MediaTray[completeList.size()];
    return (MediaTray[]) completeList.toArray(enumTable);
}
Also used : ArrayList(java.util.ArrayList) MediaTray(javax.print.attribute.standard.MediaTray)

Aggregations

MediaTray (javax.print.attribute.standard.MediaTray)12 Media (javax.print.attribute.standard.Media)4 Win32MediaTray (sun.print.Win32MediaTray)4 Chromaticity (javax.print.attribute.standard.Chromaticity)3 Copies (javax.print.attribute.standard.Copies)3 MediaSizeName (javax.print.attribute.standard.MediaSizeName)3 PrintQuality (javax.print.attribute.standard.PrintQuality)3 PrinterResolution (javax.print.attribute.standard.PrinterResolution)3 SunAlternateMedia (sun.print.SunAlternateMedia)3 Win32PrintService (sun.print.Win32PrintService)3 DocFlavor (javax.print.DocFlavor)2 DocPrintJob (javax.print.DocPrintJob)2 PrintService (javax.print.PrintService)2 PrintServiceLookup (javax.print.PrintServiceLookup)2 Attribute (javax.print.attribute.Attribute)2 PrintRequestAttributeSet (javax.print.attribute.PrintRequestAttributeSet)2 MediaPrintableArea (javax.print.attribute.standard.MediaPrintableArea)2 OrientationRequested (javax.print.attribute.standard.OrientationRequested)2 SheetCollate (javax.print.attribute.standard.SheetCollate)2 Sides (javax.print.attribute.standard.Sides)2