if (attributes == null) {
return;
}
Attribute attr;
Attribute[] attrs = attributes.toArray();
for (int i=0; i<attrs.length; i++) {
try {
attr = attrs[i];
if (attr.getCategory()==Sides.class) {
if (attr.equals(Sides.TWO_SIDED_LONG_EDGE)) {
mAttSides = 2; // DMDUP_VERTICAL
} else if (attr.equals(Sides.TWO_SIDED_SHORT_EDGE)) {
mAttSides = 3; // DMDUP_HORIZONTAL
} else { // Sides.ONE_SIDED
mAttSides = 1;
}
}
else if (attr.getCategory()==Chromaticity.class) {
if (attr.equals(Chromaticity.COLOR)) {
mAttChromaticity = 2; // DMCOLOR_COLOR
} else {
mAttChromaticity = 1; // DMCOLOR_MONOCHROME
}
}
else if (attr.getCategory()==PrinterResolution.class) {
PrinterResolution pr = (PrinterResolution)attr;
mAttXRes = pr.getCrossFeedResolution(PrinterResolution.DPI);
mAttYRes = pr.getFeedResolution(PrinterResolution.DPI);
}
else if (attr.getCategory()==PrintQuality.class) {
if (attr.equals(PrintQuality.HIGH)) {
mAttQuality = -4; // DMRES_HIGH
} else if (attr.equals(PrintQuality.NORMAL)) {
mAttQuality = -3; // DMRES_MEDIUM
} else {
mAttQuality = -2; // DMRES_LOW
}
}
else if (attr.getCategory()==SheetCollate.class) {
if (attr.equals(SheetCollate.COLLATED)) {
mAttCollate = 1; // DMCOLLATE_TRUE
} else {
mAttCollate = 0; // DMCOLLATE_FALSE
}
} 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) {
// Note: Nothing to do here.
}
if (attr instanceof MediaTray) {
if (attr.equals(MediaTray.BOTTOM)) {
mAttMediaTray = 2; // DMBIN_LOWER
} else if (attr.equals(MediaTray.ENVELOPE)) {
mAttMediaTray = 5; // DMBIN_ENVELOPE
} else if (attr.equals(MediaTray.LARGE_CAPACITY)) {
mAttMediaTray = 11; // DMBIN_LARGECAPACITY
} else if (attr.equals(MediaTray.MAIN)) {
mAttMediaTray =1; // DMBIN_UPPER
} else if (attr.equals(MediaTray.MANUAL)) {
mAttMediaTray = 4; // DMBIN_MANUAL
} else if (attr.equals(MediaTray.MIDDLE)) {
mAttMediaTray = 3; // DMBIN_MIDDLE
} else if (attr.equals(MediaTray.SIDE)) {
// no equivalent predefined value
mAttMediaTray = 7; // DMBIN_AUTO
} else if (attr.equals(MediaTray.TOP)) {
mAttMediaTray =1; // DMBIN_UPPER
} else {
if (attr instanceof Win32MediaTray) {
mAttMediaTray = ((Win32MediaTray)attr).winID;
} else {