Java 类javax.print.attribute.standard.MediaSizeName 实例源码

项目:OpenJSharp    文件:PrintJob2D.java   
public static MediaType unMapMedia(MediaSizeName mSize) {
    MediaType media = null;

    // JAVAXSIZES.length and SIZES.length must be equal!
    // Attempt to recover by getting the smaller size.
    int length = Math.min(SIZES.length, JAVAXSIZES.length);

    for (int i=0; i < length; i++) {
        if (JAVAXSIZES[i] == mSize) {
            if (SIZES[i] != null) {
                media = SIZES[i];
                break;
            }
        }
    }
    return media;
}
项目:OpenJSharp    文件:Win32PrintService.java   
public MediaSizeName findWin32Media(int dmIndex) {
    if (dmIndex >= 1 && dmIndex <= dmPaperToPrintService.length) {
        return dmPaperToPrintService[dmIndex - 1];
    }
    switch(dmIndex) {
        /* matching media sizes with indices beyond
           dmPaperToPrintService's length */
        case DMPAPER_A2:
            return MediaSizeName.ISO_A2;
        case DMPAPER_A6:
            return MediaSizeName.ISO_A6;
        case DMPAPER_B6_JIS:
            return MediaSizeName.JIS_B6;
        default:
            return null;
    }
}
项目:OpenJSharp    文件:Win32PrintService.java   
public MediaSizeName findMatchingMediaSizeNameMM (float w, float h){
    if (predefMedia != null) {
        for (int k=0; k<predefMedia.length;k++) {
            if (predefMedia[k] == null) {
                continue;
            }

            if (isSameSize(predefMedia[k].getX(MediaSize.MM),
                           predefMedia[k].getY(MediaSize.MM),
                           w, h)) {
              return predefMedia[k].getMediaSizeName();
            }
        }
    }
    return null;
}
项目:OpenJSharp    文件:WPrinterJob.java   
/** MediaSizeName / dmPaper */
private final int[] getWin32MediaAttrib() {
    int wid_ht[] = {0, 0};
    if (attributes != null) {
        Media media = (Media)attributes.get(Media.class);
        if (media instanceof MediaSizeName) {
            MediaSizeName msn = (MediaSizeName)media;
            MediaSize ms = MediaSize.getMediaSizeForName(msn);
            if (ms != null) {
                wid_ht[0] = (int)(ms.getX(MediaSize.INCH) * 72.0);
                wid_ht[1] = (int)(ms.getY(MediaSize.INCH) * 72.0);
            }
        }
    }
    return wid_ht;
}
项目:OpenJSharp    文件:WPrinterJob.java   
private void addPaperSize(PrintRequestAttributeSet aset,
                          int dmIndex, int width, int length) {

    if (aset == null) {
        return;
    }
    MediaSizeName msn =
       ((Win32PrintService)myService).findWin32Media(dmIndex);
    if (msn == null) {
        msn = ((Win32PrintService)myService).
            findMatchingMediaSizeNameMM((float)width, (float)length);
    }

    if (msn != null) {
        aset.add(msn);
    }
}
项目:OpenJSharp    文件:UnixPrintService.java   
private MediaPrintableArea[] getAllPrintableAreas() {

        if (mpas == null) {
            Media[] media = (Media[])getSupportedAttributeValues(Media.class,
                                                                 null, null);
            mpas = new MediaPrintableArea[media.length];
            for (int i=0; i< mpas.length; i++) {
                if (media[i] instanceof MediaSizeName) {
                    MediaSizeName msn = (MediaSizeName)media[i];
                    MediaSize mediaSize = MediaSize.getMediaSizeForName(msn);
                    if (mediaSize == null) {
                        mpas[i] = (MediaPrintableArea)
                            getDefaultAttributeValue(MediaPrintableArea.class);
                    } else {
                        mpas[i] = new MediaPrintableArea(0.25f, 0.25f,
                                        mediaSize.getX(MediaSize.INCH)-0.5f,
                                        mediaSize.getY(MediaSize.INCH)-0.5f,
                                        MediaSize.INCH);
                    }
                }
            }
        }
        MediaPrintableArea[] mpasCopy = new MediaPrintableArea[mpas.length];
        System.arraycopy(mpas, 0, mpasCopy, 0, mpas.length);
        return mpasCopy;
    }
