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 classClassMediaSize.EngineeringincludesMediaSizevalues for engineering media.static final classClassMediaSize.ISOincludesMediaSizevalues for ISO media.static final classClassMediaSize.JISincludesMediaSizevalues for JIS (Japanese) media.static final classClassMediaSize.NAincludesMediaSizevalues for North American media.static final classClassMediaSize.OtherincludesMediaSizevalues 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 TypeMethodDescriptionbooleanReturns 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.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.Get the media name, if any, for this size.final StringgetName()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, toStringModifier and TypeMethodDescriptionfloat[]getSize(int units) Get this two-dimensional size attribute's dimensions in the given units as floating-point values.floatgetX(int units) Returns this two-dimensional size attribute'sXdimension in the given units as a floating-point value.protected intReturns this two-dimensional size attribute'sXdimension in units of micrometers (µm).floatgetY(int units) Returns this two-dimensional size attribute'sYdimension in the given units as a floating-point value.protected intReturns this two-dimensional size attribute'sYdimension in units of micrometers (µm).inthashCode()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, waitModifier and TypeMethodDescriptionprotected Objectclone()Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.
-
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-Xdimensiony-Ydimensionunits- unit conversion factor, e.g.Size2DSyntax.INCHorSize2DSyntax.MM- Throws:
IllegalArgumentException- ifx < 0ory < 0orunits < 1orx > y
-
MediaSize
public MediaSize(int x, int y, int units) Construct a new media size attribute from the given integer values.- Parameters:
x-Xdimensiony-Ydimensionunits- unit conversion factor, e.g.Size2DSyntax.INCHorSize2DSyntax.MM- Throws:
IllegalArgumentException- ifx < 0ory < 0orunits < 1orx > y
-
MediaSize
Construct a new media size attribute from the given floating-point values.- Parameters:
x-Xdimensiony-Ydimensionunits- unit conversion factor, e.g.Size2DSyntax.INCHorSize2DSyntax.MMmedia- a media name to associate with thisMediaSize- Throws:
IllegalArgumentException- ifx < 0ory < 0orunits < 1orx > y
-
MediaSize
Construct a new media size attribute from the given integer values.- Parameters:
x-Xdimensiony-Ydimensionunits- unit conversion factor, e.g.Size2DSyntax.INCHorSize2DSyntax.MMmedia- a media name to associate with thisMediaSize- Throws:
IllegalArgumentException- ifx < 0ory < 0orunits < 1orx > y
-
-
Method Details
-
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)
-
getMediaSizeForName
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
-
findMedia
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-Xdimensiony-Ydimensionunits- unit conversion factor, e.g.Size2DSyntax.INCHorSize2DSyntax.MM- Returns:
MediaSizeNamematching 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:objectis notnull.objectis an instance of classMediaSize.- This media size attribute's
Xdimension is equal toobject'sXdimension. - This media size attribute's
Ydimension is equal toobject'sYdimension.
- Overrides:
equalsin classSize2DSyntax- Parameters:
object-Objectto compare to- Returns:
trueifobjectis equivalent to this media size attribute,falseotherwise- See Also:
-
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 interfaceAttribute- Returns:
- printing attribute class (category), an instance of class
java.lang.Class
-
getName
-