de.dante.extex.backend.documentWriter.postscript.util
Class PsUnit

java.lang.Object
  extended byde.dante.extex.backend.documentWriter.postscript.util.PsUnit

public abstract class PsUnit
extends java.lang.Object

This class contains some utility methods.

Version:
$Revision: 1.3 $
Author:
Gerd Neugebauer

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.lang.StringBuffer 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
 

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.lang.StringBuffer 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 dimen to convert
out - the target buffer
strip - indicator whether rounding to the next higher integral number is desirable