public final class MediaPrintableArea extends Object implements DocAttribute, PrintRequestAttribute, PrintJobAttribute
可打印区域在介质的总体尺寸内被指定为矩形。
由于打印机硬件限制,大多数打印机无法在介质的整个表面上进行打印。 该类可用于查询假定的打印作业的可接受值,并请求在可打印区域的约束内的区域用于打印作业。
要查询可打印区域,客户端必须提供合适的上下文。 至少没有指定使用的介质的尺寸,可以获得可印刷区域的有意义的值。
该属性没有以与纸张边缘的距离来描述,部分是为了强调该属性不是独立于特定媒体,而是必须在选择其他属性的上下文中进行描述。 此外,客户端通常更方便地使用可打印区域。
 硬件的最小边距不仅仅是打印机的属性,而是可能是介质尺寸,方向,介质类型和任何指定的功能的函数。 PrintService提供了在合适的上下文中查询属性的支持值的方法:参见PrintService.getSupportedAttributeValues() 
矩形可打印区域由此定义:(x,y)原点位于纸张的左上角,而不管请求上下文中指定的方向如何。 例如,纵向或横向A4纸的可打印区域的高度>宽度。
可打印区域属性的值作为整数以微米(μm)为单位存储,其中1微米= 10 -6米= 1/1000毫米= 1/25400英寸。 这允许将尺寸精确地表示为1/1000mm(=1μm)或1/100英寸(=254μm)的精度。 如果分数英寸以两个负的幂表示,这允许尺寸精确地表示为1/8英寸(=3175μm)但不是1/16英寸的精度(因为1/16英寸不等于整数Âμm)。
IPP兼容性: MediaPrintableArea不是IPP属性。
| Modifier and Type | Field and Description | 
|---|---|
| static int | INCH
              值表示英寸单位(英寸)。 
             | 
| static int | MM
              值表示毫米(mm)单位。 
             | 
| Constructor and Description | 
|---|
| MediaPrintableArea(float x, float y, float w, float h, int units)
              从浮点值构造一个MediaPrintableArea对象。 
             | 
| MediaPrintableArea(int x, int y, int w, int h, int units)
              从整数值构造MediaPrintableArea对象。 
             | 
| Modifier and Type | Method and Description | 
|---|---|
| boolean | equals(Object object)
              返回此介质边距属性是否等同于传入的对象。 
             | 
| 类<? extends Attribute> | getCategory()
              获取要用作此打印属性值的“类别”的打印属性类。 
             | 
| float | getHeight(int units)
              以指定单位获取可打印区域的高度。 
             | 
| String | getName()
              获取此属性值是一个实例的类别的名称。 
             | 
| float[] | getPrintableArea(int units)
              将可打印区域按照x,y,w,h的顺序排列为4个数组。 
             | 
| float | getWidth(int units)
              以指定单位获取可打印区域的宽度。 
             | 
| float | getX(int units)
              以指定单位获取可打印区域的原点的x位置。 
             | 
| float | getY(int units)
              以指定单位获取可打印区域的原点的y位置。 
             | 
| int | hashCode()
              返回此属性的哈希码值。 
             | 
| String | toString()
              返回以mm为单位的矩形大小属性的字符串版本。 
             | 
| String | toString(int units, String unitsName)
              返回给定单位的此矩形大小属性的字符串版本。 
             | 
public static final int INCH
public static final int MM
public MediaPrintableArea(float x,
                          float y,
                          float w,
                          float h,
                          int units) 
          x - 可打印x 
           y - 可打印的 
           w - 可打印的宽度 
           h - 可打印的高度 
           units - 其中表示值。 
           IllegalArgumentException - 如果 
            x < 0或 
            y < 0或 
            w <= 0或 
            h <= 0或 
            units < 1 。 
           public MediaPrintableArea(int x,
                          int y,
                          int w,
                          int h,
                          int units) 
          x - 可打印x 
           y - 可打印的 
           w - 可打印的宽度 
           h - 可打印的高度 
           units - 其中表示值。 
           IllegalArgumentException - 如果 
            x < 0或 
            y < 0或 
            w <= 0或 
            h <= 0或 
            units < 1 。 
           public float[] getPrintableArea(int units)
units - 单位换算系数,例如 
            INCH或 
            MM 。 
           IllegalArgumentException - (未经检查的异常)抛出,如果 
            units < 1 。 
           public float getX(int units)
units - 单位换算系数,例如 
            INCH或 
            MM 。 
           IllegalArgumentException - (未经检查的异常)如果 
            units < 1抛出。 
           public float getY(int units)
units - 单位换算系数,例如 
            INCH或 
            MM 。 
           IllegalArgumentException - (未经检查的异常)抛出,如果 
            units < 1 。 
           public float getWidth(int units)
units - 单位换算因子,例如 
            INCH或 
            MM 。 
           IllegalArgumentException - (未经检查的异常)如果 
            units < 1抛出。 
           public float getHeight(int units)
units - 单位换算系数,例如 
            INCH或 
            MM 。 
           IllegalArgumentException - (未经检查的异常)如果 
            units < 1抛出。 
           public boolean equals(Object object)
object不为空。 object是MediaPrintableArea类的一个实例。 equals在 
            Object类 
           object - 要比较的对象。 
           object等效于此媒体边距属性,则为true,否则为false。 
           Object.hashCode() , HashMap 
           public final 类<? extends Attribute> getCategory()
对于MediaPrintableArea类,该类别是MediaPrintableArea类。
getCategory在接口 
            Attribute 
           java.lang.Class的一个实例。 
           public final String getName()
 对于MediaPrintableArea类,类别名称为"media-printable-area" 。 
这不是IPP V1.1属性。
public String toString(int units, String unitsName)
units - 单位换算系数,例如 
            INCH或 
            MM 。 
           unitsName - 单位名称字符串,例如"in"或"mm" 。 
            如果为空,则不会在结果附加单位名称。 
           IllegalArgumentException - (未经检查的异常)如果 
            units < 1抛出。 
           public int hashCode()
hashCode在 
            Object 
           Object.equals(java.lang.Object), 
            System.identityHashCode(java.lang.Object) 
            Submit a bug or feature 
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
 Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.