de.dante.extex.interpreter.type.glue
Class Glue

java.lang.Object
  extended byde.dante.extex.interpreter.type.glue.Glue
All Implemented Interfaces:
FixedGlue, java.io.Serializable

public class Glue
extends java.lang.Object
implements java.io.Serializable, FixedGlue

This class provides the basic data type of a stretchable and shrinkable quantity of length.

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

Field Summary
protected static long serialVersionUID
          The constant serialVersionUID contains the id for serialization.
 
Fields inherited from interface de.dante.extex.interpreter.type.glue.FixedGlue
NORMAL_ORDER, S_S, ZERO
 
Constructor Summary
Glue()
          Creates a new object with a zero length.
Glue(FixedDimen theLength)
          Creates a new object with a fixed length.
Glue(FixedGlue glue)
          Creates a new object as copy of another glue.
Glue(FixedGlueComponent theLength, FixedGlueComponent theStretch, FixedGlueComponent theShrink)
          Creates a new object from the three components.
Glue(long theLength)
          Creates a new object from a fixed length.
 
Method Summary
 void add(FixedGlue g)
          Add another glue to this one.
 void add(FixedGlueComponent g)
          Add a dimen to this one glue.
 Glue copy()
          Make a copy of this object.
 boolean eq(FixedGlue glue)
          Test that the given Glue is equal to a given one.
 boolean ge(FixedGlueComponent x)
          Compare this value with a given glue and return true iff the current length is greater or equal than the given length.
 FixedDimen getLength()
          Getter for the length.
 FixedGlueComponent getShrink()
          Getter for shrink.
 FixedGlueComponent getStretch()
          Getter for stretch.
 boolean gt(FixedGlueComponent x)
          Compare this value with a given glue and return true iff the current length is greater than the given length.
 boolean le(FixedGlueComponent x)
          Compare this value with a given glue and return true iff the current length is less or equal than the given length.
 boolean lt(FixedGlueComponent x)
          Compare this value with a given glue and return true iff the current length is less than the given length.
 void multiply(long nom, long denom)
          Multiply the normal size by an integer fraction.
 void multiplyAll(long nom, long denom)
          Multiply all components by an integer fraction.
 void multiplyShrink(long nom, long denom)
          Multiply the shrink component by an integer fraction.
 void multiplyStretch(long nom, long denom)
          Multiply the stretch component by an integer fraction.
 boolean ne(FixedGlue glue)
          Test that the given Glue is differnt from a given one.
 void negateLength()
          Negate the value.
static Glue parse(TokenSource source, Context context, Typesetter typesetter)
          Creates a new object by parsing a token source.
 void set(FixedDimen theLength)
          Set the glue value to a non-stretchable and non-shrinkable length.
 void set(FixedGlue theLength)
          Set the glue value.
 void setLength(FixedDimen x)
          Setter for the length component
 void setShrink(FixedDimen x)
          Setter for the shrink component
 void setStretch(FixedDimen x)
          Setter for the stretch component
 void subtract(FixedGlue g)
          Subtract another glue to this one.
 void subtract(FixedGlueComponent g)
          Subtract a Glue component from this glue.
 java.lang.String toString()
          Determine the printable representation of the object.
 Tokens toToks(TokenFactory factory)
          Determine the printable representation of the object.
 
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

Glue

public Glue()
Creates a new object with a zero length.


Glue

public Glue(FixedDimen theLength)
Creates a new object with a fixed length.

Parameters:
theLength - the natural length

Glue

public Glue(FixedGlue glue)
Creates a new object as copy of another glue.

Parameters:
glue - the glue to clone

Glue

public Glue(FixedGlueComponent theLength,
            FixedGlueComponent theStretch,
            FixedGlueComponent theShrink)
Creates a new object from the three components.

Parameters:
theLength - the natural length
theStretch - the stretch specification
theShrink - the shrink specification

Glue

public Glue(long theLength)
Creates a new object from a fixed length.

Parameters:
theLength - the natural length in scaled point
Method Detail

parse

public static Glue parse(TokenSource source,
                         Context context,
                         Typesetter typesetter)
                  throws InterpreterException
Creates a new object by parsing a token source.
   ⟨glue⟩
     → ⟨component⟩
      |  ⟨component⟩ plus ⟨component⟩
      |  ⟨component⟩ minus ⟨component⟩
      |  ⟨component⟩ plus ⟨component⟩ minus ⟨component⟩

   ⟨component⟩
     → ⟨dimen;⟩
       |  ⟨float⟩ ⟨unit⟩

   ⟨unit⟩
     → fi | fil | fill | filll    

TODO gene: documentation incomplete

Parameters:
source - the source to read new tokens from
context - the processing context
typesetter - the typesetter
Returns:
a new instance of a Glue
Throws:
InterpreterException - in case of an error

add

public void add(FixedGlue g)
Add another glue to this one. The addition is performed independently on the components.

Parameters:
g - the glue to add

