Search in sources :

Example 1 with Fidelity

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

the class ServiceUI method printDialog.

/**
     * Presents a dialog to the user for selecting a print service (printer).
     * It is displayed at the location specified by the application and
     * is modal.
     * If the specification is invalid or would make the dialog not visible it
     * will be displayed at a location determined by the implementation.
     * The dialog blocks its calling thread and is application modal.
     * <p>
     * The dialog may include a tab panel with custom UI lazily obtained from
     * the PrintService's ServiceUIFactory when the PrintService is browsed.
     * The dialog will attempt to locate a MAIN_UIROLE first as a JComponent,
     * then as a Panel. If there is no ServiceUIFactory or no matching role
     * the custom tab will be empty or not visible.
     * <p>
     * The dialog returns the print service selected by the user if the user
     * OK's the dialog and null if the user cancels the dialog.
     * <p>
     * An application must pass in an array of print services to browse.
     * The array must be non-null and non-empty.
     * Typically an application will pass in only PrintServices capable
     * of printing a particular document flavor.
     * <p>
     * An application may pass in a PrintService to be initially displayed.
     * A non-null parameter must be included in the array of browsable
     * services.
     * If this parameter is null a service is chosen by the implementation.
     * <p>
     * An application may optionally pass in the flavor to be printed.
     * If this is non-null choices presented to the user can be better
     * validated against those supported by the services.
     * An application must pass in a PrintRequestAttributeSet for returning
     * user choices.
     * On calling the PrintRequestAttributeSet may be empty, or may contain
     * application-specified values.
     * <p>
     * These are used to set the initial settings for the initially
     * displayed print service. Values which are not supported by the print
     * service are ignored. As the user browses print services, attributes
     * and values are copied to the new display. If a user browses a
     * print service which does not support a particular attribute-value, the
     * default for that service is used as the new value to be copied.
     * <p>
     * If the user cancels the dialog, the returned attributes will not reflect
     * any changes made by the user.
     *
     * A typical basic usage of this method may be :
     * <pre>{@code
     * PrintService[] services = PrintServiceLookup.lookupPrintServices(
     *                            DocFlavor.INPUT_STREAM.JPEG, null);
     * PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
     * if (services.length > 0) {
     *    PrintService service =  ServiceUI.printDialog(null, 50, 50,
     *                                               services, services[0],
     *                                               null,
     *                                               attributes);
     *    if (service != null) {
     *     ... print ...
     *    }
     * }
     * }</pre>
     * <p>

     * @param gc used to select screen. null means primary or default screen.
     * @param x location of dialog including border in screen coordinates
     * @param y location of dialog including border in screen coordinates
     * @param services to be browsable, must be non-null.
     * @param defaultService - initial PrintService to display.
     * @param flavor - the flavor to be printed, or null.
     * @param attributes on input is the initial application supplied
     * preferences. This cannot be null but may be empty.
     * On output the attributes reflect changes made by the user.
     * @return print service selected by the user, or null if the user
     * cancelled the dialog.
     * @throws HeadlessException if GraphicsEnvironment.isHeadless()
     * returns true.
     * @throws IllegalArgumentException if services is null or empty,
     * or attributes is null, or the initial PrintService is not in the
     * list of browsable services.
     */
public static PrintService printDialog(GraphicsConfiguration gc, int x, int y, PrintService[] services, PrintService defaultService, DocFlavor flavor, PrintRequestAttributeSet attributes) throws HeadlessException {
    int defaultIndex = -1;
    if (GraphicsEnvironment.isHeadless()) {
        throw new HeadlessException();
    } else if ((services == null) || (services.length == 0)) {
        throw new IllegalArgumentException("services must be non-null " + "and non-empty");
    } else if (attributes == null) {
        throw new IllegalArgumentException("attributes must be non-null");
    }
    if (defaultService != null) {
        for (int i = 0; i < services.length; i++) {
            if (services[i].equals(defaultService)) {
                defaultIndex = i;
                break;
            }
        }
        if (defaultIndex < 0) {
            throw new IllegalArgumentException("services must contain " + "defaultService");
        }
    } else {
        defaultIndex = 0;
    }
    // For now we set owner to null. In the future, it may be passed
    // as an argument.
    Window owner = null;
    Rectangle gcBounds = (gc == null) ? GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration().getBounds() : gc.getBounds();
    ServiceDialog dialog;
    if (owner instanceof Frame) {
        dialog = new ServiceDialog(gc, x + gcBounds.x, y + gcBounds.y, services, defaultIndex, flavor, attributes, (Frame) owner);
    } else {
        dialog = new ServiceDialog(gc, x + gcBounds.x, y + gcBounds.y, services, defaultIndex, flavor, attributes, (Dialog) owner);
    }
    Rectangle dlgBounds = dialog.getBounds();
    // get union of all GC bounds
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gs = ge.getScreenDevices();
    for (int j = 0; j < gs.length; j++) {
        gcBounds = gcBounds.union(gs[j].getDefaultConfiguration().getBounds());
    }
    // if portion of dialog is not within the gc boundary
    if (!gcBounds.contains(dlgBounds)) {
        // put in the center relative to parent frame/dialog
        dialog.setLocationRelativeTo(owner);
    }
    dialog.show();
    if (dialog.getStatus() == ServiceDialog.APPROVE) {
        PrintRequestAttributeSet newas = dialog.getAttributes();
        Class dstCategory = Destination.class;
        Class amCategory = SunAlternateMedia.class;
        Class fdCategory = Fidelity.class;
        if (attributes.containsKey(dstCategory) && !newas.containsKey(dstCategory)) {
            attributes.remove(dstCategory);
        }
        if (attributes.containsKey(amCategory) && !newas.containsKey(amCategory)) {
            attributes.remove(amCategory);
        }
        attributes.addAll(newas);
        Fidelity fd = (Fidelity) attributes.get(fdCategory);
        if (fd != null) {
            if (fd == Fidelity.FIDELITY_TRUE) {
                removeUnsupportedAttributes(dialog.getPrintService(), flavor, attributes);
            }
        }
    }
    return dialog.getPrintService();
}
Also used : Window(java.awt.Window) ServiceDialog(sun.print.ServiceDialog) Destination(javax.print.attribute.standard.Destination) Fidelity(javax.print.attribute.standard.Fidelity) Frame(java.awt.Frame) HeadlessException(java.awt.HeadlessException) Rectangle(java.awt.Rectangle) SunAlternateMedia(sun.print.SunAlternateMedia) GraphicsEnvironment(java.awt.GraphicsEnvironment) Point(java.awt.Point) PrintRequestAttributeSet(javax.print.attribute.PrintRequestAttributeSet) GraphicsDevice(java.awt.GraphicsDevice) ServiceDialog(sun.print.ServiceDialog) Dialog(java.awt.Dialog)

