Java Doc for ResolutionSyntax.java in  » 6.0-JDK-Core » print » javax » print » attribute » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » print » javax.print.attribute 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   javax.print.attribute.ResolutionSyntax

All known Subclasses:   javax.print.attribute.standard.PrinterResolution,
ResolutionSyntax
abstract public class ResolutionSyntax implements Serializable,Cloneable(Code)
Class ResolutionSyntax is an abstract base class providing the common implementation of all attributes denoting a printer resolution.

A resolution attribute's value consists of two items, the cross feed direction resolution and the feed direction resolution. A resolution attribute may be constructed by supplying the two values and indicating the units in which the values are measured. Methods are provided to return a resolution attribute's values, indicating the units in which the values are to be returned. The two most common resolution units are dots per inch (dpi) and dots per centimeter (dpcm), and exported constants ResolutionSyntax.DPI DPI and ResolutionSyntax.DPCM DPCM are provided for indicating those units.

Once constructed, a resolution attribute's value is immutable.

Design

A resolution attribute's cross feed direction resolution and feed direction resolution values are stored internally using units of dots per 100 inches (dphi). Storing the values in dphi rather than, say, metric units allows precise integer arithmetic conversions between dpi and dphi and between dpcm and dphi: 1 dpi = 100 dphi, 1 dpcm = 254 dphi. Thus, the values can be stored into and retrieved back from a resolution attribute in either units with no loss of precision. This would not be guaranteed if a floating point representation were used. However, roundoff error will in general occur if a resolution attribute's values are created in one units and retrieved in different units; for example, 600 dpi will be rounded to 236 dpcm, whereas the true value (to five figures) is 236.22 dpcm.

Storing the values internally in common units of dphi lets two resolution attributes be compared without regard to the units in which they were created; for example, 300 dpcm will compare equal to 762 dpi, as they both are stored as 76200 dphi. In particular, a lookup service can match resolution attributes based on equality of their serialized representations regardless of the units in which they were created. Again, using integers for internal storage allows precise equality comparisons to be done, which would not be guaranteed if a floating point representation were used.

The exported constant ResolutionSyntax.DPI DPI is actually the conversion factor by which to multiply a value in dpi to get the value in dphi. Likewise, the exported constant ResolutionSyntax.DPCM DPCM is the conversion factor by which to multiply a value in dpcm to get the value in dphi. A client can specify a resolution value in units other than dpi or dpcm by supplying its own conversion factor. However, since the internal units of dphi was chosen with supporting only the external units of dpi and dpcm in mind, there is no guarantee that the conversion factor for the client's units will be an exact integer. If the conversion factor isn't an exact integer, resolution values in the client's units won't be stored precisely.


author:
   David Mendenhall
author:
   Alan Kaminsky



Field Summary
final public static  intDPCM
     Value to indicate units of dots per centimeter (dpcm).
final public static  intDPI
     Value to indicate units of dots per inch (dpi).

Constructor Summary
public  ResolutionSyntax(int crossFeedResolution, int feedResolution, int units)
     Construct a new resolution attribute from the given items.
Parameters:
  crossFeedResolution - Cross feed direction resolution.
Parameters:
  feedResolution - Feed direction resolution.
Parameters:
  units - Unit conversion factor, e.g.

Method Summary
public  booleanequals(Object object)
     Returns whether this resolution attribute is equivalent to the passed in object.
public  intgetCrossFeedResolution(int units)
     Returns this resolution attribute's cross feed direction resolution in the given units.
protected  intgetCrossFeedResolutionDphi()
     Returns this resolution attribute's cross feed direction resolution in units of dphi.
public  intgetFeedResolution(int units)
     Returns this resolution attribute's feed direction resolution in the given units.
protected  intgetFeedResolutionDphi()
     Returns this resolution attribute's feed direction resolution in units of dphi.
public  int[]getResolution(int units)
     Get this resolution attribute's resolution values in the given units. The values are rounded to the nearest integer.
public  inthashCode()
     Returns a hash code value for this resolution attribute.
public  booleanlessThanOrEquals(ResolutionSyntax other)
     Determine whether this resolution attribute's value is less than or equal to the given resolution attribute's value.
public  StringtoString(int units, String unitsName)
     Returns a string version of this resolution attribute in the given units.
public  StringtoString()
     Returns a string version of this resolution attribute.

Field Detail
DPCM
final public static int DPCM(Code)
Value to indicate units of dots per centimeter (dpcm). It is actually the conversion factor by which to multiply dpcm to yield dphi (254).



