|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.print.attribute.Size2DSyntax
public abstract class Size2DSyntax
Size2DSyntax
is the abstract base class of all attribute
classes which provide a two dimensional size as value (e.g. the size of
a media like Letter or A4).
A Size2DSyntax
instance consists of two integer values
describing the size in the x and y dimension. The units of
the given values is determined by two defined constants:
A size 2D attribute is constructed by two values for the size of the x and y dimension and the actual units of the given values as defined by the constants.
There are different methods provided to return the size values for the dimensions in either of the two predefined units or with a given client supplied units conversion factor.
Internal storage:
The size of the x,y dimensions are stored internally in micrometers. The
values of the provided constants for inch (value 25400) and millimeters
(value 1000) are used as conversion factors to the internal storage units.
To get the internal micrometers values a multiplication of a given
size value with its units constant value is done. Retrieving the size value
for specific units is done by dividing the internal stored value by the
units constant value. Clients are therefore able to provide their own
size units by supplying other conversion factors.
Subclasses of Size2DSyntax
have access to the internal
size values through the protected methods
getXMicrometers()
and getYMicrometers()
.
Field Summary | |
---|---|
static int |
INCH
Constant for the units of inches. |
static int |
MM
Constant for the units of millimeters. |
Constructor Summary | |
---|---|
protected |
Size2DSyntax(float x,
float y,
int units)
Creates a Size2DSyntax object with the given arguments. |
protected |
Size2DSyntax(int x,
int y,
int units)
Creates a Size2DSyntax object with the given arguments. |
Method Summary | |
---|---|
boolean |
equals(Object obj)
Tests if the given object is equal to this object. |
float[] |
getSize(int units)
Returns the size described in this object as a two field array. |
float |
getX(int units)
Returns the size in x direction. |
protected int |
getXMicrometers()
Returns the size in x direction in mircometers. |
float |
getY(int units)
Return the size in y direction. |
protected int |
getYMicrometers()
Returns the size in y direction in mircometers. |
int |
hashCode()
Returns the hashcode for this object. |
String |
toString()
Returns the string representation for this object. |
String |
toString(int units,
String unitsName)
Returns the string representation for this object. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int INCH
public static final int MM
Constructor Detail |
---|
protected Size2DSyntax(float x, float y, int units)
Size2DSyntax
object with the given arguments.
x
- the size in x directiony
- the size in y directionunits
- the units to use for the sizes
IllegalArgumentException
- if x or y < 0 or units < 1protected Size2DSyntax(int x, int y, int units)
Size2DSyntax
object with the given arguments.
x
- the size in x directiony
- the size in y directionunits
- the units to use for the sizes
IllegalArgumentException
- if x or y < 0 or units < 1Method Detail |
---|
public boolean equals(Object obj)
equals
in class Object
obj
- the object to test
true
if both objects are equal, false
otherwise.Object.hashCode()
public float[] getSize(int units)
units
- the units to use
IllegalArgumentException
- if units < 1public float getX(int units)
units
- the units to use
IllegalArgumentException
- if units < 1protected int getXMicrometers()
public float getY(int units)
units
- the units to use
IllegalArgumentException
- if units < 1protected int getYMicrometers()
public int hashCode()
hashCode
in class Object
Object.equals(Object)
,
System.identityHashCode(Object)
public String toString()
The returned string is in the form "XxY um" with X standing for size in x and Y for the size in y direction. The used micrometers units is indicated by the appended "um" notation.
toString
in class Object
Object.getClass()
,
Object.hashCode()
,
Class.getName()
,
Integer.toHexString(int)
public String toString(int units, String unitsName)
The returned string is in the form "XxY U" with X standing for size in x and Y for the size in y direction. U denotes the units name if one is supplied. The values are given as floating point values.
units
- the units to useunitsName
- the name of the units. If null
it is ommitted from the string representation.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |