Class SVGSaveDialog


  • public final class SVGSaveDialog
    extends java.lang.Object
    A save dialog to save/export a SVG image to a file.

    Supported formats:

    • SVG
    • PNG (with width and height options)
    • JPEG (with width and height options, and if an ImageWrite is available)
    • PDF (if FOP transcoders are available)
    • PS (if FOP transcoders are available)
    • EPS (if FOP transcoders are available)
    Since:
    0.2
    Author:
    Simon Mittermüller
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) static java.lang.String AUTOMAGIC_FORMAT
      Automagic file format
      static java.lang.String DEFAULT_TITLE
      The default title.
      (package private) static java.lang.String[] FORMATS
      Supported file format (extensions)
      private static Logging LOG
      Static logger reference
      (package private) static java.lang.String[] VISIBLE_FORMATS
      Visible file formats
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private SVGSaveDialog()
      Private constructor.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String[] getFormats()  
      static java.lang.String[] getVisibleFormats()  
      static java.lang.String guessFormat​(java.lang.String name)
      Guess a supported format from the file name.
      private static void showError​(java.awt.Component parent, java.lang.String title, java.lang.String msg)
      Helper method to show a error message as "popup".
      static int showSaveDialog​(SVGPlot plot, int width, int height)
      Show a "Save as" dialog.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_TITLE

        public static final java.lang.String DEFAULT_TITLE
        The default title. "Save as ...".
        See Also:
        Constant Field Values
      • LOG

        private static final Logging LOG
        Static logger reference
      • AUTOMAGIC_FORMAT

        static final java.lang.String AUTOMAGIC_FORMAT
        Automagic file format
        See Also:
        Constant Field Values
      • FORMATS

        static final java.lang.String[] FORMATS
        Supported file format (extensions)
      • VISIBLE_FORMATS

        static final java.lang.String[] VISIBLE_FORMATS
        Visible file formats
    • Constructor Detail

      • SVGSaveDialog

        private SVGSaveDialog()
        Private constructor. Static methods only.
    • Method Detail

      • showSaveDialog

        public static int showSaveDialog​(SVGPlot plot,
                                         int width,
                                         int height)
        Show a "Save as" dialog.
        Parameters:
        plot - The plot to be exported.
        width - The width of the exported image (when export to JPEG/PNG).
        height - The height of the exported image (when export to JPEG/PNG).
        Returns:
        Result from JFileChooser.showSaveDialog(java.awt.Component)
      • guessFormat

        public static java.lang.String guessFormat​(java.lang.String name)
        Guess a supported format from the file name. For "auto" format handling.
        Parameters:
        name - File name
        Returns:
        format or "null"
      • getFormats

        public static java.lang.String[] getFormats()
        Returns:
        the formats
      • getVisibleFormats

        public static java.lang.String[] getVisibleFormats()
        Returns:
        the visibleformats
      • showError

        private static void showError​(java.awt.Component parent,
                                      java.lang.String title,
                                      java.lang.String msg)
        Helper method to show a error message as "popup". Calls JOptionPane.showMessageDialog(java.awt.Component, Object).
        Parameters:
        parent - The parent component for the popup.
        msg - The message to be displayed.