API java : PageAttributes


java.awt
Class PageAttributes

java.lang.Object
  extended by java.awt.PageAttributes
All Implemented Interfaces:
Cloneable

public final class PageAttributes
extends Object
implements Cloneable

A set of attributes which control the output of a printed page.

Instances of this class control the color state, paper size (media type), orientation, logical origin, print quality, and resolution of every page which uses the instance. Attribute names are compliant with the Internet Printing Protocol (IPP) 1.1 where possible. Attribute values are partially compliant where possible.

To use a method which takes an inner class type, pass a reference to one of the constant fields of the inner class. Client code cannot create new instances of the inner class types because none of those classes has a public constructor. For example, to set the color state to monochrome, use the following code:

  1. import java.awt.PageAttributes;
  2.  
  3. public class MonochromeExample {
  4. public void setMonochrome(PageAttributes pageAttributes) {
  5. pageAttributes.setColor(PageAttributes.ColorType.MONOCHROME);
  6. }
  7. }

Every IPP attribute which supports an attributeName-default value has a corresponding setattributeNameToDefault method. Default value fields are not provided.


Nested Class Summary
static class PageAttributes.ColorType
          A type-safe enumeration of possible color states.
static class PageAttributes.MediaType
          A type-safe enumeration of possible paper sizes.
static class PageAttributes.OrientationRequestedType
          A type-safe enumeration of possible orientations.
static class PageAttributes.OriginType
          A type-safe enumeration of possible origins.
static class PageAttributes.PrintQualityType
          A type-safe enumeration of possible print qualities.
 
Constructor Summary
PageAttributes()
          Constructs a PageAttributes instance with default values for every attribute.
PageAttributes(PageAttributes.ColorType color, PageAttributes.MediaType media, PageAttributes.OrientationRequestedType orientationRequested, PageAttributes.OriginType origin, PageAttributes.PrintQualityType printQuality, int[] printerResolution)
          Constructs a PageAttributes instance with the specified values for every attribute.
PageAttributes(PageAttributes obj)
          Constructs a PageAttributes instance which is a copy of the supplied PageAttributes.
 
Method Summary
 Object clone()
          Creates and returns a copy of this PageAttributes.
 boolean equals(Object obj)
          Determines whether two PageAttributes are equal to each other.
 PageAttributes.ColorType getColor()
          Returns whether pages using these attributes will be rendered in color or monochrome.
 PageAttributes.MediaType getMedia()
          Returns the paper size for pages using these attributes.
 PageAttributes.OrientationRequestedType getOrientationRequested()
          Returns the print orientation for pages using these attributes.
 PageAttributes.OriginType getOrigin()
          Returns whether drawing at (0, 0) to pages using these attributes draws at the upper-left corner of the physical page, or at the upper-left corner of the printable area.
 int[] getPrinterResolution()
          Returns the print resolution for pages using these attributes.
 PageAttributes.PrintQualityType getPrintQuality()
          Returns the print quality for pages using these attributes.
 int hashCode()
          Returns a hash code value for this PageAttributes.
 void set(PageAttributes obj)
          Sets all of the attributes of this PageAttributes to the same values as the attributes of obj.
 void setColor(PageAttributes.ColorType color)
          Specifies whether pages using these attributes will be rendered in color or monochrome.
 void setMedia(PageAttributes.MediaType media)
          Specifies the desired paper size for pages using these attributes.
 void setMediaToDefault()
          Sets the paper size for pages using these attributes to the default size for the default locale.
 void setOrientationRequested(int orientationRequested)
          Specifies the print orientation for pages using these attributes.
 void setOrientationRequested(PageAttributes.OrientationRequestedType orientationRequested)
          Specifies the print orientation for pages using these attributes.
 void setOrientationRequestedToDefault()
          Sets the print orientation for pages using these attributes to the default.
 void setOrigin(PageAttributes.OriginType origin)
          Specifies whether drawing at (0, 0) to pages using these attributes draws at the upper-left corner of the physical page, or at the upper-left corner of the printable area.
 void setPrinterResolution(int printerResolution)
          Specifies the desired cross feed and feed print resolutions in dots per inch for pages using these attributes.
 void setPrinterResolution(int[] printerResolution)
          Specifies the desired print resolution for pages using these attributes.
 void setPrinterResolutionToDefault()
          Sets the printer resolution for pages using these attributes to the default.
 void setPrintQuality(int printQuality)
          Specifies the print quality for pages using these attributes.
 void setPrintQuality(PageAttributes.PrintQualityType printQuality)
          Specifies the print quality for pages using these attributes.
 void setPrintQualityToDefault()
          Sets the print quality for pages using these attributes to the default.
 String toString()
          Returns a string representation of this PageAttributes.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PageAttributes

