ur_rna.StructureEditor.services.drawing.export

## Class SvgGraphicsExporter

- java.lang.Object
- - ur_rna.StructureEditor.services.drawing.export.SvgGraphicsExporter

-     public class SvgGraphicsExporter
      extends java.lang.Object

  Saves Graphics operations (recorded by a Graphics2DRecorder) to SVG format.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private static java.text.DecimalFormat` | `_fmtSimpleDouble`
    `private static java.lang.String` | `CHARSET_UTF8`
    `private java.util.Map<java.lang.Integer,org.w3c.dom.Element>` | `clippingPathElements`
    `private GraphicsStyle` | `currentStyle`
    `private org.w3c.dom.Element` | `defs`
    `private org.w3c.dom.Document` | `doc`
    `private double` | `DPI`
    `private java.util.Stack<GraphicsStyle>` | `graphicsStyles`
    `private org.w3c.dom.Element` | `group`
    `private GraphicsStyle` | `groupStyle`
    `private java.util.Map<org.w3c.dom.Element,GraphicsStyle>` | `groupStyles`
    `private PageSize` | `pageSize`
    `static int` | `PrintDPI`
    `private double` | `PX_PER_MM`
    `private org.w3c.dom.Element` | `root`
    `static int` | `ScreenDPI`
    `private static java.util.Map<java.lang.Integer,java.lang.String>` | `STROKE_ENDCAPS` Mapping of stroke endcap values from Java to SVG.
    `private static java.util.Map<java.lang.Integer,java.lang.String>` | `STROKE_LINEJOIN` Mapping of line join values for path drawing from Java to SVG.
    `private static java.lang.String` | `SVG_DOCTYPE_NAME`
    `private static java.lang.String` | `SVG_DOCTYPE_PUBLIC_ID`
    `private static java.lang.String` | `SVG_DOCTYPE_SYSTEM_ID`
    `private static java.lang.String` | `SVG_NAMESPACE_URI`
    `static int` | `TrueScreenDPI`
    `private static java.lang.String` | `XLINK_NAMESPACE`
    `private static java.lang.String` | `XLINK_NAMESPACE_URI`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SvgGraphicsExporter(PageSize pageSize, double dpiResolution)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `private void` | `addToGroup(org.w3c.dom.Element e)`
    `private static void` | `appendStyle(java.lang.StringBuilder style, java.lang.String attribute, java.lang.Object value)`
    `void` | `applyOperation(GraphicsOp op)`
    `private static java.lang.String` | `encodeImage(java.awt.image.BufferedImage bufferedImage, java.lang.String format)`
    `private void` | `exitGroup()`
    `private static java.lang.String` | `fmtNumber(double number)`
    `private static java.lang.String` | `fmtObj(java.lang.Object value)`
    `private static java.lang.String` | `fmtTransform(java.awt.geom.AffineTransform tx)`
    `private org.w3c.dom.Element` | `getClipElement(java.awt.Shape clip)`
    `private java.lang.String` | `getDrawStyle(boolean filled)`
    `private org.w3c.dom.Element` | `getElement(java.awt.Image image, double x, double y, double width, double height)`
    `private org.w3c.dom.Element` | `getElement(java.awt.Shape shape)`
    `private org.w3c.dom.Element` | `getElement(java.lang.String text, double x, double y)`
    `private java.lang.String` | `getFontStyle(java.awt.Font font)`
    `private static java.lang.String` | `getImageOutput(java.awt.Image image, boolean lossyAllowed)`
    `private static java.lang.String` | `getOutput(java.awt.Color color)`
    `private static java.lang.String` | `getOutput(java.awt.Shape shape)`
    `private void` | `initDocRoot()`
    `private void` | `initGroup(org.w3c.dom.Element g)`
    `private static java.lang.String` | `join(java.lang.String delimiter, double... values)`
    `private static java.lang.String` | `join(java.lang.String delimiter, float... values)`
    `private void` | `newGroup()`
    `private static java.io.Writer` | `newUTF8Writer(java.lang.String path, boolean append)` Simplified version of `Files.newBufferedWriter(Path, Charset, OpenOption...)` that uses `StandardCharsets.UTF_8` as the charset and accepts a boolean "append" instead of an `OpenOption` argument list.
    `private GraphicsStyle` | `popState()` Pops the GraphicsStyle from the top of the stack and returns it.
    `private GraphicsStyle` | `pushState()` Pushes a new GraphicsStyle (cloned from the current one) to the top of the stack and returns it.
    `java.lang.String` | `toString()`
    `void` | `write(java.util.List<GraphicsOp> ops, java.lang.String path)`
    `void` | `write(java.util.List<GraphicsOp> ops, java.io.Writer output)`
    `void` | `writeTo(javax.xml.transform.stream.StreamResult out)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### _fmtSimpleDouble

          private static final java.text.DecimalFormat _fmtSimpleDouble

    - #### CHARSET_UTF8

          private static final java.lang.String CHARSET_UTF8

      See Also:
        Constant Field Values

    - #### clippingPathElements

          private final java.util.Map<java.lang.Integer,org.w3c.dom.Element> clippingPathElements

    - #### currentStyle

          private GraphicsStyle currentStyle

    - #### defs

          private org.w3c.dom.Element defs

    - #### doc

          private final org.w3c.dom.Document doc

    - #### DPI

          private final double DPI

    - #### graphicsStyles

          private final java.util.Stack<GraphicsStyle> graphicsStyles

    - #### group

          private org.w3c.dom.Element group

    - #### groupStyle

          private GraphicsStyle groupStyle

    - #### groupStyles

          private final java.util.Map<org.w3c.dom.Element,GraphicsStyle> groupStyles

    - #### pageSize

          private final PageSize pageSize

    - #### PrintDPI

          public static int PrintDPI

    - #### PX_PER_MM

          private final double PX_PER_MM

    - #### root

          private org.w3c.dom.Element root

    - #### ScreenDPI

          public static int ScreenDPI

    - #### STROKE_ENDCAPS

          private static final java.util.Map<java.lang.Integer,java.lang.String> STROKE_ENDCAPS

      Mapping of stroke endcap values from Java to SVG.

    - #### STROKE_LINEJOIN

          private static final java.util.Map<java.lang.Integer,java.lang.String> STROKE_LINEJOIN

      Mapping of line join values for path drawing from Java to SVG.

    - #### SVG_DOCTYPE_NAME

          private static final java.lang.String SVG_DOCTYPE_NAME

      See Also:
        Constant Field Values

    - #### SVG_DOCTYPE_PUBLIC_ID

          private static final java.lang.String SVG_DOCTYPE_PUBLIC_ID

      See Also:
        Constant Field Values

    - #### SVG_DOCTYPE_SYSTEM_ID

          private static final java.lang.String SVG_DOCTYPE_SYSTEM_ID

      See Also:
        Constant Field Values

    - #### SVG_NAMESPACE_URI

          private static final java.lang.String SVG_NAMESPACE_URI

      See Also:
        Constant Field Values

    - #### TrueScreenDPI

          public static int TrueScreenDPI

    - #### XLINK_NAMESPACE

          private static final java.lang.String XLINK_NAMESPACE

      See Also:
        Constant Field Values

    - #### XLINK_NAMESPACE_URI

          private static final java.lang.String XLINK_NAMESPACE_URI

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### SvgGraphicsExporter

          public SvgGraphicsExporter(PageSize pageSize,
                                     double dpiResolution)

  - ### Method Detail

    - #### addToGroup

          private void addToGroup(org.w3c.dom.Element e)

    - #### appendStyle

          private static void appendStyle(java.lang.StringBuilder style,
                                          java.lang.String attribute,
                                          java.lang.Object value)

    - #### applyOperation

          public void applyOperation(GraphicsOp op)

    - #### encodeImage

          private static java.lang.String encodeImage(java.awt.image.BufferedImage bufferedImage,
                                                      java.lang.String format)

    - #### exitGroup

          private void exitGroup()

    - #### fmtNumber

          private static java.lang.String fmtNumber(double number)

    - #### fmtObj

          private static java.lang.String fmtObj(java.lang.Object value)

    - #### fmtTransform

          private static java.lang.String fmtTransform(java.awt.geom.AffineTransform tx)

    - #### getClipElement

          private org.w3c.dom.Element getClipElement(java.awt.Shape clip)

    - #### getDrawStyle

          private java.lang.String getDrawStyle(boolean filled)

    - #### getElement

          private org.w3c.dom.Element getElement(java.awt.Image image,
                                                 double x,
                                                 double y,
                                                 double width,
                                                 double height)

    - #### getElement

          private org.w3c.dom.Element getElement(java.awt.Shape shape)

    - #### getElement

          private org.w3c.dom.Element getElement(java.lang.String text,
                                                 double x,
                                                 double y)

    - #### getFontStyle

          private java.lang.String getFontStyle(java.awt.Font font)

    - #### getImageOutput

          private static java.lang.String getImageOutput(java.awt.Image image,
                                                         boolean lossyAllowed)

    - #### getOutput

          private static java.lang.String getOutput(java.awt.Color color)

    - #### getOutput

          private static java.lang.String getOutput(java.awt.Shape shape)

    - #### initDocRoot

          private void initDocRoot()

    - #### initGroup

          private void initGroup(org.w3c.dom.Element g)

    - #### join

          private static java.lang.String join(java.lang.String delimiter,
                                               double... values)

    - #### join

          private static java.lang.String join(java.lang.String delimiter,
                                               float... values)

    - #### newGroup

          private void newGroup()

    - #### newUTF8Writer

          private static java.io.Writer newUTF8Writer(java.lang.String path,
                                                      boolean append)
                                               throws java.io.IOException

      Simplified version of `Files.newBufferedWriter(Path, Charset, OpenOption...)` that uses `StandardCharsets.UTF_8` as the charset and accepts a boolean "append" instead of an `OpenOption` argument list.
      Throws:
        `java.io.IOException`

    - #### popState

          private GraphicsStyle popState()

      Pops the GraphicsStyle from the top of the stack and returns it.

    - #### pushState

          private GraphicsStyle pushState()

      Pushes a new GraphicsStyle (cloned from the current one) to the top of the stack and returns it.

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### write

          public void write(java.util.List<GraphicsOp> ops,
                            java.lang.String path)
                     throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### write

          public void write(java.util.List<GraphicsOp> ops,
                            java.io.Writer output)
                     throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### writeTo

          public void writeTo(javax.xml.transform.stream.StreamResult out)
                       throws java.io.IOException

      Throws:
        `java.io.IOException`