Package javax.print.attribute.standard

Examples of javax.print.attribute.standard.MediaPrintableArea


    /*
     * Calculate MediaPrintableArea attribute for tis margins and the given
     * MediaSize object.
     */
    public MediaPrintableArea getMediaPrintableArea(MediaSize size) {
        return new MediaPrintableArea(getX1(MM),
                                      getY1(MM),
                                      size.getX(MM) - getX1(MM) - getX2(MM),
                                      size.getY(MM) - getY1(MM) - getY2(MM),
                                      MM);
    }
View Full Code Here


                        && attrs.containsKey(MediaPrintableArea.class)
                        && attrs.get(Media.class).equals(selectedMedia)
                        && isMediaSizeSelected) {      
                    /* p.1 - see fillMarginsFields() comments above*/  
                    try {
                        MediaPrintableArea attrsPA = (MediaPrintableArea)
                                attrs.get(MediaPrintableArea.class);
                        margins = new MediaMargins(selectedSize, attrsPA);
                    } catch(IllegalArgumentException e) {
                        /*
                         * If we are unable to get correct margins values from the
                         * given MediaPrintableArea (attrsPA) and MediaSize
                         * (selectedSize), we just ignore this case
                         */
                    }
                }
   
                if ((margins == null)
                        && (isMarginsSupported || (dialogType == PAGE_DIALOG))) {
                    /* p.2 - see fillMarginsFields() comments above*/  
                    margins = (MediaMargins) (attrs.containsKey(MediaMargins.class)
                         ? attrs.get(MediaMargins.class)
                         : myService.getDefaultAttributeValue(MediaMargins.class));
                }
   
                if ((margins == null
                        && isPaSupported 
                        && isMediaSupported
                        && isMediaSizeSelected) {
                    /* p.3 - see fillMarginsFields() comments above*/  
                    try {
                        MediaPrintableArea defaultPA = (MediaPrintableArea)
                                myService.getDefaultAttributeValue(
                                        MediaPrintableArea.class);
                        if ((defaultPA != null) && (selectedSize != null)) {
                            margins = new MediaMargins(selectedSize, defaultPA);
                        }
View Full Code Here

            float paperWidth = mediaSize.getX(Size2DSyntax.MM);
            float paperHeight = mediaSize.getY(Size2DSyntax.MM);
            if ((x1 + x2 >= paperWidth) || (y1 + y2 >= paperHeight)) {
                return false;
            }
            newAttrs.add(new MediaPrintableArea(x1,
                                                y1,
                                                paperWidth - x1 - x2,
                                                paperHeight - y1 - y2,
                                                MediaPrintableArea.MM));
        } else {
View Full Code Here

    /*
     * Calculate MediaPrintableArea attribute for tis margins and the given
     * MediaSize object.
     */
    public MediaPrintableArea getMediaPrintableArea(MediaSize size) {
        return new MediaPrintableArea(getX1(MM),
                                      getY1(MM),
                                      size.getX(MM) - getX1(MM) - getX2(MM),
                                      size.getY(MM) - getY1(MM) - getY2(MM),
                                      MM);
    }
View Full Code Here

                        && attrs.containsKey(MediaPrintableArea.class)
                        && attrs.get(Media.class).equals(selectedMedia)
                        && isMediaSizeSelected) {      
                    /* p.1 - see fillMarginsFields() comments above*/  
                    try {
                        MediaPrintableArea attrsPA = (MediaPrintableArea)
                                attrs.get(MediaPrintableArea.class);
                        margins = new MediaMargins(selectedSize, attrsPA);
                    } catch(IllegalArgumentException e) {
                        /*
                         * If we are unable to get correct margins values from the
                         * given MediaPrintableArea (attrsPA) and MediaSize
                         * (selectedSize), we just ignore this case
                         */
                    }
                }
   
                if ((margins == null)
                        && (isMarginsSupported || (dialogType == PAGE_DIALOG))) {
                    /* p.2 - see fillMarginsFields() comments above*/  
                    margins = (MediaMargins) (attrs.containsKey(MediaMargins.class)
                         ? attrs.get(MediaMargins.class)
                         : myService.getDefaultAttributeValue(MediaMargins.class));
                }
   
                if ((margins == null
                        && isPaSupported 
                        && isMediaSupported
                        && isMediaSizeSelected) {
                    /* p.3 - see fillMarginsFields() comments above*/  
                    try {
                        MediaPrintableArea defaultPA = (MediaPrintableArea)
                                myService.getDefaultAttributeValue(
                                        MediaPrintableArea.class);
                        if ((defaultPA != null) && (selectedSize != null)) {
                            margins = new MediaMargins(selectedSize, defaultPA);
                        }
View Full Code Here

            float paperWidth = mediaSize.getX(Size2DSyntax.MM);
            float paperHeight = mediaSize.getY(Size2DSyntax.MM);
            if ((x1 + x2 >= paperWidth) || (y1 + y2 >= paperHeight)) {
                return false;
            }
            newAttrs.add(new MediaPrintableArea(x1,
                                                y1,
                                                paperWidth - x1 - x2,
                                                paperHeight - y1 - y2,
                                                MediaPrintableArea.MM));
        } else {
View Full Code Here

                        && attrs.containsKey(MediaPrintableArea.class)
                        && attrs.get(Media.class).equals(selectedMedia)
                        && isMediaSizeSelected) {      
                    /* p.1 - see fillMarginsFields() comments above*/  
                    try {
                        MediaPrintableArea attrsPA = (MediaPrintableArea)
                                attrs.get(MediaPrintableArea.class);
                        margins = new MediaMargins(selectedSize, attrsPA);
                    } catch(IllegalArgumentException e) {
                        /*
                         * If we are unable to get correct margins values from the
                         * given MediaPrintableArea (attrsPA) and MediaSize
                         * (selectedSize), we just ignore this case
                         */
                    }
                }
   
                if ((margins == null)
                        && (isMarginsSupported || (dialogType == PAGE_DIALOG))) {
                    /* p.2 - see fillMarginsFields() comments above*/  
                    margins = (MediaMargins) (attrs.containsKey(MediaMargins.class)
                         ? attrs.get(MediaMargins.class)
                         : myService.getDefaultAttributeValue(MediaMargins.class));
                }
   
                if ((margins == null
                        && isPaSupported 
                        && isMediaSupported
                        && isMediaSizeSelected) {
                    /* p.3 - see fillMarginsFields() comments above*/  
                    try {
                        MediaPrintableArea defaultPA = (MediaPrintableArea)
                                myService.getDefaultAttributeValue(
                                        MediaPrintableArea.class);
                        if ((defaultPA != null) && (selectedSize != null)) {
                            margins = new MediaMargins(selectedSize, defaultPA);
                        }
View Full Code Here

            float paperWidth = mediaSize.getX(Size2DSyntax.MM);
            float paperHeight = mediaSize.getY(Size2DSyntax.MM);
            if ((x1 + x2 >= paperWidth) || (y1 + y2 >= paperHeight)) {
                return false;
            }
            newAttrs.add(new MediaPrintableArea(x1,
                                                y1,
                                                paperWidth - x1 - x2,
                                                paperHeight - y1 - y2,
                                                MediaPrintableArea.MM));
        } else {
View Full Code Here

    /*
     * Calculate MediaPrintableArea attribute for tis margins and the given
     * MediaSize object.
     */
    public MediaPrintableArea getMediaPrintableArea(MediaSize size) {
        return new MediaPrintableArea(getX1(MM),
                                      getY1(MM),
                                      size.getX(MM) - getX1(MM) - getX2(MM),
                                      size.getY(MM) - getY1(MM) - getY2(MM),
                                      MM);
    }
View Full Code Here

    private static PrintRequestAttributeSet formatToAttrs(
                    final PageFormat format) {
        final PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();

        if (format != null) {
            attributes.add(new MediaPrintableArea((float) (format
                            .getImageableX() / 72.0), (float) (format
                            .getImageableY() / 72.0), (float) (format
                            .getWidth() / 72.0),
                            (float) (format.getHeight() / 72.0),
                            Size2DSyntax.INCH));
View Full Code Here

TOP

Related Classes of javax.print.attribute.standard.MediaPrintableArea

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.