本文整理汇总了Java中javax.print.attribute.Attribute.getCategory方法的典型用法代码示例。如果您正苦于以下问题:Java Attribute.getCategory方法的具体用法?Java Attribute.getCategory怎么用?Java Attribute.getCategory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.print.attribute.Attribute
的用法示例。
在下文中一共展示了Attribute.getCategory方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeUnsupportedAttributes
import javax.print.attribute.Attribute; //导入方法依赖的package包/类
final private void removeUnsupportedAttributes() {
final javax.print.attribute.AttributeSet objLunsupportedAttributeSet =
this.objGprintService.getUnsupportedAttributes( null,
this.objGhashPrintRequestAttributeSet);
if (objLunsupportedAttributeSet != null) {
final Attribute[] objLattributeA = objLunsupportedAttributeSet.toArray();
for (final Attribute objLattribute : objLattributeA) {
final Class<? extends Attribute> objLcategoryClass = objLattribute.getCategory();
if (this.objGprintService.isAttributeCategorySupported(objLcategoryClass)) {
final Attribute objLdefaultAttribute = (Attribute) this.objGprintService.getDefaultAttributeValue(objLcategoryClass);
if (objLdefaultAttribute != null) {
this.objGhashPrintRequestAttributeSet.add(objLdefaultAttribute);
} else {
this.objGhashPrintRequestAttributeSet.remove(objLcategoryClass);
}
} else {
this.objGhashPrintRequestAttributeSet.remove(objLcategoryClass);
}
}
}
}
示例2: getAttributeValues
import javax.print.attribute.Attribute; //导入方法依赖的package包/类
private void getAttributeValues(DocFlavor flavor) throws PrintException {
Attribute attr;
Class category;
if (reqAttrSet.get(Fidelity.class) == Fidelity.FIDELITY_TRUE) {
fidelity = true;
} else {
fidelity = false;
}
Attribute []attrs = reqAttrSet.toArray();
for (int i=0; i<attrs.length; i++) {
attr = attrs[i];
category = attr.getCategory();
if (fidelity == true) {
if (!service.isAttributeCategorySupported(category)) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintJobAttributeException(
"unsupported category: " + category, category, null);
} else if
(!service.isAttributeValueSupported(attr, flavor, null)) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintJobAttributeException(
"unsupported attribute: " + attr, null, attr);
}
}
if (category == JobName.class) {
jobName = ((JobName)attr).getValue();
} else if (category == Copies.class) {
copies = ((Copies)attr).getValue();
} else if (category == Media.class) {
if (attr instanceof MediaSizeName &&
service.isAttributeValueSupported(attr, null, null)) {
mediaSize =
MediaSize.getMediaSizeForName((MediaSizeName)attr);
}
} else if (category == OrientationRequested.class) {
orient = (OrientationRequested)attr;
}
}
}
示例3: isAttributeValueSupported
import javax.print.attribute.Attribute; //导入方法依赖的package包/类
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;
}
示例4: getAttributeValues
import javax.print.attribute.Attribute; //导入方法依赖的package包/类
private void getAttributeValues(DocFlavor flavor) throws PrintException {
if (reqAttrSet.get(Fidelity.class) == Fidelity.FIDELITY_TRUE) {
fidelity = true;
} else {
fidelity = false;
}
Class category;
Attribute [] attrs = reqAttrSet.toArray();
for (int i=0; i<attrs.length; i++) {
Attribute attr = attrs[i];
category = attr.getCategory();
if (fidelity == true) {
if (!service.isAttributeCategorySupported(category)) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintJobAttributeException(
"unsupported category: " + category, category, null);
} else if
(!service.isAttributeValueSupported(attr, flavor, null)) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintJobAttributeException(
"unsupported attribute: " + attr, null, attr);
}
}
if (category == Destination.class) {
URI uri = ((Destination)attr).getURI();
if (!"file".equals(uri.getScheme())) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintException("Not a file: URI");
} else {
try {
mDestination = (new File(uri)).getPath();
} catch (Exception e) {
throw new PrintException(e);
}
// check write access
SecurityManager security = System.getSecurityManager();
if (security != null) {
try {
security.checkWrite(mDestination);
} catch (SecurityException se) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintException(se);
}
}
}
} else if (category == JobName.class) {
jobName = ((JobName)attr).getValue();
} else if (category == Copies.class) {
copies = ((Copies)attr).getValue();
} else if (category == Media.class) {
if (attr instanceof MediaSizeName) {
mediaName = (MediaSizeName)attr;
// If requested MediaSizeName is not supported,
// get the corresponding media size - this will
// be used to create a new PageFormat.
if (!service.isAttributeValueSupported(attr, null, null)) {
mediaSize = MediaSize.getMediaSizeForName(mediaName);
}
}
} else if (category == OrientationRequested.class) {
orient = (OrientationRequested)attr;
}
}
}
示例5: setAttributes
import javax.print.attribute.Attribute; //导入方法依赖的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) {
}
}
}
示例6: getAttributeValues
import javax.print.attribute.Attribute; //导入方法依赖的package包/类
private void getAttributeValues(DocFlavor flavor) throws PrintException {
Attribute attr;
Class category;
if (reqAttrSet.get(Fidelity.class) == Fidelity.FIDELITY_TRUE) {
fidelity = true;
} else {
fidelity = false;
}
Attribute []attrs = reqAttrSet.toArray();
for (int i=0; i<attrs.length; i++) {
attr = attrs[i];
category = attr.getCategory();
if (fidelity == true) {
if (!service.isAttributeCategorySupported(category)) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintJobAttributeException(
"unsupported category: " + category, category, null);
} else if
(!service.isAttributeValueSupported(attr, flavor, null)) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintJobAttributeException(
"unsupported attribute: " + attr, null, attr);
}
}
if (category == Destination.class) {
URI uri = ((Destination)attr).getURI();
if (!"file".equals(uri.getScheme())) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintException("Not a file: URI");
} else {
try {
mDestType = DESTFILE;
mDestination = (new File(uri)).getPath();
} catch (Exception e) {
throw new PrintException(e);
}
// check write access
SecurityManager security = System.getSecurityManager();
if (security != null) {
try {
security.checkWrite(mDestination);
} catch (SecurityException se) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintException(se);
}
}
}
} else if (category == JobSheets.class) {
if ((JobSheets)attr == JobSheets.NONE) {
mNoJobSheet = true;
}
} else if (category == JobName.class) {
jobName = ((JobName)attr).getValue();
} else if (category == Copies.class) {
copies = ((Copies)attr).getValue();
} else if (category == Media.class) {
if (attr instanceof MediaSizeName) {
mediaName = (MediaSizeName)attr;
IPPPrintService.debug_println(debugPrefix+
"mediaName "+mediaName);
if (!service.isAttributeValueSupported(attr, null, null)) {
mediaSize = MediaSize.getMediaSizeForName(mediaName);
}
} else if (attr instanceof CustomMediaTray) {
customTray = (CustomMediaTray)attr;
}
} else if (category == OrientationRequested.class) {
orient = (OrientationRequested)attr;
} else if (category == NumberUp.class) {
nUp = (NumberUp)attr;
} else if (category == Sides.class) {
sides = (Sides)attr;
}
}
}
示例7: isAttributeValueSupported
import javax.print.attribute.Attribute; //导入方法依赖的package包/类
public boolean isAttributeValueSupported(Attribute attr,
DocFlavor flavor,
AttributeSet attributes) {
if (attr == null) {
throw new NullPointerException("null attribute");
}
if (flavor != null) {
if (!isDocFlavorSupported(flavor)) {
throw new IllegalArgumentException(flavor +
" is an unsupported flavor");
} else if (isAutoSense(flavor)) {
return false;
}
}
Class category = attr.getCategory();
if (!isAttributeCategorySupported(category)) {
return false;
}
else if (attr.getCategory() == Chromaticity.class) {
if (flavor == null || isServiceFormattedFlavor(flavor)) {
return attr == Chromaticity.COLOR;
} else {
return false;
}
}
else if (attr.getCategory() == Copies.class) {
return (flavor == null ||
!(flavor.equals(DocFlavor.INPUT_STREAM.POSTSCRIPT) ||
flavor.equals(DocFlavor.URL.POSTSCRIPT) ||
flavor.equals(DocFlavor.BYTE_ARRAY.POSTSCRIPT))) &&
isSupportedCopies((Copies)attr);
} else if (attr.getCategory() == Destination.class) {
URI uri = ((Destination)attr).getURI();
if ("file".equals(uri.getScheme()) &&
!(uri.getSchemeSpecificPart().equals(""))) {
return true;
} else {
return false;
}
} else if (attr.getCategory() == Media.class) {
if (attr instanceof MediaSizeName) {
return isSupportedMedia((MediaSizeName)attr);
} else {
return false;
}
} else if (attr.getCategory() == OrientationRequested.class) {
if (attr == OrientationRequested.REVERSE_PORTRAIT ||
(flavor != null) &&
!isServiceFormattedFlavor(flavor)) {
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;
}
示例8: getAttributeValues
import javax.print.attribute.Attribute; //导入方法依赖的package包/类
private void getAttributeValues(DocFlavor flavor) throws PrintException {
if (reqAttrSet.get(Fidelity.class) == Fidelity.FIDELITY_TRUE) {
fidelity = true;
} else {
fidelity = false;
}
Attribute chroma = reqAttrSet.get( Chromaticity.class );
// TODO check whether supported by the print service
printColor = chroma == Chromaticity.COLOR;
Attribute newTray = reqAttrSet.get( Media.class );
if( newTray instanceof MediaTray ){
mediaTray = (MediaTray)newTray;
}
// TODO check whether supported by the print service
Class category;
Attribute [] attrs = reqAttrSet.toArray();
for (int i=0; i<attrs.length; i++) {
Attribute attr = attrs[i];
category = attr.getCategory();
if (fidelity == true) {
if (!service.isAttributeCategorySupported(category)) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintJobAttributeException(
"unsupported category: " + category, category, null);
} else if
(!service.isAttributeValueSupported(attr, flavor, null)) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintJobAttributeException(
"unsupported attribute: " + attr, null, attr);
}
}
if (category == Destination.class) {
URI uri = ((Destination)attr).getURI();
if (!"file".equals(uri.getScheme())) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintException("Not a file: URI");
} else {
try {
mDestination = (new File(uri)).getPath();
} catch (Exception e) {
throw new PrintException(e);
}
// check write access
SecurityManager security = System.getSecurityManager();
if (security != null) {
try {
security.checkWrite(mDestination);
} catch (SecurityException se) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintException(se);
}
}
}
} else if (category == JobName.class) {
jobName = ((JobName)attr).getValue();
} else if (category == Copies.class) {
copies = ((Copies)attr).getValue();
} else if (category == Media.class) {
if (attr instanceof MediaSizeName) {
mediaName = (MediaSizeName)attr;
// If requested MediaSizeName is not supported,
// get the corresponding media size - this will
// be used to create a new PageFormat.
if (!service.isAttributeValueSupported(attr, flavor, null)) {
mediaSize = MediaSize.getMediaSizeForName(mediaName);
}
}
} else if (category == OrientationRequested.class) {
orient = (OrientationRequested)attr;
}
}
}
示例9: getAttributeValues
import javax.print.attribute.Attribute; //导入方法依赖的package包/类
private void getAttributeValues(DocFlavor flavor) throws PrintException {
Attribute attr;
Class<? extends Attribute> category;
if (reqAttrSet.get(Fidelity.class) == Fidelity.FIDELITY_TRUE) {
fidelity = true;
} else {
fidelity = false;
}
Attribute []attrs = reqAttrSet.toArray();
for (int i=0; i<attrs.length; i++) {
attr = attrs[i];
category = attr.getCategory();
if (fidelity == true) {
if (!service.isAttributeCategorySupported(category)) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintJobAttributeException(
"unsupported category: " + category, category, null);
} else if
(!service.isAttributeValueSupported(attr, flavor, null)) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintJobAttributeException(
"unsupported attribute: " + attr, null, attr);
}
}
if (category == JobName.class) {
jobName = ((JobName)attr).getValue();
} else if (category == Copies.class) {
copies = ((Copies)attr).getValue();
} else if (category == Media.class) {
if (attr instanceof MediaSizeName &&
service.isAttributeValueSupported(attr, null, null)) {
mediaSize =
MediaSize.getMediaSizeForName((MediaSizeName)attr);
}
} else if (category == OrientationRequested.class) {
orient = (OrientationRequested)attr;
}
}
}
示例10: isAttributeValueSupported
import javax.print.attribute.Attribute; //导入方法依赖的package包/类
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<? extends Attribute> 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;
}
示例11: getAttributeValues
import javax.print.attribute.Attribute; //导入方法依赖的package包/类
private void getAttributeValues(DocFlavor flavor) throws PrintException {
Attribute attr;
Class<? extends Attribute> category;
if (reqAttrSet.get(Fidelity.class) == Fidelity.FIDELITY_TRUE) {
fidelity = true;
} else {
fidelity = false;
}
Attribute []attrs = reqAttrSet.toArray();
for (int i=0; i<attrs.length; i++) {
attr = attrs[i];
category = attr.getCategory();
if (fidelity == true) {
if (!service.isAttributeCategorySupported(category)) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintJobAttributeException(
"unsupported category: " + category, category, null);
} else if
(!service.isAttributeValueSupported(attr, flavor, null)) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintJobAttributeException(
"unsupported attribute: " + attr, null, attr);
}
}
if (category == Destination.class) {
URI uri = ((Destination)attr).getURI();
if (!"file".equals(uri.getScheme())) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintException("Not a file: URI");
} else {
try {
mDestType = DESTFILE;
mDestination = (new File(uri)).getPath();
} catch (Exception e) {
throw new PrintException(e);
}
// check write access
SecurityManager security = System.getSecurityManager();
if (security != null) {
try {
security.checkWrite(mDestination);
} catch (SecurityException se) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintException(se);
}
}
}
} else if (category == JobSheets.class) {
if ((JobSheets)attr == JobSheets.NONE) {
mNoJobSheet = true;
}
} else if (category == JobName.class) {
jobName = ((JobName)attr).getValue();
} else if (category == Copies.class) {
copies = ((Copies)attr).getValue();
} else if (category == Media.class) {
if (attr instanceof MediaSizeName) {
mediaName = (MediaSizeName)attr;
IPPPrintService.debug_println(debugPrefix+
"mediaName "+mediaName);
if (!service.isAttributeValueSupported(attr, null, null)) {
mediaSize = MediaSize.getMediaSizeForName(mediaName);
}
} else if (attr instanceof CustomMediaTray) {
customTray = (CustomMediaTray)attr;
}
} else if (category == OrientationRequested.class) {
orient = (OrientationRequested)attr;
} else if (category == NumberUp.class) {
nUp = (NumberUp)attr;
} else if (category == Sides.class) {
sides = (Sides)attr;
}
}
}
示例12: isAttributeValueSupported
import javax.print.attribute.Attribute; //导入方法依赖的package包/类
public boolean isAttributeValueSupported(Attribute attr,
DocFlavor flavor,
AttributeSet attributes) {
if (attr == null) {
throw new NullPointerException("null attribute");
}
if (flavor != null) {
if (!isDocFlavorSupported(flavor)) {
throw new IllegalArgumentException(flavor +
" is an unsupported flavor");
} else if (isAutoSense(flavor)) {
return false;
}
}
Class<? extends Attribute> category = attr.getCategory();
if (!isAttributeCategorySupported(category)) {
return false;
}
else if (attr.getCategory() == Chromaticity.class) {
if (flavor == null || isServiceFormattedFlavor(flavor)) {
return attr == Chromaticity.COLOR;
} else {
return false;
}
}
else if (attr.getCategory() == Copies.class) {
return (flavor == null ||
!(flavor.equals(DocFlavor.INPUT_STREAM.POSTSCRIPT) ||
flavor.equals(DocFlavor.URL.POSTSCRIPT) ||
flavor.equals(DocFlavor.BYTE_ARRAY.POSTSCRIPT))) &&
isSupportedCopies((Copies)attr);
} else if (attr.getCategory() == Destination.class) {
URI uri = ((Destination)attr).getURI();
if ("file".equals(uri.getScheme()) &&
!(uri.getSchemeSpecificPart().equals(""))) {
return true;
} else {
return false;
}
} else if (attr.getCategory() == Media.class) {
if (attr instanceof MediaSizeName) {
return isSupportedMedia((MediaSizeName)attr);
} else {
return false;
}
} else if (attr.getCategory() == OrientationRequested.class) {
if (attr == OrientationRequested.REVERSE_PORTRAIT ||
(flavor != null) &&
!isServiceFormattedFlavor(flavor)) {
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;
}
示例13: getAttributeValues
import javax.print.attribute.Attribute; //导入方法依赖的package包/类
private void getAttributeValues(DocFlavor flavor) throws PrintException {
if (reqAttrSet.get(Fidelity.class) == Fidelity.FIDELITY_TRUE) {
fidelity = true;
} else {
fidelity = false;
}
Class<? extends Attribute> category;
Attribute [] attrs = reqAttrSet.toArray();
for (int i=0; i<attrs.length; i++) {
Attribute attr = attrs[i];
category = attr.getCategory();
if (fidelity == true) {
if (!service.isAttributeCategorySupported(category)) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintJobAttributeException(
"unsupported category: " + category, category, null);
} else if
(!service.isAttributeValueSupported(attr, flavor, null)) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintJobAttributeException(
"unsupported attribute: " + attr, null, attr);
}
}
if (category == Destination.class) {
URI uri = ((Destination)attr).getURI();
if (!"file".equals(uri.getScheme())) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintException("Not a file: URI");
} else {
try {
mDestination = (new File(uri)).getPath();
} catch (Exception e) {
throw new PrintException(e);
}
// check write access
SecurityManager security = System.getSecurityManager();
if (security != null) {
try {
security.checkWrite(mDestination);
} catch (SecurityException se) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintException(se);
}
}
}
} else if (category == JobName.class) {
jobName = ((JobName)attr).getValue();
} else if (category == Copies.class) {
copies = ((Copies)attr).getValue();
} else if (category == Media.class) {
if (attr instanceof MediaSizeName) {
mediaName = (MediaSizeName)attr;
// If requested MediaSizeName is not supported,
// get the corresponding media size - this will
// be used to create a new PageFormat.
if (!service.isAttributeValueSupported(attr, null, null)) {
mediaSize = MediaSize.getMediaSizeForName(mediaName);
}
}
} else if (category == OrientationRequested.class) {
orient = (OrientationRequested)attr;
}
}
}
示例14: setAttributes
import javax.print.attribute.Attribute; //导入方法依赖的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) {
}
}
}