![]() |
ENSDF++ 1.1
An easy, fast and simple way to run querys towards the ENSDF database, written in C++.
|
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. More...
Public Member Functions | |
EpsGraphics2D () | |
Constructs a new EPS document that is initially empty and can be drawn on like a Graphics2D object. | |
EpsGraphics2D (String title) | |
Constructs a new EPS document that is initially empty and can be drawn on like a Graphics2D object. | |
EpsGraphics2D (String title, File file, int minX, int minY, int maxX, int maxY) throws IOException | |
Constructs a new EPS document that is initially empty and can be drawn on like a Graphics2D object. | |
EpsGraphics2D (String title, OutputStream outputStream, int minX, int minY, int maxX, int maxY) throws IOException | |
Constructs a new EPS document that is initially empty and can be drawn on like a Graphics2D object. | |
void | setAccurateTextMode (boolean b) |
Sets whether to use accurate text mode when rendering text in EPS. | |
boolean | getAccurateTextMode () |
Returns whether accurate text mode is being used. | |
void | setColorDepth (int c) |
Sets the number of colours to use when drawing on the document. | |
int | getColorDepth () |
Returns the color depth used for all drawing operations. | |
void | flush () throws IOException |
Flushes the buffered contents of this EPS document to the underlying OutputStream it is being written to. | |
void | close () throws IOException |
Closes the EPS file being output to the underlying OutputStream. | |
void | draw3DRect (int x, int y, int width, int height, boolean raised) |
Draws a 3D rectangle outline. | |
void | fill3DRect (int x, int y, int width, int height, boolean raised) |
Fills a 3D rectangle. | |
void | draw (Shape s) |
Draws a Shape on the EPS document. | |
boolean | drawImage (Image img, AffineTransform xform, ImageObserver obs) |
Draws an Image on the EPS document. | |
void | drawImage (BufferedImage img, BufferedImageOp op, int x, int y) |
Draws a BufferedImage on the EPS document. | |
void | drawRenderedImage (RenderedImage img, AffineTransform xform) |
Draws a RenderedImage on the EPS document. | |
void | drawRenderableImage (RenderableImage img, AffineTransform xform) |
Draws a RenderableImage by invoking its createDefaultRendering method. | |
void | drawString (String str, int x, int y) |
Draws a string at (x,y) | |
void | drawString (String s, float x, float y) |
Draws a string at (x,y) | |
void | drawString (AttributedCharacterIterator iterator, int x, int y) |
Draws the characters of an AttributedCharacterIterator, starting from (x,y). | |
void | drawString (AttributedCharacterIterator iterator, float x, float y) |
Draws the characters of an AttributedCharacterIterator, starting from (x,y). | |
void | drawGlyphVector (GlyphVector g, float x, float y) |
Draws a GlyphVector at (x,y) | |
void | fill (Shape s) |
Fills a Shape on the EPS document. | |
boolean | hit (Rectangle rect, Shape s, boolean onStroke) |
Checks whether or not the specified Shape intersects the specified Rectangle, which is in device space. | |
GraphicsConfiguration | getDeviceConfiguration () |
Returns the device configuration associated with this EpsGraphics2D object. | |
void | setComposite (Composite comp) |
Sets the Composite to be used by this EpsGraphics2D. | |
void | setPaint (Paint paint) |
Sets the Paint attribute for the EpsGraphics2D object. | |
void | setStroke (Stroke s) |
Sets the stroke. | |
void | setRenderingHint (RenderingHints.Key hintKey, Object hintValue) |
Sets a rendering hint. | |
Object | getRenderingHint (RenderingHints.Key hintKey) |
Returns the value of a single preference for the rendering algorithms. | |
void | setRenderingHints (Map hints) |
Sets the rendering hints. | |
void | addRenderingHints (Map hints) |
Adds rendering hints. | |
RenderingHints | getRenderingHints () |
Returns the preferences for the rendering algorithms. | |
void | translate (int x, int y) |
Translates the origin of the EpsGraphics2D context to the point (x,y) in the current coordinate system. | |
void | translate (double tx, double ty) |
Concatenates the current EpsGraphics2D Transformation with a translation transform. | |
void | rotate (double theta) |
Concatenates the current EpsGraphics2D Transform with a rotation transform. | |
void | rotate (double theta, double x, double y) |
Concatenates the current EpsGraphics2D Transform with a translated rotation transform. | |
void | scale (double sx, double sy) |
Concatenates the current EpsGraphics2D Transform with a scaling transformation. | |
void | shear (double shx, double shy) |
Concatenates the current EpsGraphics2D Transform with a shearing transform. | |
void | transform (AffineTransform Tx) |
Composes an AffineTransform object with the Transform in this EpsGraphics2D according to the rule last-specified-first-applied. | |
void | setTransform (AffineTransform Tx) |
Sets the AffineTransform to be used by this EpsGraphics2D. | |
AffineTransform | getTransform () |
Gets the AffineTransform used by this EpsGraphics2D. | |
Paint | getPaint () |
Returns the current Paint of the EpsGraphics2D object. | |
Composite | getComposite () |
returns the current Composite of the EpsGraphics2D object. | |
void | setBackground (Color color) |
Sets the background color to be used by the clearRect method. | |
Color | getBackground () |
Gets the background color that is used by the clearRect method. | |
Stroke | getStroke () |
Returns the Stroke currently used. | |
void | clip (Shape s) |
Intersects the current clip with the interior of the specified Shape and sets the clip to the resulting intersection. | |
FontRenderContext | getFontRenderContext () |
Returns the FontRenderContext. | |
Graphics | create () |
Returns a new Graphics object that is identical to this EpsGraphics2D. | |
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. | |
Color | getColor () |
Returns the current Color. | |
void | setColor (Color c) |
Sets the Color to be used when drawing all future shapes, text, etc. | |
void | setPaintMode () |
Sets the paint mode of this EpsGraphics2D object to overwrite the destination EpsDocument with the current color. | |
void | setXORMode (Color c1) |
<font color="red">Not implemented</font> - performs no action. | |
Font | getFont () |
Returns the Font currently being used. | |
void | setFont (Font font) |
Sets the Font to be used in future text. | |
FontMetrics | getFontMetrics () |
Gets the font metrics of the current font. | |
FontMetrics | getFontMetrics (Font f) |
Gets the font metrics for the specified font. | |
Rectangle | getClipBounds () |
Returns the bounding rectangle of the current clipping area. | |
void | clipRect (int x, int y, int width, int height) |
Intersects the current clip with the specified rectangle. | |
void | setClip (int x, int y, int width, int height) |
Sets the current clip to the rectangle specified by the given coordinates. | |
Shape | getClip () |
Gets the current clipping area. | |
void | setClip (Shape clip) |
Sets the current clipping area to an arbitrary clip shape. | |
void | copyArea (int x, int y, int width, int height, int dx, int dy) |
<font color="red">Not implemented</font> - performs no action. | |
void | drawLine (int x1, int y1, int x2, int y2) |
Draws a straight line from (x1,y1) to (x2,y2). | |
void | fillRect (int x, int y, int width, int height) |
Fills a rectangle with top-left corner placed at (x,y). | |
void | drawRect (int x, int y, int width, int height) |
Draws a rectangle with top-left corner placed at (x,y). | |
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 | drawRoundRect (int x, int y, int width, int height, int arcWidth, int arcHeight) |
Draws a rounded rectangle. | |
void | fillRoundRect (int x, int y, int width, int height, int arcWidth, int arcHeight) |
Fills a rounded rectangle. | |
void | drawOval (int x, int y, int width, int height) |
Draws an oval. | |
void | fillOval (int x, int y, int width, int height) |
Fills an oval. | |
void | drawArc (int x, int y, int width, int height, int startAngle, int arcAngle) |
Draws an arc. | |
void | fillArc (int x, int y, int width, int height, int startAngle, int arcAngle) |
Fills an arc. | |
void | drawPolyline (int[] xPoints, int[] yPoints, int nPoints) |
Draws a polyline. | |
void | drawPolygon (int[] xPoints, int[] yPoints, int nPoints) |
Draws a polygon made with the specified points. | |
void | drawPolygon (Polygon p) |
Draws a polygon. | |
void | fillPolygon (int[] xPoints, int[] yPoints, int nPoints) |
Fills a polygon made with the specified points. | |
void | fillPolygon (Polygon p) |
Fills a polygon. | |
void | drawChars (char[] data, int offset, int length, int x, int y) |
Draws the specified characters, starting from (x,y) | |
void | drawBytes (byte[] data, int offset, int length, int x, int y) |
Draws the specified bytes, starting from (x,y) | |
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, ImageObserver observer) |
Draws an image. | |
boolean | drawImage (Image img, int x, int y, Color bgcolor, 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 dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, 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. | |
void | dispose () |
Disposes of all resources used by this EpsGraphics2D object. | |
void | finalize () |
Finalizes the object. | |
String | toString () |
Returns the entire contents of the EPS document, complete with headers and bounding box. | |
boolean | hitClip (int x, int y, int width, int height) |
Returns true if the specified rectangular area might intersect the current clipping area. | |
Rectangle | getClipBounds (Rectangle r) |
Returns the bounding rectangle of the current clipping area. | |
Static Public Attributes | |
static final String | VERSION = "0.9.0" |
static final int | BLACK_AND_WHITE = 1 |
static final int | GRAYSCALE = 2 |
static final int | RGB = 3 |
Protected Member Functions | |
EpsGraphics2D (EpsGraphics2D g) | |
Constructs a new EpsGraphics2D instance that is a copy of the supplied argument and points at the same EpsDocument. | |
Private Member Functions | |
void | methodNotSupported () |
This method is called to indicate that a particular method is not supported yet. | |
void | append (String line) |
Appends a line to the EpsDocument. | |
Point2D | transform (float x, float y) |
Returns the point after it has been transformed by the transformation. | |
void | draw (Shape s, String action) |
Appends the commands required to draw a shape on the EPS document. | |
String | toHexString (int n) |
Returns a hex string that always contains two characters. | |
Private Attributes | |
Color | _color |
Color | _backgroundColor |
Paint | _paint |
Composite | _composite |
BasicStroke | _stroke |
Font | _font |
Shape | _clip |
AffineTransform | _clipTransform |
AffineTransform | _transform |
boolean | _accurateTextMode |
int | _colorDepth |
EpsDocument | _document |
Static Private Attributes | |
static FontRenderContext | _fontRenderContext = new FontRenderContext(null, false, true) |
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();
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/
Definition at line 76 of file EpsGraphics2D.java.
EpsGraphics2D::EpsGraphics2D | ( | ) | [inline] |
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.
Definition at line 91 of file EpsGraphics2D.java.
Referenced by create().
{ this("Untitled"); }
EpsGraphics2D::EpsGraphics2D | ( | String | title | ) | [inline] |
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.
Definition at line 101 of file EpsGraphics2D.java.
References setColor(), setComposite(), setFont(), setPaint(), and setStroke().
{ _document = new EpsDocument(title); _backgroundColor = Color.white; _clip = null; _transform = new AffineTransform(); _clipTransform = new AffineTransform(); _accurateTextMode = true; _colorDepth = EpsGraphics2D.RGB; setColor(Color.black); setPaint(Color.black); setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR)); setFont(Font.decode(null)); setStroke(new BasicStroke()); }
EpsGraphics2D::EpsGraphics2D | ( | String | title, |
File | file, | ||
int | minX, | ||
int | minY, | ||
int | maxX, | ||
int | maxY | ||
) | throws IOException [inline] |
Constructs 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.
Definition at line 125 of file EpsGraphics2D.java.
{ this(title, new FileOutputStream(file), minX, minY, maxX, maxY); }
EpsGraphics2D::EpsGraphics2D | ( | String | title, |
OutputStream | outputStream, | ||
int | minX, | ||
int | minY, | ||
int | maxX, | ||
int | maxY | ||
) | throws IOException [inline] |
Constructs 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.
Definition at line 138 of file EpsGraphics2D.java.
{ this(title); _document = new EpsDocument(title, outputStream, minX, minY, maxX, maxY); }
void EpsGraphics2D::addRenderingHints | ( | Map | hints | ) | [inline] |
Adds rendering hints.
These are ignored by EpsGraphics2D.
Definition at line 667 of file EpsGraphics2D.java.
{
// Do nothing.
}
void EpsGraphics2D::close | ( | ) | throws IOException [inline] |
Closes 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.
Definition at line 243 of file EpsGraphics2D.java.
References flush().
{ flush(); _document.close(); }
void EpsGraphics2D::dispose | ( | ) | [inline] |
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.
Definition at line 1357 of file EpsGraphics2D.java.
{ _document = null; }
void EpsGraphics2D::draw3DRect | ( | int | x, |
int | y, | ||
int | width, | ||
int | height, | ||
boolean | raised | ||
) | [inline] |
Draws a 3D rectangle outline.
If it is raised, light appears to come from the top left.
Definition at line 381 of file EpsGraphics2D.java.
References drawLine(), getColor(), getStroke(), setColor(), and setStroke().
Referenced by fill3DRect().
{ Color originalColor = getColor(); Stroke originalStroke = getStroke(); setStroke(new BasicStroke(1.0f)); if (raised) { setColor(originalColor.brighter()); } else { setColor(originalColor.darker()); } drawLine(x, y, x + width, y); drawLine(x, y, x, y + height); if (raised) { setColor(originalColor.darker()); } else { setColor(originalColor.brighter()); } drawLine(x + width, y + height, x, y + height); drawLine(x + width, y + height, x + width, y); setColor(originalColor); setStroke(originalStroke); }
void EpsGraphics2D::fill3DRect | ( | int | x, |
int | y, | ||
int | width, | ||
int | height, | ||
boolean | raised | ||
) | [inline] |
Fills a 3D rectangle.
If raised, it has bright fill and light appears to come from the top left.
Definition at line 416 of file EpsGraphics2D.java.
References draw(), draw3DRect(), getColor(), and setColor().
Color EpsGraphics2D::getColor | ( | ) | [inline] |
Returns the current Color.
This will be a default value (black) until it is changed using the setColor method.
Definition at line 864 of file EpsGraphics2D.java.
Referenced by EpsDocument::append(), clearRect(), draw3DRect(), drawImage(), and fill3DRect().
{
return _color;
}
int EpsGraphics2D::getColorDepth | ( | ) | [inline] |
Returns the color depth used for all drawing operations.
This can be either EpsGraphics2D.RGB (default) or EpsGraphics2D.GREYSCALE.
Definition at line 224 of file EpsGraphics2D.java.
Referenced by drawImage(), and setColor().
{
return _colorDepth;
}
Object EpsGraphics2D::getRenderingHint | ( | RenderingHints.Key | hintKey | ) | [inline] |
Returns the value of a single preference for the rendering algorithms.
Rendering hints are not used by EpsGraphics2D.
Definition at line 651 of file EpsGraphics2D.java.
{
return null;
}
Stroke EpsGraphics2D::getStroke | ( | ) | [inline] |
Returns the Stroke currently used.
Guaranteed to be an instance of BasicStroke.
Definition at line 807 of file EpsGraphics2D.java.
Referenced by EpsDocument::append(), draw3DRect(), and setTransform().
{
return _stroke;
}
void EpsGraphics2D::methodNotSupported | ( | ) | [inline, private] |
This method is called to indicate that a particular method is not supported yet.
The stack trace is printed to the standard output.
Definition at line 168 of file EpsGraphics2D.java.
Referenced by copyArea(), and setXORMode().
{ EpsException e = new EpsException("Method not currently supported by EpsGraphics2D version " + VERSION); e.printStackTrace(System.err); }
void EpsGraphics2D::setAccurateTextMode | ( | boolean | b | ) | [inline] |
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.
Definition at line 191 of file EpsGraphics2D.java.
References getAccurateTextMode(), getFont(), and setFont().
{ _accurateTextMode = b; if (!getAccurateTextMode()) { setFont(getFont()); } }
void EpsGraphics2D::setColorDepth | ( | int | c | ) | [inline] |
Sets the number of colours to use when drawing on the document.
Can be either EpsGraphics2D.RGB (default) or EpsGraphics2D.GREYSCALE.
Definition at line 213 of file EpsGraphics2D.java.
{
if (c == RGB || c == GRAYSCALE || c == BLACK_AND_WHITE) {
_colorDepth = c;
}
}
void EpsGraphics2D::setComposite | ( | Composite | comp | ) | [inline] |
Sets the Composite to be used by this EpsGraphics2D.
EpsGraphics2D does not make use of these.
Definition at line 591 of file EpsGraphics2D.java.
Referenced by EpsDocument::append(), and EpsGraphics2D().
{ _composite = comp; }
void EpsGraphics2D::setPaint | ( | Paint | paint | ) | [inline] |
Sets the Paint attribute for the EpsGraphics2D object.
Only Paint objects of type Color are respected by EpsGraphics2D.
Definition at line 600 of file EpsGraphics2D.java.
References setColor().
Referenced by EpsDocument::append(), and EpsGraphics2D().
{ _paint = paint; if (paint instanceof Color) { setColor((Color) paint); } }
void EpsGraphics2D::setRenderingHint | ( | RenderingHints.Key | hintKey, |
Object | hintValue | ||
) | [inline] |
Sets a rendering hint.
These are not used by EpsGraphics2D.
Definition at line 642 of file EpsGraphics2D.java.
{
// Do nothing.
}
void EpsGraphics2D::setRenderingHints | ( | Map | hints | ) | [inline] |
Sets the rendering hints.
These are ignored by EpsGraphics2D.
Definition at line 659 of file EpsGraphics2D.java.
{
// Do nothing.
}
void EpsGraphics2D::setStroke | ( | Stroke | s | ) | [inline] |
Sets the stroke.
Only accepts BasicStroke objects (or subclasses of BasicStroke).
Definition at line 612 of file EpsGraphics2D.java.
References append().
Referenced by EpsDocument::append(), draw3DRect(), EpsGraphics2D(), and setTransform().
{ if (s instanceof BasicStroke) { _stroke = (BasicStroke) s; append(_stroke.getLineWidth() + " setlinewidth"); float miterLimit = _stroke.getMiterLimit(); if (miterLimit < 1.0f) { miterLimit = 1; } append(miterLimit + " setmiterlimit"); append(_stroke.getLineJoin() + " setlinejoin"); append(_stroke.getEndCap() + " setlinecap"); StringBuffer dashes = new StringBuffer(); dashes.append("[ "); float[] dashArray = _stroke.getDashArray(); if (dashArray != null) { for (int i = 0; i < dashArray.length; i++) { dashes.append((dashArray[i]) + " "); } } dashes.append("]"); append(dashes.toString() + " 0 setdash"); } }
String EpsGraphics2D::toString | ( | ) | [inline] |
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.
Definition at line 1375 of file EpsGraphics2D.java.
References EpsDocument::write().
{ StringWriter writer = new StringWriter(); try { _document.write(writer); _document.flush(); _document.close(); } catch (IOException e) { throw new EpsException(e.toString()); } return writer.toString(); }