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

项目:OpenJSharp    文件:Win32PrintService.java   
public MediaTray findMediaTray(int dmBin) {
    if (dmBin >= 1 && dmBin <= dmPaperBinToPrintService.length) {
        return dmPaperBinToPrintService[dmBin-1];
    }
    MediaTray[] trays = getMediaTrays();
    if (trays != null) {
        for (int i=0;i<trays.length;i++) {
            if(trays[i] instanceof Win32MediaTray) {
                Win32MediaTray win32Tray = (Win32MediaTray)trays[i];
                if (win32Tray.winID == dmBin) {
                    return win32Tray;
                }
            }
        }
    }
    return Win32MediaTray.AUTO;
}
项目:OpenJSharp    文件:WPrinterJob.java   
private void setMediaTrayAttrib(Attribute attr) {
    if (attr == MediaTray.BOTTOM) {
        mAttMediaTray = 2;    // DMBIN_LOWER
    } else if (attr == MediaTray.ENVELOPE) {
        mAttMediaTray = 5;    // DMBIN_ENVELOPE
    } else if (attr == MediaTray.LARGE_CAPACITY) {
        mAttMediaTray = 11;      // DMBIN_LARGECAPACITY
    } else if (attr == MediaTray.MAIN) {
        mAttMediaTray =1;               // DMBIN_UPPER
    } else if (attr == MediaTray.MANUAL) {
        mAttMediaTray = 4;              // DMBIN_MANUAL
    } else if (attr == MediaTray.MIDDLE) {
        mAttMediaTray = 3;              // DMBIN_MIDDLE
    } else if (attr == MediaTray.SIDE) {
        // no equivalent predefined value
        mAttMediaTray = 7;              // DMBIN_AUTO
    } else if (attr == MediaTray.TOP) {
        mAttMediaTray = 1;              // DMBIN_UPPER
    } else {
        if (attr instanceof Win32MediaTray) {
            mAttMediaTray = ((Win32MediaTray)attr).winID;
        } else {
            mAttMediaTray = 1;  // default
        }
    }
}
项目:OpenJSharp    文件:Win32PrintService.java   
private MediaTray[] getMediaTrays(){
    if( mediaTrays  != null ){
        // the print service is a singleton per printer so we only do this once
        return mediaTrays;
    }
    PaperSourceCollection trays = settings.get_PaperSources();
    int count = trays.get_Count();
    List<MediaTray> trayList = new ArrayList<MediaTray>();
    for( int i=0; i < count; i++ ){
        PaperSource tray = trays.get_Item(i);
        MediaTray javaTray = getDefaultTray(tray);
        if( javaTray != null ){
            trayList.add( javaTray );
        } else {
            trayList.add( new NetMediaTray( tray ) );
        }
    }
    mediaTrays = trayList.toArray( new MediaTray[trayList.size()]);
    return mediaTrays;
}
项目:OpenJSharp    文件:Win32PrintService.java   
/**
 * Returns the Java-default {@link MediaTray} for a paper source. This is required since these default
 * trays are public constants which can be used without checking for the actually present media trays 
 * @param source the .NET paper source to get the predefined source for
 * @return the media tray or null, in case there is no mapping for the paper source
 */
private MediaTray getDefaultTray( PaperSource source ){
    // convert from .NET kind to java's pre defined MediaTrays
    switch( source.get_RawKind() ){
        case 1 : return MediaTray.TOP;
        case 2 : return MediaTray.BOTTOM;
        case 3 : return MediaTray.MIDDLE;
        case 4 : return MediaTray.MANUAL;
        case 5 : return MediaTray.ENVELOPE;
        case 6 : return Win32MediaTray.ENVELOPE_MANUAL;
        case 7 : return Win32MediaTray.AUTO;
        case 8 : return Win32MediaTray.TRACTOR;
        case 9 : return Win32MediaTray.SMALL_FORMAT;
        case 10 : return Win32MediaTray.LARGE_FORMAT;
        case 11 : return MediaTray.LARGE_CAPACITY;
        case 14 : return MediaTray.MAIN;
        case 15 : return Win32MediaTray.FORMSOURCE;
        // FIXME which PaperSourceKind is MediaTray.SIDE ???
    }
    return null;
}
项目:OpenJSharp    文件:Win32PrintService.java   
/**
   * Returns the .NET {@link PaperSource} for a media tray. This will be done either by mapping or
   * directly in case the tray is a {@link NetMediaTray}
   * @param tray the tray to get the paper source for, must not be null
   * @return the selected {@link PaperSource} or null, in case there is no matching {@link PaperSource}
   */
  public PaperSource getPaperSourceForTray( MediaTray tray ){
    if( tray instanceof NetMediaTray ){
    return ((NetMediaTray)tray).getPaperSource( this );
}
    // try to find the appropriate paper source for the Java-Defined tray
    PaperSourceCollection trays = settings.get_PaperSources();
    int count = trays.get_Count();
    for( int i=0; i < count; i++ ){
        PaperSource paperSource = trays.get_Item(i);
    if( getDefaultTray( paperSource ) == tray ){
            return paperSource;
        }
    }
    return null;
  }
