public class PostscriptGraphics
extends java.awt.Graphics2D
Currently only a small (but useful) subset of Graphics methods have been implemented. To handle the ability to Clone a Graphics object, the graphics state of the eps is set from the graphics state of the local PostscriptGraphics before output. To use, create a PostscriptGraphics object, and pass it to the PaintComponent method of a JComponent.
If necessary additional font replacements can be inserted, since some fonts might be displayed incorrectly.
addPSFontReplacement(String, String)
,
m_PSFontReplacement
Constructor and Description |
---|
PostscriptGraphics(int width,
int height,
java.io.OutputStream os)
Constructor
Creates a new PostscriptGraphics object, given dimensions and
output file.
|
Modifier and Type | Method and Description |
---|---|
static void |
addPSFontReplacement(java.lang.String replace,
java.lang.String with)
adds the PS font name to replace and its replacement in the replacement
hashtable
|
void |
addRenderingHints(java.util.Map m) |
void |
clearRect(int x,
int y,
int width,
int height)
Draw a filled rectangle with the background color.
|
void |
clip(java.awt.Shape s) |
void |
clipRect(int x,
int y,
int width,
int height)
Not implemented
|
void |
copyArea(int x,
int y,
int width,
int height,
int dx,
int dy)
Not implemented
|
java.awt.Graphics |
create()
Clone a PostscriptGraphics object
|
void |
dispose()
Not implemented
|
void |
draw(java.awt.Shape s) |
void |
draw3DRect(int x,
int y,
int width,
int height,
boolean raised)
Draw an outlined rectangle with 3D effect in current pen color.
|
void |
drawArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
Not implemented
|
void |
drawBytes(byte[] data,
int offset,
int length,
int x,
int y)
simply calls drawString(String,int,int)
|
void |
drawChars(char[] data,
int offset,
int length,
int x,
int y)
simply calls drawString(String,int,int)
|
void |
drawGlyphVector(java.awt.font.GlyphVector gv,
float f1,
float f2) |
void |
drawImage(java.awt.image.BufferedImage bi,
java.awt.image.BufferedImageOp bio,
int i1,
int i2) |
boolean |
drawImage(java.awt.Image im,
java.awt.geom.AffineTransform at,
java.awt.image.ImageObserver io) |
boolean |
drawImage(java.awt.Image img,
int x,
int y,
java.awt.Color bgcolor,
java.awt.image.ImageObserver observer)
calls drawImage(Image,int,int,int,int,Color,ImageObserver)
|
boolean |
drawImage(java.awt.Image img,
int x,
int y,
java.awt.image.ImageObserver observer)
calls drawImage(Image,int,int,Color,ImageObserver) with Color.WHITE as
background color
|
boolean |
drawImage(java.awt.Image img,
int x,
int y,
int width,
int height,
java.awt.Color bgcolor,
java.awt.image.ImageObserver observer)
PS see http://astronomy.swin.edu.au/~pbourke/geomformats/postscript/
Java http://show.docjava.com:8086/book/cgij/doc/ip/graphics/SimpleImageFrame.java.html
|
boolean |
drawImage(java.awt.Image img,
int x,
int y,
int width,
int height,
java.awt.image.ImageObserver observer)
calls drawImage(Image,int,int,int,int,Color,ImageObserver) with the color
WHITE as background
|
boolean |
drawImage(java.awt.Image img,
int dx1,
int dy1,
int dx2,
int dy2,
int sx1,
int sy1,
int sx2,
int sy2,
java.awt.Color bgcolor,
java.awt.image.ImageObserver observer)
Not implemented
|
boolean |
drawImage(java.awt.Image img,
int dx1,
int dy1,
int dx2,
int dy2,
int sx1,
int sy1,
int sx2,
int sy2,
java.awt.image.ImageObserver observer)
calls drawImage(Image,int,int,int,int,int,int,int,int,Color,ImageObserver)
with Color.WHITE as background color
|
void |
drawLine(int x1,
int y1,
int x2,
int y2)
Draw a line in current pen color.
|
void |
drawOval(int x,
int y,
int width,
int height)
Draw an Oval outline in current pen color.
|
void |
drawPolygon(int[] xPoints,
int[] yPoints,
int nPoints)
Not implemented
|
void |
drawPolyline(int[] xPoints,
int[] yPoints,
int nPoints)
Not implemented
|
void |
drawRect(int x,
int y,
int width,
int height)
Draw an outlined rectangle in current pen color.
|
void |
drawRenderableImage(java.awt.image.renderable.RenderableImage ri,
java.awt.geom.AffineTransform at) |
void |
drawRenderedImage(java.awt.image.RenderedImage ri,
java.awt.geom.AffineTransform af) |
void |
drawRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
Not implemented
|
void |
drawString(java.text.AttributedCharacterIterator aci,
float f1,
float f2) |
void |
drawString(java.text.AttributedCharacterIterator iterator,
int x,
int y)
Not implemented
|
void |
drawString(java.lang.String str,
float x,
float y) |
void |
drawString(java.lang.String str,
int x,
int y)
Draw text in current pen color.
|
void |
fill(java.awt.Shape s) |
void |
fill3DRect(int x,
int y,
int width,
int height,
boolean raised)
Draw a filled rectangle with 3D effect in current pen color.
|
void |
fillArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
Not implemented
|
void |
fillOval(int x,
int y,
int width,
int height)
Draw a filled Oval in current pen color.
|
void |
fillPolygon(int[] xPoints,
int[] yPoints,
int nPoints)
Not implemented
|
void |
fillPolygon(java.awt.Polygon p)
Not implemented
|
void |
fillRect(int x,
int y,
int width,
int height)
Draw a filled rectangle in current pen color.
|
void |
fillRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
Not implemented
|
void |
finalize()
Not implemented
|
void |
finished()
Finalizes output file.
|
java.awt.Color |
getBackground() |
java.awt.Shape |
getClip()
Not implemented
|
java.awt.Rectangle |
getClipBounds()
This returns the full current drawing area
|
java.awt.Rectangle |
getClipBounds(java.awt.Rectangle r)
This returns the full current drawing area
|
java.awt.Rectangle |
getClipRect()
Not implemented
|
java.awt.Color |
getColor()
Get current pen color.
|
java.awt.Composite |
getComposite() |
java.awt.GraphicsConfiguration |
getDeviceConfiguration() |
java.awt.Font |
getFont()
Get current font.
|
java.awt.FontMetrics |
getFontMetrics(java.awt.Font f)
Get Font metrics
|
java.awt.font.FontRenderContext |
getFontRenderContext()
START overridden Graphics2D methods
|
java.awt.Paint |
getPaint() |
java.lang.Object |
getRenderingHint(java.awt.RenderingHints.Key key) |
java.awt.RenderingHints |
getRenderingHints() |
java.awt.Stroke |
getStroke() |
java.awt.geom.AffineTransform |
getTransform() |
boolean |
hit(java.awt.Rectangle r,
java.awt.Shape s,
boolean onstroke) |
void |
rotate(double d1) |
void |
rotate(double d1,
double d2,
double d3) |
void |
scale(double d1,
double d2) |
void |
setBackground(java.awt.Color c) |
void |
setClip(int x,
int y,
int width,
int height)
Not implemented
|
void |
setClip(java.awt.Shape clip)
Not implemented
|
void |
setColor(java.awt.Color c)
Set current pen color.
|
void |
setComposite(java.awt.Composite c) |
void |
setFont(java.awt.Font font)
Set current font.
|
void |
setPaint(java.awt.Paint p) |
void |
setPaintMode()
Not implemented
|
void |
setRenderingHint(java.awt.RenderingHints.Key key,
java.lang.Object o) |
void |
setRenderingHints(java.util.Map m) |
void |
setStroke(java.awt.Stroke s) |
void |
setTransform(java.awt.geom.AffineTransform at) |
void |
setXORMode(java.awt.Color c1)
Not implemented
|
void |
shear(double d1,
double d2) |
void |
transform(java.awt.geom.AffineTransform at) |
void |
translate(double d1,
double d2) |
void |
translate(int x,
int y)
Translates the origin of the graphics context to the point (x, y) in the
current coordinate system.
|
public PostscriptGraphics(int width, int height, java.io.OutputStream os)
width
- The width of eps in points.height
- The height of eps in points.os
- File to send postscript to.public void finished()
public static void addPSFontReplacement(java.lang.String replace, java.lang.String with)
replace
- the PS font name to replacewith
- the PS font name to replace the font withpublic void clearRect(int x, int y, int width, int height)
clearRect
in class java.awt.Graphics
x
- starting x coordy
- starting y coordwidth
- rectangle widthheight
- rectangle heightpublic void clipRect(int x, int y, int width, int height)
clipRect
in class java.awt.Graphics
public void copyArea(int x, int y, int width, int height, int dx, int dy)
copyArea
in class java.awt.Graphics
public java.awt.Graphics create()
create
in class java.awt.Graphics
public void dispose()
dispose
in class java.awt.Graphics
public void draw3DRect(int x, int y, int width, int height, boolean raised)
draw3DRect
in class java.awt.Graphics2D
x
- starting x coordy
- starting y coordwidth
- rectangle widthheight
- rectangle heightraised
- True: appear raised, False: appear etchedpublic void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
drawArc
in class java.awt.Graphics
public void drawBytes(byte[] data, int offset, int length, int x, int y)
drawBytes
in class java.awt.Graphics
drawString(String,int,int)
public void drawChars(char[] data, int offset, int length, int x, int y)
drawChars
in class java.awt.Graphics
drawString(String,int,int)
public boolean drawImage(java.awt.Image img, int x, int y, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)
drawImage
in class java.awt.Graphics
drawImage(Image,int,int,int,int,Color,ImageObserver)
public boolean drawImage(java.awt.Image img, int x, int y, java.awt.image.ImageObserver observer)
drawImage
in class java.awt.Graphics
drawImage(Image,int,int,Color,ImageObserver)
,
Color.WHITE
public boolean drawImage(java.awt.Image img, int x, int y, int width, int height, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)
drawImage
in class java.awt.Graphics
public boolean drawImage(java.awt.Image img, int x, int y, int width, int height, java.awt.image.ImageObserver observer)
drawImage
in class java.awt.Graphics
drawImage(Image,int,int,int,int,Color,ImageObserver)
,
Color.WHITE
public boolean drawImage(java.awt.Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)
drawImage
in class java.awt.Graphics
public boolean drawImage(java.awt.Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.image.ImageObserver observer)
drawImage
in class java.awt.Graphics
drawImage(Image,int,int,int,int,int,int,int,int,Color,ImageObserver)
public void drawLine(int x1, int y1, int x2, int y2)
drawLine
in class java.awt.Graphics
x1
- starting x coordy1
- starting y coordx2
- ending x coordy2
- ending y coordpublic void drawOval(int x, int y, int width, int height)
drawOval
in class java.awt.Graphics
x
- x-axis center of ovaly
- y-axis center of ovalwidth
- oval widthheight
- oval heightpublic void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
drawPolygon
in class java.awt.Graphics
public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
drawPolyline
in class java.awt.Graphics
public void drawRect(int x, int y, int width, int height)
drawRect
in class java.awt.Graphics
x
- starting x coordy
- starting y coordwidth
- rectangle widthheight
- rectangle heightpublic void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
drawRoundRect
in class java.awt.Graphics
public void drawString(java.text.AttributedCharacterIterator iterator, int x, int y)
drawString
in class java.awt.Graphics2D
public void drawString(java.lang.String str, int x, int y)
drawString
in class java.awt.Graphics2D
str
- Text to outputx
- starting x coordy
- starting y coordpublic void fill3DRect(int x, int y, int width, int height, boolean raised)
fill3DRect
in class java.awt.Graphics2D
x
- starting x coordy
- starting y coordwidth
- rectangle widthheight
- rectangle heightraised
- True: appear raised, False: appear etchedpublic void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
fillArc
in class java.awt.Graphics
public void fillOval(int x, int y, int width, int height)
fillOval
in class java.awt.Graphics
x
- x-axis center of ovaly
- y-axis center of ovalwidth
- oval widthheight
- oval heightpublic void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
fillPolygon
in class java.awt.Graphics
public void fillPolygon(java.awt.Polygon p)
fillPolygon
in class java.awt.Graphics
public void fillRect(int x, int y, int width, int height)
fillRect
in class java.awt.Graphics
x
- starting x coordy
- starting y coordwidth
- rectangle widthheight
- rectangle heightpublic void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
fillRoundRect
in class java.awt.Graphics
public void finalize()
finalize
in class java.awt.Graphics
public java.awt.Shape getClip()
getClip
in class java.awt.Graphics
public java.awt.Rectangle getClipBounds()
getClipBounds
in class java.awt.Graphics
public java.awt.Rectangle getClipBounds(java.awt.Rectangle r)
getClipBounds
in class java.awt.Graphics
public java.awt.Rectangle getClipRect()
getClipRect
in class java.awt.Graphics
public java.awt.Color getColor()
getColor
in class java.awt.Graphics
public java.awt.Font getFont()
getFont
in class java.awt.Graphics
public java.awt.FontMetrics getFontMetrics(java.awt.Font f)
getFontMetrics
in class java.awt.Graphics
f
- Fontpublic void setClip(int x, int y, int width, int height)
setClip
in class java.awt.Graphics
public void setClip(java.awt.Shape clip)
setClip
in class java.awt.Graphics
public void setColor(java.awt.Color c)
setColor
in class java.awt.Graphics
c
- new pen color.public void setFont(java.awt.Font font)
setFont
in class java.awt.Graphics
font
- new font.public void setPaintMode()
setPaintMode
in class java.awt.Graphics
public void setXORMode(java.awt.Color c1)
setXORMode
in class java.awt.Graphics
public void translate(int x, int y)
translate
in class java.awt.Graphics2D
x
- the x coordinate.y
- the y coordinate.public java.awt.font.FontRenderContext getFontRenderContext()
getFontRenderContext
in class java.awt.Graphics2D
public void clip(java.awt.Shape s)
clip
in class java.awt.Graphics2D
public java.awt.Stroke getStroke()
getStroke
in class java.awt.Graphics2D
public java.awt.Color getBackground()
getBackground
in class java.awt.Graphics2D
public void setBackground(java.awt.Color c)
setBackground
in class java.awt.Graphics2D
public java.awt.Composite getComposite()
getComposite
in class java.awt.Graphics2D
public java.awt.Paint getPaint()
getPaint
in class java.awt.Graphics2D
public java.awt.geom.AffineTransform getTransform()
getTransform
in class java.awt.Graphics2D
public void setTransform(java.awt.geom.AffineTransform at)
setTransform
in class java.awt.Graphics2D
public void transform(java.awt.geom.AffineTransform at)
transform
in class java.awt.Graphics2D
public void shear(double d1, double d2)
shear
in class java.awt.Graphics2D
public void scale(double d1, double d2)
scale
in class java.awt.Graphics2D
public void rotate(double d1, double d2, double d3)
rotate
in class java.awt.Graphics2D
public void rotate(double d1)
rotate
in class java.awt.Graphics2D
public void translate(double d1, double d2)
translate
in class java.awt.Graphics2D
public java.awt.RenderingHints getRenderingHints()
getRenderingHints
in class java.awt.Graphics2D
public void addRenderingHints(java.util.Map m)
addRenderingHints
in class java.awt.Graphics2D
public void setRenderingHints(java.util.Map m)
setRenderingHints
in class java.awt.Graphics2D
public java.lang.Object getRenderingHint(java.awt.RenderingHints.Key key)
getRenderingHint
in class java.awt.Graphics2D
public void setRenderingHint(java.awt.RenderingHints.Key key, java.lang.Object o)
setRenderingHint
in class java.awt.Graphics2D
public void setStroke(java.awt.Stroke s)
setStroke
in class java.awt.Graphics2D
public void setPaint(java.awt.Paint p)
setPaint
in class java.awt.Graphics2D
public void setComposite(java.awt.Composite c)
setComposite
in class java.awt.Graphics2D
public java.awt.GraphicsConfiguration getDeviceConfiguration()
getDeviceConfiguration
in class java.awt.Graphics2D
public boolean hit(java.awt.Rectangle r, java.awt.Shape s, boolean onstroke)
hit
in class java.awt.Graphics2D
public void fill(java.awt.Shape s)
fill
in class java.awt.Graphics2D
public void drawGlyphVector(java.awt.font.GlyphVector gv, float f1, float f2)
drawGlyphVector
in class java.awt.Graphics2D
public void drawString(java.text.AttributedCharacterIterator aci, float f1, float f2)
drawString
in class java.awt.Graphics2D
public void drawString(java.lang.String str, float x, float y)
drawString
in class java.awt.Graphics2D
public void drawRenderableImage(java.awt.image.renderable.RenderableImage ri, java.awt.geom.AffineTransform at)
drawRenderableImage
in class java.awt.Graphics2D
public void drawRenderedImage(java.awt.image.RenderedImage ri, java.awt.geom.AffineTransform af)
drawRenderedImage
in class java.awt.Graphics2D
public void drawImage(java.awt.image.BufferedImage bi, java.awt.image.BufferedImageOp bio, int i1, int i2)
drawImage
in class java.awt.Graphics2D
public boolean drawImage(java.awt.Image im, java.awt.geom.AffineTransform at, java.awt.image.ImageObserver io)
drawImage
in class java.awt.Graphics2D
public void draw(java.awt.Shape s)
draw
in class java.awt.Graphics2D