Serializable
, Cloneable
, Attribute
public class MediaSize extends Size2DSyntax implements Attribute
MediaSize
is a two-dimensional size valued printing attribute class that indicates the dimensions of the medium in a portrait orientation, with the X
dimension running along the bottom edge and the Y
dimension running along the left edge. Thus, the Y
dimension must be greater than or equal to the X
dimension. Class MediaSize
declares many standard media size values, organized into nested classes for ISO, JIS, North American, engineering, and other media. MediaSize
is not yet used to specify media. Its current role is as a mapping for named media (see MediaSizeName
). Clients can use the mapping method MediaSize.getMediaSizeForName(MediaSizeName)
to find the physical dimensions of the MediaSizeName
instances enumerated in this API. This is useful for clients which need this information to format & paginate printing.
Modifier and Type | Class | Description |
---|---|---|
static final class |
MediaSize.Engineering |
Class MediaSize.Engineering includes MediaSize values for engineering media. |
static final class |
MediaSize.ISO |
Class MediaSize.ISO includes MediaSize values for ISO media. |
static final class |
MediaSize.JIS |
Class MediaSize.JIS includes MediaSize values for JIS (Japanese) media. |
static final class |
MediaSize.NA |
Class MediaSize.NA includes MediaSize values for North American media. |
static final class |
MediaSize.Other |
Class MediaSize.Other includes MediaSize values for miscellaneous media. |
INCH, MM
Constructor | Description |
---|---|
MediaSize |
Construct a new media size attribute from the given floating-point values. |
MediaSize |
Construct a new media size attribute from the given floating-point values. |
MediaSize |
Construct a new media size attribute from the given integer values. |
MediaSize |
Construct a new media size attribute from the given integer values. |
Modifier and Type | Method | Description |
---|---|---|
boolean |
equals |
Returns whether this media size attribute is equivalent to the passed in object. |
static MediaSizeName |
findMedia |
The specified dimensions are used to locate a matching MediaSize instance from amongst all the standard MediaSize instances. |
final Class |
getCategory() |
Get the printing attribute class which is to be used as the "category" for this printing attribute value. |
static MediaSize |
getMediaSizeForName |
Get the MediaSize for the specified named media. |
MediaSizeName |
getMediaSizeName() |
Get the media name, if any, for this size. |
final String |
getName() |
Get the name of the category of which this attribute value is an instance. |
getSize, getX, getXMicrometers, getY, getYMicrometers, hashCode, toString, toString
public MediaSize(float x, float y, int units)
x
- X
dimensiony
- Y
dimensionunits
- unit conversion factor, e.g. Size2DSyntax.INCH
or Size2DSyntax.MM
IllegalArgumentException
- if x < 0
or y < 0
or units < 1
or x > y
public MediaSize(int x, int y, int units)
x
- X
dimensiony
- Y
dimensionunits
- unit conversion factor, e.g. Size2DSyntax.INCH
or Size2DSyntax.MM
IllegalArgumentException
- if x < 0
or y < 0
or units < 1
or x > y
public MediaSize(float x, float y, int units, MediaSizeName media)
x
- X
dimensiony
- Y
dimensionunits
- unit conversion factor, e.g. Size2DSyntax.INCH
or Size2DSyntax.MM
media
- a media name to associate with this MediaSize
IllegalArgumentException
- if x < 0
or y < 0
or units < 1
or x > y
public MediaSize(int x, int y, int units, MediaSizeName media)
x
- X
dimensiony
- Y
dimensionunits
- unit conversion factor, e.g. Size2DSyntax.INCH
or Size2DSyntax.MM
media
- a media name to associate with this MediaSize
IllegalArgumentException
- if x < 0
or y < 0
or units < 1
or x > y
public MediaSizeName getMediaSizeName()
null
if no name was associated with this size (an anonymous size)public static MediaSize getMediaSizeForName(MediaSizeName media)
MediaSize
for the specified named media.media
- the name of the media for which the size is soughtnull
if this media is not associated with any sizepublic static MediaSizeName findMedia(float x, float y, int units)
MediaSize
instance from amongst all the standard MediaSize
instances. If there is no exact match, the closest match is used. The MediaSize
is in turn used to locate the MediaSizeName
object. This method may return null
if the closest matching MediaSize
has no corresponding Media
instance.
This method is useful for clients which have only dimensions and want to find a Media
which corresponds to the dimensions.
x
- X
dimensiony
- Y
dimensionunits
- unit conversion factor, e.g. Size2DSyntax.INCH
or Size2DSyntax.MM
MediaSizeName
matching these dimensions, or null
IllegalArgumentException
- if x <= 0
, y <= 0
, or units < 1
public boolean equals(Object object)
object
is not null
. object
is an instance of class MediaSize
. X
dimension is equal to object
's X
dimension. Y
dimension is equal to object
's Y
dimension. equals
in class Size2DSyntax
object
- Object
to compare totrue
if object
is equivalent to this media size attribute, false
otherwisepublic final Class<? extends Attribute> getCategory()
For class MediaSize
and any vendor-defined subclasses, the category is class MediaSize
itself.
getCategory
in interface Attribute
java.lang.Class
public final String getName()
For class MediaSize
and any vendor-defined subclasses, the category name is "media-size"
.
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/javax/print/attribute/standard/MediaSize.html