Example 2 with Fidelity

use of javax.print.attribute.standard.Fidelity 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 3 with Fidelity

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

the class PSStreamPrintJob method getAttributeValues.

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 == JobName.class) {
            jobName = ((JobName) attr).getValue();
        } else if (category == Copies.class) {
            copies = ((Copies) attr).getValue();
        } else if (category == Media.class) {
            if (attr instanceof MediaSizeName && service.isAttributeValueSupported(attr, null, null)) {
                mediaSize = MediaSize.getMediaSizeForName((MediaSizeName) attr);
            }
        } else if (category == OrientationRequested.class) {
            orient = (OrientationRequested) attr;
        }
    }
}
Also used : Fidelity(javax.print.attribute.standard.Fidelity) PrintJobAttribute(javax.print.attribute.PrintJobAttribute) PrintRequestAttribute(javax.print.attribute.PrintRequestAttribute) Attribute(javax.print.attribute.Attribute) MediaSizeName(javax.print.attribute.standard.MediaSizeName) Copies(javax.print.attribute.standard.Copies) java.awt.print(java.awt.print) OrientationRequested(javax.print.attribute.standard.OrientationRequested)

Example 4 with Fidelity

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

the class Win32PrintJob method getAttributeValues.

private void getAttributeValues(DocFlavor flavor) throws PrintException {
    if (reqAttrSet.get(Fidelity.class) == Fidelity.FIDELITY_TRUE) {
        fidelity = true;
    } else {
        fidelity = false;
    }
    Class category;
    Attribute[] attrs = reqAttrSet.toArray();
    for (int i = 0; i < attrs.length; i++) {
        Attribute 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 {
                    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 == 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;
                // be used to create a new PageFormat.
                if (!service.isAttributeValueSupported(attr, null, null)) {
                    mediaSize = MediaSize.getMediaSizeForName(mediaName);
                }
            }
        } else if (category == OrientationRequested.class) {
            orient = (OrientationRequested) attr;
        }
    }
}
Also used : Fidelity(javax.print.attribute.standard.Fidelity) Destination(javax.print.attribute.standard.Destination) PrintJobAttribute(javax.print.attribute.PrintJobAttribute) PrintRequestAttribute(javax.print.attribute.PrintRequestAttribute) Attribute(javax.print.attribute.Attribute) MediaSizeName(javax.print.attribute.standard.MediaSizeName) JobName(javax.print.attribute.standard.JobName) Media(javax.print.attribute.standard.Media) URI(java.net.URI) java.awt.print(java.awt.print) IOException(java.io.IOException) PrintException(javax.print.PrintException) FileNotFoundException(java.io.FileNotFoundException) PrintException(javax.print.PrintException) File(java.io.File)

Example 5 with Fidelity

use of javax.print.attribute.standard.Fidelity 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)

Aggregations

Fidelity (javax.print.attribute.standard.Fidelity)8 MediaSizeName (javax.print.attribute.standard.MediaSizeName)7 Attribute (javax.print.attribute.Attribute)6 Destination (javax.print.attribute.standard.Destination)6 OrientationRequested (javax.print.attribute.standard.OrientationRequested)6 File (java.io.File)5 JobName (javax.print.attribute.standard.JobName)5 Media (javax.print.attribute.standard.Media)5 URI (java.net.URI)4 MediaPrintableArea (javax.print.attribute.standard.MediaPrintableArea)4 RequestingUserName (javax.print.attribute.standard.RequestingUserName)4 SheetCollate (javax.print.attribute.standard.SheetCollate)4 Sides (javax.print.attribute.standard.Sides)4 java.awt.print (java.awt.print)3 IOException (java.io.IOException)3 PrintException (javax.print.PrintException)3 PrintJobAttribute (javax.print.attribute.PrintJobAttribute)3 PrintRequestAttribute (javax.print.attribute.PrintRequestAttribute)3 PrintServiceAttribute (javax.print.attribute.PrintServiceAttribute)3 Chromaticity (javax.print.attribute.standard.Chromaticity)3