项目:jdk8u-jdk    文件:PrintJob2D.java   
public static MediaType unMapMedia(MediaSizeName mSize) {
    MediaType media = null;

    // JAVAXSIZES.length and SIZES.length must be equal!
    // Attempt to recover by getting the smaller size.
    int length = Math.min(SIZES.length, JAVAXSIZES.length);

    for (int i=0; i < length; i++) {
        if (JAVAXSIZES[i] == mSize) {
            if (SIZES[i] != null) {
                media = SIZES[i];
                break;
            }
        }
    }
    return media;
}
项目:jdk8u-jdk    文件:Win32PrintService.java   
public MediaSizeName findWin32Media(int dmIndex) {
    if (dmIndex >= 1 && dmIndex <= dmPaperToPrintService.length) {
        return dmPaperToPrintService[dmIndex - 1];
    }
    switch(dmIndex) {
        /* matching media sizes with indices beyond
           dmPaperToPrintService's length */
        case DMPAPER_A2:
            return MediaSizeName.ISO_A2;
        case DMPAPER_A6:
            return MediaSizeName.ISO_A6;
        case DMPAPER_B6_JIS:
            return MediaSizeName.JIS_B6;
        default:
            return null;
    }
}
项目:jdk8u-jdk    文件:Win32PrintService.java   
public MediaSizeName findMatchingMediaSizeNameMM (float w, float h){
    if (predefMedia != null) {
        for (int k=0; k<predefMedia.length;k++) {
            if (predefMedia[k] == null) {
                continue;
            }

            if (isSameSize(predefMedia[k].getX(MediaSize.MM),
                           predefMedia[k].getY(MediaSize.MM),
                           w, h)) {
              return predefMedia[k].getMediaSizeName();
            }
        }
    }
    return null;
}
项目:jdk8u-jdk    文件:WPrinterJob.java   
/** MediaSizeName / dmPaper */
private final int[] getWin32MediaAttrib() {
    int wid_ht[] = {0, 0};
    if (attributes != null) {
        Media media = (Media)attributes.get(Media.class);
        if (media instanceof MediaSizeName) {
            MediaSizeName msn = (MediaSizeName)media;
            MediaSize ms = MediaSize.getMediaSizeForName(msn);
            if (ms != null) {
                wid_ht[0] = (int)(ms.getX(MediaSize.INCH) * 72.0);
                wid_ht[1] = (int)(ms.getY(MediaSize.INCH) * 72.0);
            }
        }
    }
    return wid_ht;
}
项目:jdk8u-jdk    文件:WPrinterJob.java   
private void addPaperSize(PrintRequestAttributeSet aset,
                          int dmIndex, int width, int length) {

    if (aset == null) {
        return;
    }
    MediaSizeName msn =
       ((Win32PrintService)myService).findWin32Media(dmIndex);
    if (msn == null) {
        msn = ((Win32PrintService)myService).
            findMatchingMediaSizeNameMM((float)width, (float)length);
    }

    if (msn != null) {
        aset.add(msn);
    }
}
项目:jdk8u-jdk    文件:UnixPrintService.java   
private MediaPrintableArea[] getAllPrintableAreas() {

        if (mpas == null) {
            Media[] media = (Media[])getSupportedAttributeValues(Media.class,
                                                                 null, null);
            mpas = new MediaPrintableArea[media.length];
            for (int i=0; i< mpas.length; i++) {
                if (media[i] instanceof MediaSizeName) {
                    MediaSizeName msn = (MediaSizeName)media[i];
                    MediaSize mediaSize = MediaSize.getMediaSizeForName(msn);
                    if (mediaSize == null) {
                        mpas[i] = (MediaPrintableArea)
                            getDefaultAttributeValue(MediaPrintableArea.class);
                    } else {
                        mpas[i] = new MediaPrintableArea(0.25f, 0.25f,
                                        mediaSize.getX(MediaSize.INCH)-0.5f,
                                        mediaSize.getY(MediaSize.INCH)-0.5f,
                                        MediaSize.INCH);
                    }
                }
            }
        }
        MediaPrintableArea[] mpasCopy = new MediaPrintableArea[mpas.length];
        System.arraycopy(mpas, 0, mpasCopy, 0, mpas.length);
        return mpasCopy;
    }
