javax.print.attribute.standard

Class MediaPrintableArea

public final class MediaPrintableArea extends Object implements DocAttribute, PrintJobAttribute, PrintRequestAttribute

The MediaPrintableArea attribute specifies the area of a media sheet which is available for printing.

Due to hardware limitation its not possible with most printers to use the whole area of a media sheet for printing. This attribute defines the area for printing through the values of the upper left corner position (x,y) on the sheet and the available width and height of the area. The units of the values are determined by two defined constants:

Internal storage:
The values of x, y, width and height are stored internally in micrometers. The values of the provided constants for inch (value 25400) and millimeters (value 1000) are used as conversion factors to the internal storage units. To get the internal micrometers values a multiplication of a given size value with its units constant value is done. Retrieving the size value for specific units is done by dividing the internal stored value by the units constant value.

IPP Compatibility: MediaPrintableArea is not an IPP 1.1 attribute.

Field Summary
static intINCH
Constant for the units of inches.
static intMM
Constant for the units of millimeters.
Constructor Summary
MediaPrintableArea(float x, float y, float w, float h, int units)
Creates a new MediaPrintableArea object with the given float values for the given units.
MediaPrintableArea(int x, int y, int w, int h, int units)
Creates a new MediaPrintableArea object with the given int values for the given units.
Method Summary
booleanequals(Object obj)
Tests if the given object is equal to this object.
Class<? extends Attribute>getCategory()
Returns category of this class.
floatgetHeight(int units)
Returns the height of the printable area for the given units.
StringgetName()
Returns the name of this attribute.
float[]getPrintableArea(int units)
Returns the printable area as an float[] with 4 values (order x, y, width, height) in the given units.
floatgetWidth(int units)
Returns the width of the printable area for the given units.
floatgetX(int units)
Returns the position in x direction of the printable area for the given units.
floatgetY(int units)
Returns the position in y direction of the printable area for the given units.
inthashCode()
Returns the hashcode for this object.
StringtoString()
Returns the string representation for this object in units of millimeters..
StringtoString(int units, String unitsName)
Returns the string representation for this object in units of millimeters..

Field Detail

INCH

public static final int INCH
Constant for the units of inches. The actual value is the conversion factor to micrometers.

MM

public static final int MM
Constant for the units of millimeters. The actual value is the conversion factor to micrometers.

Constructor Detail

MediaPrintableArea

public MediaPrintableArea(float x, float y, float w, float h, int units)
Creates a new MediaPrintableArea object with the given float values for the given units.

Parameters: x start of the printable area on the sheet in x direction. y start of the printable area on the sheet in y direction. w the width of the printable area. h the height of the printable area. units the units of the given values.

Throws: IllegalArgumentException if x i< 0 or y i< 0 or w i<= 0 or h i<= 0 or units i< 1

MediaPrintableArea

public MediaPrintableArea(int x, int y, int w, int h, int units)
Creates a new MediaPrintableArea object with the given int values for the given units.

Parameters: x start of the printable area on the sheet in x direction. y start of the printable area on the sheet in y direction. w the width of the printable area. h the height of the printable area. units the units of the given values.

Throws: IllegalArgumentException if x i< 0 or y i< 0 or w i<= 0 or h i<= 0 or units i< 1

Method Detail

equals

public boolean equals(Object obj)
Tests if the given object is equal to this object.

Parameters: obj the object to test

Returns: true if both objects are equal, false otherwise.

getCategory

public Class<? extends Attribute> getCategory()
Returns category of this class.

Returns: The class MediaPrintableArea itself.

getHeight

public float getHeight(int units)
Returns the height of the printable area for the given units.

Parameters: units the units conversion factor.

Returns: The height.

Throws: IllegalArgumentException if units is < 1

getName

public String getName()
Returns the name of this attribute.

Returns: The name "media-printable-area".

getPrintableArea

public float[] getPrintableArea(int units)
Returns the printable area as an float[] with 4 values (order x, y, width, height) in the given units.

Parameters: units the units to use.

Returns: The printable area as float array.

getWidth

public float getWidth(int units)
Returns the width of the printable area for the given units.

Parameters: units the units conversion factor.

Returns: The width.

Throws: IllegalArgumentException if units is < 1

getX

public float getX(int units)
Returns the position in x direction of the printable area for the given units.

Parameters: units the units conversion factor.

Returns: The position in x direction.

Throws: IllegalArgumentException if units is < 1

getY

public float getY(int units)
Returns the position in y direction of the printable area for the given units.

Parameters: units the units conversion factor.

Returns: The position in y direction.

Throws: IllegalArgumentException if units is < 1

hashCode

public int hashCode()
Returns the hashcode for this object.

Returns: The hashcode.

toString

public String toString()
Returns the string representation for this object in units of millimeters..

The returned string is in the form "(x,y)->(width,height)mm".

Returns: The string representation in millimeters.

toString

public String toString(int units, String unitsName)
Returns the string representation for this object in units of millimeters..

The returned string is in the form "(x,y)->(width,height)unitsName".

Parameters: units the units to use for conversion. unitsName the name of the used units, appended to the resulting string if not null.

Returns: The string representation in millimeters.

Throws: IllegalArgumentException if units is < 1