add

public void add(FixedGlueComponent g)
Add a dimen to this one glue. The addition is performed independently on the components.

Parameters:
g - the glue to add

copy

public Glue copy()
Make a copy of this object.

Specified by:
copy in interface FixedGlue
Returns:
a new instance with the same internal values

eq

public boolean eq(FixedGlue glue)
Test that the given Glue is equal to a given one.

Specified by:
eq in interface FixedGlue
Parameters:
glue - the glue to compare with
Returns:
true iff they are the same
See Also:
FixedGlue.eq( de.dante.extex.interpreter.type.glue.FixedGlue)

ge

public boolean ge(FixedGlueComponent x)
Compare this value with a given glue and return true iff the current length is greater or equal than the given length.

Parameters:
x - the value to compare to
Returns:
true iff the current length is greater or equal than the given one

getLength

public FixedDimen getLength()
Getter for the length. Note that the value returned is independent from the original object. Changing its value does not affect the length of the glue.

Specified by:
getLength in interface FixedGlue
Returns:
the natural length
See Also:
FixedGlue.getLength()

getShrink

public FixedGlueComponent getShrink()
Getter for shrink. Note that the value returned is independent from the original object. Changing its value does not affect the shrink of the glue.

Specified by:
getShrink in interface FixedGlue
Returns:
the shrink.
See Also:
FixedGlue.getShrink()

getStretch

public FixedGlueComponent getStretch()
Getter for stretch. Note that the value returned is independent from the original object. Changing its value does not affect the stretch of the glue.

Specified by:
getStretch in interface FixedGlue
Returns:
the stretch.
See Also:
FixedGlue.getStretch()

gt

public boolean gt(FixedGlueComponent x)
Compare this value with a given glue and return true iff the current length is greater than the given length.

Parameters:
x - the value to compare to
Returns:
true iff the current length is greater than the given one

le

public boolean le(FixedGlueComponent x)
Compare this value with a given glue and return true iff the current length is less or equal than the given length.

Parameters:
x - the value to compare to
Returns:
true iff the current length is less or equal than the given one

lt

public boolean lt(FixedGlueComponent x)
Compare this value with a given glue and return true iff the current length is less than the given length.

Parameters:
x - the value to compare to
Returns:
true iff the current length is less than the given one

multiply

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

length = length * nom / denom

Parameters:
nom - nominator
denom - denominator

multiplyAll

public void multiplyAll(long nom,
                        long denom)
Multiply all components by an integer fraction.

Parameters:
nom - nominator
denom - denominator

multiplyShrink

public void multiplyShrink(long nom,
                           long denom)
Multiply the shrink component by an integer fraction.

shrink = shrink * nom / denom

Parameters:
nom - nominator
denom - denominator

multiplyStretch

public void multiplyStretch(long nom,
                            long denom)
Multiply the stretch component by an integer fraction.

stretch = stretch * nom / denom

Parameters:
nom - nominator
denom - denominator

ne

public boolean ne(FixedGlue glue)
Description copied from interface: FixedGlue
Test that the given Glue is differnt from a given one.

Specified by:
ne in interface FixedGlue
Parameters:
glue - the glue to compare with
Returns:
true iff they are different
See Also:
FixedGlue.ne( de.dante.extex.interpreter.type.glue.FixedGlue)

negateLength

public void negateLength()
Negate the value. This is the same as multiplying with -1.


set

public void set(FixedDimen theLength)
Set the glue value to a non-stretchable and non-shrinkable length.

Parameters:
theLength - the new length

set

public void set(FixedGlue theLength)
Set the glue value.

Parameters:
theLength - the new length

setLength

public void setLength(FixedDimen x)
Setter for the length component

Parameters:
x - the new length component

setShrink

public void setShrink(FixedDimen x)
Setter for the shrink component

Parameters:
x - the new shrink component

setStretch

public void setStretch(FixedDimen x)
Setter for the stretch component

Parameters:
x - the new stretch component

subtract

public void subtract(FixedGlue g)
Subtract another glue to this one. The subtraction is performed independently on the components.

Parameters:
g - the glue to add

subtract

public void subtract(FixedGlueComponent g)
Subtract a Glue component from this glue. The subtraction is performed on the length only.

Parameters:
g - the glue to subtract

toString

public java.lang.String toString()
Determine the printable representation of the object. The value returned is exactly the string which would be produced by TeX to print the skip register.

Specified by:
toString in interface FixedGlue
Returns:
the string representation of this glue
See Also:
"TeX – The Program [178,177]"

toToks

public Tokens toToks(TokenFactory factory)
              throws GeneralException
Determine the printable representation of the object. The value returned is exactly the string which would be produced by TeX to print the skip register.

Specified by:
toToks in interface FixedGlue
Parameters:
factory - the factory to get the tokens from
Returns:
the string representation of this glue
Throws:
GeneralException - in case of an error
See Also:
"TeX – The Program [178,177]"