项目:jdk8u-jdk    文件:PrintServiceStub.java   
public PrintServiceStub(String name) {
    _name = name;
    _flavors = new HashSet<DocFlavor>();
    _flavors.add(DocFlavor.SERVICE_FORMATTED.PAGEABLE);
    _flavors.add(DocFlavor.SERVICE_FORMATTED.PRINTABLE);
    _attributes = new HashMap<>();
    _attributes.put(PrinterName.class, new PrinterName(name, null));
    _attributes.put(PrinterState.class, PrinterState.IDLE);
    _attributes.put(PrinterInfo.class, new PrinterInfo("Custom location",
            null));
    _attributes.put(PrinterIsAcceptingJobs.class,
            PrinterIsAcceptingJobs.ACCEPTING_JOBS);
    _attributes.put(PrinterMakeAndModel.class, new PrinterMakeAndModel(
            "Custom printer", null));
    _attributes.put(Media.class, new Media[] { MediaSizeName.ISO_A4 });
}
项目:openjdk-jdk10    文件:PrintJob2D.java   
public static MediaType unMapMedia(MediaSizeName mSize) {
    MediaType media = null;

    // JAVAXSIZES.length and SIZES.length must be equal!
    // Attempt to recover by getting the smaller size.
    int length = Math.min(SIZES.length, JAVAXSIZES.length);

    for (int i=0; i < length; i++) {
        if (JAVAXSIZES[i] == mSize) {
            if (SIZES[i] != null) {
                media = SIZES[i];
                break;
            }
        }
    }
    return media;
}
项目:openjdk-jdk10    文件:UnixPrintService.java   
private MediaPrintableArea[] getAllPrintableAreas() {

        if (mpas == null) {
            Media[] media = (Media[])getSupportedAttributeValues(Media.class,
                                                                 null, null);
            mpas = new MediaPrintableArea[media.length];
            for (int i=0; i< mpas.length; i++) {
                if (media[i] instanceof MediaSizeName) {
                    MediaSizeName msn = (MediaSizeName)media[i];
                    MediaSize mediaSize = MediaSize.getMediaSizeForName(msn);
                    if (mediaSize == null) {
                        mpas[i] = (MediaPrintableArea)
                            getDefaultAttributeValue(MediaPrintableArea.class);
                    } else {
                        mpas[i] = new MediaPrintableArea(0.25f, 0.25f,
                                        mediaSize.getX(MediaSize.INCH)-0.5f,
                                        mediaSize.getY(MediaSize.INCH)-0.5f,
                                        MediaSize.INCH);
                    }
                }
            }
        }
        MediaPrintableArea[] mpasCopy = new MediaPrintableArea[mpas.length];
        System.arraycopy(mpas, 0, mpasCopy, 0, mpas.length);
        return mpasCopy;
    }
