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

项目: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    文件:GDIClient.java   
public Object getDefaultAttributeValue(Class category) {
    if (category.equals(JobName.class)) {
        return new JobName("Java GDI client print job", Locale.US);
    } else if (category.equals(RequestingUserName.class)) {
        return new RequestingUserName(System.getProperty("user.name"),
                Locale.US);
    } else if (category.equals(Destination.class)) {
        File file = new File(System.getProperty("user.dir") +
                File.separator + "output.prn");
        return new Destination(file.toURI());
    } else if (category.equals(SheetCollate.class)) {
        return SheetCollate.COLLATED;
    } else if (category.equals(Copies.class)) {
        return new Copies(1);
    }
    return null;
}
项目:freeVM    文件:GDIClient.java   
public Object getDefaultAttributeValue(Class category) {
    if (category.equals(JobName.class)) {
        return new JobName("Java GDI client print job", Locale.US);
    } else if (category.equals(RequestingUserName.class)) {
        return new RequestingUserName(System.getProperty("user.name"),
                Locale.US);
    } else if (category.equals(Destination.class)) {
        File file = new File(System.getProperty("user.dir") +
                File.separator + "output.prn");
        return new Destination(file.toURI());
    } else if (category.equals(SheetCollate.class)) {
        return SheetCollate.COLLATED;
    } else if (category.equals(Copies.class)) {
        return new Copies(1);
    }
    return null;
}
项目:freeVM    文件: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);
    }
}
项目:freeVM    文件:GDIClient.java   
public Object getDefaultAttributeValue(Class category) {
    if (category.equals(JobName.class)) {
        return new JobName("Java GDI client print job", Locale.US);
    } else if (category.equals(RequestingUserName.class)) {
        return new RequestingUserName(System.getProperty("user.name"),
                Locale.US);
    } else if (category.equals(Destination.class)) {
        File file = new File(System.getProperty("user.dir") +
                File.separator + "output.prn");
        return new Destination(file.toURI());
    } else if (category.equals(SheetCollate.class)) {
        return SheetCollate.COLLATED;
    } else if (category.equals(Copies.class)) {
        return new Copies(1);
    }
    return null;
}
项目:OpenJSharp    文件:WPrinterJob.java   
private void setCollateAttrib(Attribute attr) {
    if (attr == SheetCollate.COLLATED) {
        mAttCollate = 1; // DMCOLLATE_TRUE
    } else {
        mAttCollate = 0; // DMCOLLATE_FALSE
    }
}
项目:JuggleMasterPro    文件:PrintCopiesSubJPanel.java   
final public void actionPerformed(ActionEvent e) {
    if (this.objGcollateJCheckBox.isSelected()) {
        this.objGprintJDialog.getAttributes().add(SheetCollate.COLLATED);
    } else {
        this.objGprintJDialog.getAttributes().add(SheetCollate.UNCOLLATED);
    }
}
项目:jdk8u-jdk    文件:WPrinterJob.java   
private void setCollateAttrib(Attribute attr) {
    if (attr == SheetCollate.COLLATED) {
        mAttCollate = 1; // DMCOLLATE_TRUE
    } else {
        mAttCollate = 0; // DMCOLLATE_FALSE
    }
}
项目:openjdk-jdk10    文件:WPrinterJob.java   
private void setCollateAttrib(Attribute attr) {
    if (attr == SheetCollate.COLLATED) {
        mAttCollate = 1; // DMCOLLATE_TRUE
    } else {
        mAttCollate = 0; // DMCOLLATE_FALSE
    }
}
项目:openjdk-jdk10    文件:ServiceDlgSheetCollateTest.java   
private static void printTest() {
    ServiceDlgSheetCollateTest pd = new ServiceDlgSheetCollateTest();
    DocFlavor flavor = DocFlavor.INPUT_STREAM.JPEG;
    //DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
    PrintService defService = null, service[] = null;
    defService = PrintServiceLookup.lookupDefaultPrintService();
    service = PrintServiceLookup.lookupPrintServices(flavor, null);

    if ((service == null) || (service.length == 0)) {
        throw new RuntimeException("No Printer services found");
    }
    if (defService != null) {
        System.out.println("\nDefault print service: " + service );
        System.out.println("is flavor: "+flavor+" supported? "+
                        defService.isDocFlavorSupported(flavor));
        System.out.println("is SheetCollate category supported? "+
              defService.isAttributeCategorySupported(SheetCollate.class));
        System.out.println("is SheetCollate.COLLATED value supported ? "+
              defService.isAttributeValueSupported(SheetCollate.COLLATED,
                                                        flavor, null));
    }
    HashPrintRequestAttributeSet prSet = new HashPrintRequestAttributeSet();
    try {
        PrintService selService = ServiceUI.printDialog(null, 200, 200, service, defService, flavor, prSet);
    } catch (IllegalArgumentException ia) {
        System.out.println("Exception thrown : " + ia);
    }

    System.out.println("\nSelected Values\n");
    Attribute attr[] = prSet.toArray();
    for (int x = 0; x < attr.length; x ++) {
        System.out.println("Attribute: " + attr[x].getName() + " Value: " + attr[x]);
    }

}
项目:openjdk9    文件:WPrinterJob.java   
private void setCollateAttrib(Attribute attr) {
    if (attr == SheetCollate.COLLATED) {
        mAttCollate = 1; // DMCOLLATE_TRUE
    } else {
        mAttCollate = 0; // DMCOLLATE_FALSE
    }
}
项目:jdk8u_jdk    文件:WPrinterJob.java   
private void setCollateAttrib(Attribute attr) {
    if (attr == SheetCollate.COLLATED) {
        mAttCollate = 1; // DMCOLLATE_TRUE
    } else {
        mAttCollate = 0; // DMCOLLATE_FALSE
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:WPrinterJob.java   
private void setCollateAttrib(Attribute attr) {
    if (attr == SheetCollate.COLLATED) {
        mAttCollate = 1; // DMCOLLATE_TRUE
    } else {
        mAttCollate = 0; // DMCOLLATE_FALSE
    }
}
项目:javify    文件:PrinterDialog.java   
public void stateChanged(ChangeEvent event)
{
  int value = ((Integer) copies.getValue()).intValue();
  atts.add(new Copies(value));

  if (value > 1 && categorySupported(SheetCollate.class))
    sort.setEnabled(true);
  else
    sort.setEnabled(false);
}
项目:jvm-stm    文件:PrinterDialog.java   
public void stateChanged(ChangeEvent event)
{
  int value = ((Integer) copies.getValue()).intValue();
  atts.add(new Copies(value));

  if (value > 1 && categorySupported(SheetCollate.class))
    sort.setEnabled(true);
  else
    sort.setEnabled(false);                
}
项目:infobip-open-jdk-8    文件:WPrinterJob.java   
private void setCollateAttrib(Attribute attr) {
    if (attr == SheetCollate.COLLATED) {
        mAttCollate = 1; // DMCOLLATE_TRUE
    } else {
        mAttCollate = 0; // DMCOLLATE_FALSE
    }
}
项目:jdk8u-dev-jdk    文件:WPrinterJob.java   
private void setCollateAttrib(Attribute attr) {
    if (attr == SheetCollate.COLLATED) {
        mAttCollate = 1; // DMCOLLATE_TRUE
    } else {
        mAttCollate = 0; // DMCOLLATE_FALSE
    }
}
项目:jdk7-jdk    文件:WPrinterJob.java   
private void setCollateAttrib(Attribute attr) {
    if (attr == SheetCollate.COLLATED) {
        mAttCollate = 1; // DMCOLLATE_TRUE
    } else {
        mAttCollate = 0; // DMCOLLATE_FALSE
    }
}
项目:openjdk-source-code-learn    文件:WPrinterJob.java   
private void setCollateAttrib(Attribute attr) {
    if (attr == SheetCollate.COLLATED) {
        mAttCollate = 1; // DMCOLLATE_TRUE
    } else {
        mAttCollate = 0; // DMCOLLATE_FALSE
    }
}
项目:OLD-OpenJDK8    文件:WPrinterJob.java   
private void setCollateAttrib(Attribute attr) {
    if (attr == SheetCollate.COLLATED) {
        mAttCollate = 1; // DMCOLLATE_TRUE
    } else {
        mAttCollate = 0; // DMCOLLATE_FALSE
    }
}
项目:cn1    文件:WinPrintService.java   
public Object getDefaultAttributeValue(
                final Class<? extends Attribute> category) {
    checkArgs(category, null);

    final DevmodeStructWrapper dm = getDefaultPrinterProps();

    if (JobName.class.equals(category)) {
        return DEFAULT_JOB_NAME;
    } else if (RequestingUserName.class.equals(category)) {
        return new RequestingUserName(getSystemProperty("user.name"), //$NON-NLS-1$
                        null);
    } else if (Destination.class.equals(category)) {
        File file = new File(getSystemProperty("user.dir") //$NON-NLS-1$
                        + File.separator + "output.prn"); //$NON-NLS-1$
        return new Destination(file.toURI());
    } else if (OrientationRequested.class.equals(category)) {
        return dm.getOrientation();
    } else if (Paper.class.equals(category)) {
        return getDefaultPaper();
    } else if (Media.class.equals(category)) {
        return getDefaultPaper().getSize().getMediaSizeName();
    } else if (MediaSize.class.equals(category)) {
        return getDefaultPaper().getSize();
    } else if (PrintQuality.class.equals(category)) {
        return dm.getPrintQuality();
    } else if (Sides.class.equals(category)) {
        return dm.getSides();
    } else if (Copies.class.equals(category)) {
        return dm.getCopies();
    } else if (SheetCollate.class.equals(category)) {
        return dm.getCollate();
    } else if (PrinterResolution.class.equals(category)) {
        return dm.getPrinterResolution();
    } else if (Chromaticity.class.equals(category)) {
        return dm.getChromaticity();
    }

    return null;
}
项目:cn1    文件:DevmodeStructWrapper.java   
public void setCollate(final SheetCollate collate) {
    if (SheetCollate.UNCOLLATED.equals(collate)) {
        setDmCollate(structPtr, DMCOLLATE_FALSE);
    } else if (SheetCollate.COLLATED.equals(collate)) {
        setDmCollate(structPtr, DMCOLLATE_TRUE);
    }
}
项目:cn1    文件:GDIClient.java   
public Class[] getSupportedAttributeCategories() {
    ArrayList supportedCategories = new ArrayList();
    if (getCopiesSupported(serviceName) >= 1) {
        supportedCategories.add(Copies.class);
    }
    if (getSidesSupported(serviceName)) {
        supportedCategories.add(Sides.class);
    }
    if (getSupportedMediaSizeNames() != null) {
        supportedCategories.add(Media.class);
    }
    if (getResolutionsSupported(serviceName) != null) {
        supportedCategories.add(PrinterResolution.class);
    }
    if (getOrientationSupported(serviceName)) {
        supportedCategories.add(OrientationRequested.class);
    }
    if (getCollateSupported(serviceName)) {
        supportedCategories.add(SheetCollate.class);
    }
    supportedCategories.add(Chromaticity.class);
    supportedCategories.add(JobName.class);
    supportedCategories.add(RequestingUserName.class);
    supportedCategories.add(Destination.class);

    Class[] categories = new Class[supportedCategories.size()];
    supportedCategories.toArray(categories);
    return categories;
}
项目:cn1    文件:ServiceUIDialog.java   
void fillCollateBox() {
    boolean isSupported = 
        myService.isAttributeCategorySupported(SheetCollate.class);
    SheetCollate [] supported = (SheetCollate []) (myService
            .getSupportedAttributeValues(SheetCollate.class, flavor, attrs));
    Attribute attr = attrs.get(SheetCollate.class);
    int spinnerValue = ((Integer) cpSpinner.getValue()).intValue();

    if ((supported == null) || !isSupported) {
        if (attrs.containsKey(SheetCollate.class)) {
            collateBox.setSelected(attr.equals(SheetCollate.COLLATED));
        }
    } else {
        boolean isValueSupported = myService.isAttributeValueSupported(
                SheetCollate.COLLATED, flavor, attrs);
        if (attrs.containsKey(SheetCollate.class) && isValueSupported) {
            collateBox.setSelected(attr.equals(SheetCollate.COLLATED)); 
        } else {
            Object defaul = 
                    myService.getDefaultAttributeValue(SheetCollate.class);
            collateBox.setSelected(defaul != null
                    ? defaul.equals(SheetCollate.COLLATED)
                    : true);
        }
    }

    collateBox.setEnabled(isSupported 
                       && (spinnerValue > 1)
                       && (!(supported == null || supported.length <= 1)));
}
项目:cn1    文件:ServiceUIDialog.java   
private void updateCollate() {
    if (collateBox.isEnabled()) {
        newAttrs.add(collateBox.isSelected() 
                ? SheetCollate.COLLATED 
                : SheetCollate.UNCOLLATED);
    } else {
        removeAttribute(SheetCollate.class);
    }
}
项目:JamVM-PH    文件:PrinterDialog.java   
public void stateChanged(ChangeEvent event)
{
  int value = ((Integer) copies.getValue()).intValue();
  atts.add(new Copies(value));

  if (value > 1 && categorySupported(SheetCollate.class))
    sort.setEnabled(true);
  else
    sort.setEnabled(false);                
}
项目:openjdk-jdk7u-jdk    文件:WPrinterJob.java   
private void setCollateAttrib(Attribute attr) {
    if (attr == SheetCollate.COLLATED) {
        mAttCollate = 1; // DMCOLLATE_TRUE
    } else {
        mAttCollate = 0; // DMCOLLATE_FALSE
    }
}
项目:classpath    文件:PrinterDialog.java   
public void stateChanged(ChangeEvent event)
{
  int value = ((Integer) copies.getValue()).intValue();
  atts.add(new Copies(value));

  if (value > 1 && categorySupported(SheetCollate.class))
    sort.setEnabled(true);
  else
    sort.setEnabled(false);
}
项目:freeVM    文件:GDIClient.java   
public Class[] getSupportedAttributeCategories() {
    ArrayList supportedCategories = new ArrayList();
    if (getCopiesSupported(serviceName) >= 1) {
        supportedCategories.add(Copies.class);
    }
    if (getSidesSupported(serviceName)) {
        supportedCategories.add(Sides.class);
    }
    if (getSupportedMediaSizeNames() != null) {
        supportedCategories.add(Media.class);
    }
    if (getResolutionsSupported(serviceName) != null) {
        supportedCategories.add(PrinterResolution.class);
    }
    if (getOrientationSupported(serviceName)) {
        supportedCategories.add(OrientationRequested.class);
    }
    if (getCollateSupported(serviceName)) {
        supportedCategories.add(SheetCollate.class);
    }
    supportedCategories.add(Chromaticity.class);
    supportedCategories.add(JobName.class);
    supportedCategories.add(RequestingUserName.class);
    supportedCategories.add(Destination.class);

    Class[] categories = new Class[supportedCategories.size()];
    supportedCategories.toArray(categories);
    return categories;
}
项目:freeVM    文件:ServiceUIDialog.java   
void fillCollateBox() {
    boolean isSupported = 
        myService.isAttributeCategorySupported(SheetCollate.class);
    SheetCollate [] supported = (SheetCollate []) (myService
            .getSupportedAttributeValues(SheetCollate.class, flavor, attrs));
    Attribute attr = attrs.get(SheetCollate.class);
    int spinnerValue = ((Integer) cpSpinner.getValue()).intValue();

    if ((supported == null) || !isSupported) {
        if (attrs.containsKey(SheetCollate.class)) {
            collateBox.setSelected(attr.equals(SheetCollate.COLLATED));
        }
    } else {
        boolean isValueSupported = myService.isAttributeValueSupported(
                SheetCollate.COLLATED, flavor, attrs);
        if (attrs.containsKey(SheetCollate.class) && isValueSupported) {
            collateBox.setSelected(attr.equals(SheetCollate.COLLATED)); 
        } else {
            Object defaul = 
                    myService.getDefaultAttributeValue(SheetCollate.class);
            collateBox.setSelected(defaul != null
                    ? defaul.equals(SheetCollate.COLLATED)
                    : true);
        }
    }

    collateBox.setEnabled(isSupported 
                       && (spinnerValue > 1)
                       && (!(supported == null || supported.length <= 1)));
}
项目:freeVM    文件:ServiceUIDialog.java   
private void updateCollate() {
    if (collateBox.isEnabled()) {
        newAttrs.add(collateBox.isSelected() 
                ? SheetCollate.COLLATED 
                : SheetCollate.UNCOLLATED);
    } else {
        removeAttribute(SheetCollate.class);
    }
}
项目:freeVM    文件:WinPrintService.java   
public Object getDefaultAttributeValue(
                final Class<? extends Attribute> category) {
    checkArgs(category, null);

    final DevmodeStructWrapper dm = getDefaultPrinterProps();

    if (JobName.class.equals(category)) {
        return DEFAULT_JOB_NAME;
    } else if (RequestingUserName.class.equals(category)) {
        return new RequestingUserName(getSystemProperty("user.name"), //$NON-NLS-1$
                        null);
    } else if (Destination.class.equals(category)) {
        File file = new File(getSystemProperty("user.dir") //$NON-NLS-1$
                        + File.separator + "output.prn"); //$NON-NLS-1$
        return new Destination(file.toURI());
    } else if (OrientationRequested.class.equals(category)) {
        return dm.getOrientation();
    } else if (Paper.class.equals(category)) {
        return getDefaultPaper();
    } else if (Media.class.equals(category)) {
        return getDefaultPaper().getSize().getMediaSizeName();
    } else if (MediaSize.class.equals(category)) {
        return getDefaultPaper().getSize();
    } else if (PrintQuality.class.equals(category)) {
        return dm.getPrintQuality();
    } else if (Sides.class.equals(category)) {
        return dm.getSides();
    } else if (Copies.class.equals(category)) {
        return dm.getCopies();
    } else if (SheetCollate.class.equals(category)) {
        return dm.getCollate();
    } else if (PrinterResolution.class.equals(category)) {
        return dm.getPrinterResolution();
    } else if (Chromaticity.class.equals(category)) {
        return dm.getChromaticity();
    }

    return null;
}
项目:freeVM    文件:DevmodeStructWrapper.java   
public void setCollate(final SheetCollate collate) {
    if (SheetCollate.UNCOLLATED.equals(collate)) {
        setDmCollate(structPtr, DMCOLLATE_FALSE);
    } else if (SheetCollate.COLLATED.equals(collate)) {
        setDmCollate(structPtr, DMCOLLATE_TRUE);
    }
}
项目:freeVM    文件:GDIClient.java   
public Class[] getSupportedAttributeCategories() {
    ArrayList supportedCategories = new ArrayList();
    if (getCopiesSupported(serviceName) >= 1) {
        supportedCategories.add(Copies.class);
    }
    if (getSidesSupported(serviceName)) {
        supportedCategories.add(Sides.class);
    }
    if (getSupportedMediaSizeNames() != null) {
        supportedCategories.add(Media.class);
    }
    if (getResolutionsSupported(serviceName) != null) {
        supportedCategories.add(PrinterResolution.class);
    }
    if (getOrientationSupported(serviceName)) {
        supportedCategories.add(OrientationRequested.class);
    }
    if (getCollateSupported(serviceName)) {
        supportedCategories.add(SheetCollate.class);
    }
    supportedCategories.add(Chromaticity.class);
    supportedCategories.add(JobName.class);
    supportedCategories.add(RequestingUserName.class);
    supportedCategories.add(Destination.class);

    Class[] categories = new Class[supportedCategories.size()];
    supportedCategories.toArray(categories);
    return categories;
}
项目:freeVM    文件:ServiceUIDialog.java   
void fillCollateBox() {
    boolean isSupported = 
        myService.isAttributeCategorySupported(SheetCollate.class);
    SheetCollate [] supported = (SheetCollate []) (myService
            .getSupportedAttributeValues(SheetCollate.class, flavor, attrs));
    Attribute attr = attrs.get(SheetCollate.class);
    int spinnerValue = ((Integer) cpSpinner.getValue()).intValue();

    if ((supported == null) || !isSupported) {
        if (attrs.containsKey(SheetCollate.class)) {
            collateBox.setSelected(attr.equals(SheetCollate.COLLATED));
        }
    } else {
        boolean isValueSupported = myService.isAttributeValueSupported(
                SheetCollate.COLLATED, flavor, attrs);
        if (attrs.containsKey(SheetCollate.class) && isValueSupported) {
            collateBox.setSelected(attr.equals(SheetCollate.COLLATED)); 
        } else {
            Object defaul = 
                    myService.getDefaultAttributeValue(SheetCollate.class);
            collateBox.setSelected(defaul != null
                    ? defaul.equals(SheetCollate.COLLATED)
                    : true);
        }
    }

    collateBox.setEnabled(isSupported 
                       && (spinnerValue > 1)
                       && (!(supported == null || supported.length <= 1)));
}
项目:freeVM    文件:ServiceUIDialog.java   
private void updateCollate() {
    if (collateBox.isEnabled()) {
        newAttrs.add(collateBox.isSelected() 
                ? SheetCollate.COLLATED 
                : SheetCollate.UNCOLLATED);
    } else {
        removeAttribute(SheetCollate.class);
    }
}
项目:openjdk-icedtea7    文件:WPrinterJob.java   
private void setCollateAttrib(Attribute attr) {
    if (attr == SheetCollate.COLLATED) {
        mAttCollate = 1; // DMCOLLATE_TRUE
    } else {
        mAttCollate = 0; // DMCOLLATE_FALSE
    }
}
项目:OpenJSharp    文件:PSStreamPrintService.java   
public boolean isAttributeValueSupported(Attribute attr,
                                         DocFlavor flavor,
                                         AttributeSet attributes) {
    if (attr == null) {
        throw new NullPointerException("null attribute");
    }
    if (flavor != null && !isDocFlavorSupported(flavor)) {
        throw new IllegalArgumentException(flavor +
                                           " is an unsupported flavor");
    }
    Class category = attr.getCategory();
    if (!isAttributeCategorySupported(category)) {
        return false;
    }
    else if (attr.getCategory() == Chromaticity.class) {
        return attr == Chromaticity.COLOR;
    }
    else if (attr.getCategory() == Copies.class) {
        return isSupportedCopies((Copies)attr);
    } else if (attr.getCategory() == Media.class &&
               attr instanceof MediaSizeName) {
        return isSupportedMedia((MediaSizeName)attr);
    } else if (attr.getCategory() == OrientationRequested.class) {
        if (attr == OrientationRequested.REVERSE_PORTRAIT ||
            (flavor != null) &&
            !(flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) ||
            flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE))) {
            return false;
        }
    } else if (attr.getCategory() == PageRanges.class) {
        if (flavor != null &&
            !(flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) ||
            flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE))) {
            return false;
        }
    } else if (attr.getCategory() == SheetCollate.class) {
        if (flavor != null &&
            !(flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) ||
            flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE))) {
            return false;
        }
    } else if (attr.getCategory() == Sides.class) {
        if (flavor != null &&
            !(flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) ||
            flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE))) {
            return false;
        }
    }
    return true;
}
项目:OpenJSharp    文件:WPrinterJob.java   
/**
 * copy the attributes to the native print job
 * Note that this method, and hence the re-initialisation
 * of the GDI values is done on each entry to the print dialog since
 * an app could redisplay the print dialog for the same job and
 * 1) the application may have changed attribute settings
 * 2) the application may have changed the printer.
 * In the event that the user changes the printer using the
  dialog, then it is up to GDI to report back all changed values.
 */
