* This is the case when we use the values from the attribute set.
*/
Media media = (Media)attributes.get(Media.class);
OrientationRequested orientReq =
(OrientationRequested)attributes.get(OrientationRequested.class);
MediaPrintableArea mpa =
(MediaPrintableArea)attributes.get(MediaPrintableArea.class);
if ((orientReq != null || media != null || mpa != null) &&
isOpenBook(getPageable())) {
Pageable pageable = getPageable();
Printable printable = pageable.getPrintable(0);
PageFormat pf = (PageFormat)pageable.getPageFormat(0).clone();
Paper paper = pf.getPaper();
if (isSupportedValue(orientReq, attributes) ||
(!fidelity & orientReq != null)) {
int orient;
if (orientReq.equals(OrientationRequested.REVERSE_LANDSCAPE)) {
orient = PageFormat.REVERSE_LANDSCAPE;
} else if (orientReq.equals(OrientationRequested.LANDSCAPE)) {
orient = PageFormat.LANDSCAPE;
} else {
orient = PageFormat.PORTRAIT;
}
pf.setOrientation(orient);
}
if (isSupportedValue(mpa, attributes) ||
(!fidelity & mpa != null)) {
float [] printableArea =
mpa.getPrintableArea(MediaPrintableArea.INCH);
for (int i=0; i < printableArea.length; i++) {
printableArea[i] = printableArea[i] * DPI;
}
paper.setImageableArea(printableArea[0], printableArea[1],
printableArea[2], printableArea[3]);