项目:openjdk-jdk10    文件:Win32PrintService.java   
public MediaSizeName findWin32Media(int dmIndex) {
    if (dmIndex >= 1 && dmIndex <= dmPaperToPrintService.length) {
        return dmPaperToPrintService[dmIndex - 1];
    }
    switch(dmIndex) {
        /* matching media sizes with indices beyond
           dmPaperToPrintService's length */
        case DMPAPER_A2:
            return MediaSizeName.ISO_A2;
        case DMPAPER_A6:
            return MediaSizeName.ISO_A6;
        case DMPAPER_B6_JIS:
            return MediaSizeName.JIS_B6;
        default:
            return null;
    }
}
项目:openjdk-jdk10    文件:Win32PrintService.java   
public MediaSizeName findMatchingMediaSizeNameMM (float w, float h){
    if (predefMedia != null) {
        for (int k=0; k<predefMedia.length;k++) {
            if (predefMedia[k] == null) {
                continue;
            }

            if (isSameSize(predefMedia[k].getX(MediaSize.MM),
                           predefMedia[k].getY(MediaSize.MM),
                           w, h)) {
              return predefMedia[k].getMediaSizeName();
            }
        }
    }
    return null;
}
项目:openjdk-jdk10    文件:WPrinterJob.java   
/** MediaSizeName / dmPaper */
private int[] getWin32MediaAttrib() {
    int wid_ht[] = {0, 0};
    if (attributes != null) {
        Media media = (Media)attributes.get(Media.class);
        if (media instanceof MediaSizeName) {
            MediaSizeName msn = (MediaSizeName)media;
            MediaSize ms = MediaSize.getMediaSizeForName(msn);
            if (ms != null) {
                wid_ht[0] = (int)(ms.getX(MediaSize.INCH) * 72.0);
                wid_ht[1] = (int)(ms.getY(MediaSize.INCH) * 72.0);
            }
        }
    }
    return wid_ht;
}
项目:openjdk-jdk10    文件:WPrinterJob.java   
private void addPaperSize(PrintRequestAttributeSet aset,
                          int dmIndex, int width, int length) {

    if (aset == null) {
        return;
    }
    MediaSizeName msn =
       ((Win32PrintService)myService).findWin32Media(dmIndex);
    if (msn == null) {
        msn = ((Win32PrintService)myService).
            findMatchingMediaSizeNameMM((float)width, (float)length);
    }

    if (msn != null) {
        aset.add(msn);
    }
}
项目:openjdk-jdk10    文件:WrongPaperPrintingTest.java   
private static void doTest() {
    PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
    aset.add(Chromaticity.MONOCHROME);

    MediaSize isoA5Size = MediaSize.getMediaSizeForName(MediaSizeName.ISO_A5);
    float[] size = isoA5Size.getSize(Size2DSyntax.INCH);
    Paper paper = new Paper();
    paper.setSize(size[0] * 72.0, size[1] * 72.0);
    paper.setImageableArea(0.0, 0.0, size[0] * 72.0, size[1] * 72.0);
    PageFormat pf = new PageFormat();
    pf.setPaper(paper);

    PrinterJob job = PrinterJob.getPrinterJob();
    job.setPrintable(new WrongPaperPrintingTest(), job.validatePage(pf));
    if (job.printDialog()) {
        try {
            job.print(aset);
        } catch (PrinterException pe) {
            throw new RuntimeException(pe);
        }
    }
}
项目:openjdk-jdk10    文件:PrintServiceStub.java   
public PrintServiceStub(String name) {
    _name = name;
    _flavors = new HashSet<DocFlavor>();
    _flavors.add(DocFlavor.SERVICE_FORMATTED.PAGEABLE);
    _flavors.add(DocFlavor.SERVICE_FORMATTED.PRINTABLE);
    _attributes = new HashMap<>();
    _attributes.put(PrinterName.class, new PrinterName(name, null));
    _attributes.put(PrinterState.class, PrinterState.IDLE);
    _attributes.put(PrinterInfo.class, new PrinterInfo("Custom location",
            null));
    _attributes.put(PrinterIsAcceptingJobs.class,
            PrinterIsAcceptingJobs.ACCEPTING_JOBS);
    _attributes.put(PrinterMakeAndModel.class, new PrinterMakeAndModel(
            "Custom printer", null));
    _attributes.put(Media.class, new Media[] { MediaSizeName.ISO_A4 });
}
项目:openjdk9    文件:PrintJob2D.java   
public static MediaType unMapMedia(MediaSizeName mSize) {
    MediaType media = null;

    // JAVAXSIZES.length and SIZES.length must be equal!
    // Attempt to recover by getting the smaller size.
    int length = Math.min(SIZES.length, JAVAXSIZES.length);

    for (int i=0; i < length; i++) {
        if (JAVAXSIZES[i] == mSize) {
            if (SIZES[i] != null) {
                media = SIZES[i];
                break;
            }
        }
    }
    return media;
}
项目:openjdk9    文件:UnixPrintService.java   
private MediaPrintableArea[] getAllPrintableAreas() {

        if (mpas == null) {
            Media[] media = (Media[])getSupportedAttributeValues(Media.class,
                                                                 null, null);
            mpas = new MediaPrintableArea[media.length];
            for (int i=0; i< mpas.length; i++) {
                if (media[i] instanceof MediaSizeName) {
                    MediaSizeName msn = (MediaSizeName)media[i];
                    MediaSize mediaSize = MediaSize.getMediaSizeForName(msn);
                    if (mediaSize == null) {
                        mpas[i] = (MediaPrintableArea)
                            getDefaultAttributeValue(MediaPrintableArea.class);
                    } else {
                        mpas[i] = new MediaPrintableArea(0.25f, 0.25f,
                                        mediaSize.getX(MediaSize.INCH)-0.5f,
                                        mediaSize.getY(MediaSize.INCH)-0.5f,
                                        MediaSize.INCH);
                    }
                }
            }
        }
        MediaPrintableArea[] mpasCopy = new MediaPrintableArea[mpas.length];
        System.arraycopy(mpas, 0, mpasCopy, 0, mpas.length);
        return mpasCopy;
    }
