uk.ac.starlink.ttools.plot
Class GraphicExporter

java.lang.Object
  extended by uk.ac.starlink.ttools.plot.GraphicExporter

public abstract class GraphicExporter
extends Object

Exports a graphical component to a graphics file.

Since:
1 Aug 2008
Author:
Mark Taylor

Field Summary
static GraphicExporter EPS
          Exports to Encapsulated PostScript.
static GraphicExporter EPS_GZIP
          Exports to gzipped Encapsulated PostScript.
static GraphicExporter GIF
          Exports to GIF format.
static GraphicExporter JPEG
          Exports to JPEG format.
static GraphicExporter PNG
          Exports to PNG format.
 
Constructor Summary
protected GraphicExporter(String name, String mimeType, String[] fileSuffixes)
          Constructor.
 
Method Summary
abstract  void exportGraphic(JComponent comp, OutputStream out)
          Exports the graphic content of a given component to an output stream using some graphics format or other.
 String getContentEncoding()
          Returns the content encoding for the output used by this exporter.
 String[] getFileSuffixes()
          Returns an array of file suffixes which usually indicate a file with an export format used by this instance.
 String getMimeType()
          Returns the MIME type for the graphics format used by this exporter.
 String getName()
          Returns the name of this exporter (usually the graphics format name).
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

JPEG

public static final GraphicExporter JPEG
Exports to JPEG format.


PNG

public static final GraphicExporter PNG
Exports to PNG format.


GIF

public static final GraphicExporter GIF
Exports to GIF format.

There's something wrong with this - it ought to produce a transparent background, but it doesn't. I'm not sure why, or even whether it's to do with the plot or the encoder.


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(String name,
                          String mimeType,
                          String[] fileSuffixes)
Constructor.

Parameters:
name - exporter name (usually graphics format name)
mimeType - MIME type for this exporter's output format
fileSuffixes - file suffixes which usually indicate the export format used by this instance (may be null)
Method Detail

exportGraphic

public abstract void exportGraphic(JComponent comp,
                                   OutputStream out)
                            throws IOException
Exports the graphic content of a given component to an output stream using some graphics format or other. The output stream should not be closed following the write.

Parameters:
comp - component to draw
out - destination output stream
Throws:
IOException

getName

public String getName()
Returns the name of this exporter (usually the graphics format name).

Returns:
exporter name

getMimeType

public String getMimeType()
Returns the MIME type for the graphics format used by this exporter.

Returns:
MIME type string

getContentEncoding

public 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 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 String toString()
Overrides:
toString in class Object


Copyright © 2009 Central Laboratory of the Research Councils. All Rights Reserved.