1615 psCurrent.getSupportedAttributeValues(mpaCategory, 1616 docFlavor, 1617 tmpASet); 1618 if (values instanceof MediaPrintableArea[] && 1619 ((MediaPrintableArea[])values).length > 0) { 1620 mpaMax = ((MediaPrintableArea[])values)[0]; 1621 1622 } 1623 } 1624 if (mpaMax == null) { 1625 mpaMax = new MediaPrintableArea(0f, 0f, 1626 mediaSize.getX(units), 1627 mediaSize.getY(units), 1628 units); 1629 } 1630 1631 float wid = mediaSize.getX(units); 1632 float hgt = mediaSize.getY(units); 1633 float pax = lm; 1634 float pay = tm; 1635 float paw = wid - lm - rm; 1636 float pah = hgt - tm - bm; 1637 1638 if (paw <= 0f || pah <= 0f || pax < 0f || pay < 0f || 1639 pax < mpaMax.getX(units) || paw > mpaMax.getWidth(units) || 1640 pay < mpaMax.getY(units) || pah > mpaMax.getHeight(units)) { 1641 return null; 1642 } else { 1643 return new MediaPrintableArea(lm, tm, paw, pah, units); 1644 } 1645 } 1646 1647 /* This is complex as a MediaPrintableArea is valid only within 1648 * a particular context of media size. 1649 * So we need a MediaSize as well as a MediaPrintableArea. 1650 * MediaSize can be obtained from MediaSizeName. 1651 * If the application specifies a MediaPrintableArea, we accept it 1652 * to the extent its valid for the Media they specify. If they 1653 * don't specify a Media, then the default is assumed. 1654 * 1655 * If an application doesn't define a MediaPrintableArea, we need to 1656 * create a suitable one, this is created using the specified (or 1657 * default) Media and default 1 inch margins. This is validated 1658 * against the paper in case this is too large for tiny media. | 1615 psCurrent.getSupportedAttributeValues(mpaCategory, 1616 docFlavor, 1617 tmpASet); 1618 if (values instanceof MediaPrintableArea[] && 1619 ((MediaPrintableArea[])values).length > 0) { 1620 mpaMax = ((MediaPrintableArea[])values)[0]; 1621 1622 } 1623 } 1624 if (mpaMax == null) { 1625 mpaMax = new MediaPrintableArea(0f, 0f, 1626 mediaSize.getX(units), 1627 mediaSize.getY(units), 1628 units); 1629 } 1630 1631 float wid = mediaSize.getX(units); 1632 float hgt = mediaSize.getY(units); 1633 float pax = lm; 1634 float pay = tm; 1635 float par = rm; 1636 float pab = bm; 1637 float paw = wid - lm - rm; 1638 float pah = hgt - tm - bm; 1639 1640 if (paw <= 0f || pah <= 0f || pax < 0f || pay < 0f || 1641 par <= 0f || pab <= 0f || 1642 pax < mpaMax.getX(units) || paw > mpaMax.getWidth(units) || 1643 pay < mpaMax.getY(units) || pah > mpaMax.getHeight(units)) { 1644 return null; 1645 } else { 1646 return new MediaPrintableArea(lm, tm, paw, pah, units); 1647 } 1648 } 1649 1650 /* This is complex as a MediaPrintableArea is valid only within 1651 * a particular context of media size. 1652 * So we need a MediaSize as well as a MediaPrintableArea. 1653 * MediaSize can be obtained from MediaSizeName. 1654 * If the application specifies a MediaPrintableArea, we accept it 1655 * to the extent its valid for the Media they specify. If they 1656 * don't specify a Media, then the default is assumed. 1657 * 1658 * If an application doesn't define a MediaPrintableArea, we need to 1659 * create a suitable one, this is created using the specified (or 1660 * default) Media and default 1 inch margins. This is validated 1661 * against the paper in case this is too large for tiny media. |