Class SVGOutput

    • Constructor Detail

      • SVGOutput

        public SVGOutput​(int width,
                         int height)
        Create a new SVGOutput
        Parameters:
        width - the width of the image in user units
        height - the height of the image in user units
      • SVGOutput

        public SVGOutput​(int width,
                         int height,
                         Paint background)
        Create a new SVGOutput
        Parameters:
        width - the width of the image
        height - the height of the image
        background - the background color of the SVG, or null for no background
    • Method Detail

      • setXMLExtras

        public void setXMLExtras​(String extraxml,
                                 String svgatts)
        Add additional XML to the XVG object and/or additional attributes to the <svg> tag. Additional XML is specified with the extraxml parameter, and is added immediately after the <svg> tag. Additional attributes for the <svg> tag are specified with the svgatts parameter. Both parameters may be null. As an example, calling setXMLExtras("<script xlink:href=\"myscript.js\" />", "xmlns:xlink=\"http://www.w3.org/1999/xlink\""); would result in SVG that looks something like this (features set by this call in bold):
         <svg width="300" height="300" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink"<
         <script xlink:href="myscript.js" />
         <g><polygon ...
         
        Parameters:
        extraxml - the XML which should be inserted immediately after the <svg> tag. May be null.
        svgatts - any additional attributes for the <svg> tag. May be null.
        Since:
        2.1
      • writeSVG

        public void writeSVG​(Writer writer,
                             boolean header)
                      throws IOException

        Write the SVG data to the specified writer. For standalone SVG documents, the header flag should be set to true to generate the <?xml version="1.0"... header, and the DOCTYPE line defining the output as an SVG document.

        Note that when writing to an OutputStreamWriter or FileWriter, the encoding of the XML header will be set to match the encoding of that Writer. This implies that if you want to control the encoding of the XML, make sure you set the encoding explicitly when creating the OutputStreamWriter object, eg. new OutputStreamWriter(stream, "UTF-8") instead of new OutputStreamWriter(stream)

        Parameters:
        writer - the Writer to write the finished SVG to.
        header - whether to include the "<?xml"... header and the DOCTYPE.
        Throws:
        IOException
      • getTrace

        public String getTrace​(String name)
        Return the path taken by the specified line series. This method functions a similar way to the Output.getAreas() method - given a line series called "Prices", passing in the string "trace.graph.series.Prices" will return a String containing a list of comma-separated points which define the path taken by that series. There is no reason for end users to call this method.
        Since:
        2.1
      • setPrefix

        public void setPrefix​(String prefix)
        Set the prefix to use for any "id" attributes that need to be created
        Parameters:
        prefix - the prefix, or null for none
        Since:
        2.4.9