public PageAttributes()
Constructs a PageAttributes instance with default values for every attribute.


PageAttributes

public PageAttributes(PageAttributes obj)
Constructs a PageAttributes instance which is a copy of the supplied PageAttributes.

Parameters:
obj - the PageAttributes to copy.

PageAttributes

public PageAttributes(PageAttributes.ColorType color,
                      PageAttributes.MediaType media,
                      PageAttributes.OrientationRequestedType orientationRequested,
                      PageAttributes.OriginType origin,
                      PageAttributes.PrintQualityType printQuality,
                      int[] printerResolution)
Constructs a PageAttributes instance with the specified values for every attribute.

Parameters:
color - ColorType.COLOR or ColorType.MONOCHROME.
media - one of the constant fields of the MediaType class.
orientationRequested - OrientationRequestedType.PORTRAIT or OrientationRequestedType.LANDSCAPE.
origin - OriginType.PHYSICAL or OriginType.PRINTABLE
printQuality - PrintQualityType.DRAFT, PrintQualityType.NORMAL, or PrintQualityType.HIGH
printerResolution - an integer array of 3 elements. The first element must be greater than 0. The second element must be must be greater than 0. The third element must be either 3 or 4.
Throws:
IllegalArgumentException - if one or more of the above conditions is violated.
Method Detail

clone

public Object clone()
Creates and returns a copy of this PageAttributes.

Overrides:
clone in class Object
Returns:
the newly created copy. It is safe to cast this Object into a PageAttributes.
See Also:
Cloneable

set

public void set(PageAttributes obj)
Sets all of the attributes of this PageAttributes to the same values as the attributes of obj.

Parameters:
obj - the PageAttributes to copy.

getColor

public PageAttributes.ColorType getColor()
Returns whether pages using these attributes will be rendered in color or monochrome. This attribute is updated to the value chosen by the user.

Returns:
ColorType.COLOR or ColorType.MONOCHROME.

setColor

public void setColor(PageAttributes.ColorType color)
Specifies whether pages using these attributes will be rendered in color or monochrome. Not specifying this attribute is equivalent to specifying ColorType.MONOCHROME.

Parameters:
color - ColorType.COLOR or ColorType.MONOCHROME.
Throws:
IllegalArgumentException - if color is null.

getMedia

public PageAttributes.MediaType getMedia()
Returns the paper size for pages using these attributes. This attribute is updated to the value chosen by the user.

Returns:
one of the constant fields of the MediaType class.

setMedia

public void setMedia(PageAttributes.MediaType media)
Specifies the desired paper size for pages using these attributes. The actual paper size will be determined by the limitations of the target printer. If an exact match cannot be found, an implementation will choose the closest possible match. Not specifying this attribute is equivalent to specifying the default size for the default locale. The default size for locales in the United States and Canada is MediaType.NA_LETTER. The default size for all other locales is MediaType.ISO_A4.

Parameters:
media - one of the constant fields of the MediaType class.
Throws:
IllegalArgumentException - if media is null.

setMediaToDefault

public void setMediaToDefault()
Sets the paper size for pages using these attributes to the default size for the default locale. The default size for locales in the United States and Canada is MediaType.NA_LETTER. The default size for all other locales is MediaType.ISO_A4.


getOrientationRequested

public PageAttributes.OrientationRequestedType getOrientationRequested()
Returns the print orientation for pages using these attributes. This attribute is updated to the value chosen by the user.

Returns:
OrientationRequestedType.PORTRAIT or OrientationRequestedType.LANDSCAPE.

setOrientationRequested

public void setOrientationRequested(PageAttributes.OrientationRequestedType orientationRequested)
Specifies the print orientation for pages using these attributes. Not specifying the property is equivalent to specifying OrientationRequestedType.PORTRAIT.

Parameters:
orientationRequested - OrientationRequestedType.PORTRAIT or OrientationRequestedType.LANDSCAPE.
Throws:
IllegalArgumentException - if orientationRequested is null.

setOrientationRequested

public void setOrientationRequested(int orientationRequested)
Specifies the print orientation for pages using these attributes. Specifying 3 denotes portrait. Specifying 4 denotes landscape. Specifying any other value will generate an IllegalArgumentException. Not specifying the property is equivalent to calling setOrientationRequested(OrientationRequestedType.PORTRAIT).

