Class 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
    • Method Detail

      • 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 - format
        out - 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 - format
        file - 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 - format
        path - 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 visitor
        bounds - a bound rendering element
        zoom - if the diagram is zoomed at all
        viewBounds - 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)