- java.lang.Object
- 
- javax.print.attribute.Size2DSyntax
- 
- javax.print.attribute.standard.MediaSize
 
 
- 
- All Implemented Interfaces:
- Serializable,- Cloneable,- Attribute
 
 public class MediaSize extends Size2DSyntax implements Attribute ClassMediaSizeis a two-dimensional size valued printing attribute class that indicates the dimensions of the medium in a portrait orientation, with theXdimension running along the bottom edge and theYdimension running along the left edge. Thus, theYdimension must be greater than or equal to theXdimension. ClassMediaSizedeclares many standard media size values, organized into nested classes for ISO, JIS, North American, engineering, and other media.MediaSizeis not yet used to specify media. Its current role is as a mapping for named media (seeMediaSizeName). Clients can use the mapping methodMediaSize.getMediaSizeForName(MediaSizeName)to find the physical dimensions of theMediaSizeNameinstances enumerated in this API. This is useful for clients which need this information to format & paginate printing.- See Also:
- Serialized Form
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classMediaSize.EngineeringClassMediaSize.EngineeringincludesMediaSizevalues for engineering media.static classMediaSize.ISOClassMediaSize.ISOincludesMediaSizevalues for ISO media.static classMediaSize.JISClassMediaSize.JISincludesMediaSizevalues for JIS (Japanese) media.static classMediaSize.NAClassMediaSize.NAincludesMediaSizevalues for North American media.static classMediaSize.OtherClassMediaSize.OtherincludesMediaSizevalues for miscellaneous media.
 - 
Field Summary- 
Fields declared in class javax.print.attribute.Size2DSyntaxINCH, MM
 
- 
 - 
Constructor SummaryConstructors Constructor Description MediaSize(float x, float y, int units)Construct a new media size attribute from the given floating-point values.MediaSize(float x, float y, int units, MediaSizeName media)Construct a new media size attribute from the given floating-point values.MediaSize(int x, int y, int units)Construct a new media size attribute from the given integer values.MediaSize(int x, int y, int units, MediaSizeName media)Construct a new media size attribute from the given integer values.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object object)Returns whether this media size attribute is equivalent to the passed in object.static MediaSizeNamefindMedia(float x, float y, int units)The specified dimensions are used to locate a matchingMediaSizeinstance from amongst all the standardMediaSizeinstances.Class<? extends Attribute>getCategory()Get the printing attribute class which is to be used as the "category" for this printing attribute value.static MediaSizegetMediaSizeForName(MediaSizeName media)Get theMediaSizefor the specified named media.MediaSizeNamegetMediaSizeName()Get the media name, if any, for this size.StringgetName()Get the name of the category of which this attribute value is an instance.- 
Methods declared in class javax.print.attribute.Size2DSyntaxgetSize, getX, getXMicrometers, getY, getYMicrometers, hashCode, toString, toString
 
- 
 
- 
- 
- 
Constructor Detail- 
MediaSizepublic MediaSize(float x, float y, int units)Construct a new media size attribute from the given floating-point values.- Parameters:
- x-- Xdimension
- y-- Ydimension
- units- unit conversion factor, e.g.- Size2DSyntax.INCHor- Size2DSyntax.MM
- Throws:
- IllegalArgumentException- if- x < 0or- y < 0or- units < 1or- x > y
 
 - 
MediaSizepublic MediaSize(int x, int y, int units)Construct a new media size attribute from the given integer values.- Parameters:
- x-- Xdimension
- y-- Ydimension
- units- unit conversion factor, e.g.- Size2DSyntax.INCHor- Size2DSyntax.MM
- Throws:
- IllegalArgumentException- if- x < 0or- y < 0or- units < 1or- x > y
 
 - 
MediaSizepublic MediaSize(float x, float y, int units, MediaSizeName media)Construct a new media size attribute from the given floating-point values.- Parameters:
- x-- Xdimension
- y-- Ydimension
- units- unit conversion factor, e.g.- Size2DSyntax.INCHor- Size2DSyntax.MM
- media- a media name to associate with this- MediaSize
- Throws:
- IllegalArgumentException- if- x < 0or- y < 0or- units < 1or- x > y
 
 - 
MediaSizepublic MediaSize(int x, int y, int units, MediaSizeName media)Construct a new media size attribute from the given integer values.- Parameters:
- x-- Xdimension
- y-- Ydimension
- units- unit conversion factor, e.g.- Size2DSyntax.INCHor- Size2DSyntax.MM
- media- a media name to associate with this- MediaSize
- Throws:
- IllegalArgumentException- if- x < 0or- y < 0or- units < 1or- x > y
 
 
- 
 - 
Method Detail- 
getMediaSizeNamepublic MediaSizeName getMediaSizeName() Get the media name, if any, for this size.- Returns:
- the name for this media size, or nullif no name was associated with this size (an anonymous size)
 
 - 
getMediaSizeForNamepublic static MediaSize getMediaSizeForName(MediaSizeName media) Get theMediaSizefor the specified named media.- Parameters:
- media- the name of the media for which the size is sought
- Returns:
- size of the media, or nullif this media is not associated with any size
 
 - 
findMediapublic static MediaSizeName findMedia(float x, float y, int units) The specified dimensions are used to locate a matchingMediaSizeinstance from amongst all the standardMediaSizeinstances. If there is no exact match, the closest match is used.The MediaSizeis in turn used to locate theMediaSizeNameobject. This method may returnnullif the closest matchingMediaSizehas no correspondingMediainstance.This method is useful for clients which have only dimensions and want to find a Mediawhich corresponds to the dimensions.- Parameters:
- x-- Xdimension
- y-- Ydimension
- units- unit conversion factor, e.g.- Size2DSyntax.INCHor- Size2DSyntax.MM
- Returns:
- MediaSizeNamematching these dimensions, or- null
- Throws:
- IllegalArgumentException- if- x <= 0,- y <= 0, or- units < 1
 
 - 
equalspublic boolean equals(Object object) Returns whether this media size attribute is equivalent to the passed in object. To be equivalent, all of the following conditions must be true:- objectis not- null.
- objectis an instance of class- MediaSize.
- This media size attribute's Xdimension is equal toobject'sXdimension.
- This media size attribute's Ydimension is equal toobject'sYdimension.
 - Overrides:
- equalsin class- Size2DSyntax
- Parameters:
- object-- Objectto compare to
- Returns:
- trueif- objectis equivalent to this media size attribute,- falseotherwise
- See Also:
- Object.hashCode(),- HashMap
 
 - 
getCategorypublic final Class<? extends Attribute> getCategory() Get the printing attribute class which is to be used as the "category" for this printing attribute value.For class MediaSizeand any vendor-defined subclasses, the category is classMediaSizeitself.- Specified by:
- getCategoryin interface- Attribute
- Returns:
- printing attribute class (category), an instance of class
         java.lang.Class
 
 
- 
 
-