项目:jdk8u-jdk    文件:Win32PrintService.java   
public MediaTray findMediaTray(int dmBin) {
    if (dmBin >= 1 && dmBin <= dmPaperBinToPrintService.length) {
        return dmPaperBinToPrintService[dmBin-1];
    }
    MediaTray[] trays = getMediaTrays();
    if (trays != null) {
        for (int i=0;i<trays.length;i++) {
            if(trays[i] instanceof Win32MediaTray) {
                Win32MediaTray win32Tray = (Win32MediaTray)trays[i];
                if (win32Tray.winID == dmBin) {
                    return win32Tray;
                }
            }
        }
    }
    return Win32MediaTray.AUTO;
}
项目:jdk8u-jdk    文件:WPrinterJob.java   
private void setMediaTrayAttrib(Attribute attr) {
    if (attr == MediaTray.BOTTOM) {
        mAttMediaTray = 2;    // DMBIN_LOWER
    } else if (attr == MediaTray.ENVELOPE) {
        mAttMediaTray = 5;    // DMBIN_ENVELOPE
    } else if (attr == MediaTray.LARGE_CAPACITY) {
        mAttMediaTray = 11;      // DMBIN_LARGECAPACITY
    } else if (attr == MediaTray.MAIN) {
        mAttMediaTray =1;               // DMBIN_UPPER
    } else if (attr == MediaTray.MANUAL) {
        mAttMediaTray = 4;              // DMBIN_MANUAL
    } else if (attr == MediaTray.MIDDLE) {
        mAttMediaTray = 3;              // DMBIN_MIDDLE
    } else if (attr == MediaTray.SIDE) {
        // no equivalent predefined value
        mAttMediaTray = 7;              // DMBIN_AUTO
    } else if (attr == MediaTray.TOP) {
        mAttMediaTray = 1;              // DMBIN_UPPER
    } else {
        if (attr instanceof Win32MediaTray) {
            mAttMediaTray = ((Win32MediaTray)attr).winID;
        } else {
            mAttMediaTray = 1;  // default
        }
    }
}
项目:openjdk-jdk10    文件:Win32PrintService.java   
public MediaTray findMediaTray(int dmBin) {
    if (dmBin >= 1 && dmBin <= dmPaperBinToPrintService.length) {
        return dmPaperBinToPrintService[dmBin-1];
    }
    MediaTray[] trays = getMediaTrays();
    if (trays != null) {
        for (int i=0;i<trays.length;i++) {
            if(trays[i] instanceof Win32MediaTray) {
                Win32MediaTray win32Tray = (Win32MediaTray)trays[i];
                if (win32Tray.winID == dmBin) {
                    return win32Tray;
                }
            }
        }
    }
    return Win32MediaTray.AUTO;
}
项目:openjdk-jdk10    文件:WPrinterJob.java   
private void setMediaTrayAttrib(Attribute attr) {
    if (attr == MediaTray.BOTTOM) {
        mAttMediaTray = 2;    // DMBIN_LOWER
    } else if (attr == MediaTray.ENVELOPE) {
        mAttMediaTray = 5;    // DMBIN_ENVELOPE
    } else if (attr == MediaTray.LARGE_CAPACITY) {
        mAttMediaTray = 11;      // DMBIN_LARGECAPACITY
    } else if (attr == MediaTray.MAIN) {
        mAttMediaTray =1;               // DMBIN_UPPER
    } else if (attr == MediaTray.MANUAL) {
        mAttMediaTray = 4;              // DMBIN_MANUAL
    } else if (attr == MediaTray.MIDDLE) {
        mAttMediaTray = 3;              // DMBIN_MIDDLE
    } else if (attr == MediaTray.SIDE) {
        // no equivalent predefined value
        mAttMediaTray = 7;              // DMBIN_AUTO
    } else if (attr == MediaTray.TOP) {
        mAttMediaTray = 1;              // DMBIN_UPPER
    } else {
        if (attr instanceof Win32MediaTray) {
            mAttMediaTray = ((Win32MediaTray)attr).winID;
        } else {
            mAttMediaTray = 1;  // default
        }
    }
}
项目:openjdk-jdk10    文件:TestMediaTraySelection.java   
private static void printTest() {

        MediaTray tray = null;
        //tray = getMediaTray( prservices, "Bypass Tray" );
        tray = getMediaTray( prservices, "Tray 4" );
        PrintRequestAttributeSet atrset = new HashPrintRequestAttributeSet();
        //atrset.add( MediaSizeName.ISO_A4 );
        atrset.add(tray);
        PrinterJob pjob = PrinterJob.getPrinterJob();
        pjob.setPrintable(new TestMediaTraySelection());
        try {
            pjob.print(atrset);
        } catch (PrinterException e) {
            e.printStackTrace();
            fail();
        }
    }
