public class MeasureUnit
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static MeasureUnit |
Centimeter
Specifies centimeters as the unit of measure.
|
static MeasureUnit |
Document
Specifies document units (1/300 inch) as the unit of measure.
|
static MeasureUnit |
Inch
Specifies inches as the unit of measure.
|
static MeasureUnit |
Millimeter
Specifies millimeters as the unit of measure.
|
static MeasureUnit |
Pixel
Specifies device pixels as the unit of measure.
|
static MeasureUnit |
Point
Specifies printer's points (1/72 inch) as the unit of measure.
|
static MeasureUnit |
WpfPoint
Specifies device-independent pixels (1/96 inch) as the unit of measure.
|
| Constructor and Description |
|---|
MeasureUnit(java.lang.String name,
double unitsPerInch)
Initializes a new instance of the MeasureUnit class with the specified amount.
|
MeasureUnit(java.lang.String name,
double unitsPerInch,
int standardDivisions)
Initializes a new instance of the
MeasureUnit class with the specified amount. |
MeasureUnit(java.lang.String name,
MeasureUnit baseUnit,
double scale)
Initializes a new instance of the
MeasureUnit class with the specified unit of measure as a base. |
MeasureUnit(java.lang.String name,
MeasureUnit baseUnit,
double scale,
int standardDivisions)
Initializes a new instance of the
MeasureUnit class with the specified unit of measure as a base. |
| Modifier and Type | Method and Description |
|---|---|
double |
convert(double value,
MeasureUnit targetUnit,
java.lang.Object context)
Converts the specified value from this unit to the specified unit.
|
java.awt.geom.Point2D |
convert(java.awt.geom.Point2D p,
MeasureUnit targetUnit,
java.lang.Object context)
Converts the specified point from this unit to the specified unit.
|
java.awt.geom.Rectangle2D |
convert(java.awt.geom.Rectangle2D r,
MeasureUnit targetUnit,
java.lang.Object context)
Converts the specified rectangle from this unit to the specified unit.
|
boolean |
equals(java.lang.Object obj) |
static MeasureUnit |
fromId(int id)
Returns a
MeasureUnit from its integer identifier. |
int |
getId()
Gets the unit identifier.
|
java.lang.String |
getName()
Gets the name of the unit.
|
int |
hashCode() |
boolean |
isEqualTo(MeasureUnit unit)
Determines whether the specified measure unit is equal to the current measure unit.
|
java.lang.String |
toString() |
public static final MeasureUnit Millimeter
public static final MeasureUnit Centimeter
public static final MeasureUnit Inch
public static final MeasureUnit Point
public static final MeasureUnit Pixel
public static final MeasureUnit Document
public static final MeasureUnit WpfPoint
public MeasureUnit(java.lang.String name,
MeasureUnit baseUnit,
double scale)
MeasureUnit class with the specified unit of measure as a base.name - The name of the new unit.baseUnit - The base of the new unit.scale - The scale of the new unit, relatively to the base.public MeasureUnit(java.lang.String name,
MeasureUnit baseUnit,
double scale,
int standardDivisions)
MeasureUnit class with the specified unit of measure as a base.name - The name of the new unit.baseUnit - The base of the new unit.scale - The scale of the new unit, relatively to the base.standardDivisions - The number of divisions of the new unit.public MeasureUnit(java.lang.String name,
double unitsPerInch)
name - The name of the new unit.unitsPerInch - The amount of the new unit that is equal to one inch.public MeasureUnit(java.lang.String name,
double unitsPerInch,
int standardDivisions)
MeasureUnit class with the specified amount.name - The name of the new unit.unitsPerInch - The amount of the new unit that is equal to one inch.standardDivisions - The number of divisions of the new unit.public java.lang.String toString()
toString in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic boolean isEqualTo(MeasureUnit unit)
unit - The object to compare to this measure unit.true if the specified measure unit is equal to this object; otherwise, false.public double convert(double value,
MeasureUnit targetUnit,
java.lang.Object context)
If the target represents logical unit (such as millimeter, inch, point) or a unit derived from a logical unit, and the current unit is not logical (for example pixel), the third parameter is required to perform the conversion.
value - The value to convert, expressed in the current measure unit.targetUnit - The target measure unit.context - A parameter that is used when converting from logical units (such as
inches and millimeters) to device units (such as pixels) or special units.public java.awt.geom.Point2D convert(java.awt.geom.Point2D p,
MeasureUnit targetUnit,
java.lang.Object context)
If the target represents logical unit (such as millimeter, inch, point) or a unit derived from a logical unit, and the current unit is not logical (for example pixel), the third parameter is required to perform the conversion. If both units are of the same generic type, context is ignored.
p - The point to convert, expressed in the current measure unit.targetUnit - The target measure unit.context - A parameter that is used when converting from logical units (such as
inches and millimeters) to device units (such as pixels) or special units.public java.awt.geom.Rectangle2D convert(java.awt.geom.Rectangle2D r,
MeasureUnit targetUnit,
java.lang.Object context)
If the target represents logical unit (such as mm, inch, point) or a unit derived from a logical unit, and the current unit is not logical (for example pixel), the third parameter is required to perform the conversion. If both units are of the same generic type, context is ignored.
r - The rectangle to convert, expressed in the current measure unit.targetUnit - The target measure unit.context - A parameter that is used when converting from logical units
(such as inches and millimeters) to device units (such as pixels) or special units.public static MeasureUnit fromId(int id)
MeasureUnit from its integer identifier.id - The identifier of one of the built-in measure units.public int getId()
MeasureUnit objects.public java.lang.String getName()