Class MediaSize
- All Implemented Interfaces:
Serializable, Cloneable, 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.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
ClassMediaSize.Engineering
includesMediaSize
values for engineering media.static final class
ClassMediaSize.ISO
includesMediaSize
values for ISO media.static final class
ClassMediaSize.JIS
includesMediaSize
values for JIS (Japanese) media.static final class
ClassMediaSize.NA
includesMediaSize
values for North American media.static final class
ClassMediaSize.Other
includesMediaSize
values for miscellaneous media. -
Field Summary
Fields declared in class Size2DSyntax
INCH, MM
-
Constructor Summary
ConstructorsConstructorDescriptionMediaSize
(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 Summary
Modifier and TypeMethodDescriptionboolean
Returns whether this media size attribute is equivalent to the passed in object.static MediaSizeName
findMedia
(float x, float y, int units) The specified dimensions are used to locate a matchingMediaSize
instance from amongst all the standardMediaSize
instances.Get the printing attribute class which is to be used as the "category" for this printing attribute value.static MediaSize
getMediaSizeForName
(MediaSizeName media) Get theMediaSize
for the specified named media.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.Methods declared in class Size2DSyntax
getSize, getX, getXMicrometers, getY, getYMicrometers, hashCode, toString, toString
Modifier and TypeMethodDescriptionfloat[]
getSize
(int units) Get this two-dimensional size attribute's dimensions in the given units as floating-point values.float
getX
(int units) Returns this two-dimensional size attribute'sX
dimension in the given units as a floating-point value.protected int
Returns this two-dimensional size attribute'sX
dimension in units of micrometers (µm).float
getY
(int units) Returns this two-dimensional size attribute'sY
dimension in the given units as a floating-point value.protected int
Returns this two-dimensional size attribute'sY
dimension in units of micrometers (µm).int
hashCode()
Returns a hash code value for this two-dimensional size attribute.toString()
Returns a string version of this two-dimensional size attribute.Returns a string version of this two-dimensional size attribute in the given units.Methods declared in class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Modifier and TypeMethodDescriptionprotected Object
clone()
Creates and returns a copy of this object.protected void
finalize()
Deprecated, for removal: This API element is subject to removal in a future version.Finalization is deprecated and subject to removal in a future release.final Class
<?> getClass()
Returns the runtime class of thisObject
.final void
notify()
Wakes up a single thread that is waiting on this object's monitor.final void
Wakes up all threads that are waiting on this object's monitor.final void
wait()
Causes the current thread to wait until it is awakened, typically by being notified or interrupted.final void
wait
(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.final void
wait
(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
-
Constructor Details
-
MediaSize
public MediaSize(float x, float y, int units) Construct a new media size attribute from the given floating-point values.- Parameters:
x
-X
dimensiony
-Y
dimensionunits
- unit conversion factor, e.g.Size2DSyntax.INCH
orSize2DSyntax.MM
- Throws:
IllegalArgumentException
- ifx < 0
ory < 0
orunits < 1
orx > y
-
MediaSize
public MediaSize(int x, int y, int units) Construct a new media size attribute from the given integer values.- Parameters:
x
-X
dimensiony
-Y
dimensionunits
- unit conversion factor, e.g.Size2DSyntax.INCH
orSize2DSyntax.MM
- Throws:
IllegalArgumentException
- ifx < 0
ory < 0
orunits < 1
orx > y
-
MediaSize
Construct a new media size attribute from the given floating-point values.- Parameters:
x
-X
dimensiony
-Y
dimensionunits
- unit conversion factor, e.g.Size2DSyntax.INCH
orSize2DSyntax.MM
media
- a media name to associate with thisMediaSize
- Throws:
IllegalArgumentException
- ifx < 0
ory < 0
orunits < 1
orx > y
-
MediaSize
Construct a new media size attribute from the given integer values.- Parameters:
x
-X
dimensiony
-Y
dimensionunits
- unit conversion factor, e.g.Size2DSyntax.INCH
orSize2DSyntax.MM
media
- a media name to associate with thisMediaSize
- Throws:
IllegalArgumentException
- ifx < 0
ory < 0
orunits < 1
orx > y
-
-
Method Details
-
getMediaSizeName
Get the media name, if any, for this size.- Returns:
- the name for this media size, or
null
if no name was associated with this size (an anonymous size)
-
getMediaSizeForName
Get theMediaSize
for the specified named media.- Parameters:
media
- the name of the media for which the size is sought- Returns:
- size of the media, or
null
if this media is not associated with any size
-
findMedia
The specified dimensions are used to locate a matchingMediaSize
instance from amongst all the standardMediaSize
instances. If there is no exact match, the closest match is used.The
MediaSize
is in turn used to locate theMediaSizeName
object. This method may returnnull
if the closest matchingMediaSize
has no correspondingMedia
instance.This method is useful for clients which have only dimensions and want to find a
Media
which corresponds to the dimensions.- Parameters:
x
-X
dimensiony
-Y
dimensionunits
- unit conversion factor, e.g.Size2DSyntax.INCH
orSize2DSyntax.MM
- Returns:
MediaSizeName
matching these dimensions, ornull
- Throws:
IllegalArgumentException
- ifx <= 0
,y <= 0
, orunits < 1
-
equals
Returns whether this media size attribute is equivalent to the passed in object. To be equivalent, all of the following conditions must be true:object
is notnull
.object
is an instance of classMediaSize
.- This media size attribute's
X
dimension is equal toobject
'sX
dimension. - This media size attribute's
Y
dimension is equal toobject
'sY
dimension.
- Overrides:
equals
in classSize2DSyntax
- Parameters:
object
-Object
to compare to- Returns:
true
ifobject
is equivalent to this media size attribute,false
otherwise- See Also:
-
getCategory
Get the printing attribute class which is to be used as the "category" for this printing attribute value.For class
MediaSize
and any vendor-defined subclasses, the category is classMediaSize
itself.- Specified by:
getCategory
in interfaceAttribute
- Returns:
- printing attribute class (category), an instance of class
java.lang.Class
-
getName
-