项目:openjdk9    文件:Win32PrintService.java   
public MediaSizeName findWin32Media(int dmIndex) {
    if (dmIndex >= 1 && dmIndex <= dmPaperToPrintService.length) {
        return dmPaperToPrintService[dmIndex - 1];
    }
    switch(dmIndex) {
        /* matching media sizes with indices beyond
           dmPaperToPrintService's length */
        case DMPAPER_A2:
            return MediaSizeName.ISO_A2;
        case DMPAPER_A6:
            return MediaSizeName.ISO_A6;
        case DMPAPER_B6_JIS:
            return MediaSizeName.JIS_B6;
        default:
            return null;
    }
}
项目:openjdk9    文件:Win32PrintService.java   
public MediaSizeName findMatchingMediaSizeNameMM (float w, float h){
    if (predefMedia != null) {
        for (int k=0; k<predefMedia.length;k++) {
            if (predefMedia[k] == null) {
                continue;
            }

            if (isSameSize(predefMedia[k].getX(MediaSize.MM),
                           predefMedia[k].getY(MediaSize.MM),
                           w, h)) {
              return predefMedia[k].getMediaSizeName();
            }
        }
    }
    return null;
}
项目:openjdk9    文件:WPrinterJob.java   
/** MediaSizeName / dmPaper */
private int[] getWin32MediaAttrib() {
    int wid_ht[] = {0, 0};
    if (attributes != null) {
        Media media = (Media)attributes.get(Media.class);
        if (media instanceof MediaSizeName) {
            MediaSizeName msn = (MediaSizeName)media;
            MediaSize ms = MediaSize.getMediaSizeForName(msn);
            if (ms != null) {
                wid_ht[0] = (int)(ms.getX(MediaSize.INCH) * 72.0);
                wid_ht[1] = (int)(ms.getY(MediaSize.INCH) * 72.0);
            }
        }
    }
    return wid_ht;
}
项目:openjdk9    文件:WPrinterJob.java   
private void addPaperSize(PrintRequestAttributeSet aset,
                          int dmIndex, int width, int length) {

    if (aset == null) {
        return;
    }
    MediaSizeName msn =
       ((Win32PrintService)myService).findWin32Media(dmIndex);
    if (msn == null) {
        msn = ((Win32PrintService)myService).
            findMatchingMediaSizeNameMM((float)width, (float)length);
    }

    if (msn != null) {
        aset.add(msn);
    }
}
项目:openjdk9    文件:PrintServiceStub.java   
public PrintServiceStub(String name) {
    _name = name;
    _flavors = new HashSet<DocFlavor>();
    _flavors.add(DocFlavor.SERVICE_FORMATTED.PAGEABLE);
    _flavors.add(DocFlavor.SERVICE_FORMATTED.PRINTABLE);
    _attributes = new HashMap<>();
    _attributes.put(PrinterName.class, new PrinterName(name, null));
    _attributes.put(PrinterState.class, PrinterState.IDLE);
    _attributes.put(PrinterInfo.class, new PrinterInfo("Custom location",
            null));
    _attributes.put(PrinterIsAcceptingJobs.class,
            PrinterIsAcceptingJobs.ACCEPTING_JOBS);
    _attributes.put(PrinterMakeAndModel.class, new PrinterMakeAndModel(
            "Custom printer", null));
    _attributes.put(Media.class, new Media[] { MediaSizeName.ISO_A4 });
}
项目:jasperreports    文件:PrintServiceApp.java   
/**
 *
 */
