|
EPS Graphics2D | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Graphics | +--java.awt.Graphics2D | +--org.jibble.epsgraphics.EpsGraphics2D
EpsGraphics2D is suitable for creating high quality EPS graphics for use in documents and papers, and can be used just like a standard Graphics2D object.
Many Java programs use Graphics2D to draw stuff on the screen, and while it is easy to save the output as a png or jpeg file, it is a little harder to export it as an EPS for including in a document or paper.
This class makes the whole process extremely easy, because you can use it as if it's a Graphics2D object. The only difference is that all of the implemented methods create EPS output, which means the diagrams you draw can be resized without leading to any of the jagged edges you may see when resizing pixel-based images, such as jpeg and png files.
Example usage:
Graphics2D g = new EpsGraphics2D(); g.setColor(Color.black); // Line thickness 2. g.setStroke(new BasicStroke(2.0f)); // Draw a line. g.drawLine(10, 10, 50, 10); // Fill a rectangle in blue g.setColor(Color.blue); g.fillRect(10, 0, 20, 20); // Get the EPS output. String output = g.toString(); // Free up resources. g.dispose();
You do not need to worry about the size of the canvas when drawing on a EpsGraphics2D object. The bounding box of the EPS document will automatically resize to accomodate new items that you draw.
Not all methods are implemented yet. Those that are not are clearly labelled.
Copyright Paul Mutton, http://www.jibble.org/
Field Summary | |
static String |
VERSION
|
Constructor Summary | |
EpsGraphics2D()
Constructs a new EPS document that is initially empty and can be drawn on like a Graphics2D object. |
Method Summary | |
void |
addRenderingHints(Map hints)
Not implemented |
void |
clear()
Clears the contents of the current EPS document. |
void |
clearRect(int x,
int y,
int width,
int height)
Clears a rectangle with top-left corner placed at (x,y) using the current background color. |
void |
clip(Shape s)
Not implemented |
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()
Not implemented |
Graphics |
create(int x,
int y,
int width,
int height)
Not implemented |
void |
dispose()
Disposes of all resources used by this EpsGraphics2D object. |
void |
draw(Shape s)
Draws a Shape on the EPS document. |
void |
draw3DRect(int x,
int y,
int width,
int height,
boolean raised)
Draws a 3D rectangle outline. |
void |
drawArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
Draws an arc. |
void |
drawBytes(byte[] data,
int offset,
int length,
int x,
int y)
Draws the specified bytes, starting from (x,y) |
void |
drawChars(char[] data,
int offset,
int length,
int x,
int y)
Draws the specified characters, starting from (x,y) |
void |
drawGlyphVector(GlyphVector g,
float x,
float y)
Not implemented |
void |
drawImage(BufferedImage img,
BufferedImageOp op,
int x,
int y)
Not implemented |
boolean |
drawImage(Image img,
AffineTransform xform,
ImageObserver obs)
Not implemented |
boolean |
drawImage(Image img,
int x,
int y,
Color bgcolor,
ImageObserver observer)
Draws an image. |
boolean |
drawImage(Image img,
int x,
int y,
ImageObserver observer)
Draws an image. |
boolean |
drawImage(Image img,
int x,
int y,
int width,
int height,
Color bgcolor,
ImageObserver observer)
Draws an image. |
boolean |
drawImage(Image img,
int x,
int y,
int width,
int height,
ImageObserver observer)
Draws an image. |
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 an image. |
boolean |
drawImage(Image img,
int dx1,
int dy1,
int dx2,
int dy2,
int sx1,
int sy1,
int sx2,
int sy2,
ImageObserver observer)
Draws an image. |
void |
drawLine(int x1,
int y1,
int x2,
int y2)
Draws a straight line from (x1,y1) to (x2,y2). |
void |
drawOval(int x,
int y,
int width,
int height)
Draws an oval. |
void |
drawPolygon(int[] xPoints,
int[] yPoints,
int nPoints)
Draws a polygon made with the specified points. |
void |
drawPolygon(Polygon p)
Draws a polygon. |
void |
drawPolyline(int[] xPoints,
int[] yPoints,
int nPoints)
Draws a polyline. |
void |
drawRect(int x,
int y,
int width,
int height)
Draws a rectangle with top-left corner placed at (x,y). |
void |
drawRenderableImage(RenderableImage img,
AffineTransform xform)
Not implemented |
void |
drawRenderedImage(RenderedImage img,
AffineTransform xform)
Not implemented |
void |
drawRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
Draws a rounded rectangle. |
void |
drawString(AttributedCharacterIterator iterator,
float x,
float y)
Draws the characters of an AttributedCharacterIterator, starting from (x,y) |
void |
drawString(AttributedCharacterIterator iterator,
int x,
int y)
Draws the characters of an AttributedCharacterIterator, starting from (x,y) |
void |
drawString(String s,
float x,
float y)
Draws a string at (x,y) |
void |
drawString(String str,
int x,
int y)
Draws a string at (x,y) |
void |
fill(Shape s)
Fills a Shape on the EPS document. |
void |
fill3DRect(int x,
int y,
int width,
int height,
boolean raised)
Fills a 3D rectangle. |
void |
fillArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
Fills an arc. |
void |
fillOval(int x,
int y,
int width,
int height)
Fills an oval. |
void |
fillPolygon(int[] xPoints,
int[] yPoints,
int nPoints)
Fills a polygon made with the specified points. |
void |
fillPolygon(Polygon p)
Fills a polygon. |
void |
fillRect(int x,
int y,
int width,
int height)
Fills a rectangle with top-left corner placed at (x,y). |
void |
fillRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
Fills a rounded rectangle. |
void |
finalize()
Not implemented |
Color |
getBackground()
Gets the background color that is used by the clearRect method. |
Shape |
getClip()
Not implemented |
Rectangle |
getClipBounds()
Not implemented |
Rectangle |
getClipBounds(Rectangle r)
Not implemented |
Color |
getColor()
Returns the current Color. |
Composite |
getComposite()
Not implemented |
GraphicsConfiguration |
getDeviceConfiguration()
Not implemented |
Font |
getFont()
Returns the Font currently being used. |
FontMetrics |
getFontMetrics()
Not implemented |
FontMetrics |
getFontMetrics(Font f)
Not implemented |
FontRenderContext |
getFontRenderContext()
Not implemented |
Paint |
getPaint()
Not implemented |
Object |
getRenderingHint(RenderingHints.Key hintKey)
Not implemented |
RenderingHints |
getRenderingHints()
Not implemented |
Stroke |
getStroke()
Returns the Stroke currently used. |
String |
getTitle()
Returns the title of the EPS document. |
AffineTransform |
getTransform()
Gets the AffineTransform used by this EpsGraphics2D. |
boolean |
hit(Rectangle rect,
Shape s,
boolean onStroke)
Not implemented |
boolean |
hitClip(int x,
int y,
int width,
int height)
Not implemented |
void |
rotate(double theta)
Not implemented |
void |
rotate(double theta,
double x,
double y)
Not implemented |
void |
scale(double sx,
double sy)
Not implemented |
void |
setBackground(Color color)
Sets the background color to be used by the clearRect method. |
void |
setClip(int x,
int y,
int width,
int height)
Not implemented |
void |
setClip(Shape clip)
Not implemented |
void |
setColor(Color c)
Sets the Color to be used when drawing all future shapes, text, etc. |
void |
setComposite(Composite comp)
Not implemented |
void |
setFont(Font font)
Sets the Font to be used in future text. |
void |
setPaint(Paint paint)
Not implemented |
void |
setPaintMode()
Not implemented |
void |
setRenderingHint(RenderingHints.Key hintKey,
Object hintValue)
Not implemented |
void |
setRenderingHints(Map hints)
Not implemented |
void |
setStroke(Stroke s)
Sets the stroke. |
void |
setTitle(String title)
Sets the title of the EPS document. |
void |
setTransform(AffineTransform Tx)
Sets the AffineTransform to be used by this EpsGraphics2D. |
void |
setXORMode(Color c1)
Not implemented |
void |
shear(double shx,
double shy)
Not implemented |
String |
toString()
Not implemented |
void |
transform(AffineTransform Tx)
Not implemented |
void |
translate(double tx,
double ty)
Not implemented |
void |
translate(int x,
int y)
Not implemented |
Methods inherited from class java.awt.Graphics |
getClipRect |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final String VERSION
Constructor Detail |
public EpsGraphics2D()
Method Detail |
public void clear()
public String getTitle()
public void setTitle(String title)
public void draw3DRect(int x, int y, int width, int height, boolean raised)
draw3DRect
in class Graphics2D
public void fill3DRect(int x, int y, int width, int height, boolean raised)
fill3DRect
in class Graphics2D
public void draw(Shape s)
draw
in class Graphics2D
public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs)
drawImage
in class Graphics2D
public void drawImage(BufferedImage img, BufferedImageOp op, int x, int y)
drawImage
in class Graphics2D
public void drawRenderedImage(RenderedImage img, AffineTransform xform)
drawRenderedImage
in class Graphics2D
public void drawRenderableImage(RenderableImage img, AffineTransform xform)
drawRenderableImage
in class Graphics2D
public void drawString(String str, int x, int y)
drawString
in class Graphics2D
public void drawString(String s, float x, float y)
drawString
in class Graphics2D
public void drawString(AttributedCharacterIterator iterator, int x, int y)
drawString
in class Graphics2D
public void drawString(AttributedCharacterIterator iterator, float x, float y)
drawString
in class Graphics2D
public void drawGlyphVector(GlyphVector g, float x, float y)
drawGlyphVector
in class Graphics2D
public void fill(Shape s)
fill
in class Graphics2D
public boolean hit(Rectangle rect, Shape s, boolean onStroke)
hit
in class Graphics2D
public GraphicsConfiguration getDeviceConfiguration()
getDeviceConfiguration
in class Graphics2D
public void setComposite(Composite comp)
setComposite
in class Graphics2D
public void setPaint(Paint paint)
setPaint
in class Graphics2D
public void setStroke(Stroke s)
setStroke
in class Graphics2D
public void setRenderingHint(RenderingHints.Key hintKey, Object hintValue)
setRenderingHint
in class Graphics2D
public Object getRenderingHint(RenderingHints.Key hintKey)
getRenderingHint
in class Graphics2D
public void setRenderingHints(Map hints)
setRenderingHints
in class Graphics2D
public void addRenderingHints(Map hints)
addRenderingHints
in class Graphics2D
public RenderingHints getRenderingHints()
getRenderingHints
in class Graphics2D
public void translate(int x, int y)
translate
in class Graphics2D
public void translate(double tx, double ty)
translate
in class Graphics2D
public void rotate(double theta)
rotate
in class Graphics2D
public void rotate(double theta, double x, double y)
rotate
in class Graphics2D
public void scale(double sx, double sy)
scale
in class Graphics2D
public void shear(double shx, double shy)
shear
in class Graphics2D
public void transform(AffineTransform Tx)
transform
in class Graphics2D
public void setTransform(AffineTransform Tx)
setTransform
in class Graphics2D
public AffineTransform getTransform()
getTransform
in class Graphics2D
public Paint getPaint()
getPaint
in class Graphics2D
public Composite getComposite()
getComposite
in class Graphics2D
public void setBackground(Color color)
setBackground
in class Graphics2D
public Color getBackground()
getBackground
in class Graphics2D
public Stroke getStroke()
getStroke
in class Graphics2D
public void clip(Shape s)
clip
in class Graphics2D
public FontRenderContext getFontRenderContext()
getFontRenderContext
in class Graphics2D
public Graphics create()
create
in class Graphics
public Graphics create(int x, int y, int width, int height)
create
in class Graphics
public Color getColor()
getColor
in class Graphics
public void setColor(Color c)
setColor
in class Graphics
public void setPaintMode()
setPaintMode
in class Graphics
public void setXORMode(Color c1)
setXORMode
in class Graphics
public Font getFont()
getFont
in class Graphics
public void setFont(Font font)
setFont
in class Graphics
public FontMetrics getFontMetrics()
getFontMetrics
in class Graphics
public FontMetrics getFontMetrics(Font f)
getFontMetrics
in class Graphics
public Rectangle getClipBounds()
getClipBounds
in class Graphics
public void clipRect(int x, int y, int width, int height)
clipRect
in class Graphics
public void setClip(int x, int y, int width, int height)
setClip
in class Graphics
public Shape getClip()
getClip
in class Graphics
public void setClip(Shape clip)
setClip
in class Graphics
public void copyArea(int x, int y, int width, int height, int dx, int dy)
copyArea
in class Graphics
public void drawLine(int x1, int y1, int x2, int y2)
drawLine
in class Graphics
public void fillRect(int x, int y, int width, int height)
fillRect
in class Graphics
public void drawRect(int x, int y, int width, int height)
drawRect
in class Graphics
public void clearRect(int x, int y, int width, int height)
clearRect
in class Graphics
public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
drawRoundRect
in class Graphics
public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
fillRoundRect
in class Graphics
public void drawOval(int x, int y, int width, int height)
drawOval
in class Graphics
public void fillOval(int x, int y, int width, int height)
fillOval
in class Graphics
public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
drawArc
in class Graphics
public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
fillArc
in class Graphics
public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
drawPolyline
in class Graphics
public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
drawPolygon
in class Graphics
public void drawPolygon(Polygon p)
drawPolygon
in class Graphics
public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
fillPolygon
in class Graphics
public void fillPolygon(Polygon p)
fillPolygon
in class Graphics
public void drawChars(char[] data, int offset, int length, int x, int y)
drawChars
in class Graphics
public void drawBytes(byte[] data, int offset, int length, int x, int y)
drawBytes
in class Graphics
public boolean drawImage(Image img, int x, int y, ImageObserver observer)
drawImage
in class Graphics
public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer)
drawImage
in class Graphics
public boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer)
drawImage
in class Graphics
public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer)
drawImage
in class Graphics
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 Graphics
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)
drawImage
in class Graphics
public void dispose()
dispose
in class Graphics
public void finalize()
finalize
in class Graphics
public String toString()
toString
in class Graphics
public boolean hitClip(int x, int y, int width, int height)
hitClip
in class Graphics
public Rectangle getClipBounds(Rectangle r)
getClipBounds
in class Graphics
|
EPS Graphics2D | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |