Home / Development / Documentation / 2.0.44 / SVGTranscodeWriter
TreeGraph 2

Class SVGTranscodeWriter

  extended by info.bioinfweb.treegraph.graphics.export.AbstractGraphicWriter
      extended by info.bioinfweb.treegraph.graphics.export.SVGTranscodeWriter
All Implemented Interfaces:
Direct Known Subclasses:
JPEGWriter, PDFWriter, PNGWriter, SVGWriter, TIFFWriter

public class SVGTranscodeWriter
extends AbstractGraphicWriter
implements GraphicWriter

This class generates an image file from a tree document. Therefor is first generates an SVG file and then transcodes it into the specified format (e.g. PNG or PDF).

Ben Stöver

Field Summary
private  Class<? extends org.apache.batik.transcoder.Transcoder> transcoderClass
Fields inherited from interface info.bioinfweb.treegraph.graphics.export.GraphicWriter
Constructor Summary
SVGTranscodeWriter(Class<? extends org.apache.batik.transcoder.Transcoder> transcoderClass)
Method Summary
protected  void addTranscodingHints(org.apache.batik.transcoder.Transcoder transcoder, GraphicWriterHints writerHints)
          This method can be overwritten to add more transcoding hints to the transcoder.
 void write(Document document, TreePainter painter, GraphicWriterHints hints, OutputStream stream)
          Writes the given document to the given stream in the graphic format provided by the transcoder-class specified in the constructor.
Methods inherited from class info.bioinfweb.treegraph.graphics.export.AbstractGraphicWriter
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface info.bioinfweb.treegraph.graphics.export.GraphicWriter

Field Detail


private Class<? extends org.apache.batik.transcoder.Transcoder> transcoderClass
Constructor Detail


public SVGTranscodeWriter(Class<? extends org.apache.batik.transcoder.Transcoder> transcoderClass)
Method Detail


protected void addTranscodingHints(org.apache.batik.transcoder.Transcoder transcoder,
                                   GraphicWriterHints writerHints)

This method can be overwritten to add more transcoding hints to the transcoder. This can e.g. be done by copying graphic writer hints to transcoding hints.

Note that KEY_PIXEL_UNIT_TO_MILLIMETER, KEY_WIDTH, KEY_HEIGHT and KEY_BACKGROUND_COLOR (the brackground color for formats which do not support transparency) have already been added.

transcoder - the transcoder that transcodes from SVG to the respective image format
writerHints - the hints that were specified when the write-method of this writer was called


public void write(Document document,
                  TreePainter painter,
                  GraphicWriterHints hints,
                  OutputStream stream)

Writes the given document to the given stream in the graphic format provided by the transcoder-class specified in the constructor.

The resolution the image is exportet with is taken from the hint-value for KEY_PIXELS_PER_MILLIMETER. Is this hint is not provided TreeViewPanel.PIXELS_PER_MM_100 is unsed instead.

The width and the height of the resulting image are taken from the hint-values for KEY_WIDTH and KEY_HEIGHT if both of them are specified. If this is not the case, width and height are calculated from the resolution (see above) and the size of the document. The width and height can be either defines in millimeters or in pixels. The unit can be specified with the key KEY_DIMENSIONS_IN_PIXELS. (false is used by default.)

The hint specified by KEY_TRANSPARENT is used to define the transparency of the image. (false if the default value if this hint is not given.)

Specified by:
write in interface GraphicWriter
document - the document to be exported
painter - the painter to display the document
hints - the graphic writer hints to specify certain writing options
stream - the output stream to write the graphic to
See Also:
GraphicWriter.write(info.bioinfweb.treegraph.document.Document, info.bioinfweb.treegraph.graphics.positionpaint.TreePainter, info.bioinfweb.treegraph.graphics.export.GraphicWriterHints, java.io.OutputStream)