Package javax.print.attribute

Examples of javax.print.attribute.PrintRequestAttributeSet


        }
    }

    int[] convertAttributes(PrintRequestAttributeSet attrs, DocFlavor flavor)
            throws PrintException {
        PrintRequestAttributeSet attributes = null;
        if (attrs == null ||
            flavor.equals(DocFlavor.INPUT_STREAM.AUTOSENSE) ||
            flavor.equals(DocFlavor.BYTE_ARRAY.AUTOSENSE) ||
            flavor.equals(DocFlavor.URL.AUTOSENSE)) {
            int[] defaultValues = {-1, -1, -1, -1, -1, -1, -1, -1};
            return defaultValues;
        } else {
            attributes = attrs;
        }
        Attribute[] requestAttrs = attributes.toArray();
        int[] printAttributes = new int[ATTRIBUTES_ARRAY_SIZE];
        Arrays.fill(printAttributes, -1);
        for (int i = 0; i < requestAttrs.length; i++) {
            Class category = requestAttrs[i].getCategory();
            if (!isAttributeValueSupported(requestAttrs[i], flavor, attrs)) {
View Full Code Here


        }

        /* Combine this PrinterJob attrs attribute set and printerAttrs set
           and resolve MediaPrintableArea/MediaMargins conflict if it is
           needed */
        PrintRequestAttributeSet sum =
                updateMediaAndMarginsIfNeeded(dialogAttrs);

        Rectangle screen = GraphicsEnvironment.getLocalGraphicsEnvironment().
                getDefaultScreenDevice().getDefaultConfiguration().getBounds();

View Full Code Here

                ? wnd : new Frame());

        /* Combine this PrinterJob this.attrs attribute set and attrs set
            and resolve MediaPrintableArea/MediaMargins conflict if it is
            needed */
        PrintRequestAttributeSet sum = updateMediaAndMarginsIfNeeded(arg_attrs);

        Rectangle screen = GraphicsEnvironment.getLocalGraphicsEnvironment()
                .getDefaultScreenDevice().getDefaultConfiguration().getBounds();

        /* create and show the page dialog */
        ServiceUIDialog dialog = new ServiceUIDialog(null,
                                                     screen.width/3,
                                                     screen.height/3,
                                                     getPrintService(),
                                                     sum,
                                                     owner);
        dialog.show();

        if (owner != wnd) {
            owner.dispose();
        }

        /* update this.attrs attribute set and result page format to return */
        if (dialog.getResult() == ServiceUIDialog.APPROVE_PRINT) {
            PrintRequestAttributeSet newattrs = dialog.getAttributes();

            if (!newattrs.containsKey(Media.class)) {
                this.attrs.remove(Media.class);
            }
            if (!newattrs.containsKey(OrientationRequested.class)) {
                this.attrs.remove(OrientationRequested.class);
            }
            if (!newattrs.containsKey(MediaPrintableArea.class)) {
                this.attrs.remove(MediaPrintableArea.class);
            }
            if (!newattrs.containsKey(MediaMargins.class)) {
                this.attrs.remove(MediaMargins.class);
            }
            this.attrs.addAll(newattrs);
            return getPageFormatForAttrs(newattrs);
        }
View Full Code Here

     */
    protected PrintRequestAttributeSet updateMediaAndMarginsIfNeeded(
            PrintRequestAttributeSet newAttrs) {

        /* create copy of this.attrs*/
        PrintRequestAttributeSet sum =
                new HashPrintRequestAttributeSet(this.attrs);

        /* remove MediaMargins and MediaPrintableArea attributes from the copy
           of job attributes if newAttrs contains  MediaMargins or
           PrintableArea */
        if (newAttrs.containsKey(MediaPrintableArea.class)
                    || attrs.containsKey(MediaMargins.class)) {
            sum.remove(MediaPrintableArea.class);
            sum.remove(MediaMargins.class);
        }

        sum.addAll(newAttrs);
        return sum;
    }
View Full Code Here

        }
    }

    int[] convertAttributes(PrintRequestAttributeSet attrs, DocFlavor flavor)
            throws PrintException {
        PrintRequestAttributeSet attributes = null;
        if (attrs == null ||
            flavor.equals(DocFlavor.INPUT_STREAM.AUTOSENSE) ||
            flavor.equals(DocFlavor.BYTE_ARRAY.AUTOSENSE) ||
            flavor.equals(DocFlavor.URL.AUTOSENSE)) {
            int[] defaultValues = {-1, -1, -1, -1, -1, -1, -1, -1};
            return defaultValues;
        } else {
            attributes = attrs;
        }
        Attribute[] requestAttrs = attributes.toArray();
        int[] printAttributes = new int[ATTRIBUTES_ARRAY_SIZE];
        Arrays.fill(printAttributes, -1);
        for (int i = 0; i < requestAttrs.length; i++) {
            Class category = requestAttrs[i].getCategory();
            if (!isAttributeValueSupported(requestAttrs[i], flavor, attrs)) {
View Full Code Here

        }

        /* Combine this PrinterJob attrs attribute set and printerAttrs set
           and resolve MediaPrintableArea/MediaMargins conflict if it is
           needed */
        PrintRequestAttributeSet sum =
                updateMediaAndMarginsIfNeeded(dialogAttrs);

        Rectangle screen = GraphicsEnvironment.getLocalGraphicsEnvironment().
                getDefaultScreenDevice().getDefaultConfiguration().getBounds();

View Full Code Here

                ? wnd : new Frame());

        /* Combine this PrinterJob this.attrs attribute set and attrs set
            and resolve MediaPrintableArea/MediaMargins conflict if it is
            needed */
        PrintRequestAttributeSet sum = updateMediaAndMarginsIfNeeded(arg_attrs);

        Rectangle screen = GraphicsEnvironment.getLocalGraphicsEnvironment()
                .getDefaultScreenDevice().getDefaultConfiguration().getBounds();

        /* create and show the page dialog */
        ServiceUIDialog dialog = new ServiceUIDialog(null,
                                                     screen.width/3,
                                                     screen.height/3,
                                                     getPrintService(),
                                                     sum,
                                                     owner);
        dialog.show();

        if (owner != wnd) {
            owner.dispose();
        }

        /* update this.attrs attribute set and result page format to return */
        if (dialog.getResult() == ServiceUIDialog.APPROVE_PRINT) {
            PrintRequestAttributeSet newattrs = dialog.getAttributes();

            if (!newattrs.containsKey(Media.class)) {
                this.attrs.remove(Media.class);
            }
            if (!newattrs.containsKey(OrientationRequested.class)) {
                this.attrs.remove(OrientationRequested.class);
            }
            if (!newattrs.containsKey(MediaPrintableArea.class)) {
                this.attrs.remove(MediaPrintableArea.class);
            }
            if (!newattrs.containsKey(MediaMargins.class)) {
                this.attrs.remove(MediaMargins.class);
            }
            this.attrs.addAll(newattrs);
            return getPageFormatForAttrs(newattrs);
        }
View Full Code Here

     */
    protected PrintRequestAttributeSet updateMediaAndMarginsIfNeeded(
            PrintRequestAttributeSet newAttrs) {

        /* create copy of this.attrs*/
        PrintRequestAttributeSet sum =
                new HashPrintRequestAttributeSet(this.attrs);

        /* remove MediaMargins and MediaPrintableArea attributes from the copy
           of job attributes if newAttrs contains  MediaMargins or
           PrintableArea */
        if (newAttrs.containsKey(MediaPrintableArea.class)
                    || attrs.containsKey(MediaMargins.class)) {
            sum.remove(MediaPrintableArea.class);
            sum.remove(MediaMargins.class);
        }

        sum.addAll(newAttrs);
        return sum;
    }
View Full Code Here

        if (doc == null) {
            // Neither Printable nor Pageable specified
            throw new PrinterException(Messages.getString("awt.29A")); //$NON-NLS-1$
        }

        final PrintRequestAttributeSet attrs = mergeAttrs(attributes);
        final PrintService service = getPrintService();

        if (service == null) {
            // Printer not found
            throw new PrinterException(Messages.getString("awt.29A")); //$NON-NLS-1$
View Full Code Here

        if (attributes == null) {
            throw new NullPointerException();
        }

        final PrintRequestAttributeSet attrs = mergeAttrs(attributes);
        final Rectangle screen = GraphicsEnvironment
                        .getLocalGraphicsEnvironment().getDefaultScreenDevice()
                        .getDefaultConfiguration().getBounds();
        final PrintService newService = ServiceUI.printDialog(null,
                        screen.width / 3, screen.height / 3,
View Full Code Here

TOP

Related Classes of javax.print.attribute.PrintRequestAttributeSet

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