JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.page
Class JCUnit

java.lang.Object
  |
  +--com.klg.jclass.page.JCUnit

public final class JCUnit
extends Object

JCUnit defines the supported linear units of measurement: inches, centimeters, and points.


Nested Class Summary
static class JCUnit.Dimension
          Dimension is similar in concept to java.awt.Dimension, but the values are stored as double-precision numbers and the units of measurement are recorded as well.
static class JCUnit.Margins
          Stores the sizes of the margins around a figure or area.
static class JCUnit.Measure
          Measure encapsulates a linear distance with its units of measurement.
static class JCUnit.Point
          Point is roughly equivalent to java.awt.Point, but the coordinates are stored as double-precision numbers and the units of measurement are recorded as well.
 
Field Summary
static com.klg.jclass.page.JCUnit CM
           
static com.klg.jclass.page.JCUnit INCHES
           
static double INCHES_TO_CM_FACTOR
           
static com.klg.jclass.page.JCUnit INTERNAL
           
protected  String name
           
static com.klg.jclass.page.JCUnit POINTS
           
static double POINTS_TO_CM_FACTOR
           
static com.klg.jclass.page.JCUnit[] UNITS
          List of available built-in units.
 
Constructor Summary
JCUnit(String name)
          Creates a new unit instance.
 
Method Summary
static boolean areProbablyEqual(double value1, double value2)
          Returns true if two numbers are within an accepted tolerance.
static JCUnit.Measure[] doublesToMeasures(com.klg.jclass.page.JCUnit unit, double[] doubles)
          A convenience method that creates an array of measures from the specified array of doubles.
 boolean equals(Object o)
           
static double getAs(com.klg.jclass.page.JCUnit to, com.klg.jclass.page.JCUnit from, double measure)
           
static double getAsCentimeters(com.klg.jclass.page.JCUnit units, double measure)
          Converts a given distance in the given units to a distance in centimeters.
static double getAsInches(com.klg.jclass.page.JCUnit units, double measure)
          Converts a given distance in the given units to a distance in inches.
static double getAsPoints(com.klg.jclass.page.JCUnit units, double measure)
          Converts a given distance in the given units to a distance in points.
static com.klg.jclass.page.JCUnit getDefaultUnits()
          Gets the JCUnit which specifies the interpretation of all numeric distances.
static double getIU(com.klg.jclass.page.JCUnit units, double measure)
          Converts a given distance, given as a JCUnit, to a distance in internal units.
 int hashCode()
          Creates a hash that generates the same value depending on the property values.
protected static int hashMeasure(double baseMeasure)
          Derives a hash value for a measure that will return the same hash value when areProbablyEqual() returns true.
static void setDefaultUnit(com.klg.jclass.page.JCUnit new_default)
          Sets the JCUnit which specifies the interpretation of all numeric distances.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

INCHES

public static final com.klg.jclass.page.JCUnit INCHES

CM

public static final com.klg.jclass.page.JCUnit CM

POINTS

public static final com.klg.jclass.page.JCUnit POINTS

INTERNAL

public static final com.klg.jclass.page.JCUnit INTERNAL

INCHES_TO_CM_FACTOR

public static final double INCHES_TO_CM_FACTOR
See Also:
Constant Field Values

POINTS_TO_CM_FACTOR

public static final double POINTS_TO_CM_FACTOR
See Also:
Constant Field Values

UNITS

public static final com.klg.jclass.page.JCUnit[] UNITS
List of available built-in units.


name

protected String name
Constructor Detail

JCUnit

public JCUnit(String name)
Creates a new unit instance.

Parameters:
name -
Method Detail

doublesToMeasures

public static final JCUnit.Measure[] doublesToMeasures(com.klg.jclass.page.JCUnit unit,
                                                       double[] doubles)
A convenience method that creates an array of measures from the specified array of doubles.

Parameters:
doubles -
unit -
Returns:

toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
Creates a hash that generates the same value depending on the property values.

Overrides:
hashCode in class Object
Returns:

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashMeasure

protected static int hashMeasure(double baseMeasure)
Derives a hash value for a measure that will return the same hash value when areProbablyEqual() returns true.

Parameters:
baseMeasure -
Returns:

areProbablyEqual

public static boolean areProbablyEqual(double value1,
                                       double value2)
Returns true if two numbers are within an accepted tolerance.
Note: This tolerance must correspond to the value used in hashMeasure, otherwise two objects that are equal will not return the same hashcode.

Parameters:
value1 -
value2 -
Returns:
true if two numbers are within an accepted tolerance

getDefaultUnits

public static final com.klg.jclass.page.JCUnit getDefaultUnits()
Gets the JCUnit which specifies the interpretation of all numeric distances.

Returns:
current global units setting

setDefaultUnit

public static final void setDefaultUnit(com.klg.jclass.page.JCUnit new_default)
Sets the JCUnit which specifies the interpretation of all numeric distances.

Parameters:
new_default - unit of measure to be applied globally

getAsCentimeters

public static final double getAsCentimeters(com.klg.jclass.page.JCUnit units,
                                            double measure)
Converts a given distance in the given units to a distance in centimeters.

Parameters:
units -
measure -
Returns:
the equivalent distance in centimeters

getIU

public static final double getIU(com.klg.jclass.page.JCUnit units,
                                 double measure)
Converts a given distance, given as a JCUnit, to a distance in internal units.

Parameters:
measure -
units -
Returns:
the equivalent distance in internal units

getAsInches

public static final double getAsInches(com.klg.jclass.page.JCUnit units,
                                       double measure)
Converts a given distance in the given units to a distance in inches.

Parameters:
units -
measure -
Returns:
the equivalent distance in inches

getAsPoints

public static final double getAsPoints(com.klg.jclass.page.JCUnit units,
                                       double measure)
Converts a given distance in the given units to a distance in points.

Parameters:
units -
measure -
Returns:
the equivalent distance in points

getAs

public static final double getAs(com.klg.jclass.page.JCUnit to,
                                 com.klg.jclass.page.JCUnit from,
                                 double measure)

Copyright © 2004 Quest Software Inc..
All rights reserved.