org.extex.font.format.tfm
Class TfmFixWord

java.lang.Object
  extended by org.extex.font.format.tfm.TfmFixWord
All Implemented Interfaces:
java.io.Serializable

public class TfmFixWord
extends java.lang.Object
implements java.io.Serializable

TFM-FixWord.

The dimensions are represented in the same way as in tfm files. Higher 12 bits is the whole part and lower 20 bits is the fractional part.

Version:
$Revision: 6121 $
Author:
Michael Niedermair
See Also:
Serialized Form

Field Summary
static int CONV
          conf.
static int FIXWORDDENOMINATOR
          fixdominator.
static int FRACTIONDIGITS
          FRACTIONDIGITS.
static TfmFixWord NULL
          NULL.
static int POINTSHIFT
          POINT-SHIFT.
static TfmFixWord TEN
          TEN.
static int TFMCONV
          tfmconf.
static TfmFixWord UNITY
          UNITY.
static TfmFixWord ZERO
          ZERO.
 
Constructor Summary
TfmFixWord()
          Create a new object.
TfmFixWord(int val)
          Create a new object.
TfmFixWord(int num, int den)
          Create new object.
TfmFixWord(java.lang.String val)
          Create a new object.
 
Method Summary
 long getValue()
          Return the internal value.
 boolean lessThan(int num)
          less than.
 boolean moreThan(int num)
          more than.
 void setValue(long v)
          Set the value.
 Dimen toDimen(FixedDimen size)
          Convert the fixword value to a dimen value.
static Dimen toDimen(FixedDimen desingsize, long val)
          Convert the fixword value to a dimen value.
static Dimen toDimen(FixedDimen desingsize, TfmFixWord fw)
          Convert the fixword to a dimen value.
 double toDouble()
          Returns the value as double in untis.
 java.lang.String toString()
          Return the values as String.
 java.lang.String toStringComma()
          Returns the value as Sting in untis with comma (0.00000..).
 java.lang.String toStringUnits()
          Return the value as String in units.
static long toValue(FixedDimen desingsize, FixedDimen dimen)
          Convert a dimen to a fix word value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONV

public static final int CONV
conf.

See Also:
Constant Field Values

FIXWORDDENOMINATOR

public static final int FIXWORDDENOMINATOR
fixdominator.

See Also:
Constant Field Values

FRACTIONDIGITS

public static final int FRACTIONDIGITS
FRACTIONDIGITS.

See Also:
Constant Field Values

NULL

public static final TfmFixWord NULL
NULL.


POINTSHIFT

public static final int POINTSHIFT
POINT-SHIFT.

See Also:
Constant Field Values

TEN

public static final TfmFixWord TEN
TEN.


TFMCONV

public static final int TFMCONV
tfmconf.

See Also:
Constant Field Values

UNITY

public static final TfmFixWord UNITY
UNITY.


ZERO

public static final TfmFixWord ZERO
ZERO.

Constructor Detail

TfmFixWord

public TfmFixWord()
Create a new object.


TfmFixWord

public TfmFixWord(int val)
Create a new object.

Parameters:
val - the values as int. This int value represents the length in points.

TfmFixWord

public TfmFixWord(int num,
                  int den)
Create new object. The value represented by this instance is num / den in points.

Parameters:
num - the num
den - the den

TfmFixWord

public TfmFixWord(java.lang.String val)
Create a new object.

Parameters:
val - the values as String
Method Detail

toDimen

public static Dimen toDimen(FixedDimen desingsize,
                            long val)
Convert the fixword value to a dimen value.

see toDimen(FixedDimen size)

Parameters:
desingsize - The design size.
val - The value.
Returns:
Return the Dimen of the value.

toDimen

public static Dimen toDimen(FixedDimen desingsize,
                            TfmFixWord fw)
Convert the fixword to a dimen value.

see toDimen(FixedDimen size)

Parameters:
desingsize - The design size.
fw - The fix word.
Returns:
Return the Dimen of the value.

toValue

public static long toValue(FixedDimen desingsize,
                           FixedDimen dimen)
Convert a dimen to a fix word value.

Parameters:
desingsize - The design size.
dimen - The dimen value.
Returns:
Returns the fix word value of the dimen.

getValue

public long getValue()
Return the internal value.

Returns:
the internal value

lessThan

public boolean lessThan(int num)
less than.

Parameters:
num - the value to compare
Returns:
true, if the internal values is lesser, otherwise false

moreThan

public boolean moreThan(int num)
more than.

Parameters:
num - the value to compare
Returns:
true, if the internal values are more, otherwise false

setValue

public void setValue(long v)
Set the value.

Parameters:
v - The value to set.

toDimen

public Dimen toDimen(FixedDimen size)
Convert the fixword value to a dimen value.

the simple calculation fw.getValue() * actualsize.getValue() / TFMFixWord.FIXWORDDENOMINATOR leads to different rounding than in TeX due to a limitation to 4 byte integer precission. Note that fw.getValue() * actualsize.getValue() might exceed the 4 byte range. Hence TTP 571 cancels actualsize.getValue() and TFMFixWord.FIXWORDDENOMINATOR to allow for a bytewise calculation. We do not need this bytewise calculation since we have long integers, but we need to be precise in performing the same rounding.

Parameters:
size - The font size (design size for font dimen, actual size for all others)
Returns:
Returns the Dimen value.

toDouble

public double toDouble()
Returns the value as double in untis.

Returns:
Returns the value as double in untis.

toString

public java.lang.String toString()
Return the values as String.

Overrides:
toString in class java.lang.Object
Returns:
the values as String

toStringComma

public java.lang.String toStringComma()
Returns the value as Sting in untis with comma (0.00000..).

Returns:
Returns the value as Sting in untis with comma.

toStringUnits

public java.lang.String toStringUnits()
Return the value as String in units.

It devide the value by 1000.

Returns:
the value as String in units