public class PostscriptGraphics extends 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,
OutputStream os)
Constructor
Creates a new PostscriptGraphics object, given dimensions and
output file.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
addPSFontReplacement(String replace,
String with)
adds the PS font name to replace and its replacement in the replacement
hashtable
|
void |
addRenderingHints(Map m) |
void |
clearRect(int x,
int y,
int width,
int height)
Draw a filled rectangle with the background color.
|
void |
clip(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
|
Graphics |
create()
Clone a PostscriptGraphics object
|
void |
dispose()
Not implemented
|
void |
draw(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(GlyphVector gv,
float f1,
float f2) |
void |
drawImage(BufferedImage bi,
BufferedImageOp bio,
int i1,
int i2) |
boolean |
drawImage(Image im,
AffineTransform at,
ImageObserver io) |
boolean |
drawImage(Image img,
int x,
int y,
Color bgcolor,
ImageObserver observer)
calls drawImage(Image,int,int,int,int,Color,ImageObserver)
|
boolean |
drawImage(Image img,
int x,
int y,
ImageObserver observer)
calls drawImage(Image,int,int,Color,ImageObserver) with Color.WHITE as
background color
|
boolean |
drawImage(Image img,
int x,
int y,
int width,
int height,
Color bgcolor,
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(Image img,
int x,
int y,
int width,
int height,
ImageObserver observer)
calls drawImage(Image,int,int,int,int,Color,ImageObserver) with the color
WHITE as background
|
boolean |
drawImage(Image img,
int dx1,
int dy1,
int dx2,
int dy2,
int sx1,
int sy1,
int sx2,
int sy2,
Color bgcolor,
ImageObserver observer)
Not implemented
|
boolean |
drawImage(Image img,
int dx1,
int dy1,
int dx2,
int dy2,
int sx1,
int sy1,
int sx2,
int sy2,
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(RenderableImage ri,
AffineTransform at) |
void |
drawRenderedImage(RenderedImage ri,
AffineTransform af) |
void |
drawRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
Not implemented
|
void |
drawString(AttributedCharacterIterator aci,
float f1,
float f2) |
void |
drawString(AttributedCharacterIterator iterator,
int x,
int y)
Not implemented
|
void |
drawString(String str,
float x,
float y) |
void |
drawString(String str,
int x,
int y)
Draw text in current pen color.
|
void |
fill(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(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.
|
Color |
getBackground() |
Shape |
getClip()
Not implemented
|
Rectangle |
getClipBounds()
This returns the full current drawing area
|
Rectangle |
getClipBounds(Rectangle r)
This returns the full current drawing area
|
Rectangle |
getClipRect()
Not implemented
|
Color |
getColor()
Get current pen color.
|
Composite |
getComposite() |
GraphicsConfiguration |
getDeviceConfiguration() |
Font |
getFont()
Get current font.
|
FontMetrics |
getFontMetrics(Font f)
Get Font metrics
|
FontRenderContext |
getFontRenderContext()
START overridden Graphics2D methods
|
Paint |
getPaint() |
Object |
getRenderingHint(RenderingHints.Key key) |
RenderingHints |
getRenderingHints() |
Stroke |
getStroke() |
AffineTransform |
getTransform() |
boolean |
hit(Rectangle r,
Shape s,
boolean onstroke) |
void |
rotate(double d1) |
void |
rotate(double d1,
double d2,
double d3) |
void |
scale(double d1,
double d2) |
void |
setBackground(Color c) |
void |
setClip(int x,
int y,
int width,
int height)
Not implemented
|
void |
setClip(Shape clip)
Not implemented
|
void |
setColor(Color c)
Set current pen color.
|
void |
setComposite(Composite c) |
void |
setFont(Font font)
Set current font.
|
void |
setPaint(Paint p) |
void |
setPaintMode()
Not implemented
|
void |
setRenderingHint(RenderingHints.Key key,
Object o) |
void |
setRenderingHints(Map m) |
void |
setStroke(Stroke s) |
void |
setTransform(AffineTransform at) |
void |
setXORMode(Color c1)
Not implemented
|
void |
shear(double d1,
double d2) |
void |
transform(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.
|
create, drawPolygon, getFontMetrics, hitClip, toStringpublic PostscriptGraphics(int width,
int height,
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(String replace, 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)
public void clipRect(int x,
int y,
int width,
int height)
public void copyArea(int x,
int y,
int width,
int height,
int dx,
int dy)
public Graphics create()
public void draw3DRect(int x,
int y,
int width,
int height,
boolean raised)
draw3DRect in class Graphics2Dx - 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)
public void drawBytes(byte[] data,
int offset,
int length,
int x,
int y)
drawBytes in class GraphicsdrawString(String,int,int)public void drawChars(char[] data,
int offset,
int length,
int x,
int y)
drawChars in class GraphicsdrawString(String,int,int)public boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer)
drawImage in class GraphicsdrawImage(Image,int,int,int,int,Color,ImageObserver)public boolean drawImage(Image img, int x, int y, ImageObserver observer)
drawImage in class GraphicsdrawImage(Image,int,int,Color,ImageObserver),
Color.WHITEpublic boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer)
public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer)
drawImage in class GraphicsdrawImage(Image,int,int,int,int,Color,ImageObserver),
Color.WHITEpublic boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer)
public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer)
drawImage in class GraphicsdrawImage(Image,int,int,int,int,int,int,int,int,Color,ImageObserver)public void drawLine(int x1,
int y1,
int x2,
int y2)
public void drawOval(int x,
int y,
int width,
int height)
public void drawPolygon(int[] xPoints,
int[] yPoints,
int nPoints)
drawPolygon in class Graphicspublic void drawPolyline(int[] xPoints,
int[] yPoints,
int nPoints)
drawPolyline in class Graphicspublic void drawRect(int x,
int y,
int width,
int height)
public void drawRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
drawRoundRect in class Graphicspublic void drawString(AttributedCharacterIterator iterator, int x, int y)
drawString in class Graphics2Dpublic void drawString(String str, int x, int y)
drawString in class Graphics2Dstr - Text to outputx - starting x coordy - starting y coordpublic void fill3DRect(int x,
int y,
int width,
int height,
boolean raised)
fill3DRect in class Graphics2Dx - 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)
public void fillOval(int x,
int y,
int width,
int height)
public void fillPolygon(int[] xPoints,
int[] yPoints,
int nPoints)
fillPolygon in class Graphicspublic void fillPolygon(Polygon p)
fillPolygon in class Graphicspublic void fillRect(int x,
int y,
int width,
int height)
public void fillRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
fillRoundRect in class Graphicspublic Rectangle getClipBounds()
getClipBounds in class Graphicspublic Rectangle getClipBounds(Rectangle r)
getClipBounds in class Graphicspublic Rectangle getClipRect()
getClipRect in class Graphicspublic Color getColor()
public Font getFont()
public FontMetrics getFontMetrics(Font f)
getFontMetrics in class Graphicsf - Fontpublic void setClip(int x,
int y,
int width,
int height)
public void setColor(Color c)
public void setFont(Font font)
public void setPaintMode()
setPaintMode in class Graphicspublic void setXORMode(Color c1)
setXORMode in class Graphicspublic void translate(int x,
int y)
translate in class Graphics2Dx - the x coordinate.y - the y coordinate.public FontRenderContext getFontRenderContext()
getFontRenderContext in class Graphics2Dpublic void clip(Shape s)
clip in class Graphics2Dpublic Stroke getStroke()
getStroke in class Graphics2Dpublic Color getBackground()
getBackground in class Graphics2Dpublic void setBackground(Color c)
setBackground in class Graphics2Dpublic Composite getComposite()
getComposite in class Graphics2Dpublic Paint getPaint()
getPaint in class Graphics2Dpublic AffineTransform getTransform()
getTransform in class Graphics2Dpublic void setTransform(AffineTransform at)
setTransform in class Graphics2Dpublic void transform(AffineTransform at)
transform in class Graphics2Dpublic void shear(double d1,
double d2)
shear in class Graphics2Dpublic void scale(double d1,
double d2)
scale in class Graphics2Dpublic void rotate(double d1,
double d2,
double d3)
rotate in class Graphics2Dpublic void rotate(double d1)
rotate in class Graphics2Dpublic void translate(double d1,
double d2)
translate in class Graphics2Dpublic RenderingHints getRenderingHints()
getRenderingHints in class Graphics2Dpublic void addRenderingHints(Map m)
addRenderingHints in class Graphics2Dpublic void setRenderingHints(Map m)
setRenderingHints in class Graphics2Dpublic Object getRenderingHint(RenderingHints.Key key)
getRenderingHint in class Graphics2Dpublic void setRenderingHint(RenderingHints.Key key, Object o)
setRenderingHint in class Graphics2Dpublic void setStroke(Stroke s)
setStroke in class Graphics2Dpublic void setPaint(Paint p)
setPaint in class Graphics2Dpublic void setComposite(Composite c)
setComposite in class Graphics2Dpublic GraphicsConfiguration getDeviceConfiguration()
getDeviceConfiguration in class Graphics2Dpublic boolean hit(Rectangle r, Shape s, boolean onstroke)
hit in class Graphics2Dpublic void fill(Shape s)
fill in class Graphics2Dpublic void drawGlyphVector(GlyphVector gv, float f1, float f2)
drawGlyphVector in class Graphics2Dpublic void drawString(AttributedCharacterIterator aci, float f1, float f2)
drawString in class Graphics2Dpublic void drawString(String str, float x, float y)
drawString in class Graphics2Dpublic void drawRenderableImage(RenderableImage ri, AffineTransform at)
drawRenderableImage in class Graphics2Dpublic void drawRenderedImage(RenderedImage ri, AffineTransform af)
drawRenderedImage in class Graphics2Dpublic void drawImage(BufferedImage bi, BufferedImageOp bio, int i1, int i2)
drawImage in class Graphics2Dpublic boolean drawImage(Image im, AffineTransform at, ImageObserver io)
drawImage in class Graphics2Dpublic void draw(Shape s)
draw in class Graphics2DCopyright © 2012 University of Waikato, Hamilton, NZ. All Rights Reserved.