Package org.openscience.cdk.depict
Class Depiction
- java.lang.Object
-
- org.openscience.cdk.depict.Depiction
-
public abstract class Depiction extends Object
Base class of a pre-rendered depiction. The class allows introspection of depiction size (decided at generation time) and serialization to raster and vector graphic formats.- Author:
- John May
-
-
Field Summary
Fields Modifier and Type Field Description protected static double
DEFAULT_PADDING_FACTOR
When no fixed padding value is specified we use margin multiplied by this value.static String
EPS_FMT
Encapsulated PostScript (EPS) format key.static String
GIF_FMT
Graphics Interchange Format (GIF) format key.static String
JPG_FMT
Joint Photographic Experts Group (JPG) format key.protected static double
MM_TO_POINT
For converting MM coordinates to PS Point (1/72 inch)protected RendererModel
model
static String
PDF_FMT
Portable Document Format (PDF) format key.static String
PNG_FMT
Portable Network Graphics (PNG) format key.static String
PS_FMT
PostScript (PS) format key.static String
SVG_FMT
Structured Vector Graphics (SVG) format key.static String
UNITS_MM
Units in MM (specific to SVG).static String
UNITS_PX
Units in PX (specific to SVG).
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected double
calcFitting(org.openscience.cdk.depict.Dimensions srcDim, org.openscience.cdk.depict.Dimensions dstDim, double margin)
protected void
draw(IDrawVisitor visitor, double zoom, Bounds bounds, Rectangle2D viewBounds)
Low-level draw method used by other rendering methods.List<String>
listFormats()
List the available formats that can be rendered.protected void
svgStyleCache(String fmt, double rescale, org.openscience.cdk.depict.SvgDrawVisitor visitor, List<? extends IRenderingElement> elements)
String
toEpsStr()
Render the image to an EPS (Encapsulated PostScript) format string.abstract BufferedImage
toImg()
Render the depiction to a Java AWTBufferedImage
.String
toPdfStr()
Render the image to an PDF format string.String
toPsStr()
Render the image to an PS (PostScript) format string.String
toSvgStr()
Render the image to an SVG image.String
toSvgStr(String units)
Render the image to an SVG image.void
writeTo(String path)
Write the depiction to the provided file path, the format is determined by the path suffix.void
writeTo(String fmt, File file)
Write the depiction to the provided output stream.void
writeTo(String fmt, OutputStream out)
Write the depiction to the provided output stream.void
writeTo(String fmt, String path)
Write the depiction to the provided file path.
-
-
-
Field Detail
-
MM_TO_POINT
protected static final double MM_TO_POINT
For converting MM coordinates to PS Point (1/72 inch)- See Also:
- Constant Field Values
-
DEFAULT_PADDING_FACTOR
protected static final double DEFAULT_PADDING_FACTOR
When no fixed padding value is specified we use margin multiplied by this value.- See Also:
- Constant Field Values
-
SVG_FMT
public static final String SVG_FMT
Structured Vector Graphics (SVG) format key.- See Also:
- Constant Field Values
-
PS_FMT
public static final String PS_FMT
PostScript (PS) format key.- See Also:
- Constant Field Values
-
EPS_FMT
public static final String EPS_FMT
Encapsulated PostScript (EPS) format key.- See Also:
- Constant Field Values
-
PDF_FMT
public static final String PDF_FMT
Portable Document Format (PDF) format key.- See Also:
- Constant Field Values
-
JPG_FMT
public static final String JPG_FMT
Joint Photographic Experts Group (JPG) format key.- See Also:
- Constant Field Values
-
PNG_FMT
public static final String PNG_FMT
Portable Network Graphics (PNG) format key.- See Also:
- Constant Field Values
-
GIF_FMT
public static final String GIF_FMT
Graphics Interchange Format (GIF) format key.- See Also:
- Constant Field Values
-
UNITS_MM
public static final String UNITS_MM
Units in MM (specific to SVG).- See Also:
- Constant Field Values
-
UNITS_PX
public static final String UNITS_PX
Units in PX (specific to SVG).- See Also:
- Constant Field Values
-
model
protected final RendererModel model
-
-
Method Detail
-
toImg
public abstract BufferedImage toImg()
Render the depiction to a Java AWTBufferedImage
.- Returns:
- AWT buffered image
-
toSvgStr
public final String toSvgStr()
Render the image to an SVG image.- Returns:
- svg XML content
-
toSvgStr
public final String toSvgStr(String units)
Render the image to an SVG image.- Parameters:
units
- the units for SVG - 'px' or 'mm'- Returns:
- svg XML content
-
toPsStr
public final String toPsStr()
Render the image to an PS (PostScript) format string.- Returns:
- PS content
-
toEpsStr
public final String toEpsStr()
Render the image to an EPS (Encapsulated PostScript) format string.- Returns:
- EPS content
-
toPdfStr
public final String toPdfStr()
Render the image to an PDF format string.- Returns:
- pdf content
-
listFormats
public final List<String> listFormats()
List the available formats that can be rendered.- Returns:
- supported formats
-
writeTo
public final void writeTo(String fmt, OutputStream out) throws IOException
Write the depiction to the provided output stream.- Parameters:
fmt
- formatout
- output stream- Throws:
IOException
- depiction could not be written, low level IO problem- See Also:
listFormats()
-
writeTo
public final void writeTo(String fmt, File file) throws IOException
Write the depiction to the provided output stream.- Parameters:
fmt
- formatfile
- output destination- Throws:
IOException
- depiction could not be written, low level IO problem- See Also:
listFormats()
-
writeTo
public final void writeTo(String fmt, String path) throws IOException
Write the depiction to the provided file path.- Parameters:
fmt
- formatpath
- output destination path- Throws:
IOException
- depiction could not be written, low level IO problem- See Also:
listFormats()
-
writeTo
public final void writeTo(String path) throws IOException
Write the depiction to the provided file path, the format is determined by the path suffix.- Parameters:
path
- output destination path- Throws:
IOException
- depiction could not be written, low level IO problem- See Also:
listFormats()
-
draw
protected final void draw(IDrawVisitor visitor, double zoom, Bounds bounds, Rectangle2D viewBounds)
Low-level draw method used by other rendering methods.- Parameters:
visitor
- the draw visitorbounds
- a bound rendering elementzoom
- if the diagram is zoomed at allviewBounds
- the view bounds - the root will be centered in the bounds
-
svgStyleCache
protected void svgStyleCache(String fmt, double rescale, org.openscience.cdk.depict.SvgDrawVisitor visitor, List<? extends IRenderingElement> elements)
-
calcFitting
protected double calcFitting(org.openscience.cdk.depict.Dimensions srcDim, org.openscience.cdk.depict.Dimensions dstDim, double margin)
-
-