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

项目: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    文件: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    文件: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    文件: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    文件: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 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    文件: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);
        }
    }
}
项目: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 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;
}
项目: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    文件: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;
    }
项目: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;
}
项目:lookaside_java-1.8.0-openjdk    文件: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;
    }
项目:metasfresh    文件:CPaper.java   
/**
 *  Constructor.
 *  Derive Paper from PageForamt
 *  @param pf PageFormat
 */
public CPaper (PageFormat pf)
{
    super();
    m_landscape = pf.getOrientation() != PageFormat.PORTRAIT;
    //  try to find MediaSize
    float x = (float)pf.getWidth();
    float y = (float)pf.getHeight();
    MediaSizeName msn = MediaSize.findMedia (x/72, y/72, MediaSize.INCH);
    MediaSize ms = null;
    if (msn == null)
        msn = MediaSize.findMedia (y/72, x/72, MediaSize.INCH); //  flip it
    if (msn != null)
        ms = MediaSize.getMediaSizeForName(msn);
    setMediaSize(ms, m_landscape);
    //  set size directly
    setSize(pf.getWidth(), pf.getHeight());
    setImageableArea(pf.getImageableX(), pf.getImageableY(),
        pf.getImageableWidth(), pf.getImageableHeight());
}
项目:metasfresh    文件:CPaper.java   
/**
 *  Get "nice" String Representation
 *  @param ctx context
 *  @return info
 */
public String toString (Properties ctx)
{
    StringBuffer sb = new StringBuffer();
    //  Print Media size
    //AA Goodwill : Custom Paper Support
    if (m_mediaSize != null){
        sb.append(m_mediaSize.getMediaSizeName());
        //  Print dimension
        String name = m_mediaSize.getMediaSizeName().toString();
        if (!name.startsWith("iso"))
            sb.append(" - ").append(m_mediaSize.toString(MediaSize.INCH,"\""))
                .append(" (").append(getMediaPrintableArea().toString(MediaPrintableArea.INCH,"\""));
        if (!name.startsWith("na"))
            sb.append(" - ").append(m_mediaSize.toString(MediaSize.MM,"mm"))
                .append(" (").append(getMediaPrintableArea().toString(MediaPrintableArea.MM,"mm"));
        //  Print Orientation
        sb.append(") - ")
            .append(Msg.getMsg(ctx, m_landscape ? "Landscape" : "Portrait"));
    }       
    else sb.append("Custom - ").append(toString());
    //End Of AA Goodwill
    return sb.toString();
}
项目:metasfresh    文件:Helper.java   
public void createPrinterHWCalibration(final String printerName, final String mediaSizeName, final String trayName, final int calX, final int calY)
{
    final I_AD_PrinterHW printer = getCreatePrinterHW(printerName);

    final I_AD_PrinterHW_MediaSize mediaSize = printingDAO.newInstance(ctx, I_AD_PrinterHW_MediaSize.class, ITrx.TRXNAME_None);
    mediaSize.setName(mediaSizeName);
    mediaSize.setAD_PrinterHW(printer);
    printingDAO.save(mediaSize);

    final I_AD_PrinterHW_MediaTray mediaTray = getCreatePrinterTrayHW(printerName, trayName);
    // created by 'getCreatePrinterHW(printerName)'
    final I_AD_PrinterHW_MediaSize hwMediaSize = printingDAO.retrieveMediaSize(printer, MediaSize.ISO.A4, true);

    final I_AD_PrinterHW_Calibration calibration = printingDAO.newInstance(ctx, I_AD_PrinterHW_Calibration.class, ITrx.TRXNAME_None);
    calibration.setAD_PrinterHW(printer);
    calibration.setAD_PrinterHW_MediaTray(mediaTray);
    calibration.setAD_PrinterHW_MediaSize(hwMediaSize);
    calibration.setCalX(calX);
    calibration.setCalY(calY);
    printingDAO.save(calibration);
}
项目:infobip-open-jdk-8    文件: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;
}
项目:infobip-open-jdk-8    文件: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;
}
项目:infobip-open-jdk-8    文件: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-dev-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-dev-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-dev-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;
    }
项目:jdk7-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;
}
项目:jdk7-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;
}
项目:jdk7-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;
    }
项目:openjdk-source-code-learn    文件: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-source-code-learn    文件: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;
}
项目:openjdk-source-code-learn    文件: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;
    }
项目:OLD-OpenJDK8    文件: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;
}
项目:OLD-OpenJDK8    文件: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;
}
项目:OLD-OpenJDK8    文件: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;
    }
项目:cn1    文件:DevmodeStructWrapper.java   
public Paper getPaper() {
    final short size = getDmPaperSize(structPtr);
    Paper p = StdPaper.getPaper(size);

    if (p == null) {
        final long fields = getDmFields();

        if (((fields & DM_PAPERLENGTH) != 0)
                        && ((fields & DM_PAPERWIDTH) != 0)) {
            p = new CustomPaper(size, new MediaSize(
                            getDmPaperWidth(structPtr) / 10,
                            getDmPaperLength(structPtr) / 10,
                            Size2DSyntax.MM));
        }
    }

    return p;
}
项目:cn1    文件:DevmodeStructWrapper.java   
public void setAttribute(final Attribute attr) {
    final Class<? extends Attribute> category = attr.getCategory();

    if (OrientationRequested.class.equals(category)) {
        setOrientation((OrientationRequested) attr);
    } else if (MediaSize.class.equals(category)) {
        setPaper((MediaSize) attr);
    } else if (Media.class.equals(category)) {
        setPaper((MediaSizeName) attr);
    } else if (Paper.class.equals(category)) {
        setPaper((Paper) attr);
    } else if (Copies.class.equals(category)) {
        setCopies((Copies) attr);
    } else if (PrintQuality.class.equals(category)) {
        setPrintQuality((PrintQuality) attr);
    } else if (Sides.class.equals(category)) {
        setSides((Sides) attr);
    } else if (SheetCollate.class.equals(category)) {
        setCollate((SheetCollate) attr);
    } else if (PrinterResolution.class.equals(category)) {
        setPrinterResolution((PrinterResolution) attr);
    } else if (Chromaticity.class.equals(category)) {
        setChromaticity((Chromaticity) attr);
    }
}
项目:cn1    文件:WinPrinterFactory.java   
public static MediaSizeName[] getSupportedMediaSizeNames(final long handle)
                throws PrintException {
    final MediaSizeName[] names;
    final int[] sizes = getSupportedPaperSizes(handle);
    final Vector<MediaSizeName> v = new Vector<MediaSizeName>(
                    sizes.length / 2);

    for (int i = 0; i < sizes.length; i += 2) {
        if ((sizes[i] > 0) && (sizes[i + 1] > 0)) {
            final MediaSizeName name = MediaSize.findMedia(sizes[i] / 10,
                            sizes[i + 1] / 10, Size2DSyntax.MM);

            if ((name != null) && !v.contains(name)) {
                v.add(name);
            }
        }
    }

    names = new MediaSizeName[v.size()];
    return v.toArray(names);
}