- 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
Class 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 methodMediaSize.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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static class
MediaSize.Engineering
Class MediaSize.Engineering includesMediaSize
values for engineering media.static class
MediaSize.ISO
Class MediaSize.ISO includesMediaSize
values for ISO media.static class
MediaSize.JIS
Class MediaSize.JIS includesMediaSize
values for JIS (Japanese) media.static class
MediaSize.NA
Class MediaSize.NA includesMediaSize
values for North American media.static class
MediaSize.Other
Class MediaSize.Other includesMediaSize
values for miscellaneous media.
-
Constructor Summary
Constructors Constructor and 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 Summary
Methods Modifier and Type Method and Description boolean
equals(Object object)
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 matching MediaSize instance from amongst all the standard MediaSize instances.Class<? extends Attribute>
getCategory()
Get the printing attribute class which is to be used as the "category" for this printing attribute value.static MediaSize
getMediaSizeForName(MediaSizeName media)
Get the MediaSize for the specified named media.MediaSizeName
getMediaSizeName()
Get the media name, if any, for this size.String
getName()
Get the name of the category of which this attribute value is an instance.-
Methods inherited from class javax.print.attribute.Size2DSyntax
getSize, getX, getXMicrometers, getY, getYMicrometers, hashCode, toString, toString
-
-
-
-
Constructor Detail
-
MediaSize
public MediaSize(float x, float y, int units)
Construct a new media size attribute from the given floating-point values.- Parameters:
x
- X dimension.y
- Y dimension.units
- Unit conversion factor, e.g.Size2DSyntax.INCH
orSize2DSyntax.MM
.- Throws:
IllegalArgumentException
- (Unchecked exception) Thrown 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 dimension.y
- Y dimension.units
- Unit conversion factor, e.g.Size2DSyntax.INCH
orSize2DSyntax.MM
.- Throws:
IllegalArgumentException
- (Unchecked exception) Thrown ifx
< 0 ory
< 0 orunits
< 1 orx
>y
.
-
MediaSize
public MediaSize(float x, float y, int units, MediaSizeName media)
Construct a new media size attribute from the given floating-point values.- Parameters:
x
- X dimension.y
- Y dimension.units
- Unit conversion factor, e.g.Size2DSyntax.INCH
orSize2DSyntax.MM
.media
- a media name to associate with this MediaSize- Throws:
IllegalArgumentException
- (Unchecked exception) Thrown ifx
< 0 ory
< 0 orunits
< 1 orx
>y
.
-
MediaSize
public MediaSize(int x, int y, int units, MediaSizeName media)
Construct a new media size attribute from the given integer values.- Parameters:
x
- X dimension.y
- Y dimension.units
- Unit conversion factor, e.g.Size2DSyntax.INCH
orSize2DSyntax.MM
.media
- a media name to associate with this MediaSize- Throws:
IllegalArgumentException
- (Unchecked exception) Thrown ifx
< 0 ory
< 0 orunits
< 1 orx
>y
.
-
-
Method Detail
-
getMediaSizeName
public MediaSizeName 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
public static MediaSize getMediaSizeForName(MediaSizeName media)
Get the MediaSize 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
public static MediaSizeName findMedia(float x, float y, int units)
The specified dimensions are used to locate a matching 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.
- Parameters:
x
- - X dimensiony
- - Y dimension.units
- Unit conversion factor, e.g.Size2DSyntax.INCH
orSize2DSyntax.MM
- Returns:
- MediaSizeName matching these dimensions, or null.
- Throws:
IllegalArgumentException
- if x <= 0, y <= 0, or units < 1
-
equals
public 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:-
object
is not null. -
object
is an instance of class MediaSize. -
This media size attribute's X dimension is equal to
object
's X dimension. -
This media size attribute's Y dimension is equal to
object
's Y dimension.
- Overrides:
equals
in classSize2DSyntax
- Parameters:
object
- Object to compare to.- Returns:
- True if
object
is equivalent to this media size attribute, false otherwise. - See Also:
Object.hashCode()
,HashMap
-
-
getCategory
public 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 MediaSize and any vendor-defined subclasses, the category is class MediaSize itself.
- Specified by:
getCategory
in interfaceAttribute
- Returns:
- Printing attribute class (category), an instance of class
java.lang.Class
.
-
-
Traduction non disponible
Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Version en cache
22/12/2024 16:36:20 Cette version de la page est en cache (à la date du 22/12/2024 16:36:20) afin d'accélérer le traitement. Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la dernère version de la page.Document créé le 17/12/2006, dernière modification le 04/03/2020
Source du document imprimé : https://www.gaudry.be/java-api-rf-javax/print/attribute/standard/mediasize.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.