org.extex.backend.documentWriter.postscript.util
Class PsUnit

java.lang.Object
  extended by org.extex.backend.documentWriter.postscript.util.PsUnit

public abstract class PsUnit
extends java.lang.Object

This class contains some utility methods.

Version:
$Revision: 6447 $
Author:
Gerd Neugebauer

Field Summary
static int CM100_PER_IN
          The constant CM100_PER_IN contains the number of 100 centimeters per inch.
static int POINT_PER_100_IN
          The field POINT_PER_100_IN contains the conversion factor from inch to point.
static int PT_PER_PC
          The constant PT_PER_PC contains the number of points per pica.
 
Method Summary
static int getChar(java.lang.CharSequence seq, Count index)
          Get the next character from a character sequence.
static long getFloat(java.lang.CharSequence seq, Count index)
          Scan a floating point number from a character sequence.
static long getLength(java.lang.CharSequence seq, Count index)
          Parse a character sequence for a length and return it in sp.
static void toPoint(FixedDimen d, java.io.PrintStream out, boolean strip)
          This method produces a printable representation of a length in terms of PostScript points.
static void toPoint(FixedDimen d, java.lang.StringBuilder out, boolean strip)
          This method produces a printable representation of a length in terms of PostScript points.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CM100_PER_IN

public static final int CM100_PER_IN
The constant CM100_PER_IN contains the number of 100 centimeters per inch.

See Also:
Constant Field Values

POINT_PER_100_IN

public static final int POINT_PER_100_IN
The field POINT_PER_100_IN contains the conversion factor from inch to point. The value contained is the number of points in 100 inch.

See Also:
Constant Field Values

PT_PER_PC

public static final int PT_PER_PC
The constant PT_PER_PC contains the number of points per pica.

See Also:
Constant Field Values
Method Detail

getChar

public static int getChar(java.lang.CharSequence seq,
                          Count index)
Get the next character from a character sequence.

Parameters:
seq - the sequence to read from
index - the index of the next character to read
Returns:
the code of the next character or a negative number if none could be read

getFloat

public static long getFloat(java.lang.CharSequence seq,
                            Count index)
Scan a floating point number from a character sequence. White-space characters at the beginning and after the optional sign are ignored.

Parameters:
seq - the sequence to read from
index - the index of the next character to read
Returns:
the fixed point number in multiples of 2^16

getLength

public static long getLength(java.lang.CharSequence seq,
                             Count index)
                      throws java.lang.NumberFormatException
Parse a character sequence for a length and return it in sp. The length is given as a float number optionally preceded by white-space and a sign. This number is followed by optional white-space and a unit given as two letters. The following units are supported: pt, sp, bp, mm, cm, cc, dd, pc.

Examples

  1sp
  .2 pt
  -3.4 mm
 

Parameters:
seq - the sequence to read from
index - the index of the next character to read
Returns:
the length in scaled points
Throws:
java.lang.NumberFormatException - in case of a parsing error

toPoint

public static void toPoint(FixedDimen d,
                           java.io.PrintStream out,
                           boolean strip)
This method produces a printable representation of a length in terms of PostScript points. This means that 72 PostScript points are 1 inch.

Parameters:
d - the length to convert
out - the target buffer
strip - indicator whether rounding to the next higher integral number is desirable

toPoint

public static void toPoint(FixedDimen d,
                           java.lang.StringBuilder out,
                           boolean strip)
This method produces a printable representation of a length in terms of PostScript points. This means that 72 PostScript points are 1 inch.

Parameters:
d - the length to convert
out - the target buffer
strip - indicator whether rounding to the next higher integral number is desirable