javax.print.attribute
Class Size2DSyntax
- Cloneable, Serializable
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:
- INCH - defines an inch
- MM - defines a millimeter
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()
.
static int | INCH - Constant for the units of inches.
|
static int | MM - Constant for the units of millimeters.
|
Size2DSyntax(float x, float y, int units) - Creates a
Size2DSyntax object with the given arguments.
|
Size2DSyntax(int x, int y, int units) - Creates a
Size2DSyntax object with the given arguments.
|
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.
|
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
INCH
public static final int INCH
Constant for the units of inches.
The actual value is the conversion factor to micrometers.
MM
public static final int MM
Constant for the units of millimeters.
The actual value is the conversion factor to micrometers.
Size2DSyntax
protected Size2DSyntax(float x,
float y,
int units)
Creates a Size2DSyntax
object with the given arguments.
x
- the size in x directiony
- the size in y directionunits
- the units to use for the sizes
Size2DSyntax
protected Size2DSyntax(int x,
int y,
int units)
Creates a Size2DSyntax
object with the given arguments.
x
- the size in x directiony
- the size in y directionunits
- the units to use for the sizes
equals
public boolean equals(Object obj)
Tests if the given object is equal to this object.
- equals in interface Object
true
if both objects are equal, false
otherwise.
getSize
public float[] getSize(int units)
Returns the size described in this object as a two field array.
Index 0 contains the size in x direction, index 1 the size in
y direction.
- The array with the size dimensions.
getX
public float getX(int units)
Returns the size in x direction.
getXMicrometers
protected int getXMicrometers()
Returns the size in x direction in mircometers.
To be used by sublcasses that need access to the internal storage value.
- The size in x direction in micrometers.
getY
public float getY(int units)
Return the size in y direction.
getYMicrometers
protected int getYMicrometers()
Returns the size in y direction in mircometers.
To be used by sublcasses that need access to the internal storage value.
- The size in y direction in micrometers.
toString
public String toString()
Returns the string representation for this object.
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 interface Object
- The string representation in micrometers.
toString
public String toString(int units,
String unitsName)
Returns the string representation for this object.
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.
- The string representation.
Size2DSyntax.java --
Copyright (C) 2003, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.