本文整理汇总了Java中javax.print.attribute.PrintRequestAttributeSet.toArray方法的典型用法代码示例。如果您正苦于以下问题:Java PrintRequestAttributeSet.toArray方法的具体用法?Java PrintRequestAttributeSet.toArray怎么用?Java PrintRequestAttributeSet.toArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.print.attribute.PrintRequestAttributeSet
的用法示例。
在下文中一共展示了PrintRequestAttributeSet.toArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setAttributes
import javax.print.attribute.PrintRequestAttributeSet; //导入方法依赖的package包/类
/**
* 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) {
}
}
}
示例2: setAttributes
import javax.print.attribute.PrintRequestAttributeSet; //导入方法依赖的package包/类
/**
* 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) {
if (myService.isAttributeValueSupported(attr, null, null)) {
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) {
}
}
}