public void print() throws JRException
{
    long start = System.currentTimeMillis();
    PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
    printRequestAttributeSet.add(MediaSizeName.ISO_A4);

    PrintServiceAttributeSet printServiceAttributeSet = new HashPrintServiceAttributeSet();
    //printServiceAttributeSet.add(new PrinterName("Epson Stylus 820 ESC/P 2", null));
    //printServiceAttributeSet.add(new PrinterName("hp LaserJet 1320 PCL 6", null));
    //printServiceAttributeSet.add(new PrinterName("PDFCreator", null));

    JRPrintServiceExporter exporter = new JRPrintServiceExporter();

    exporter.setExporterInput(new SimpleExporterInput("build/reports/PrintServiceReport.jrprint"));
    SimplePrintServiceExporterConfiguration configuration = new SimplePrintServiceExporterConfiguration();
    configuration.setPrintRequestAttributeSet(printRequestAttributeSet);
    configuration.setPrintServiceAttributeSet(printServiceAttributeSet);
    configuration.setDisplayPageDialog(false);
    configuration.setDisplayPrintDialog(true);
    exporter.setConfiguration(configuration);
    exporter.exportReport();

    System.err.println("Printing time : " + (System.currentTimeMillis() - start));
}
项目:jdk8u_jdk    文件:PrintJob2D.java   
public static MediaType unMapMedia(MediaSizeName mSize) {
    MediaType media = null;

    // JAVAXSIZES.length and SIZES.length must be equal!
    // Attempt to recover by getting the smaller size.
    int length = Math.min(SIZES.length, JAVAXSIZES.length);

    for (int i=0; i < length; i++) {
        if (JAVAXSIZES[i] == mSize) {
            if (SIZES[i] != null) {
                media = SIZES[i];
                break;
            }
        }
    }
    return media;
}
项目:jdk8u_jdk    文件:Win32PrintService.java   
public MediaSizeName findWin32Media(int dmIndex) {
    if (dmIndex >= 1 && dmIndex <= dmPaperToPrintService.length) {
        return dmPaperToPrintService[dmIndex - 1];
    }
    switch(dmIndex) {
        /* matching media sizes with indices beyond
           dmPaperToPrintService's length */
        case DMPAPER_A2:
            return MediaSizeName.ISO_A2;
        case DMPAPER_A6:
            return MediaSizeName.ISO_A6;
        case DMPAPER_B6_JIS:
            return MediaSizeName.JIS_B6;
        default:
            return null;
    }
}
项目:jdk8u_jdk    文件:Win32PrintService.java   
public MediaSizeName findMatchingMediaSizeNameMM (float w, float h){
    if (predefMedia != null) {
        for (int k=0; k<predefMedia.length;k++) {
            if (predefMedia[k] == null) {
                continue;
            }

            if (isSameSize(predefMedia[k].getX(MediaSize.MM),
                           predefMedia[k].getY(MediaSize.MM),
                           w, h)) {
              return predefMedia[k].getMediaSizeName();
            }
        }
    }
    return null;
}
项目:jdk8u_jdk    文件:WPrinterJob.java   
/** MediaSizeName / dmPaper */
private final int[] getWin32MediaAttrib() {
    int wid_ht[] = {0, 0};
    if (attributes != null) {
        Media media = (Media)attributes.get(Media.class);
        if (media instanceof MediaSizeName) {
            MediaSizeName msn = (MediaSizeName)media;
            MediaSize ms = MediaSize.getMediaSizeForName(msn);
            if (ms != null) {
                wid_ht[0] = (int)(ms.getX(MediaSize.INCH) * 72.0);
                wid_ht[1] = (int)(ms.getY(MediaSize.INCH) * 72.0);
            }
        }
    }
    return wid_ht;
}
项目:jdk8u_jdk    文件:WPrinterJob.java   
private void addPaperSize(PrintRequestAttributeSet aset,
                          int dmIndex, int width, int length) {

    if (aset == null) {
        return;
    }
    MediaSizeName msn =
       ((Win32PrintService)myService).findWin32Media(dmIndex);
    if (msn == null) {
        msn = ((Win32PrintService)myService).
            findMatchingMediaSizeNameMM((float)width, (float)length);
    }

    if (msn != null) {
        aset.add(msn);
    }
}
项目:jdk8u_jdk    文件:UnixPrintService.java   
private MediaPrintableArea[] getAllPrintableAreas() {

        if (mpas == null) {
            Media[] media = (Media[])getSupportedAttributeValues(Media.class,
                                                                 null, null);
            mpas = new MediaPrintableArea[media.length];
            for (int i=0; i< mpas.length; i++) {
                if (media[i] instanceof MediaSizeName) {
                    MediaSizeName msn = (MediaSizeName)media[i];
                    MediaSize mediaSize = MediaSize.getMediaSizeForName(msn);
                    if (mediaSize == null) {
                        mpas[i] = (MediaPrintableArea)
                            getDefaultAttributeValue(MediaPrintableArea.class);
                    } else {
                        mpas[i] = new MediaPrintableArea(0.25f, 0.25f,
                                        mediaSize.getX(MediaSize.INCH)-0.5f,
                                        mediaSize.getY(MediaSize.INCH)-0.5f,
                                        MediaSize.INCH);
                    }
                }
            }
        }
        MediaPrintableArea[] mpasCopy = new MediaPrintableArea[mpas.length];
        System.arraycopy(mpas, 0, mpasCopy, 0, mpas.length);
        return mpasCopy;
    }