Parameters:
orientationRequested - 3 or 4
Throws:
IllegalArgumentException - if orientationRequested is not 3 or 4

setOrientationRequestedToDefault

public void setOrientationRequestedToDefault()
Sets the print orientation for pages using these attributes to the default. The default orientation is portrait.


getOrigin

public PageAttributes.OriginType getOrigin()
Returns whether drawing at (0, 0) to pages using these attributes draws at the upper-left corner of the physical page, or at the upper-left corner of the printable area. (Note that these locations could be equivalent.) This attribute cannot be modified by, and is not subject to any limitations of, the implementation or the target printer.

Returns:
OriginType.PHYSICAL or OriginType.PRINTABLE

setOrigin

public void setOrigin(PageAttributes.OriginType origin)
Specifies whether drawing at (0, 0) to pages using these attributes draws at the upper-left corner of the physical page, or at the upper-left corner of the printable area. (Note that these locations could be equivalent.) Not specifying the property is equivalent to specifying OriginType.PHYSICAL.

Parameters:
origin - OriginType.PHYSICAL or OriginType.PRINTABLE
Throws:
IllegalArgumentException - if origin is null.

getPrintQuality

public PageAttributes.PrintQualityType getPrintQuality()
Returns the print quality for pages using these attributes. This attribute is updated to the value chosen by the user.

Returns:
PrintQualityType.DRAFT, PrintQualityType.NORMAL, or PrintQualityType.HIGH

setPrintQuality

public void setPrintQuality(PageAttributes.PrintQualityType printQuality)
Specifies the print quality for pages using these attributes. Not specifying the property is equivalent to specifying PrintQualityType.NORMAL.

Parameters:
printQuality - PrintQualityType.DRAFT, PrintQualityType.NORMAL, or PrintQualityType.HIGH
Throws:
IllegalArgumentException - if printQuality is null.

setPrintQuality

public void setPrintQuality(int printQuality)
Specifies the print quality for pages using these attributes. Specifying 3 denotes draft. Specifying 4 denotes normal. Specifying 5 denotes high. Specifying any other value will generate an IllegalArgumentException. Not specifying the property is equivalent to calling setPrintQuality(PrintQualityType.NORMAL).

Parameters:
printQuality - 3, 4, or 5
Throws:
IllegalArgumentException - if printQuality is not 3 , 4, or 5

setPrintQualityToDefault

public void setPrintQualityToDefault()
Sets the print quality for pages using these attributes to the default. The default print quality is normal.


getPrinterResolution

public int[] getPrinterResolution()
Returns the print resolution for pages using these attributes. Index 0 of the array specifies the cross feed direction resolution (typically the horizontal resolution). Index 1 of the array specifies the feed direction resolution (typically the vertical resolution). Index 2 of the array specifies whether the resolutions are in dots per inch or dots per centimeter. 3 denotes dots per inch. 4 denotes dots per centimeter.

Returns:
an integer array of 3 elements. The first element must be greater than 0. The second element must be must be greater than 0. The third element must be either 3 or 4.

setPrinterResolution

public void setPrinterResolution(int[] printerResolution)
Specifies the desired print resolution for pages using these attributes. The actual resolution will be determined by the limitations of the implementation and the target printer. Index 0 of the array specifies the cross feed direction resolution (typically the horizontal resolution). Index 1 of the array specifies the feed direction resolution (typically the vertical resolution). Index 2 of the array specifies whether the resolutions are in dots per inch or dots per centimeter. 3 denotes dots per inch. 4 denotes dots per centimeter. Note that the 1.1 printing implementation (Toolkit.getPrintJob) requires that the feed and cross feed resolutions be the same. Not specifying the property is equivalent to calling setPrinterResolution(72).

Parameters:
printerResolution - an integer array of 3 elements. The first element must be greater than 0. The second element must be must be greater than 0. The third element must be either 3 or 4.
Throws:
IllegalArgumentException - if one or more of the above conditions is violated.

setPrinterResolution

public void setPrinterResolution(int printerResolution)
Specifies the desired cross feed and feed print resolutions in dots per inch for pages using these attributes. The same value is used for both resolutions. The actual resolutions will be determined by the limitations of the implementation and the target printer. Not specifying the property is equivalent to specifying 72.

Parameters:
printerResolution - an integer greater than 0.
Throws:
IllegalArgumentException - if printerResolution is less than or equal to 0.