@Override
protected void setAttributes(PrintRequestAttributeSet attributes)
    throws PrinterException {

    // initialize attribute values
    initAttributeMembers();
    super.setAttributes(attributes);

    mAttCopies = getCopiesInt();
    mDestination = destinationAttr;

    if (attributes == null) {
        return; // now always use attributes, so this shouldn't happen.
    }
    Attribute[] attrs = attributes.toArray();
    for (int i=0; i< attrs.length; i++) {
        Attribute attr = attrs[i];
        try {
             if (attr.getCategory() == Sides.class) {
                setSidesAttrib(attr);
            }
            else if (attr.getCategory() == Chromaticity.class) {
                setColorAttrib(attr);
            }
            else if (attr.getCategory() == PrinterResolution.class) {
                setResolutionAttrib(attr);
            }
            else if (attr.getCategory() == PrintQuality.class) {
                setQualityAttrib(attr);
            }
            else if (attr.getCategory() == SheetCollate.class) {
                setCollateAttrib(attr);
            }  else if (attr.getCategory() == Media.class ||
                        attr.getCategory() == SunAlternateMedia.class) {
                /* SunAlternateMedia is used if its a tray, and
                 * any Media that is specified is not a tray.
                 */
                if (attr.getCategory() == SunAlternateMedia.class) {
                    Media media = (Media)attributes.get(Media.class);
                    if (media == null ||
                        !(media instanceof MediaTray)) {
                        attr = ((SunAlternateMedia)attr).getMedia();
                    }
                }
                if (attr instanceof MediaSizeName) {
                    setWin32MediaAttrib(attr);
                }
                if (attr instanceof MediaTray) {
                    setMediaTrayAttrib(attr);
                }
            }

        } catch (ClassCastException e) {
        }
    }
}
项目:OpenJSharp    文件:WPrinterJob.java   
private final void setNativeAttributes(int flags, int fields, int values) {
    if (attributes == null) {
        return;
    }
    if ((flags & PD_PRINTTOFILE) != 0) {
        Destination destPrn = (Destination)attributes.get(
                                             Destination.class);
        if (destPrn == null) {
            try {
                attributes.add(new Destination(
                                           new File("./out.prn").toURI()));
            } catch (SecurityException se) {
                try {
                    attributes.add(new Destination(
                                            new URI("file:out.prn")));
                } catch (URISyntaxException e) {
                }
            }
        }
    } else {
        attributes.remove(Destination.class);
    }

    if ((flags & PD_COLLATE) != 0) {
        setCollateAttrib(SheetCollate.COLLATED, attributes);
    } else {
        setCollateAttrib(SheetCollate.UNCOLLATED, attributes);
    }

    if ((flags & PD_PAGENUMS) != 0) {
        attributes.add(SunPageSelection.RANGE);
    } else if ((flags & PD_SELECTION) != 0) {
        attributes.add(SunPageSelection.SELECTION);
    } else {
        attributes.add(SunPageSelection.ALL);
    }

    if ((fields & DM_ORIENTATION) != 0) {
        if ((values & SET_ORIENTATION) != 0) {
            setOrientAttrib(OrientationRequested.LANDSCAPE, attributes);
        } else {
            setOrientAttrib(OrientationRequested.PORTRAIT, attributes);
        }
    }

    if ((fields & DM_COLOR) != 0) {
        if ((values & SET_COLOR) != 0) {
            setColorAttrib(Chromaticity.COLOR, attributes);
        } else {
            setColorAttrib(Chromaticity.MONOCHROME, attributes);
        }
    }

    if ((fields & DM_PRINTQUALITY) != 0) {
        PrintQuality quality;
        if ((values & SET_RES_LOW) != 0) {
            quality = PrintQuality.DRAFT;
        } else if ((fields & SET_RES_HIGH) != 0) {
            quality = PrintQuality.HIGH;
        } else {
            quality = PrintQuality.NORMAL;
        }
        setQualityAttrib(quality, attributes);
    }

    if ((fields & DM_DUPLEX) != 0) {
        Sides sides;
        if ((values & SET_DUP_VERTICAL) != 0) {
            sides = Sides.TWO_SIDED_LONG_EDGE;
        } else if ((values & SET_DUP_HORIZONTAL) != 0) {
            sides = Sides.TWO_SIDED_SHORT_EDGE;
        } else {
            sides = Sides.ONE_SIDED;
        }
        setSidesAttrib(sides, attributes);
    }
}