src/solaris/classes/sun/print/CUPSPrinter.java

Print this page




 123     }
 124 
 125 
 126     /**
 127      * Returns array of MediaSizeNames derived from PPD.
 128      */
 129     public MediaSizeName[] getMediaSizeNames() {
 130         initMedia();
 131         return cupsMediaSNames;
 132     }
 133 
 134 
 135     /**
 136      * Returns array of Custom MediaSizeNames derived from PPD.
 137      */
 138     public CustomMediaSizeName[] getCustomMediaSizeNames() {
 139         initMedia();
 140         return cupsCustomMediaSNames;
 141     }
 142 



 143 
 144     /**
 145      * Returns array of MediaPrintableArea derived from PPD.
 146      */
 147     public MediaPrintableArea[] getMediaPrintableArea() {
 148         initMedia();
 149         return cupsMediaPrintables;
 150     }
 151 
 152     /**
 153      * Returns array of MediaTrays derived from PPD.
 154      */
 155     public MediaTray[] getMediaTrays() {
 156         initMedia();
 157         return cupsMediaTrays;
 158     }
 159 
 160 
 161     /**
 162      * Initialize media by translating PPD info to PrintService attributes.


 184         for (int i=0; i<nPageSizes; i++) {
 185             // media width and length
 186             width = (float)(pageSizes[i*6]/PRINTER_DPI);
 187             length = (float)(pageSizes[i*6+1]/PRINTER_DPI);
 188             // media printable area
 189             x = (float)(pageSizes[i*6+2]/PRINTER_DPI);
 190             h = (float)(pageSizes[i*6+3]/PRINTER_DPI);
 191             w = (float)(pageSizes[i*6+4]/PRINTER_DPI);
 192             y = (float)(pageSizes[i*6+5]/PRINTER_DPI);
 193 
 194             msn = new CustomMediaSizeName(media[i*2], media[i*2+1],
 195                                           width, length);
 196 
 197             // add to list of standard MediaSizeNames
 198             if ((cupsMediaSNames[i] = msn.getStandardMedia()) == null) {
 199                 // add custom if no matching standard media
 200                 cupsMediaSNames[i] = msn;
 201 
 202                 // add this new custom msn to MediaSize array
 203                 if ((width > 0.0) && (length > 0.0)) {

 204                     new MediaSize(width, length,
 205                                   Size2DSyntax.INCH, msn);






 206                 }
 207             }
 208 
 209             // add to list of custom MediaSizeName
 210             // for internal use of IPPPrintService
 211             cupsCustomMediaSNames[i] = msn;
 212 
 213             mpa = null;
 214             try {
 215                 mpa = new MediaPrintableArea(x, y, w, h,
 216                                              MediaPrintableArea.INCH);
 217             } catch (IllegalArgumentException e) {
 218                 if (width > 0 && length > 0) {
 219                     mpa = new MediaPrintableArea(0, 0, width, length,
 220                                              MediaPrintableArea.INCH);
 221                 }
 222             }
 223             cupsMediaPrintables[i] = mpa;
 224         }
 225 




 123     }
 124 
 125 
 126     /**
 127      * Returns array of MediaSizeNames derived from PPD.
 128      */
 129     public MediaSizeName[] getMediaSizeNames() {
 130         initMedia();
 131         return cupsMediaSNames;
 132     }
 133 
 134 
 135     /**
 136      * Returns array of Custom MediaSizeNames derived from PPD.
 137      */
 138     public CustomMediaSizeName[] getCustomMediaSizeNames() {
 139         initMedia();
 140         return cupsCustomMediaSNames;
 141     }
 142 
 143     public int getDefaultMediaIndex() {
 144         return ((pageSizes.length >1) ? (int)(pageSizes[pageSizes.length -1]) : 0);
 145     }
 146 
 147     /**
 148      * Returns array of MediaPrintableArea derived from PPD.
 149      */
 150     public MediaPrintableArea[] getMediaPrintableArea() {
 151         initMedia();
 152         return cupsMediaPrintables;
 153     }
 154 
 155     /**
 156      * Returns array of MediaTrays derived from PPD.
 157      */
 158     public MediaTray[] getMediaTrays() {
 159         initMedia();
 160         return cupsMediaTrays;
 161     }
 162 
 163 
 164     /**
 165      * Initialize media by translating PPD info to PrintService attributes.


 187         for (int i=0; i<nPageSizes; i++) {
 188             // media width and length
 189             width = (float)(pageSizes[i*6]/PRINTER_DPI);
 190             length = (float)(pageSizes[i*6+1]/PRINTER_DPI);
 191             // media printable area
 192             x = (float)(pageSizes[i*6+2]/PRINTER_DPI);
 193             h = (float)(pageSizes[i*6+3]/PRINTER_DPI);
 194             w = (float)(pageSizes[i*6+4]/PRINTER_DPI);
 195             y = (float)(pageSizes[i*6+5]/PRINTER_DPI);
 196 
 197             msn = new CustomMediaSizeName(media[i*2], media[i*2+1],
 198                                           width, length);
 199 
 200             // add to list of standard MediaSizeNames
 201             if ((cupsMediaSNames[i] = msn.getStandardMedia()) == null) {
 202                 // add custom if no matching standard media
 203                 cupsMediaSNames[i] = msn;
 204 
 205                 // add this new custom msn to MediaSize array
 206                 if ((width > 0.0) && (length > 0.0)) {
 207                     try {
 208                     new MediaSize(width, length,
 209                                   Size2DSyntax.INCH, msn);
 210                     } catch (IllegalArgumentException e) {
 211                         /* PDF printer in Linux for Ledger paper causes
 212                         "IllegalArgumentException: X dimension > Y dimension".
 213                         We rotate based on IPP spec. */
 214                         new MediaSize(length, width, Size2DSyntax.INCH, msn);
 215                     }
 216                 }
 217             }
 218 
 219             // add to list of custom MediaSizeName
 220             // for internal use of IPPPrintService
 221             cupsCustomMediaSNames[i] = msn;
 222 
 223             mpa = null;
 224             try {
 225                 mpa = new MediaPrintableArea(x, y, w, h,
 226                                              MediaPrintableArea.INCH);
 227             } catch (IllegalArgumentException e) {
 228                 if (width > 0 && length > 0) {
 229                     mpa = new MediaPrintableArea(0, 0, width, length,
 230                                              MediaPrintableArea.INCH);
 231                 }
 232             }
 233             cupsMediaPrintables[i] = mpa;
 234         }
 235