com.mindfusion.diagramming
Class MeasureUnit

java.lang.Object
  extended by com.mindfusion.diagramming.MeasureUnit

public class MeasureUnit
extends java.lang.Object

Specifies units of measure.


Field Summary
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 Percent
          Specifies percents 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 Summary
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.
 
Method Summary
 double convert(double value, MeasureUnit targetUnit, DiagramView view)
          Converts the specified value from this unit to the specified unit.
 java.awt.geom.Point2D convert(java.awt.geom.Point2D p, MeasureUnit targetUnit, DiagramView view)
          Converts the specified point from this unit to the specified unit.
 java.awt.geom.Rectangle2D convert(java.awt.geom.Rectangle2D r, MeasureUnit targetUnit, DiagramView view)
          Converts the specified rectangle from this unit to the specified unit.
 boolean equals(java.lang.Object obj)
          Object.equals(java.lang.Object) override.
static MeasureUnit fromGraphicsUnit(int unit)
          Returns the measure unit corresponding to the specified graphics unit.
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()
          Object.hashCode() override.
static boolean op_Equality(MeasureUnit a, MeasureUnit b)
          Compares two MeasureUnit objects for equality.
static boolean op_Inequality(MeasureUnit a, MeasureUnit b)
          Compares two MeasureUnit objects for inequality.
 java.lang.String toString()
          Object.toString() override.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

Millimeter

public static final MeasureUnit Millimeter
Specifies millimeters as the unit of measure.


Inch

public static final MeasureUnit Inch
Specifies inches as the unit of measure.


Point

public static final MeasureUnit Point
Specifies printer's points (1/72 inch) as the unit of measure.


Pixel

public static final MeasureUnit Pixel
Specifies device pixels as the unit of measure.


Document

public static final MeasureUnit Document
Specifies document units (1/300 inch) as the unit of measure.


WpfPoint

public static final MeasureUnit WpfPoint
Specifies device-independent pixels (1/96 inch) as the unit of measure.


Percent

public static final MeasureUnit Percent
Specifies percents as the unit of measure.

Constructor Detail

MeasureUnit

public 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.

Parameters:
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.

MeasureUnit

public 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.

Parameters:
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.

MeasureUnit

public MeasureUnit(java.lang.String name,
                   double unitsPerInch)
Initializes a new instance of the MeasureUnit class with the specified amount.

Parameters:
name - The name of the new unit.
unitsPerInch - The amount of the new unit that is equal to one inch.

MeasureUnit

public MeasureUnit(java.lang.String name,
                   double unitsPerInch,
                   int standardDivisions)
Initializes a new instance of the MeasureUnit class with the specified amount.

Parameters:
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.
Method Detail

toString

public java.lang.String toString()
Object.toString() override.

Overrides:
toString in class java.lang.Object
Returns:
The name of the unit.

hashCode

public int hashCode()
Object.hashCode() override.

Overrides:
hashCode in class java.lang.Object
Returns:
A hash code for the current unit.

equals

public boolean equals(java.lang.Object obj)
Object.equals(java.lang.Object) override.

Overrides:
equals in class java.lang.Object
Parameters:
obj - The object to compare with the current unit.
Returns:
true if the specified object is the same as or is equal to the current unit; otherwise, false.

op_Equality

public static boolean op_Equality(MeasureUnit a,
                                  MeasureUnit b)
Compares two MeasureUnit objects for equality.

Parameters:
a - The first MeasureUnit to compare.
b - The second MeasureUnit to compare.
Returns:
true if the specified arguments are equal; otherwise, false.

op_Inequality

public static boolean op_Inequality(MeasureUnit a,
                                    MeasureUnit b)
Compares two MeasureUnit objects for inequality.

Parameters:
a - The first MeasureUnit to compare.
b - The second MeasureUnit to compare.
Returns:
true if the specified arguments are not equal; otherwise, false.

convert

public double convert(double value,
                      MeasureUnit targetUnit,
                      DiagramView view)
Converts the specified value from this unit to the specified unit.

Parameters:
value - The value to convert, expressed in the current measure unit.
targetUnit - The target measure unit.
view - A parameter that is used when converting to special units (such as percents).
Returns:
The converted value.

convert

public java.awt.geom.Point2D convert(java.awt.geom.Point2D p,
                                     MeasureUnit targetUnit,
                                     DiagramView view)
Converts the specified point from this unit to the specified unit.

Parameters:
p - The point to convert, expressed in the current measure unit.
targetUnit - The target measure unit.
view - A parameter that is used when converting to special units (such as percents).
Returns:
The converted point.

convert

public java.awt.geom.Rectangle2D convert(java.awt.geom.Rectangle2D r,
                                         MeasureUnit targetUnit,
                                         DiagramView view)
Converts the specified rectangle from this unit to the specified unit.

Parameters:
r - The rectangle to convert, expressed in the current measure unit.
targetUnit - The target measure unit.
view - A parameter that is used when converting to special units (such as percents).
Returns:
The converted rectangle.

fromId

public static MeasureUnit fromId(int id)
Returns a MeasureUnit from its integer identifier.

Parameters:
id - The identifier of one of the built-in measure units.
Returns:
The built-in MeasureUnit corresponding to the specified identifier.

fromGraphicsUnit

public static MeasureUnit fromGraphicsUnit(int unit)
Returns the measure unit corresponding to the specified graphics unit.

Parameters:
unit - One of the GraphicsUnit values.
Returns:
The built-in MeasureUnit corresponding to the specified graphics unit. If unit is World, this method returns null. If unit is Display, this method returns Pixel.

getId

public int getId()
Gets the unit identifier.

This property returns -1 for custom MeasureUnit objects.


getName

public java.lang.String getName()
Gets the name of the unit.