All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class BrainWave.PostScript

java.lang.Object
   |
   +----BrainWave.PostScript

public class PostScript
extends Object
A static class that produces Strings of PostScript interpretable text.
Version:
0.9.1
This revision fixes a bug for encapsulated PostScript AND changes EPS so that there is no "scaling" to an A4 page.

0.9
Provides a system for generating PostScript from java.awt.Graphics style methods. Calling these static methods returns a String containing the PostScript required to display that graphics primitive. By concatenating a series of these strings for different graphics routines, objects drawn on the screen may be converted to PostScript.

Author:
Raymond Smith

Variable Index

 o A4
The printing area of A4.
 o BW
Black and White printing option if true, ignore setcolor and print all colours as black.
 o CurrB
Current Color (RGB) - blue component.
 o CurrFont
Current font.
 o CurrG
Current Color (RGB) - green component.
 o CurrR
Current Color (RGB) - red component.
 o DefaultFont
Default font.
 o DefaultFontName
Default font name.
 o DefaultFontPoint
Default font point size.
 o Letter
The printing area of Letter.
 o Xscale
X scaling factor used to map screen positions to PostScript points.
 o Yscale
Y scaling factor used to map screen positions to PostScript points.

Constructor Index

 o PostScript()

Method Index

 o drawLine(int, int, int, int)
Draw a line from (x1,y1) to (x2,y2).
 o drawRect(int, int, int, int)
Draw an outline of a rectangle with left corner (x,y) and dimensions w * h.
 o drawRect(String, String, String, String)
Same as the above, but takes coordinates and dimensions as Strings of PostScript (which may be String representing of numbers).
 o drawString(String, int, int)
write the String str to the PostScript page.
 o drawString(String, String, String)
write String str to PostScript page.
 o fillRect(int, int, int, int)
Draw a filled rectangle with left corner (x,y) and dimensions w * h.
 o fillRect(String, String, String, String)
 o insertComment(String)
Add a single line comment.
 o postAmble(boolean)
Trailing information to complete a PostScript document.
 o preAmble(boolean)
Provided for compatibility with previous versions - orienation is assumed to be portrait.
 o preAmble(boolean, boolean)
Provided for compatibility with previous versions - no paper size is selected.
 o preAmble(boolean, boolean, Paper, int, int)
Pre-amble information for a minimally conforming PostScript document.
 o setColor(Color)
Set the PostScript colour to c.
 o setColor(int, int, int)
Set a colour with RGB settings r, g, b modulo 255.
 o setFont(Font)
Set the PostScript font to fnt if fnt is TimesRoman, Courier, or Helvetica, or Symbol.
 o setFont(Graphics, Font)
Set the PostScript font to fnt, scaling point size.
 o stringWidth(Graphics, Font, String)
 o whichFont(Font)
Return a PostScript font name for fnt.

Variables

 o A4
 public static Paper A4
The printing area of A4. The length and width given here are slightly smaller than the physical dimensions to allow for margins (printers will not print over a whole page).
 o Letter
 public static Paper Letter
The printing area of Letter. The length and width given here are slightly smaller than the physical dimensions to allow for margins (printers will not print over a whole page).
 o Yscale
 protected static double Yscale
Y scaling factor used to map screen positions to PostScript points.
 o Xscale
 protected static double Xscale
X scaling factor used to map screen positions to PostScript points.
 o DefaultFontName
 protected static String DefaultFontName
Default font name.
 o DefaultFontPoint
 protected static int DefaultFontPoint
Default font point size.
 o DefaultFont
 protected static Font DefaultFont
Default font.
 o CurrFont
 protected static Font CurrFont
Current font.
 o CurrR
 protected static int CurrR
Current Color (RGB) - red component.
 o CurrG
 protected static int CurrG
Current Color (RGB) - green component.
 o CurrB
 protected static int CurrB
Current Color (RGB) - blue component.
 o BW
 public static boolean BW
Black and White printing option if true, ignore setcolor and print all colours as black.

Constructors

 o PostScript
 public PostScript()

Methods

 o preAmble
 public static String preAmble(boolean encap,
                               boolean land,
                               Paper pge,
                               int sw,
                               int sl)
Pre-amble information for a minimally conforming PostScript document. Specifies type of PostScript (encapsulated or note) and orientation (landscape or not).
 o preAmble
 public static String preAmble(boolean encap,
                               boolean landscape)
Provided for compatibility with previous versions - no paper size is selected.
 o preAmble
 public static String preAmble(boolean encap)
Provided for compatibility with previous versions - orienation is assumed to be portrait.
 o postAmble
 public static String postAmble(boolean encap)
Trailing information to complete a PostScript document.
 o drawString
 public static String drawString(String str,
                                 int x,
                                 int y)
write the String str to the PostScript page. Precondition: str contains no newlines.
 o drawString
 public static String drawString(String str,
                                 String x,
                                 String y)
write String str to PostScript page. Precondition: str contains no newlines, and x and y are PostScript commands that evaluate to a single numeric value
 o whichFont
 public static String whichFont(Font fnt)
Return a PostScript font name for fnt. If fnt is TimesRoman, Courier, Helvetica, or Symbol, this is the corresponding font. Any other font is returned as Courier.
 o setFont
 public static String setFont(Graphics g,
                              Font fnt)
Set the PostScript font to fnt, scaling point size. The font must be TimesRoman, Courier, Helvetica, or Symbol.
 o setFont
 protected static String setFont(Font fnt)
Set the PostScript font to fnt if fnt is TimesRoman, Courier, or Helvetica, or Symbol. Otherwise, set font to Courier. This method blindly sets the point size without scaling.
 o drawLine
 public static String drawLine(int x1,
                               int y1,
                               int x2,
                               int y2)
Draw a line from (x1,y1) to (x2,y2).
 o fillRect
 public static String fillRect(int x,
                               int y,
                               int w,
                               int h)
Draw a filled rectangle with left corner (x,y) and dimensions w * h.
 o fillRect
 public static String fillRect(String x,
                               String y,
                               String w,
                               String h)
 o drawRect
 public static String drawRect(int x,
                               int y,
                               int w,
                               int h)
Draw an outline of a rectangle with left corner (x,y) and dimensions w * h.
 o drawRect
 public static String drawRect(String x,
                               String y,
                               String w,
                               String h)
Same as the above, but takes coordinates and dimensions as Strings of PostScript (which may be String representing of numbers). All sequences of commands must evaluate to a single integer in the 4th 4th quadrant (ie x>= 0, y <= 0).
 o setColor
 public static String setColor(Color c)
Set the PostScript colour to c.
 o setColor
 public static String setColor(int r,
                               int g,
                               int b)
Set a colour with RGB settings r, g, b modulo 255.
 o insertComment
 public static String insertComment(String str)
Add a single line comment. Precondition: str must contain no newlines.
 o stringWidth
 public static String stringWidth(Graphics g,
                                  Font f,
                                  String str)

All Packages  Class Hierarchy  This Package  Previous  Next  Index