项目:openjdk9    文件:Win32PrintService.java   
public MediaTray findMediaTray(int dmBin) {
    if (dmBin >= 1 && dmBin <= dmPaperBinToPrintService.length) {
        return dmPaperBinToPrintService[dmBin-1];
    }
    MediaTray[] trays = getMediaTrays();
    if (trays != null) {
        for (int i=0;i<trays.length;i++) {
            if(trays[i] instanceof Win32MediaTray) {
                Win32MediaTray win32Tray = (Win32MediaTray)trays[i];
                if (win32Tray.winID == dmBin) {
                    return win32Tray;
                }
            }
        }
    }
    return Win32MediaTray.AUTO;
}
项目:openjdk9    文件:WPrinterJob.java   
private void setMediaTrayAttrib(Attribute attr) {
    if (attr == MediaTray.BOTTOM) {
        mAttMediaTray = 2;    // DMBIN_LOWER
    } else if (attr == MediaTray.ENVELOPE) {
        mAttMediaTray = 5;    // DMBIN_ENVELOPE
    } else if (attr == MediaTray.LARGE_CAPACITY) {
        mAttMediaTray = 11;      // DMBIN_LARGECAPACITY
    } else if (attr == MediaTray.MAIN) {
        mAttMediaTray =1;               // DMBIN_UPPER
    } else if (attr == MediaTray.MANUAL) {
        mAttMediaTray = 4;              // DMBIN_MANUAL
    } else if (attr == MediaTray.MIDDLE) {
        mAttMediaTray = 3;              // DMBIN_MIDDLE
    } else if (attr == MediaTray.SIDE) {
        // no equivalent predefined value
        mAttMediaTray = 7;              // DMBIN_AUTO
    } else if (attr == MediaTray.TOP) {
        mAttMediaTray = 1;              // DMBIN_UPPER
    } else {
        if (attr instanceof Win32MediaTray) {
            mAttMediaTray = ((Win32MediaTray)attr).winID;
        } else {
            mAttMediaTray = 1;  // default
        }
    }
}
项目:jdk8u_jdk    文件:Win32PrintService.java   
public MediaTray findMediaTray(int dmBin) {
    if (dmBin >= 1 && dmBin <= dmPaperBinToPrintService.length) {
        return dmPaperBinToPrintService[dmBin-1];
    }
    MediaTray[] trays = getMediaTrays();
    if (trays != null) {
        for (int i=0;i<trays.length;i++) {
            if(trays[i] instanceof Win32MediaTray) {
                Win32MediaTray win32Tray = (Win32MediaTray)trays[i];
                if (win32Tray.winID == dmBin) {
                    return win32Tray;
                }
            }
        }
    }
    return Win32MediaTray.AUTO;
}
项目:jdk8u_jdk    文件:WPrinterJob.java   
private void setMediaTrayAttrib(Attribute attr) {
    if (attr == MediaTray.BOTTOM) {
        mAttMediaTray = 2;    // DMBIN_LOWER
    } else if (attr == MediaTray.ENVELOPE) {
        mAttMediaTray = 5;    // DMBIN_ENVELOPE
    } else if (attr == MediaTray.LARGE_CAPACITY) {
        mAttMediaTray = 11;      // DMBIN_LARGECAPACITY
    } else if (attr == MediaTray.MAIN) {
        mAttMediaTray =1;               // DMBIN_UPPER
    } else if (attr == MediaTray.MANUAL) {
        mAttMediaTray = 4;              // DMBIN_MANUAL
    } else if (attr == MediaTray.MIDDLE) {
        mAttMediaTray = 3;              // DMBIN_MIDDLE
    } else if (attr == MediaTray.SIDE) {
        // no equivalent predefined value
        mAttMediaTray = 7;              // DMBIN_AUTO
    } else if (attr == MediaTray.TOP) {
        mAttMediaTray = 1;              // DMBIN_UPPER
    } else {
        if (attr instanceof Win32MediaTray) {
            mAttMediaTray = ((Win32MediaTray)attr).winID;
        } else {
            mAttMediaTray = 1;  // default
        }
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:Win32PrintService.java   
public MediaTray findMediaTray(int dmBin) {
    if (dmBin >= 1 && dmBin <= dmPaperBinToPrintService.length) {
        return dmPaperBinToPrintService[dmBin-1];
    }
    MediaTray[] trays = getMediaTrays();
    if (trays != null) {
        for (int i=0;i<trays.length;i++) {
            if(trays[i] instanceof Win32MediaTray) {
                Win32MediaTray win32Tray = (Win32MediaTray)trays[i];
                if (win32Tray.winID == dmBin) {
                    return win32Tray;
                }
            }
        }
    }
    return Win32MediaTray.AUTO;
}
项目:lookaside_java-1.8.0-openjdk    文件:WPrinterJob.java   
private void setMediaTrayAttrib(Attribute attr) {
    if (attr == MediaTray.BOTTOM) {
        mAttMediaTray = 2;    // DMBIN_LOWER
    } else if (attr == MediaTray.ENVELOPE) {
        mAttMediaTray = 5;    // DMBIN_ENVELOPE
    } else if (attr == MediaTray.LARGE_CAPACITY) {
        mAttMediaTray = 11;      // DMBIN_LARGECAPACITY
    } else if (attr == MediaTray.MAIN) {
        mAttMediaTray =1;               // DMBIN_UPPER
    } else if (attr == MediaTray.MANUAL) {
        mAttMediaTray = 4;              // DMBIN_MANUAL
    } else if (attr == MediaTray.MIDDLE) {
        mAttMediaTray = 3;              // DMBIN_MIDDLE
    } else if (attr == MediaTray.SIDE) {
        // no equivalent predefined value
        mAttMediaTray = 7;              // DMBIN_AUTO
    } else if (attr == MediaTray.TOP) {
        mAttMediaTray = 1;              // DMBIN_UPPER
    } else {
        if (attr instanceof Win32MediaTray) {
            mAttMediaTray = ((Win32MediaTray)attr).winID;
        } else {
            mAttMediaTray = 1;  // default
        }
    }
}
项目:Camel    文件:PrinterProducer.java   
private PrintRequestAttributeSet assignPrintAttributes() throws PrintException {
    PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
    if (config.getCopies() >= 1) {
        printRequestAttributeSet.add(new Copies(config.getCopies()));
    } else {
        throw new PrintException("Number of print copies should be greater than zero");
    }
    printRequestAttributeSet.add(config.getMediaSizeName());
    printRequestAttributeSet.add(config.getInternalSides());
    printRequestAttributeSet.add(config.getInternalOrientation());

    if (config.getMediaTray() != null) {
        MediaTray mediaTray = resolveMediaTray(config.getMediaTray());

        if (mediaTray == null) {
            throw new PrintException("mediatray not found " + config.getMediaTray());
        }

        printRequestAttributeSet.add(mediaTray);
    }

    return printRequestAttributeSet;
}
项目:Camel    文件:PrinterProducer.java   
private MediaTray resolveMediaTray(String tray) {
    Media medias[] = (Media[]) getPrintService().getSupportedAttributeValues(Media.class, null, null);

    if (medias == null) {
        return null;
    } else {
        for (Media media : medias) {
            if (media instanceof MediaTray) {
                MediaTray mediaTray = (MediaTray) media;
                String trayName = mediaTray.toString().trim();
                if (trayName.contains(" ")) {
                    trayName = trayName.replace(' ', '_');
                }
                if (trayName.equals(tray)) {
                    return mediaTray;
                }
            }
        }
        return null;
    }
}
项目:Camel    文件:PrinterPrintTest.java   
@Test
public void printToMiddleTray() throws Exception {
    PrinterEndpoint endpoint = new PrinterEndpoint();
    PrinterConfiguration configuration = new PrinterConfiguration();
    configuration.setHostname("localhost");
    configuration.setPort(631);
    configuration.setPrintername("DefaultPrinter");
    configuration.setMediaSizeName(MediaSizeName.ISO_A4);
    configuration.setInternalSides(Sides.ONE_SIDED);
    configuration.setInternalOrientation(OrientationRequested.PORTRAIT);
    configuration.setMediaTray("middle");

    PrinterProducer producer = new PrinterProducer(endpoint, configuration);
    producer.start();
    PrinterOperations printerOperations = producer.getPrinterOperations();
    PrintRequestAttributeSet attributeSet = printerOperations.getPrintRequestAttributeSet();

    Attribute attribute = attributeSet.get(javax.print.attribute.standard.Media.class);
    assertNotNull(attribute);
    assertTrue(attribute instanceof MediaTray);
    MediaTray mediaTray = (MediaTray) attribute;
    assertEquals("middle", mediaTray.toString());
}
项目:Camel    文件:PrinterPrintTest.java   
protected void setupJavaPrint() {
    // "install" another default printer
    PrintService psDefault = mock(PrintService.class);
    when(psDefault.getName()).thenReturn("DefaultPrinter");
    when(psDefault.isDocFlavorSupported(any(DocFlavor.class))).thenReturn(Boolean.TRUE);
    PrintServiceLookup psLookup = mock(PrintServiceLookup.class);
    when(psLookup.getPrintServices()).thenReturn(new PrintService[]{psDefault});
    when(psLookup.getDefaultPrintService()).thenReturn(psDefault);
    DocPrintJob docPrintJob = mock(DocPrintJob.class);
    when(psDefault.createPrintJob()).thenReturn(docPrintJob);
    MediaTray[] trays = new MediaTray[]{
        MediaTray.TOP,
        MediaTray.MIDDLE,
        MediaTray.BOTTOM
    };
    when(psDefault.getSupportedAttributeValues(Media.class, null, null)).thenReturn(trays);
    PrintServiceLookup.registerServiceProvider(psLookup);
}
项目:infobip-open-jdk-8    文件:Win32PrintService.java   
public MediaTray findMediaTray(int dmBin) {
    if (dmBin >= 1 && dmBin <= dmPaperBinToPrintService.length) {
        return dmPaperBinToPrintService[dmBin-1];
    }
    MediaTray[] trays = getMediaTrays();
    if (trays != null) {
        for (int i=0;i<trays.length;i++) {
            if(trays[i] instanceof Win32MediaTray) {
                Win32MediaTray win32Tray = (Win32MediaTray)trays[i];
                if (win32Tray.winID == dmBin) {
                    return win32Tray;
                }
            }
        }
    }
    return Win32MediaTray.AUTO;
}
项目:infobip-open-jdk-8    文件:WPrinterJob.java   
private void setMediaTrayAttrib(Attribute attr) {
    if (attr == MediaTray.BOTTOM) {
        mAttMediaTray = 2;    // DMBIN_LOWER
    } else if (attr == MediaTray.ENVELOPE) {
        mAttMediaTray = 5;    // DMBIN_ENVELOPE
    } else if (attr == MediaTray.LARGE_CAPACITY) {
        mAttMediaTray = 11;      // DMBIN_LARGECAPACITY
    } else if (attr == MediaTray.MAIN) {
        mAttMediaTray =1;               // DMBIN_UPPER
    } else if (attr == MediaTray.MANUAL) {
        mAttMediaTray = 4;              // DMBIN_MANUAL
    } else if (attr == MediaTray.MIDDLE) {
        mAttMediaTray = 3;              // DMBIN_MIDDLE
    } else if (attr == MediaTray.SIDE) {
        // no equivalent predefined value
        mAttMediaTray = 7;              // DMBIN_AUTO
    } else if (attr == MediaTray.TOP) {
        mAttMediaTray = 1;              // DMBIN_UPPER
    } else {
        if (attr instanceof Win32MediaTray) {
            mAttMediaTray = ((Win32MediaTray)attr).winID;
        } else {
            mAttMediaTray = 1;  // default
        }
    }
}
项目:jdk8u-dev-jdk    文件:Win32PrintService.java   
public MediaTray findMediaTray(int dmBin) {
    if (dmBin >= 1 && dmBin <= dmPaperBinToPrintService.length) {
        return dmPaperBinToPrintService[dmBin-1];
    }
    MediaTray[] trays = getMediaTrays();
    if (trays != null) {
        for (int i=0;i<trays.length;i++) {
            if(trays[i] instanceof Win32MediaTray) {
                Win32MediaTray win32Tray = (Win32MediaTray)trays[i];
                if (win32Tray.winID == dmBin) {
                    return win32Tray;
                }
            }
        }
    }
    return Win32MediaTray.AUTO;
}
项目:jdk8u-dev-jdk    文件:WPrinterJob.java   
private void setMediaTrayAttrib(Attribute attr) {
    if (attr == MediaTray.BOTTOM) {
        mAttMediaTray = 2;    // DMBIN_LOWER
    } else if (attr == MediaTray.ENVELOPE) {
        mAttMediaTray = 5;    // DMBIN_ENVELOPE
    } else if (attr == MediaTray.LARGE_CAPACITY) {
        mAttMediaTray = 11;      // DMBIN_LARGECAPACITY
    } else if (attr == MediaTray.MAIN) {
        mAttMediaTray =1;               // DMBIN_UPPER
    } else if (attr == MediaTray.MANUAL) {
        mAttMediaTray = 4;              // DMBIN_MANUAL
    } else if (attr == MediaTray.MIDDLE) {
        mAttMediaTray = 3;              // DMBIN_MIDDLE
    } else if (attr == MediaTray.SIDE) {
        // no equivalent predefined value
        mAttMediaTray = 7;              // DMBIN_AUTO
    } else if (attr == MediaTray.TOP) {
        mAttMediaTray = 1;              // DMBIN_UPPER
    } else {
        if (attr instanceof Win32MediaTray) {
            mAttMediaTray = ((Win32MediaTray)attr).winID;
        } else {
            mAttMediaTray = 1;  // default
        }
    }
}
项目:jdk7-jdk    文件:Win32PrintService.java   
public MediaTray findMediaTray(int dmBin) {
    if (dmBin >= 1 && dmBin <= dmPaperBinToPrintService.length) {
        return dmPaperBinToPrintService[dmBin-1];
    }
    MediaTray[] trays = getMediaTrays();
    if (trays != null) {
        for (int i=0;i<trays.length;i++) {
            if(trays[i] instanceof Win32MediaTray) {
                Win32MediaTray win32Tray = (Win32MediaTray)trays[i];
                if (win32Tray.winID == dmBin) {
                    return win32Tray;
                }
            }
        }
    }
    return Win32MediaTray.AUTO;
}
项目:jdk7-jdk    文件:WPrinterJob.java   
private void setMediaTrayAttrib(Attribute attr) {
    if (attr == MediaTray.BOTTOM) {
        mAttMediaTray = 2;    // DMBIN_LOWER
    } else if (attr == MediaTray.ENVELOPE) {
        mAttMediaTray = 5;    // DMBIN_ENVELOPE
    } else if (attr == MediaTray.LARGE_CAPACITY) {
        mAttMediaTray = 11;      // DMBIN_LARGECAPACITY
    } else if (attr == MediaTray.MAIN) {
        mAttMediaTray =1;               // DMBIN_UPPER
    } else if (attr == MediaTray.MANUAL) {
        mAttMediaTray = 4;              // DMBIN_MANUAL
    } else if (attr == MediaTray.MIDDLE) {
        mAttMediaTray = 3;              // DMBIN_MIDDLE
    } else if (attr == MediaTray.SIDE) {
        // no equivalent predefined value
        mAttMediaTray = 7;              // DMBIN_AUTO
    } else if (attr == MediaTray.TOP) {
        mAttMediaTray =1;               // DMBIN_UPPER
    } else {
        if (attr instanceof Win32MediaTray) {
            mAttMediaTray = ((Win32MediaTray)attr).winID;
        } else {
            mAttMediaTray = 1;  // default
        }
    }
}
项目:openjdk-source-code-learn    文件:Win32PrintService.java   
public MediaTray findMediaTray(int dmBin) {
    if (dmBin >= 1 && dmBin <= dmPaperBinToPrintService.length) {
        return dmPaperBinToPrintService[dmBin-1];
    }
    MediaTray[] trays = getMediaTrays();
    if (trays != null) {
        for (int i=0;i<trays.length;i++) {
            if(trays[i] instanceof Win32MediaTray) {
                Win32MediaTray win32Tray = (Win32MediaTray)trays[i];
                if (win32Tray.winID == dmBin) {
                    return win32Tray;
                }
            }
        }
    }
    return Win32MediaTray.AUTO;
}
项目:openjdk-source-code-learn    文件:WPrinterJob.java   
private void setMediaTrayAttrib(Attribute attr) {
    if (attr == MediaTray.BOTTOM) {
        mAttMediaTray = 2;    // DMBIN_LOWER
    } else if (attr == MediaTray.ENVELOPE) {
        mAttMediaTray = 5;    // DMBIN_ENVELOPE
    } else if (attr == MediaTray.LARGE_CAPACITY) {
        mAttMediaTray = 11;      // DMBIN_LARGECAPACITY
    } else if (attr == MediaTray.MAIN) {
        mAttMediaTray =1;               // DMBIN_UPPER
    } else if (attr == MediaTray.MANUAL) {
        mAttMediaTray = 4;              // DMBIN_MANUAL
    } else if (attr == MediaTray.MIDDLE) {
        mAttMediaTray = 3;              // DMBIN_MIDDLE
    } else if (attr == MediaTray.SIDE) {
        // no equivalent predefined value
        mAttMediaTray = 7;              // DMBIN_AUTO
    } else if (attr == MediaTray.TOP) {
        mAttMediaTray =1;               // DMBIN_UPPER
    } else {
        if (attr instanceof Win32MediaTray) {
            mAttMediaTray = ((Win32MediaTray)attr).winID;
        } else {
            mAttMediaTray = 1;  // default
        }
    }
}
项目:ph-commons    文件:JavaPrinterTrayFinderFuncTest.java   
@Test
public void testListPrinterTrays ()
{
  final PrintService [] aAllServices = PrintServiceLookup.lookupPrintServices (null, null);
  for (final PrintService aService : aAllServices)
  {
    s_aLogger.info (aService.toString ());
    final Object aAttrs = aService.getSupportedAttributeValues (Media.class,
                                                                DocFlavor.SERVICE_FORMATTED.PAGEABLE,
                                                                null);
    if (ArrayHelper.isArray (aAttrs))
    {
      for (final Media aElement : (Media []) aAttrs)
        if (aElement instanceof MediaTray)
          s_aLogger.info ("  " + aElement);
    }
  }
}
项目:OLD-OpenJDK8    文件:Win32PrintService.java   
public MediaTray findMediaTray(int dmBin) {
    if (dmBin >= 1 && dmBin <= dmPaperBinToPrintService.length) {
        return dmPaperBinToPrintService[dmBin-1];
    }
    MediaTray[] trays = getMediaTrays();
    if (trays != null) {
        for (int i=0;i<trays.length;i++) {
            if(trays[i] instanceof Win32MediaTray) {
                Win32MediaTray win32Tray = (Win32MediaTray)trays[i];
                if (win32Tray.winID == dmBin) {
                    return win32Tray;
                }
            }
        }
    }
    return Win32MediaTray.AUTO;
}
项目:OLD-OpenJDK8    文件:WPrinterJob.java   
private void setMediaTrayAttrib(Attribute attr) {
    if (attr == MediaTray.BOTTOM) {
        mAttMediaTray = 2;    // DMBIN_LOWER
    } else if (attr == MediaTray.ENVELOPE) {
        mAttMediaTray = 5;    // DMBIN_ENVELOPE
    } else if (attr == MediaTray.LARGE_CAPACITY) {
        mAttMediaTray = 11;      // DMBIN_LARGECAPACITY
    } else if (attr == MediaTray.MAIN) {
        mAttMediaTray =1;               // DMBIN_UPPER
    } else if (attr == MediaTray.MANUAL) {
        mAttMediaTray = 4;              // DMBIN_MANUAL
    } else if (attr == MediaTray.MIDDLE) {
        mAttMediaTray = 3;              // DMBIN_MIDDLE
    } else if (attr == MediaTray.SIDE) {
        // no equivalent predefined value
        mAttMediaTray = 7;              // DMBIN_AUTO
    } else if (attr == MediaTray.TOP) {
        mAttMediaTray = 1;              // DMBIN_UPPER
    } else {
        if (attr instanceof Win32MediaTray) {
            mAttMediaTray = ((Win32MediaTray)attr).winID;
        } else {
            mAttMediaTray = 1;  // default
        }
    }
}
项目:openjdk-jdk7u-jdk    文件:Win32PrintService.java   
public MediaTray findMediaTray(int dmBin) {
    if (dmBin >= 1 && dmBin <= dmPaperBinToPrintService.length) {
        return dmPaperBinToPrintService[dmBin-1];
    }
    MediaTray[] trays = getMediaTrays();
    if (trays != null) {
        for (int i=0;i<trays.length;i++) {
            if(trays[i] instanceof Win32MediaTray) {
                Win32MediaTray win32Tray = (Win32MediaTray)trays[i];
                if (win32Tray.winID == dmBin) {
                    return win32Tray;
                }
            }
        }
    }
    return Win32MediaTray.AUTO;
}
项目:openjdk-jdk7u-jdk    文件:WPrinterJob.java   
private void setMediaTrayAttrib(Attribute attr) {
    if (attr == MediaTray.BOTTOM) {
        mAttMediaTray = 2;    // DMBIN_LOWER
    } else if (attr == MediaTray.ENVELOPE) {
        mAttMediaTray = 5;    // DMBIN_ENVELOPE
    } else if (attr == MediaTray.LARGE_CAPACITY) {
        mAttMediaTray = 11;      // DMBIN_LARGECAPACITY
    } else if (attr == MediaTray.MAIN) {
        mAttMediaTray =1;               // DMBIN_UPPER
    } else if (attr == MediaTray.MANUAL) {
        mAttMediaTray = 4;              // DMBIN_MANUAL
    } else if (attr == MediaTray.MIDDLE) {
        mAttMediaTray = 3;              // DMBIN_MIDDLE
    } else if (attr == MediaTray.SIDE) {
        // no equivalent predefined value
        mAttMediaTray = 7;              // DMBIN_AUTO
    } else if (attr == MediaTray.TOP) {
        mAttMediaTray = 1;              // DMBIN_UPPER
    } else {
        if (attr instanceof Win32MediaTray) {
            mAttMediaTray = ((Win32MediaTray)attr).winID;
        } else {
            mAttMediaTray = 1;  // default
        }
    }
}
项目:openjdk-icedtea7    文件:Win32PrintService.java   
public MediaTray findMediaTray(int dmBin) {
    if (dmBin >= 1 && dmBin <= dmPaperBinToPrintService.length) {
        return dmPaperBinToPrintService[dmBin-1];
    }
    MediaTray[] trays = getMediaTrays();
    if (trays != null) {
        for (int i=0;i<trays.length;i++) {
            if(trays[i] instanceof Win32MediaTray) {
                Win32MediaTray win32Tray = (Win32MediaTray)trays[i];
                if (win32Tray.winID == dmBin) {
                    return win32Tray;
                }
            }
        }
    }
    return Win32MediaTray.AUTO;
}
项目:openjdk-icedtea7    文件:WPrinterJob.java   
private void setMediaTrayAttrib(Attribute attr) {
    if (attr == MediaTray.BOTTOM) {
        mAttMediaTray = 2;    // DMBIN_LOWER
    } else if (attr == MediaTray.ENVELOPE) {
        mAttMediaTray = 5;    // DMBIN_ENVELOPE
    } else if (attr == MediaTray.LARGE_CAPACITY) {
        mAttMediaTray = 11;      // DMBIN_LARGECAPACITY
    } else if (attr == MediaTray.MAIN) {
        mAttMediaTray =1;               // DMBIN_UPPER
    } else if (attr == MediaTray.MANUAL) {
        mAttMediaTray = 4;              // DMBIN_MANUAL
    } else if (attr == MediaTray.MIDDLE) {
        mAttMediaTray = 3;              // DMBIN_MIDDLE
    } else if (attr == MediaTray.SIDE) {
        // no equivalent predefined value
        mAttMediaTray = 7;              // DMBIN_AUTO
    } else if (attr == MediaTray.TOP) {
        mAttMediaTray =1;               // DMBIN_UPPER
    } else {
        if (attr instanceof Win32MediaTray) {
            mAttMediaTray = ((Win32MediaTray)attr).winID;
        } else {
            mAttMediaTray = 1;  // default
        }
    }
}
项目:wildfly-camel    文件:PrinterIntegrationTest.java   
@Before
public void setup() {
    PrintService psDefault = Mockito.mock(PrintService.class);
    Mockito.when(psDefault.getName()).thenReturn("DefaultPrinter");
    Mockito.when(psDefault.isDocFlavorSupported(Mockito.any(DocFlavor.class))).thenReturn(Boolean.TRUE);
    PrintServiceLookup psLookup = Mockito.mock(PrintServiceLookup.class);
    Mockito.when(psLookup.getPrintServices()).thenReturn(new PrintService[]{psDefault});
    Mockito.when(psLookup.getDefaultPrintService()).thenReturn(psDefault);
    DocPrintJob docPrintJob = Mockito.mock(DocPrintJob.class);
    Mockito.when(psDefault.createPrintJob()).thenReturn(docPrintJob);
    MediaTray[] trays = new MediaTray[]{
        MediaTray.TOP,
        MediaTray.MIDDLE,
        MediaTray.BOTTOM
    };
    Mockito.when(psDefault.getSupportedAttributeValues(Media.class, null, null)).thenReturn(trays);
    PrintServiceLookup.registerServiceProvider(psLookup);
}
项目:elexis-3-core    文件:TextTemplatePrintSettingsDialog.java   
private void initSelection(){
    if (selPrinter == null) {
        PrintService defaultPrintService = PrintServiceLookup.lookupDefaultPrintService();
        if (defaultPrintService != null && printServices.contains(defaultPrintService)) {
            cvPrinters.setSelection(new StructuredSelection(defaultPrintService));
        }
    } else {
        for (PrintService ps : printServices) {
            if (ps.getName().equals(selPrinter)) {
                cvPrinters.setSelection(new StructuredSelection(ps));
            }
        }
    }

    if (!mediaTrays.isEmpty()) {
        if (selTray == null) {
            cvTrays.setSelection(new StructuredSelection(mediaTrays.get(0)));
        } else {
            for (MediaTray mt : mediaTrays) {
                if (mt.toString().equals(selTray)) {
                    cvTrays.setSelection(new StructuredSelection(mt));
                }
            }
        }
    }
}
项目:elexis-3-core    文件:TextTemplatePrintSettingsDialog.java   
@Override
protected void okPressed(){
    IStructuredSelection selPrintService = (IStructuredSelection) cvPrinters.getSelection();
    if (selPrintService != null && !selPrintService.isEmpty()) {
        selPrinter = ((PrintService) selPrintService.getFirstElement()).getName();
    }

    IStructuredSelection selMediaTray = (IStructuredSelection) cvTrays.getSelection();
    if (selMediaTray != null) {
        if (selMediaTray.isEmpty()) {
            selTray = "";
        } else {
            selTray = ((MediaTray) selMediaTray.getFirstElement()).toString();
        }
    }
    super.okPressed();
}
项目:OpenJSharp    文件:Win32PrintService.java   
public int findTrayID(MediaTray tray) {

        getMediaTrays(); // make sure they are initialised.

        if (tray instanceof Win32MediaTray) {
            Win32MediaTray winTray = (Win32MediaTray)tray;
            return winTray.getDMBinID();
        }
        for (int id=0; id<dmPaperBinToPrintService.length; id++) {
            if (tray.equals(dmPaperBinToPrintService[id])) {
                return id+1; // DMBIN_FIRST = 1;
            }
        }
        return 0; // didn't find the tray
    }
项目:OpenJSharp    文件:Win32PrintService.java   
private boolean isSupportedMediaTray(MediaTray msn) {
    MediaTray[] trays = getMediaTrays();

    if (trays != null) {
        for (int i=0; i<trays.length; i++) {
            if (msn.equals(trays[i])) {
                return true;
            }
        }
    }
    return false;
}