All Packages Class Hierarchy This Package Previous Next Index
Class att.grappa.PSGr
java.lang.Object
|
+----java.awt.Graphics
|
+----att.grappa.PSGr
- public class PSGr
- extends Graphics
PSGr is a class which takes an image and saves it to a stream
as PostScript.
The original PSGr was written and released by:
(C) 1996 E.J. Friedman-Hill and Sandia National Labs
Ernest Friedman-Hill
ejfried@ca.sandia.gov
http://herzberg.ca.sandia.gov
This versions has some minor modifications to the original code.
Original source:
- Version:
- 1.0
- Author:
- Ernest Friedman-Hill, ejfried@ca.sandia.gov, http://herzberg.ca.sandia.gov
Minor modifications:, John Mocenigo, Research @ AT&T Labs
-
backClr
- The background color of the current widget.
-
charsPerRow
- number of chars in a full row of pixel data
-
clippingRect
-
-
CLONE
-
-
clr
- The current color
-
drawBox
-
-
font
- The current font
-
g
-
-
hd
- hexadecimal digits
-
os
- Output stream where postscript goes
-
PAGEHEIGHT
-
-
pageheight
-
-
PAGEWIDTH
-
-
pagewidth
-
-
PSGR_CLOSE
-
-
PSGR_FILL
-
-
XOFFSET
-
-
YOFFSET
-
-
PSGr(OutputStream, Graphics)
- Constructs a new PSGr Object.
-
PSGr(OutputStream, Graphics, Rectangle, int)
-
-
PSGr(Writer, Graphics)
- Constructs a new PSGr Object.
-
PSGr(Writer, Graphics, Rectangle)
-
-
PSGr(Writer, Graphics, Rectangle, int)
-
-
clearRect(int, int, int, int)
-
Clears the specified rectangle by filling it with the current background color
of the current drawing surface.
-
clipRect(int, int, int, int)
-
Clips to a rectangle.
-
copyArea(int, int, int, int, int, int)
- Copies an area of the screen.
-
create()
- Creates a new PSGr Object that is a copy of the original PSGr Object.
-
create(int, int, int, int)
- Creates a new Graphics Object with the specified parameters,
based on the original
Graphics Object.
-
dispose()
- Disposes of this graphics context.
-
doImage(Image, int, int, int, int, ImageObserver, Color)
-
-
doRect(int, int, int, int, boolean)
-
-
draw3DRect(int, int, int, int, boolean)
- Draws a highlighted 3-D rectangle.
-
drawArc(int, int, int, int, int, int)
- Draws an arc bounded by the specified rectangle from startAngle to
endAngle.
-
drawBytes(byte[], int, int, int, int)
-
Draws the specified bytes using the current font and color.
-
drawChars(char[], int, int, int, int)
-
Draws the specified characters using the current font and color.
-
drawImage(Image, int, int, Color, ImageObserver)
-
Draws the specified image at the specified coordinate (x, y).
-
drawImage(Image, int, int, ImageObserver)
-
Draws the specified image at the specified coordinate (x, y).
-
drawImage(Image, int, int, int, int, Color, ImageObserver)
- Draws the specified image inside the specified rectangle.
-
drawImage(Image, int, int, int, int, ImageObserver)
- Draws the specified image inside the specified rectangle.
-
drawImage(Image, int, int, int, int, int, int, int, int, Color, ImageObserver)
- Draws as much of the specified area of the specified image as is
currently available, scaling it on the fly to fit inside the
specified area of the destination drawable surface.
-
drawImage(Image, int, int, int, int, int, int, int, int, ImageObserver)
- Draws as much of the specified area of the specified image as is
currently available, scaling it on the fly to fit inside the
specified area of the destination drawable surface.
-
drawLine(int, int, int, int)
-
Draws a line between the coordinates (x1,y1) and (x2,y2).
-
drawOval(int, int, int, int)
-
Draws an oval inside the specified rectangle using the current color.
-
drawPolygon(int[], int[], int)
-
Draws a polygon defined by an array of x points and y points.
-
drawPolygon(Polygon)
-
Draws a polygon defined by the specified point.
-
drawPolyline(int[], int[], int)
-
Draws a polyline defined by an array of x points and y points.
-
drawRect(int, int, int, int)
-
Draws the outline of the specified rectangle using the current color.
-
drawRoundRect(int, int, int, int, int, int)
-
Draws an outlined rounded corner rectangle using the current color.
-
drawString(String, int, int)
-
Draws the specified String using the current font and color.
-
emitColorImageProlog(int)
-
-
emitProlog()
- Top of every PS file
-
emitThis(String)
-
-
fill3DRect(int, int, int, int, boolean)
- Paints a highlighted 3-D rectangle using the current color.
-
fillArc(int, int, int, int, int, int)
-
Fills an arc using the current color.
-
fillOval(int, int, int, int)
-
Fills an oval inside the specified rectangle using the current color.
-
fillPolygon(int[], int[], int)
-
Fills a polygon with the current color.
-
fillPolygon(Polygon)
-
Fills the specified polygon with the current color.
-
fillRect(int, int, int, int)
-
Fills the specified rectangle with the current color.
-
fillRoundRect(int, int, int, int, int, int)
-
Draws a rounded rectangle filled in with the current color.
-
finalize()
- Disposes of this graphics context once it is no longer referenced.
-
getClip()
-
Returns the shape representing the current clipping area.
-
getClipBounds()
-
Returns the bounding rectangle of the current clipping area.
-
getColor()
- Gets the current color.
-
getFont()
- Gets the current font.
-
getFontMetrics()
- Gets the current font metrics.
-
getFontMetrics(Font)
- Gets the current font metrics for the specified font.
-
grestore()
-
-
gsave()
-
-
scale(float, float)
- Scales the graphics context.
-
setBackground(Color)
- Sets the background color.
-
setClip(int, int, int, int)
- Sets the current clip to the rectangle specified by the given
coordinates.
-
setClip(Shape)
- Sets the current clip to the specified shape.
-
setColor(Color)
- Sets the current color to the specified color.
-
setFont(Font)
- Sets the font for all subsequent text-drawing operations.
-
setPaintMode()
- Sets the default paint mode to overwrite the destination with the
current color.
-
setXORMode(Color)
- Sets the paint mode to alternate between the current color
and the new specified color.
-
showpage()
- Writes a PostScript
showpage
directive and flushes
the Writer stream.
-
toString()
- Returns a String object representing this Graphic's value.
-
transformX(int)
-
-
transformY(int)
- Flip Y coords so Postscript looks like Java
-
translate(int, int)
- Translates the specified parameters into the origin of
the graphics context.
PSGR_CLOSE
public static final int PSGR_CLOSE
PSGR_FILL
public static final int PSGR_FILL
CLONE
public static final int CLONE
PAGEHEIGHT
protected static final int PAGEHEIGHT
PAGEWIDTH
protected static final int PAGEWIDTH
XOFFSET
protected static final int XOFFSET
YOFFSET
protected static final int YOFFSET
hd
protected static final char hd[]
- hexadecimal digits
charsPerRow
protected static final int charsPerRow
- number of chars in a full row of pixel data
pageheight
protected int pageheight
pagewidth
protected int pagewidth
os
protected PrintWriter os
- Output stream where postscript goes
clr
protected Color clr
- The current color
backClr
protected Color backClr
- The background color of the current widget.
It's up to the client software to set this correctly!
font
protected Font font
- The current font
clippingRect
protected Rectangle clippingRect
drawBox
protected Rectangle drawBox
g
protected Graphics g
PSGr
public PSGr(OutputStream o,
Graphics g)
- Constructs a new PSGr Object. Unlike regular Graphics objects,
PSGr contexts can be created directly.
- Parameters:
- o - Output stream for PostScript output
- See Also:
- create
PSGr
public PSGr(Writer o,
Graphics g)
- Constructs a new PSGr Object. Unlike regular Graphics objects,
PSGr contexts can be created directly.
- Parameters:
- o - Output stream for PostScript output
- See Also:
- create
PSGr
public PSGr(Writer o,
Graphics g,
Rectangle drawBox)
PSGr
public PSGr(OutputStream o,
Graphics g,
Rectangle drawBox,
int what)
PSGr
public PSGr(Writer o,
Graphics g,
Rectangle drawBox,
int what)
create
public Graphics create()
- Creates a new PSGr Object that is a copy of the original PSGr Object.
- Overrides:
- create in class Graphics
create
public Graphics create(int x,
int y,
int width,
int height)
- Creates a new Graphics Object with the specified parameters,
based on the original
Graphics Object.
This method translates the specified parameters, x and y, to
the proper origin coordinates and then clips the Graphics Object to the
area.
- Parameters:
- x - the x coordinate
- y - the y coordinate
- width - the width of the area
- height - the height of the area
- Overrides:
- create in class Graphics
- See Also:
- translate
translate
public void translate(int x,
int y)
- Translates the specified parameters into the origin of
the graphics context. All subsequent
operations on this graphics context will be relative to this origin.
- Parameters:
- x - the x coordinate
- y - the y coordinate
- Overrides:
- translate in class Graphics
- See Also:
- scale
scale
public void scale(float sx,
float sy)
- Scales the graphics context. All subsequent operations on this
graphics context will be affected.
- Parameters:
- sx - the scaled x coordinate
- sy - the scaled y coordinate
- See Also:
- translate
getColor
public Color getColor()
- Gets the current color.
- Overrides:
- getColor in class Graphics
- See Also:
- setColor
setBackground
public Color setBackground(Color c)
- Sets the background color.
- Returns:
- the previous background color
- See Also:
- setColor
setColor
public void setColor(Color c)
- Sets the current color to the specified color. All subsequent graphics operations
will use this specified color.
- Parameters:
- c - the color to be set
- Overrides:
- setColor in class Graphics
- See Also:
- Color, getColor
setPaintMode
public void setPaintMode()
- Sets the default paint mode to overwrite the destination with the
current color. PostScript has only paint mode.
- Overrides:
- setPaintMode in class Graphics
setXORMode
public void setXORMode(Color c1)
- Sets the paint mode to alternate between the current color
and the new specified color. PostScript does not support XOR mode.
- Parameters:
- c1 - the second color
- Overrides:
- setXORMode in class Graphics
getFont
public Font getFont()
- Gets the current font.
- Overrides:
- getFont in class Graphics
- See Also:
- setFont
setFont
public void setFont(Font f)
- Sets the font for all subsequent text-drawing operations.
- Parameters:
- font - the specified font
- Overrides:
- setFont in class Graphics
- See Also:
- Font, getFont, drawString, drawBytes, drawChars
getFontMetrics
public FontMetrics getFontMetrics()
- Gets the current font metrics.
- Overrides:
- getFontMetrics in class Graphics
- See Also:
- getFont
getFontMetrics
public FontMetrics getFontMetrics(Font f)
- Gets the current font metrics for the specified font.
- Parameters:
- f - the specified font
- Overrides:
- getFontMetrics in class Graphics
- See Also:
- getFont, getFontMetrics
getClipBounds
public Rectangle getClipBounds()
- Returns the bounding rectangle of the current clipping area.
- Overrides:
- getClipBounds in class Graphics
- See Also:
- clipRect
getClip
public Shape getClip()
- Returns the shape representing the current clipping area.
- Overrides:
- getClip in class Graphics
- See Also:
- clipRect
clipRect
public void clipRect(int x,
int y,
int width,
int height)
- Clips to a rectangle. The resulting clipping area is the
intersection of the current clipping area and the specified
rectangle. Graphic operations have no effect outside of the
clipping area.
- Parameters:
- x - the x coordinate
- y - the y coordinate
- width - the width of the rectangle
- height - the height of the rectangle
- Overrides:
- clipRect in class Graphics
- See Also:
- getClipRect
setClip
public void setClip(int x,
int y,
int width,
int height)
- Sets the current clip to the rectangle specified by the given
coordinates.
Rendering operations have no effect outside of the clipping area.
- Parameters:
- x - the x coordinate of the new clip rectangle.
- y - the y coordinate of the new clip rectangle.
- width - the width of the new clip rectangle.
- height - the height of the new clip rectangle.
- Overrides:
- setClip in class Graphics
setClip
public void setClip(Shape shp)
- Sets the current clip to the specified shape.
Here it only works correctly for rectangular shapes.
- Parameters:
- shp - the Shape to use
- Overrides:
- setClip in class Graphics
copyArea
public void copyArea(int x,
int y,
int width,
int height,
int dx,
int dy)
- Copies an area of the screen.
- Parameters:
- x - the x-coordinate of the source
- y - the y-coordinate of the source
- width - the width
- height - the height
- dx - the horizontal distance
- dy - the vertical distance
Note: copyArea not supported by PostScript
- Overrides:
- copyArea in class Graphics
drawLine
public void drawLine(int x1,
int y1,
int x2,
int y2)
- Draws a line between the coordinates (x1,y1) and (x2,y2). The line is drawn
below and to the left of the logical coordinates.
- Parameters:
- x1 - the first point's x coordinate
- y1 - the first point's y coordinate
- x2 - the second point's x coordinate
- y2 - the second point's y coordinate
- Overrides:
- drawLine in class Graphics
doRect
protected void doRect(int x,
int y,
int width,
int height,
boolean fill)
fillRect
public void fillRect(int x,
int y,
int width,
int height)
- Fills the specified rectangle with the current color.
- Parameters:
- x - the x coordinate
- y - the y coordinate
- width - the width of the rectangle
- height - the height of the rectangle
- Overrides:
- fillRect in class Graphics
- See Also:
- drawRect, clearRect
drawRect
public void drawRect(int x,
int y,
int width,
int height)
- Draws the outline of the specified rectangle using the current color.
Use drawRect(x, y, width-1, height-1) to draw the outline inside the specified
rectangle.
- Parameters:
- x - the x coordinate
- y - the y coordinate
- width - the width of the rectangle
- height - the height of the rectangle
- Overrides:
- drawRect in class Graphics
- See Also:
- fillRect, clearRect
clearRect
public void clearRect(int x,
int y,
int width,
int height)
- Clears the specified rectangle by filling it with the current background color
of the current drawing surface.
Which drawing surface it selects depends on how the graphics context
was created.
- Parameters:
- x - the x coordinate
- y - the y coordinate
- width - the width of the rectangle
- height - the height of the rectangle
- Overrides:
- clearRect in class Graphics
- See Also:
- fillRect, drawRect
drawRoundRect
public void drawRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
- Draws an outlined rounded corner rectangle using the current color.
- Parameters:
- x - the x coordinate
- y - the y coordinate
- width - the width of the rectangle
- height - the height of the rectangle
- arcWidth - the diameter of the arc
- arcHeight - the radius of the arc
- Overrides:
- drawRoundRect in class Graphics
- See Also:
- fillRoundRect
fillRoundRect
public void fillRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
- Draws a rounded rectangle filled in with the current color.
- Parameters:
- x - the x coordinate
- y - the y coordinate
- width - the width of the rectangle
- height - the height of the rectangle
- arcWidth - the diameter of the arc
- arcHeight - the radius of the arc
- Overrides:
- fillRoundRect in class Graphics
- See Also:
- drawRoundRect
draw3DRect
public void draw3DRect(int x,
int y,
int width,
int height,
boolean raised)
- Draws a highlighted 3-D rectangle.
- Parameters:
- x - the x coordinate
- y - the y coordinate
- width - the width of the rectangle
- height - the height of the rectangle
- raised - a boolean that states whether the rectangle is raised or not
- Overrides:
- draw3DRect in class Graphics
fill3DRect
public void fill3DRect(int x,
int y,
int width,
int height,
boolean raised)
- Paints a highlighted 3-D rectangle using the current color.
- Parameters:
- x - the x coordinate
- y - the y coordinate
- width - the width of the rectangle
- height - the height of the rectangle
- raised - a boolean that states whether the rectangle is raised or not
- Overrides:
- fill3DRect in class Graphics
drawOval
public void drawOval(int x,
int y,
int width,
int height)
- Draws an oval inside the specified rectangle using the current color.
- Parameters:
- x - the x coordinate
- y - the y coordinate
- width - the width of the rectangle
- height - the height of the rectangle
- Overrides:
- drawOval in class Graphics
- See Also:
- fillOval
fillOval
public void fillOval(int x,
int y,
int width,
int height)
- Fills an oval inside the specified rectangle using the current color.
- Parameters:
- x - the x coordinate
- y - the y coordinate
- width - the width of the rectangle
- height - the height of the rectangle
- Overrides:
- fillOval in class Graphics
- See Also:
- drawOval
drawArc
public void drawArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
- Draws an arc bounded by the specified rectangle from startAngle to
endAngle. 0 degrees is at the 3-o'clock position.Positive arc
angles indicate counter-clockwise rotations, negative arc angles are
drawn clockwise.
- Parameters:
- x - the x coordinate
- y - the y coordinate
- width - the width of the rectangle
- height - the height of the rectangle
- startAngle - the beginning angle
- arcAngle - the angle of the arc (relative to startAngle).
- Overrides:
- drawArc in class Graphics
- See Also:
- fillArc
fillArc
public void fillArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
- Fills an arc using the current color. This generates a pie shape.
- Parameters:
- x - the x coordinate
- y - the y coordinate
- width - the width of the arc
- height - the height of the arc
- startAngle - the beginning angle
- arcAngle - the angle of the arc (relative to startAngle).
- Overrides:
- fillArc in class Graphics
- See Also:
- drawArc
drawPolyline
public void drawPolyline(int xPoints[],
int yPoints[],
int nPoints)
- Draws a polyline defined by an array of x points and y points.
- Parameters:
- xPoints - an array of x points
- yPoints - an array of y points
- nPoints - the total number of points
- Overrides:
- drawPolyline in class Graphics
drawPolygon
public void drawPolygon(int xPoints[],
int yPoints[],
int nPoints)
- Draws a polygon defined by an array of x points and y points.
- Parameters:
- xPoints - an array of x points
- yPoints - an array of y points
- nPoints - the total number of points
- Overrides:
- drawPolygon in class Graphics
- See Also:
- fillPolygon
drawPolygon
public void drawPolygon(Polygon p)
- Draws a polygon defined by the specified point.
- Parameters:
- p - the specified polygon
- Overrides:
- drawPolygon in class Graphics
- See Also:
- fillPolygon
fillPolygon
public void fillPolygon(int xPoints[],
int yPoints[],
int nPoints)
- Fills a polygon with the current color.
- Parameters:
- xPoints - an array of x points
- yPoints - an array of y points
- nPoints - the total number of points
- Overrides:
- fillPolygon in class Graphics
- See Also:
- drawPolygon
fillPolygon
public void fillPolygon(Polygon p)
- Fills the specified polygon with the current color.
- Parameters:
- p - the polygon
- Overrides:
- fillPolygon in class Graphics
- See Also:
- drawPolygon
drawString
public void drawString(String str,
int x,
int y)
- Draws the specified String using the current font and color.
The x,y position is the starting point of the baseline of the String.
- Parameters:
- str - the String to be drawn
- x - the x coordinate
- y - the y coordinate
- Overrides:
- drawString in class Graphics
- See Also:
- drawChars, drawBytes
drawChars
public void drawChars(char data[],
int offset,
int length,
int x,
int y)
- Draws the specified characters using the current font and color.
- Parameters:
- data - the array of characters to be drawn
- offset - the start offset in the data
- length - the number of characters to be drawn
- x - the x coordinate
- y - the y coordinate
- Overrides:
- drawChars in class Graphics
- See Also:
- drawString, drawBytes
drawBytes
public void drawBytes(byte data[],
int offset,
int length,
int x,
int y)
- Draws the specified bytes using the current font and color.
Assumes ISO8859-1 byte-to-character conversion, zeros out
high bte if that fails.
- Parameters:
- data - the data to be drawn
- offset - the start offset in the data
- length - the number of bytes that are drawn
- x - the x coordinate
- y - the y coordinate
- Overrides:
- drawBytes in class Graphics
- See Also:
- drawString, drawChars
doImage
public boolean doImage(Image img,
int x,
int y,
int width,
int height,
ImageObserver observer,
Color bgcolor)
drawImage
public boolean drawImage(Image img,
int x,
int y,
ImageObserver observer)
- Draws the specified image at the specified coordinate (x, y). If the image is
incomplete the image observer will be notified later.
- Parameters:
- img - the specified image to be drawn
- x - the x coordinate
- y - the y coordinate
- observer - notifies if the image is complete or not
- Overrides:
- drawImage in class Graphics
- See Also:
- Image, ImageObserver
drawImage
public boolean drawImage(Image img,
int x,
int y,
int width,
int height,
ImageObserver observer)
- Draws the specified image inside the specified rectangle. The image is
scaled if necessary. If the image is incomplete the image observer will be
notified later.
- Parameters:
- img - the specified image to be drawn
- x - the x coordinate
- y - the y coordinate
- width - the width of the rectangle
- height - the height of the rectangle
- observer - notifies if the image is complete or not
- Overrides:
- drawImage in class Graphics
- See Also:
- Image, ImageObserver
drawImage
public boolean drawImage(Image img,
int x,
int y,
Color bgcolor,
ImageObserver observer)
- Draws the specified image at the specified coordinate (x, y). If the image is
incomplete the image observer will be notified later.
- Parameters:
- img - the specified image to be drawn
- x - the x coordinate
- y - the y coordinate
- bgcolor - the background color
- observer - notifies if the image is complete or not
- Overrides:
- drawImage in class Graphics
- See Also:
- Image, ImageObserver
drawImage
public boolean drawImage(Image img,
int x,
int y,
int width,
int height,
Color bgcolor,
ImageObserver observer)
- Draws the specified image inside the specified rectangle. The image is
scaled if necessary. If the image is incomplete the image observer will be
notified later.
- Parameters:
- img - the specified image to be drawn
- x - the x coordinate
- y - the y coordinate
- width - the width of the rectangle
- height - the height of the rectangle
- bgcolor - the background color
- observer - notifies if the image is complete or not
- Overrides:
- drawImage in class Graphics
- See Also:
- Image, ImageObserver
drawImage
public boolean drawImage(Image img,
int dx1,
int dy1,
int dx2,
int dy2,
int sx1,
int sy1,
int sx2,
int sy2,
Color bgcolor,
ImageObserver observer)
- Draws as much of the specified area of the specified image as is
currently available, scaling it on the fly to fit inside the
specified area of the destination drawable surface.
- Overrides:
- drawImage in class Graphics
drawImage
public boolean drawImage(Image img,
int dx1,
int dy1,
int dx2,
int dy2,
int sx1,
int sy1,
int sx2,
int sy2,
ImageObserver observer)
- Draws as much of the specified area of the specified image as is
currently available, scaling it on the fly to fit inside the
specified area of the destination drawable surface.
- Overrides:
- drawImage in class Graphics
dispose
public void dispose()
- Disposes of this graphics context. The Graphics context cannot be used after
being disposed of.
- Overrides:
- dispose in class Graphics
- See Also:
- finalize
finalize
public void finalize()
- Disposes of this graphics context once it is no longer referenced.
- Overrides:
- finalize in class Graphics
- See Also:
- dispose
toString
public String toString()
- Returns a String object representing this Graphic's value.
- Overrides:
- toString in class Graphics
transformY
protected int transformY(int y)
- Flip Y coords so Postscript looks like Java
transformX
protected int transformX(int x)
emitProlog
protected void emitProlog()
- Top of every PS file
emitColorImageProlog
protected void emitColorImageProlog(int xdim)
gsave
public void gsave()
grestore
public void grestore()
emitThis
public void emitThis(String s)
showpage
public void showpage()
- Writes a PostScript
showpage
directive and flushes
the Writer stream.
All Packages Class Hierarchy This Package Previous Next Index