setPrinterResolutionToDefault

public void setPrinterResolutionToDefault()
Sets the printer resolution for pages using these attributes to the default. The default is 72 dpi for both the feed and cross feed resolutions.


equals

public boolean equals(Object obj)
Determines whether two PageAttributes are equal to each other.

Two PageAttributes are equal if and only if each of their attributes are equal. Attributes of enumeration type are equal if and only if the fields refer to the same unique enumeration object. This means that an aliased media is equal to its underlying unique media. Printer resolutions are equal if and only if the feed resolution, cross feed resolution, and units are equal.

Overrides:
equals in class Object
Parameters:
obj - the object whose equality will be checked.
Returns:
whether obj is equal to this PageAttribute according to the above criteria.
See Also:
Object.hashCode(), Hashtable

hashCode

public int hashCode()
Returns a hash code value for this PageAttributes.

Overrides:
hashCode in class Object
Returns:
the hash code.
See Also:
Object.equals(java.lang.Object), Hashtable

toString

public String toString()
Returns a string representation of this PageAttributes.

Overrides:
toString in class Object
Returns:
the string representation.

Ces informations proviennent du site de http://java.sun.com

Remarques

Contenu

Le contenu de cette page provient du site de Sun, et est généré depuis un cache sur l'infobrol après certains traitements automatisés. La présentation peut donc différer du document original, mais le contenu aussi. Vous pouvez utiliser ce bouton pour afficher la page originale du site de Sun :

Quels sont les motivations de cette démarche?

Maintenir les pages en cache sur différents sites peut offrir plus de disponibilité.

Chaque page est indexée dans la base de donnée, ce qui permet de retrouver facilement les informations, au moyen des sommaires, du moteur de recherche interne, etc.

Des facilités sont mises en place pour que les membres de l'infobrol puissent effectuer des traductions en français des différents documents. Ceci devrait permettre aux débutants en programmation Java de consulter les API en français s'ils maîtrisent moins bien la langue de Shakespeare. Dans le cas où une traduction a été soumise, elle est disponible au moyen d'un lien en bas de page. Si la traduction a été validée, la page s'affiche par défaut en français, et un lien en bas de page permet d'atteindre la version en anglais.

Le code sur l'infobrol est automatiquement coloré selon la syntaxe, et les différents mots clés sont transformés en liens pour accéder rapidement aux informations.

Vous avez la possibilité de partager vos expériences en proposant vos propres extraits de code en utilisant le bouton "ajouter un commentaire" en bas de page. Si vous visitez simplement l'infobrol, vous avez déjà accès à cette fonction, mais si vous étes membre du brol, vous pouvez en plus utiliser des boutons supplémentaires de mise en forme, dont la coloration automatique de vos extraits de codes.

Réseaux sociaux

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher les interactions avec les réseaux sociaux sur ces pages.

 

Nuage de mots clés

6 mots clés dont 0 définis manuellement (plus d'information...).

Avertissement

Cette page ne possède pas encore de mots clés manuels, ceci est donc un exemple automatique (les niveaux de pertinence sont fictifs, mais les liens sont valables). Pour tester le nuage avec une page qui contient des mots définis manuellement, vous pouvez cliquer ici.

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher le nuage de mots clés.

 

Astuce pour imprimer les couleurs des cellules de tableaux : http://www.gaudry.be/ast-rf-450.html
Aucun commentaire pour cette page

© Ce document issu de l′infobrol est enregistré sous le certificat Cyber PrInterDeposit Digital Numbertection. Enregistrement IDDN n° 5329-12859
Document créé le 14/04/08 01:41, dernière modification le Vendredi 17 Juin 2011, 12:12
Source du document imprimé : http://www.gaudry.be/java-api-javaee-rf-javax/mail/MethodNotSupportedException.html Document affiché 1 fois ce mois de Juin.
St.Gaudry©07.01.02
Outils (masquer)
||
Recherche (afficher)
Recherche :

Utilisateur (masquer)
Apparence (afficher)
Stats (afficher)
15832 documents
452 astuces.
549 niouzes.
3099 definitions.
447 membres.
8115 messages.

Document genere en :
0,90 seconde

Mises à jour :
Mises à jour du site
Citation (masquer)
Qui comprend le nouveau en réchauffant l'ancien peut devenir un maître.

Confucius
 
l'infobrol
Nous sommes le Vendredi 01 Juin 2012, 09:54, toutes les heures sont au format GMT+1.00 Heure, heure d'été (+1)