Methods Summary |
---|
protected void | doLine(java.lang.String line)Process one line from the current input
tabPos = 0;
// count leading (not imbedded) tabs.
for (int i=0; i<line.length(); i++) {
if (line.charAt(i)=='\t")
tabPos++;
else
break;
}
String l = line.trim(); // removes spaces AND tabs
if (l.length() == 0) {
++lineNum;
return;
}
moveTo(leftMargin + (tabPos * INCH),
topMargin-(lineNum++ * leading));
println('(" + toPSString(l)+ ") show");
// If we just hit the bottom, start a new page
if (curY <= botMargin)
startPage();
|
public static void | main(java.lang.String[] av)
if (av.length == 0)
new PSFormatter(
new InputStreamReader(System.in)).process();
else for (int i = 0; i < av.length; i++) {
new PSFormatter(av[i]).process();
}
|
protected void | moveTo(int x, int y)
curX = x;
curY = y;
println(x + " " + y + " " + "moveto");
|
protected void | println(java.lang.String s)
System.out.println(s);
|
protected void | process()Main processing of the current input source.
String line;
prologue(); // emit PostScript prologue, once.
startPage(); // emit top-of-page (ending previous)
while ((line = br.readLine()) != null) {
if (line.startsWith("\f") || line.trim().equals(".bp")) {
startPage();
continue;
}
doLine(line);
}
// finish last page, if not already done.
if (lineNum != 0)
println("showpage");
|
void | prologue()
println("%!PS-Adobe");
println("/Courier findfont " + points + " scalefont setfont ");
|
protected void | startPage()Handle start of page details.
if (pageNum++ > 0)
println("showpage");
lineNum = 0;
moveTo(leftMargin, topMargin);
|
protected java.lang.String | toPSString(java.lang.String o)
StringBuffer sb = new StringBuffer();
for (int i=0; i<o.length(); i++) {
char c = o.charAt(i);
switch(c) {
case '(": sb.append("\\("); break;
case ')": sb.append("\\)"); break;
default: sb.append(c); break;
}
}
return sb.toString();
|