| Prev Class | Next Class | Frames | No Frames |
| Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.awt.Graphics2Dorg.sourceforge.jlibeps.epsgraphics.EpsGraphics2Dpublic class EpsGraphics2Dextends java.awt.Graphics2DGraphics2D 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();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 accommodate new items that you draw. Not all methods are implemented yet. Those that are not are clearly labelled. Copyright 2001-2006 Paul James Mutton, http://www.jibble.org/
Field Summary | |
static int | |
static int | |
static int | |
static String | |
private boolean | |
private Color | |
private Shape | |
private AffineTransform | |
private Color | |
private int | |
private Composite | |
private EpsDocument | |
private Font | |
private static FontRenderContext | |
private Paint | |
private BasicStroke | |
private AffineTransform | |
Constructor Summary | |
| |
| |
| |
| |
| |
Method Summary | |
void |
|
private void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
Graphics |
|
Graphics |
|
void |
|
void |
|
private void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
boolean |
|
Color |
|
Shape |
|
Rectangle |
|
Rectangle |
|
Color |
|
int |
|
Composite |
|
GraphicsConfiguration |
|
Font |
|
FontMetrics |
|
FontMetrics |
|
FontRenderContext |
|
Paint |
|
Object |
|
RenderingHints |
|
Stroke |
|
AffineTransform |
|
boolean |
|
boolean |
|
private void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
private String |
|
String |
|
void |
|
private Point2D |
|
void |
|
void |
|
public static final int BLACK_AND_WHITE
- Field Value:
- 1
public static final int GRAYSCALE
- Field Value:
- 2
public static final int RGB
- Field Value:
- 3
public static final String VERSION
private boolean _accurateTextMode
private Color _backgroundColor
private Shape _clip
private AffineTransform _clipTransform
private Color _color
private int _colorDepth
private Composite _composite
private EpsDocument _document
private Font _font
private static FontRenderContext _fontRenderContext
private Paint _paint
private BasicStroke _stroke
private AffineTransform _transform
public EpsGraphics2D()
Constructs a new EPS document that is initially empty and can be drawn on like a Graphics2D object. The EPS document is stored in memory.
- Since:
- 0.1
protected EpsGraphics2D(EpsGraphics2D g)
Constructs a new EpsGraphics2D instance that is a copy of the supplied argument and points at the same EpsDocument.
- Since:
- 0.1
public EpsGraphics2D(String title)
Constructs a new EPS document that is initially empty and can be drawn on like a Graphics2D object. The EPS document is stored in memory.
- Since:
- 0.1
public EpsGraphics2D(String title,
File file,
int minX,
int minY,
int maxX,
int maxY)
throws IOExceptionConstructs a new EPS document that is initially empty and can be drawn on like a Graphics2D object. The EPS document is written to the file as it goes, which reduces memory usage. The bounding box of the document is fixed and specified at construction time by minX,minY,maxX,maxY. The file is flushed and closed when the close() method is called.
- Since:
- 0.1
public EpsGraphics2D(String title,
OutputStream outputStream,
int minX,
int minY,
int maxX,
int maxY)
throws IOExceptionConstructs a new EPS document that is initially empty and can be drawn on like a Graphics2D object. The EPS document is written to the output stream as it goes, which reduces memory usage. The bounding box of the document is fixed and specified at construction time by minX,minY,maxX,maxY. The output stream is flushed and closed when the close() method is called.
- Since:
- 0.1
public void addRenderingHints(Map hints)
Adds rendering hints. These are ignored by EpsGraphics2D.
- Since:
- 0.1
private void append(String line)
Appends a line to the EpsDocument.
- Since:
- 0.1
public 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.
- Since:
- 0.1
public void clip(Shape s)
Intersects the current clip with the interior of the specified Shape and sets the clip to the resulting intersection.
- Since:
- 0.1
public void clipRect(int x,
int y,
int width,
int height)Intersects the current clip with the specified rectangle.
- Since:
- 0.1
public void close()
throws IOExceptionCloses the EPS file being output to the underlying OutputStream. The OutputStream is automatically flushed before being closed. If you forget to do this, the file may be incomplete.
- Since:
- 0.1
public void copyArea(int x,
int y,
int width,
int height,
int dx,
int dy)Not implemented - performs no action.
- Since:
- 0.1
public Graphics create()
Returns a new Graphics object that is identical to this EpsGraphics2D.
- Since:
- 0.1
public Graphics create(int x,
int y,
int width,
int height)Returns an EpsGraphics2D object based on this Graphics object, but with a new translation and clip area.
- Since:
- 0.1
public void dispose()
Disposes of all resources used by this EpsGraphics2D object. If this is the only remaining EpsGraphics2D instance pointing at a EpsDocument object, then the EpsDocument object shall become eligible for garbage collection.
- Since:
- 0.1
public void draw(Shape s)
Draws a Shape on the EPS document.
- Since:
- 0.1
private void draw(Shape s,
String action)Appends the commands required to draw a shape on the EPS document.
- Since:
- 0.1
public void draw3DRect(int x,
int y,
int width,
int height,
boolean raised)Draws a 3D rectangle outline. If it is raised, light appears to come from the top left.
- Since:
- 0.1
public void drawArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)Draws an arc.
- Since:
- 0.1
public void drawBytes(byte[] data,
int offset,
int length,
int x,
int y)Draws the specified bytes, starting from (x,y).
- Since:
- 0.1
public void drawChars(char[] data,
int offset,
int length,
int x,
int y)Draws the specified characters, starting from (x,y).
- Since:
- 0.1
public void drawGlyphVector(GlyphVector g,
float x,
float y)Draws a GlyphVector at (x,y).
- Since:
- 0.1
public void drawImage(BufferedImage img,
BufferedImageOp op,
int x,
int y)Draws a BufferedImage on the EPS document.
- Since:
- 0.1
public boolean drawImage(Image img,
AffineTransform xform,
ImageObserver obs)Draws an Image on the EPS document.
- Since:
- 0.1
public boolean drawImage(Image img,
int x,
int y,
Color bgcolor,
ImageObserver observer)Draws an image.
- Since:
- 0.1
public boolean drawImage(Image img,
int x,
int y,
ImageObserver observer)Draws an image.
- Since:
- 0.1
public boolean drawImage(Image img,
int x,
int y,
int width,
int height,
Color bgcolor,
ImageObserver observer)Draws an image.
- Since:
- 0.1
public boolean drawImage(Image img,
int x,
int y,
int width,
int height,
ImageObserver observer)Draws an image.
- Since:
- 0.1
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 an image.
- Since:
- 0.1
public 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.
- Since:
- 0.1
public void drawLine(int x1,
int y1,
int x2,
int y2)Draws a straight line from (x1,y1) to (x2,y2).
- Since:
- 0.1
public void drawOval(int x,
int y,
int width,
int height)Draws an oval.
- Since:
- 0.1
public void drawPolygon(Polygon p)
Draws a polygon.
- Since:
- 0.1
public void drawPolygon(int[] xPoints,
int[] yPoints,
int nPoints)Draws a polygon made with the specified points.
- Since:
- 0.1
public void drawPolyline(int[] xPoints,
int[] yPoints,
int nPoints)Draws a polyline.
- Since:
- 0.1
public void drawRect(int x,
int y,
int width,
int height)Draws a rectangle with top-left corner placed at (x,y).
- Since:
- 0.1
public void drawRenderableImage(RenderableImage img,
AffineTransform xform)Draws a RenderableImage by invoking its createDefaultRendering method.
- Since:
- 0.1
public void drawRenderedImage(RenderedImage img,
AffineTransform xform)Draws a RenderedImage on the EPS document.
- Since:
- 0.1
public void drawRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)Draws a rounded rectangle.
- Since:
- 0.1
public void drawString(AttributedCharacterIterator iterator,
float x,
float y)Draws the characters of an AttributedCharacterIterator, starting from (x,y).
- Since:
- 0.1
public void drawString(AttributedCharacterIterator iterator,
int x,
int y)Draws the characters of an AttributedCharacterIterator, starting from (x,y).
- Since:
- 0.1
public void drawString(String s,
float x,
float y)Draws a string at (x,y).
- Since:
- 0.1
public void drawString(String str,
int x,
int y)Draws a string at (x,y).
- Since:
- 0.1
public void fill(Shape s)
Fills a Shape on the EPS document.
- Since:
- 0.1
public void fill3DRect(int x,
int y,
int width,
int height,
boolean raised)Fills a 3D rectangle. If raised, it has bright fill and light appears to come from the top left.
- Since:
- 0.1
public void fillArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)Fills an arc.
- Since:
- 0.1
public void fillOval(int x,
int y,
int width,
int height)Fills an oval.
- Since:
- 0.1
public void fillPolygon(Polygon p)
Fills a polygon.
- Since:
- 0.1
public void fillPolygon(int[] xPoints,
int[] yPoints,
int nPoints)Fills a polygon made with the specified points.
- Since:
- 0.1
public void fillRect(int x,
int y,
int width,
int height)Fills a rectangle with top-left corner placed at (x,y).
- Since:
- 0.1
public void fillRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)Fills a rounded rectangle.
- Since:
- 0.1
public void finalize()
Finalises the object.
- Since:
- 0.1
public void flush()
throws IOExceptionFlushes the buffered contents of this EPS document to the underlying OutputStream it is being written to.
- Since:
- 0.1
public boolean getAccurateTextMode()
Returns whether accurate text mode is being used.
- Since:
- 0.1
public Color getBackground()
Gets the background colour that is used by the clearRect method.
- Since:
- 0.1
public Shape getClip()
Gets the current clipping area.
- Since:
- 0.1
public Rectangle getClipBounds()
Returns the bounding rectangle of the current clipping area.
- Since:
- 0.1
public Rectangle getClipBounds(Rectangle r)
Returns the bounding rectangle of the current clipping area.
- Since:
- 0.1
public Color getColor()
Returns the current Color. This will be a default value (black) until it is changed using the setColor method.
- Since:
- 0.1
public int getColorDepth()
Returns the colour depth used for all drawing operations. This can be either EpsGraphics2D.RGB (default) or EpsGraphics2D.GREYSCALE.
- Since:
- 0.1
public Composite getComposite()
returns the current Composite of the EpsGraphics2D object.
- Since:
- 0.1
public GraphicsConfiguration getDeviceConfiguration()
Returns the device configuration associated with this EpsGraphics2D object.
- Since:
- 0.1
public Font getFont()
Returns the Font currently being used.
- Since:
- 0.1
public FontMetrics getFontMetrics()
Gets the font metrics of the current font.
- Since:
- 0.1
public FontMetrics getFontMetrics(Font f)
Gets the font metrics for the specified font.
- Since:
- 0.1
public FontRenderContext getFontRenderContext()
Returns the FontRenderContext.
- Since:
- 0.1
public Paint getPaint()
Returns the current Paint of the EpsGraphics2D object.
- Since:
- 0.1
public Object getRenderingHint(RenderingHints.Key hintKey)
Returns the value of a single preference for the rendering algorithms. Rendering hints are not used by EpsGraphics2D.
- Since:
- 0.1
public RenderingHints getRenderingHints()
Returns the preferences for the rendering algorithms.
- Since:
- 0.1
public Stroke getStroke()
Returns the Stroke currently used. Guaranteed to be an instance of BasicStroke.
- Since:
- 0.1
public AffineTransform getTransform()
Gets the AffineTransform used by this EpsGraphics2D.
- Since:
- 0.1
public boolean hit(Rectangle rect,
Shape s,
boolean onStroke)Checks whether or not the specified Shape intersects the specified Rectangle, which is in device space.
- Since:
- 0.1
public boolean hitClip(int x,
int y,
int width,
int height)Returns true if the specified rectangular area might intersect the current clipping area.
- Since:
- 0.1
private void methodNotSupported()
This method is called to indicate that a particular method is not supported yet. The stack trace is printed to the standard output.
- Since:
- 0.1
public void rotate(double theta)
Concatenates the current EpsGraphics2D Transform with a rotation transform.
public void rotate(double theta,
double x,
double y)Concatenates the current EpsGraphics2D Transform with a translated rotation transform.
- Since:
- 0.1
public void scale(double sx,
double sy)Concatenates the current EpsGraphics2D Transform with a scaling transformation.
- Since:
- 0.1
public void setAccurateTextMode(boolean b)
Sets whether to use accurate text mode when rendering text in EPS. This is enabled (true) by default. When accurate text mode is used, all text will be rendered in EPS to appear exactly the same as it would do when drawn with a Graphics2D context. With accurate text mode enabled, it is not necessary for the EPS viewer to have the required font installed. Turning off accurate text mode will require the EPS viewer to have the necessary fonts installed. If you are using a lot of text, you will find that this significantly reduces the file size of your EPS documents. AffineTransforms can only affect the starting point of text using this simpler text mode - all text will be horizontal.
- Since:
- 0.1
public void setBackground(Color color)
Sets the background colour to be used by the clearRect method.
- Since:
- 0.1
public void setClip(Shape clip)
Sets the current clipping area to an arbitrary clip shape.
- Since:
- 0.1
public void setClip(int x,
int y,
int width,
int height)Sets the current clip to the rectangle specified by the given coordinates.
- Since:
- 0.1
public void setColor(Color c)
Sets the Color to be used when drawing all future shapes, text, etc.
- Since:
- 0.1
public void setColorDepth(int c)
Sets the number of colours to use when drawing on the document. Can be either EpsGraphics2D.RGB (default) or EpsGraphics2D.GREYSCALE.
- Since:
- 0.1
public void setComposite(Composite comp)
Sets the Composite to be used by this EpsGraphics2D. EpsGraphics2D does not make use of these.
- Since:
- 0.1
public void setFont(Font font)
Sets the Font to be used in future text.
- Since:
- 0.1
public void setPaint(Paint paint)
Sets the Paint attribute for the EpsGraphics2D object. Only Paint objects of type Color are respected by EpsGraphics2D.
- Since:
- 0.1
public void setPaintMode()
Sets the paint mode of this EpsGraphics2D object to overwrite the destination EpsDocument with the current colour.
- Since:
- 0.1
public void setRenderingHint(RenderingHints.Key hintKey,
Object hintValue)Sets a rendering hint. These are not used by EpsGraphics2D.
- Since:
- 0.1
public void setRenderingHints(Map hints)
Sets the rendering hints. These are ignored by EpsGraphics2D.
- Since:
- 0.1
public void setStroke(Stroke s)
Sets the stroke. Only accepts BasicStroke objects (or subclasses of BasicStroke).
- Since:
- 0.1
public void setTransform(AffineTransform Tx)
Sets the AffineTransform to be used by this EpsGraphics2D.
- Since:
- 0.1
public void setXORMode(Color c1)
Not implemented - performs no action.
- Since:
- 0.1
public void shear(double shx,
double shy)Concatenates the current EpsGraphics2D Transform with a shearing transform.
- Since:
- 0.1
private String toHexString(int n)
Returns a hex string that always contains two characters.
- Since:
- 0.1
public String toString()
Returns the entire contents of the EPS document, complete with headers and bounding box. The returned String is suitable for being written directly to disk as an EPS file.
- Since:
- 0.1
public void transform(AffineTransform Tx)
Composes an AffineTransform object with the Transform in this EpsGraphics2D according to the rule last-specified-first-applied.
- Since:
- 0.1
private Point2D transform(float x,
float y)Returns the point after it has been transformed by the transformation.
- Since:
- 0.1
public void translate(double tx,
double ty)Concatenates the current EpsGraphics2D Transformation with a translation transform.
- Since:
- 0.1
public void translate(int x,
int y)Translates the origin of the EpsGraphics2D context to the point (x,y) in the current coordinate system.
- Since:
- 0.1