Package org.openscience.cdk.depict
Class Depiction
java.lang.Object
org.openscience.cdk.depict.Depiction
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
FieldsModifier and TypeFieldDescriptionprotected static final doubleWhen no fixed padding value is specified we use margin multiplied by this value.static final StringEncapsulated PostScript (EPS) format key.static final StringGraphics Interchange Format (GIF) format key.static final StringJoint Photographic Experts Group (JPG) format key.protected static final doubleFor converting MM coordinates to PS Point (1/72 inch)protected final RendererModelstatic final StringPortable Document Format (PDF) format key.static final StringPortable Network Graphics (PNG) format key.static final StringPostScript (PS) format key.static final StringStructured Vector Graphics (SVG) format key.static final StringUnits in MM (specific to SVG).static final StringUnits in PX (specific to SVG). -
Method Summary
Modifier and TypeMethodDescriptionprotected doublecalcFitting(org.openscience.cdk.depict.Dimensions srcDim, org.openscience.cdk.depict.Dimensions dstDim, double margin) protected final voiddraw(IDrawVisitor visitor, double zoom, Bounds bounds, Rectangle2D viewBounds) Low-level draw method used by other rendering methods.List the available formats that can be rendered.protected voidsvgStyleCache(String fmt, double rescale, org.openscience.cdk.depict.SvgDrawVisitor visitor, List<? extends IRenderingElement> elements) final StringtoEpsStr()Render the image to an EPS (Encapsulated PostScript) format string.abstract BufferedImagetoImg()Render the depiction to a Java AWTBufferedImage.final byte[]toPdf()Render the image to an PDF format byte array.final StringtoPdfStr()Render the image to an PDF format string.final StringtoPsStr()Render the image to an PS (PostScript) format string.final StringtoSvgStr()Render the image to an SVG image.final StringRender the image to an SVG image.final voidWrite the depiction to the provided file path, the format is determined by the path suffix.final voidWrite the depiction to the provided output stream.final voidwriteTo(String fmt, OutputStream out) Write the depiction to the provided output stream.final voidWrite the depiction to the provided file path.
-
Field Details
-
MM_TO_POINT
protected static final double MM_TO_POINTFor converting MM coordinates to PS Point (1/72 inch)- See Also:
-
DEFAULT_PADDING_FACTOR
protected static final double DEFAULT_PADDING_FACTORWhen no fixed padding value is specified we use margin multiplied by this value.- See Also:
-
SVG_FMT
Structured Vector Graphics (SVG) format key.- See Also:
-
PS_FMT
PostScript (PS) format key.- See Also:
-
EPS_FMT
Encapsulated PostScript (EPS) format key.- See Also:
-
PDF_FMT
Portable Document Format (PDF) format key.- See Also:
-
JPG_FMT
Joint Photographic Experts Group (JPG) format key.- See Also:
-
PNG_FMT
Portable Network Graphics (PNG) format key.- See Also:
-
GIF_FMT
Graphics Interchange Format (GIF) format key.- See Also:
-
UNITS_MM
Units in MM (specific to SVG).- See Also:
-
UNITS_PX
Units in PX (specific to SVG).- See Also:
-
model
-
-
Method Details
-
toImg
Render the depiction to a Java AWTBufferedImage.- Returns:
- AWT buffered image
-
toSvgStr
Render the image to an SVG image.- Returns:
- svg XML content
-
toSvgStr
Render the image to an SVG image.- Parameters:
units- the units for SVG - 'px' or 'mm'- Returns:
- svg XML content
-
toPsStr
Render the image to an PS (PostScript) format string.- Returns:
- PS content
-
toEpsStr
Render the image to an EPS (Encapsulated PostScript) format string.- Returns:
- EPS content
-
toPdfStr
Render the image to an PDF format string.- Returns:
- pdf content
-
toPdf
public final byte[] toPdf()Render the image to an PDF format byte array.- Returns:
- pdf content
-
listFormats
List the available formats that can be rendered.- Returns:
- supported formats
-
writeTo
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:
-
writeTo
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:
-
writeTo
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:
-
writeTo
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:
-
draw
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)
-