org.extex.core.dimen
Class Dimen

java.lang.Object
  extended by org.extex.core.dimen.DimenConstant
      extended by org.extex.core.dimen.Dimen
All Implemented Interfaces:
java.io.Serializable, FixedDimen

public class Dimen
extends DimenConstant

This class implements the dimen value. This is a length with fixed point arithmetic.

Version:
$Revision: 4726 $
Author:
Gerd Neugebauer, Michael Niedermair
See Also:
Serialized Form

Field Summary
static long ONE
          The constant ONE contains the internal representation for 1pt.
static FixedDimen ONE_INCH
          The constant ONE_INCH contains the immutable dimen register representing the length of 1 in.
static FixedDimen ONE_PT
          The constant ONE_PT contains the immutable dimen register representing the length of 1 pt.
static FixedDimen ONE_SP
          The constant ONE_SP contains the immutable dimen register representing the length of 1 scaled point.
protected static long serialVersionUID
          The constant serialVersionUID contains the id for serialization.
static FixedDimen ZERO
          The constant ZERO contains the non-stretchable and non-shrinkable value of 0 pt.
static FixedDimen ZERO_PT
          The constant ZERO_PT contains the immutable dimen register representing the length of 0 pt.
 
Fields inherited from class org.extex.core.dimen.DimenConstant
value
 
Constructor Summary
Dimen()
          Creates a new object.
Dimen(FixedDimen value)
          Creates a new object.
Dimen(long value)
          Creates a new object.
 
Method Summary
 void abs(FixedDimen d)
          Set the value of this dimen to the absolute value of a given value.
 void add(FixedDimen d)
          Add the value of the argument to the current value.
 void add(long d)
          Add the value of the argument to the current value.
 void divide(long denom)
          Divide the current value with a given number.
 boolean isZero()
          Test for a value of zero.
 void max(FixedDimen d)
          Sets the value of the dimen to the maximum of the value already stored and a given argument.
 void min(FixedDimen d)
          Sets the value of the dimen to the minimum of the value already stored and a given argument.
 void multiply(long factor)
          Multiply the current value with a given number.
 void multiply(long nom, long denom)
          Multiply the value by an integer fraction.
 void negate()
          Negate the value of the argument to the current value.
 void set(FixedDimen d)
          Setter for the value.
 void set(long d)
          Setter for the value.
 void subtract(FixedDimen d)
          Subtract the value of the argument from the current value.
 
Methods inherited from class org.extex.core.dimen.DimenConstant
copy, eq, ge, getValue, gt, le, lt, ne, toString, toString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ZERO

public static final FixedDimen ZERO
The constant ZERO contains the non-stretchable and non-shrinkable value of 0 pt.


ONE

public static final long ONE
The constant ONE contains the internal representation for 1pt.

See Also:
"TeX – The Program [101]", Constant Field Values

ONE_INCH

public static final FixedDimen ONE_INCH
The constant ONE_INCH contains the immutable dimen register representing the length of 1 in.


ONE_PT

public static final FixedDimen ONE_PT
The constant ONE_PT contains the immutable dimen register representing the length of 1 pt.


ONE_SP

public static final FixedDimen ONE_SP
The constant ONE_SP contains the immutable dimen register representing the length of 1 scaled point.


serialVersionUID

protected static final long serialVersionUID
The constant serialVersionUID contains the id for serialization.

See Also:
Constant Field Values

ZERO_PT

public static final FixedDimen ZERO_PT
The constant ZERO_PT contains the immutable dimen register representing the length of 0 pt.

Constructor Detail

Dimen

public Dimen()
Creates a new object. The length stored in it is initialized to 0 pt.


Dimen

public Dimen(FixedDimen value)
Creates a new object. This method makes a new instance of the class with the same value as the given instance. I.e. it acts like clone().

Parameters:
value - the value to imitate

Dimen

public Dimen(long value)
Creates a new object. This method makes a new instance of the class with the given value.

Parameters:
value - the value to set
Method Detail

abs

public void abs(FixedDimen d)
Set the value of this dimen to the absolute value of a given value.

Parameters:
d - the given value

add

public void add(FixedDimen d)
Add the value of the argument to the current value. This operation modifies the instance.

|this| → |this| + |d|

Parameters:
d - the Dimen to add

add

public void add(long d)
Add the value of the argument to the current value. This operation modifies the instance.

|this| → |this| + |d|

Parameters:
d - the value to add in sp

divide

public void divide(long denom)
            throws java.lang.ArithmeticException
Divide the current value with a given number. This operation modifies this instance.

|this| → |this| / denom

Parameters:
denom - denominator to divide by
Throws:
java.lang.ArithmeticException - in case of a division by 0, i.e. if denom is 0.

isZero

public boolean isZero()
Test for a value of zero.

Returns:
true iff the value is 0

max

public void max(FixedDimen d)
Sets the value of the dimen to the maximum of the value already stored and a given argument. |this| = max(|this|, |d|)

Parameters:
d - the other dimen

min

public void min(FixedDimen d)
Sets the value of the dimen to the minimum of the value already stored and a given argument. |this| = min(|this|, |d|)

Parameters:
d - the other dimen

multiply

public void multiply(long nom,
                     long denom)
Multiply the value by an integer fraction.

length = length * nom / denom

Parameters:
nom - nominator
denom - denominator

multiply

public void multiply(long factor)
Multiply the current value with a given number. This operation modifies this instance.

|this| → |this| * factor

Parameters:
factor - the factor to multiply with

negate

public void negate()
Negate the value of the argument to the current value. This operation modifies the instance.

|this| → - |this|


set

public void set(FixedDimen d)
Setter for the value. The order of the argument is ignored.

Parameters:
d - the new value

set

public void set(long d)
Setter for the value. The order of the argument is ignored.

Parameters:
d - the new value

subtract

public void subtract(FixedDimen d)
Subtract the value of the argument from the current value. This operation modifies the instance.

|this| → |this| - |d|

Parameters:
d - the Dimen to subtract