DPI
final public static int DPI(Code)
Value to indicate units of dots per inch (dpi). It is actually the conversion factor by which to multiply dpi to yield dphi (100).




Constructor Detail
ResolutionSyntax
public ResolutionSyntax(int crossFeedResolution, int feedResolution, int units)(Code)
Construct a new resolution attribute from the given items.
Parameters:
  crossFeedResolution - Cross feed direction resolution.
Parameters:
  feedResolution - Feed direction resolution.
Parameters:
  units - Unit conversion factor, e.g. ResolutionSyntax.DPI DPI orResolutionSyntax.DPCM DPCM.
exception:
  IllegalArgumentException - (unchecked exception) Thrown if crossFeedResolution < 1 or feedResolution < 1 or units < 1.




Method Detail
equals
public boolean equals(Object object)(Code)
Returns whether this resolution attribute is equivalent to the passed in object. To be equivalent, all of the following conditions must be true:
  1. object is not null.
  2. object is an instance of class ResolutionSyntax.
  3. This attribute's cross feed direction resolution is equal to object's cross feed direction resolution.
  4. This attribute's feed direction resolution is equal to object's feed direction resolution.

Parameters:
  object - Object to compare to. True if object is equivalent to this resolutionattribute, false otherwise.



getCrossFeedResolution
public int getCrossFeedResolution(int units)(Code)
Returns this resolution attribute's cross feed direction resolution in the given units. The value is rounded to the nearest integer.
Parameters:
  units - Unit conversion factor, e.g. ResolutionSyntax.DPI DPI orResolutionSyntax.DPCM DPCM. Cross feed direction resolution.
exception:
  IllegalArgumentException - (unchecked exception) Thrown if units < 1.



getCrossFeedResolutionDphi
protected int getCrossFeedResolutionDphi()(Code)
Returns this resolution attribute's cross feed direction resolution in units of dphi. (For use in a subclass.) Cross feed direction resolution.



getFeedResolution
public int getFeedResolution(int units)(Code)
Returns this resolution attribute's feed direction resolution in the given units. The value is rounded to the nearest integer.
Parameters:
  units - Unit conversion factor, e.g. ResolutionSyntax.DPI DPI or ResolutionSyntax.DPCM DPCM. Feed direction resolution.
exception:
  IllegalArgumentException - (unchecked exception) Thrown if units < 1.



getFeedResolutionDphi
protected int getFeedResolutionDphi()(Code)
Returns this resolution attribute's feed direction resolution in units of dphi. (For use in a subclass.) Feed direction resolution.



getResolution
public int[] getResolution(int units)(Code)
Get this resolution attribute's resolution values in the given units. The values are rounded to the nearest integer.
Parameters:
  units - Unit conversion factor, e.g. ResolutionSyntax.DPI DPI orResolutionSyntax.DPCM DPCM. A two-element array with the cross feed direction resolutionat index 0 and the feed direction resolution at index 1.
exception:
  IllegalArgumentException - (unchecked exception) Thrown if units < 1.



hashCode
public int hashCode()(Code)
Returns a hash code value for this resolution attribute.



lessThanOrEquals
public boolean lessThanOrEquals(ResolutionSyntax other)(Code)
Determine whether this resolution attribute's value is less than or equal to the given resolution attribute's value. This is true if all of the following conditions are true:
  • This attribute's cross feed direction resolution is less than or equal to the other attribute's cross feed direction resolution.
  • This attribute's feed direction resolution is less than or equal to the other attribute's feed direction resolution.

Parameters:
  other - Resolution attribute to compare with. True if this resolution attribute is less than or equal to theother resolution attribute, false otherwise.
exception:
  NullPointerException - (unchecked exception) Thrown if other is null.



toString
public String toString(int units, String unitsName)(Code)
Returns a string version of this resolution attribute in the given units. The string takes the form "CxF U", where C is the cross feed direction resolution, F is the feed direction resolution, and U is the units name. The values are rounded to the nearest integer.
Parameters:
  units - Unit conversion factor, e.g. ResolutionSyntax.DPI DPI or ResolutionSyntax.DPCM DPCM.
Parameters:
  unitsName - Units name string, e.g. "dpi" or "dpcm". If null, no units name is appended to the result. String version of this resolution attribute.
exception:
  IllegalArgumentException - (unchecked exception) Thrown if units < 1.



toString
public String toString()(Code)
Returns a string version of this resolution attribute. The string takes the form "CxF dphi", where C is the cross feed direction resolution and F is the feed direction resolution. The values are reported in the internal units of dphi.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.