de.dante.extex.interpreter.type.muskip
Class Mudimen

java.lang.Object
  extended byde.dante.extex.interpreter.type.muskip.Mudimen
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
Muskip

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

This class provides a dimen value with a length which is a multiple of math units (mu).

Version:
$Revision: 1.15 $
Author:
Gerd Neugebauer
See Also:
Serialized Form

Field Summary
protected static long serialVersionUID
          The constant serialVersionUID contains the id for serialization.
 
Constructor Summary
Mudimen()
          Creates a new object.
Mudimen(long len)
          Creates a new object.
 
Method Summary
 void add(long value)
          Add some other length to the current value.
 GlueComponent getLength()
          Getter for length.
 boolean isZero()
          Check for a zero value.
 void multiply(long nom, long denom)
          Multiply the value by an integer fraction.
static Mudimen parseMudimen(Context context, TokenSource source, Typesetter typesetter)
          Creates a new object and fills it from a token stream.
protected static long scanMu(Context context, TokenSource source, Typesetter typesetter)
          Scan a math unit.
 java.lang.String toString()
          Return the string representation of the instance.
 void toString(java.lang.StringBuffer sb)
          Append the string representation of the instance to a string buffer.
 void toToks(Tokens toks, TokenFactory factory, char c1, char c2)
          Determine the printable representation of the object and return it as a list of Tokens.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

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

See Also:
Constant Field Values
Constructor Detail

Mudimen

public Mudimen()
Creates a new object. All components are 0.


Mudimen

public Mudimen(long len)
Creates a new object.

Parameters:
len - the length
Method Detail

scanMu

protected static long scanMu(Context context,
                             TokenSource source,
                             Typesetter typesetter)
                      throws InterpreterException
Scan a math unit.

Parameters:
context - the processor context
source - the source for new tokens
typesetter - the typesetter
Returns:
the number of scaled points for the mu
Throws:
InterpreterException - in case of an error

parseMudimen

public static Mudimen parseMudimen(Context context,
                                   TokenSource source,
                                   Typesetter typesetter)
                            throws InterpreterException
Creates a new object and fills it from a token stream. This method parses the following syntactic entity:
    ⟨mudimen⟩
      → ⟨float⟩ mu
       |  ⟨mudimen variable⟩
 
The value of ⟨mudimen⟩ is either a floating point number followed by the unit mu or a variable value resulting in a mudimen value.

Parameters:
context - the processor context
source - the source for new tokens
Throws:
InterpreterException - in case of an error

add

public void add(long value)
Add some other length to the current value.

Parameters:
value - the value to add

getLength

public GlueComponent getLength()
Getter for length.

Returns:
the length

isZero

public boolean isZero()
Check for a zero value.

Returns:
true iff the length is zero

multiply

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

length = length * nom / denom

Parameters:
nom - nominator
denom - denominator

toString

public java.lang.String toString()
Return the string representation of the instance.

Returns:
the string representation of this glue
See Also:
"TeX – The Program [???]"

toString

public void toString(java.lang.StringBuffer sb)
Append the string representation of the instance to a string buffer.

Parameters:
sb - the target string buffer

toToks

public void toToks(Tokens toks,
                   TokenFactory factory,
                   char c1,
                   char c2)
            throws CatcodeException
Determine the printable representation of the object and return it as a list of Tokens. The value returned is exactly the string which would be produced by TeX to print the Mudimen. This means the result is expressed in mu and properly rounded to be read back in again without loss of information.

Parameters:
toks - the tokens to append to
factory - the token factory to get the required tokens from
c1 - the first character of the unit
c2 - the second character of the unit
Throws:
CatcodeException - in case of an error