项目:jdk8u_jdk    文件:PrintServiceStub.java   
public PrintServiceStub(String name) {
    _name = name;
    _flavors = new HashSet<DocFlavor>();
    _flavors.add(DocFlavor.SERVICE_FORMATTED.PAGEABLE);
    _flavors.add(DocFlavor.SERVICE_FORMATTED.PRINTABLE);
    _attributes = new HashMap<>();
    _attributes.put(PrinterName.class, new PrinterName(name, null));
    _attributes.put(PrinterState.class, PrinterState.IDLE);
    _attributes.put(PrinterInfo.class, new PrinterInfo("Custom location",
            null));
    _attributes.put(PrinterIsAcceptingJobs.class,
            PrinterIsAcceptingJobs.ACCEPTING_JOBS);
    _attributes.put(PrinterMakeAndModel.class, new PrinterMakeAndModel(
            "Custom printer", null));
    _attributes.put(Media.class, new Media[] { MediaSizeName.ISO_A4 });
}
项目:lookaside_java-1.8.0-openjdk    文件:PrintJob2D.java   
public static MediaType unMapMedia(MediaSizeName mSize) {
    MediaType media = null;

    // JAVAXSIZES.length and SIZES.length must be equal!
    // Attempt to recover by getting the smaller size.
    int length = Math.min(SIZES.length, JAVAXSIZES.length);

    for (int i=0; i < length; i++) {
        if (JAVAXSIZES[i] == mSize) {
            if (SIZES[i] != null) {
                media = SIZES[i];
                break;
            }
        }
    }
    return media;
}
项目:lookaside_java-1.8.0-openjdk    文件:Win32PrintService.java   
public MediaSizeName findWin32Media(int dmIndex) {
    if (dmIndex >= 1 && dmIndex <= dmPaperToPrintService.length) {
        return dmPaperToPrintService[dmIndex - 1];
    }
    switch(dmIndex) {
        /* matching media sizes with indices beyond
           dmPaperToPrintService's length */
        case DMPAPER_A2:
            return MediaSizeName.ISO_A2;
        case DMPAPER_A6:
            return MediaSizeName.ISO_A6;
        case DMPAPER_B6_JIS:
            return MediaSizeName.JIS_B6;
        default:
            return null;
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:Win32PrintService.java   
public MediaSizeName findMatchingMediaSizeNameMM (float w, float h){
    if (predefMedia != null) {
        for (int k=0; k<predefMedia.length;k++) {
            if (predefMedia[k] == null) {
                continue;
            }

            if (isSameSize(predefMedia[k].getX(MediaSize.MM),
                           predefMedia[k].getY(MediaSize.MM),
                           w, h)) {
              return predefMedia[k].getMediaSizeName();
            }
        }
    }
    return null;
}
项目:lookaside_java-1.8.0-openjdk    文件:WPrinterJob.java   
/** MediaSizeName / dmPaper */
private final int[] getWin32MediaAttrib() {
    int wid_ht[] = {0, 0};
    if (attributes != null) {
        Media media = (Media)attributes.get(Media.class);
        if (media instanceof MediaSizeName) {
            MediaSizeName msn = (MediaSizeName)media;
            MediaSize ms = MediaSize.getMediaSizeForName(msn);
            if (ms != null) {
                wid_ht[0] = (int)(ms.getX(MediaSize.INCH) * 72.0);
                wid_ht[1] = (int)(ms.getY(MediaSize.INCH) * 72.0);
            }
        }
    }
    return wid_ht;
}