package Sequenic.T2.Obj ; import java.util.* ; /** * Simple library for pretty printing text. A PP object represents * essentially a list of strings. The method {@link #render render} can be used * to render this object to a single string formatted in a certain * way. * *
Logically the strings to be pretty printed are grouped * hierarchically into groups that have to be printed side by side, * and groups that have to be printed above the other. * * *
Internally, PP is structured recursively. It has * right and under pointers that again point to PP * objects. The PP at 'right' is to be printed right to the current * PP, and the PP at 'under' is to be printed below the current * PP. There is also a field line which contains a single * string (which should not contain a newline). It represents the * single line of text belonging to the currect PP. * *
The field indent specifies an indentation offset for the PP (and * all PP's below it). * *
In addition to the redering method, this library also provides * some methods for constructing PPs. * *
Example: see source code.
*
* @author Wishnu Prasetya (wishnu@cs.uu.nl)
*
*/
public class XPP {
/**
* Offset indentation for this PP.
*/
private int indent = 0 ;
/**
* A single line of string which is the content of this PP.
*/
private String line = "" ;
/**
* The PP to be printed right to this PP.
*/
private XPP right = null ;
/**
* The PP to be printed below this PP.
*/
private XPP under = null ;
/**
* Creating an empty PP.
*/
public XPP() { }
/**
* Accumulate reachable nodes in visited.
*/
private void reachableNodes(Collection