Class GraphicExporter

  • Direct Known Subclasses:
    PdfGraphicExporter

    public abstract class GraphicExporter
    extends java.lang.Object
    Exports painted graphics to an output file in some graphics format.
    Since:
    1 Aug 2008
    Author:
    Mark Taylor
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected GraphicExporter​(java.lang.String name, java.lang.String mimeType, boolean isVector, java.lang.String description, java.lang.String[] fileSuffixes)
      Constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract void exportGraphic​(Picture picture, java.io.OutputStream out)
      Paints the given picture to an output stream using some graphics format or other.
      java.lang.String getContentEncoding()
      Returns the content encoding for the output used by this exporter.
      java.lang.String getDescription()
      Returns a minimal description of this exporter.
      java.lang.String[] getFileSuffixes()
      Returns an array of file suffixes which usually indicate a file with an export format used by this instance.
      static GraphicExporter[] getKnownExporters​(PdfGraphicExporter pdfEx)
      Returns a standard list of available GraphicExporter objects.
      java.lang.String getMimeType()
      Returns the MIME type for the graphics format used by this exporter.
      java.lang.String getName()
      Returns the name of this exporter (usually the graphics format name).
      boolean isVector()
      Indicates whether this exports to a vector or bitmapped graphics format.
      static Picture toPicture​(javax.swing.JComponent comp)
      Utility method to acquire a Picture object which can paint the content of a screen component.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • PNG

        public static final GraphicExporter PNG
        Exports to PNG format with a standard (currently opaque) background.
      • PNG_TRANSPARENT

        public static final GraphicExporter PNG_TRANSPARENT
        Exports to PNG format with a transparent background.
      • EPS

        public static final GraphicExporter EPS
        Exports to Encapsulated PostScript.
      • EPS_GZIP

        public static final GraphicExporter EPS_GZIP
        Exports to gzipped Encapsulated PostScript.
    • Constructor Detail

      • GraphicExporter

        protected GraphicExporter​(java.lang.String name,
                                  java.lang.String mimeType,
                                  boolean isVector,
                                  java.lang.String description,
                                  java.lang.String[] fileSuffixes)
        Constructor.
        Parameters:
        name - exporter name (usually graphics format name)
        mimeType - MIME type for this exporter's output format
        isVector - true for vector formats, false for bitmapped
        description - minimal description of format (may just be name)
        fileSuffixes - file suffixes which usually indicate the export format used by this instance (may be null)
    • Method Detail

      • exportGraphic

        public abstract void exportGraphic​(Picture picture,
                                           java.io.OutputStream out)
                                    throws java.io.IOException
        Paints the given picture to an output stream using some graphics format or other. This method should not close the stream.
        Parameters:
        picture - picture to draw
        out - destination output stream
        Throws:
        java.io.IOException
      • getName

        public java.lang.String getName()
        Returns the name of this exporter (usually the graphics format name).
        Returns:
        exporter name
      • getMimeType

        public java.lang.String getMimeType()
        Returns the MIME type for the graphics format used by this exporter.
        Returns:
        MIME type string
      • isVector

        public boolean isVector()
        Indicates whether this exports to a vector or bitmapped graphics format.
        Returns:
        true for vector graphics, false for bitmapped
      • getDescription

        public java.lang.String getDescription()
        Returns a minimal description of this exporter. This may just be the format's name if there's nothing else to say.
        Returns:
        description
      • getContentEncoding

        public java.lang.String getContentEncoding()
        Returns the content encoding for the output used by this exporter. The default implementation returns null, meaning no special encoding.
        Returns:
        content encoding
      • getFileSuffixes

        public java.lang.String[] getFileSuffixes()
        Returns an array of file suffixes which usually indicate a file with an export format used by this instance.
        Returns:
        copy of file suffix list; may be empty but will not be null
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • toPicture

        public static Picture toPicture​(javax.swing.JComponent comp)
        Utility method to acquire a Picture object which can paint the content of a screen component. The component should not be altered while the picture is in use.
        Parameters:
        comp - screen component
        Returns:
        object to draw comp's content
      • getKnownExporters

        public static GraphicExporter[] getKnownExporters​(PdfGraphicExporter pdfEx)
        Returns a standard list of available GraphicExporter objects. However, the one for exporting PDFs must be supplied explicitly, since which to choose (if any) depends on configuration.
        Parameters:
        pdfEx - exporter for PDF graphics, or null if none required
        Returns:
        list of available exporters including the supplied PDF one