info.bioinfweb.treegraph.document.io.xtg
Class XTGWriter

java.lang.Object
  extended by info.bioinfweb.treegraph.document.io.AbstractDocumentWriter
      extended by info.bioinfweb.treegraph.document.io.xtg.XTGWriter
All Implemented Interfaces:
DocumentWriter, XTGConstants

public class XTGWriter
extends AbstractDocumentWriter
implements XTGConstants, DocumentWriter


Field Summary
static java.lang.String STREAM_ENCODING
           
private  javax.xml.stream.XMLStreamWriter writer
           
static java.lang.String XML_ENCODING
           
static java.lang.String XML_VERSION
           
 
Fields inherited from class info.bioinfweb.treegraph.document.io.AbstractDocumentWriter
DEFAULT_ADAPTER, document
 
Fields inherited from interface info.bioinfweb.treegraph.document.io.xtg.XTGConstants
ALIGN_LEFT, ALIGN_RIGHT, ALIGN_TREE_WIDTH, ATTR_ALIGN_TO_SUBTREE, ATTR_BG_COLOR, ATTR_BOTTOM, ATTR_BRANCH_LENGTH, ATTR_BRANCH_LENGTH_SCALE, ATTR_CONSTANT_WIDTH, ATTR_DECIMAL_FORMAT, ATTR_EDGE_RADIUS, ATTR_FONT_FAMILY, ATTR_HEIGHT, ATTR_ICON, ATTR_ICON_FILLED, ATTR_ICON_HEIGHT, ATTR_ICON_WIDTH, ATTR_ID, ATTR_LABEL_ABOVE, ATTR_LABEL_SPACING, ATTR_LEFT, ATTR_LEGEND_POS, ATTR_LEGEND_SPACING, ATTR_LEGEND_STYLE, ATTR_LINE_COLOR, ATTR_LINE_NO, ATTR_LINE_POS, ATTR_LINE_WIDTH, ATTR_LOCALE_COUNTRY, ATTR_LOCALE_LANG, ATTR_LOCALE_VARIANT, ATTR_LONG_INTERVAL, ATTR_MIN_BRANCH_LENGTH, ATTR_MIN_SPACE_ABOVE, ATTR_MIN_SPACE_BELOW, ATTR_MIN_TREE_DISTANCE, ATTR_POSITION_LABELS_TO_LEFT, ATTR_RIGHT, ATTR_SCALE_BAR_ALIGN, ATTR_SCALE_BAR_DISTANCE, ATTR_SCALE_BAR_HEIGHT, ATTR_SCALE_BAR_INCREASE, ATTR_SCALE_BAR_START, ATTR_SCALE_BAR_WIDTH, ATTR_SHOW_ROOTED, ATTR_SHOW_SCALE_BAR, ATTR_SMALL_INTERVAL, ATTR_TEXT, ATTR_TEXT_COLOR, ATTR_TEXT_HEIGHT, ATTR_TEXT_IS_DECIMAL, ATTR_TEXT_ORIENTATION, ATTR_TEXT_STYLE, ATTR_TOP, ATTR_UNIQUE_NAME, ATTR_WIDTH, BRANCH_LENGTH_UNITS, MILLIMETERS, ORIENT_DOWN, ORIENT_HORIZONTAL, ORIENT_UP, PRE_LEGEND_ANCHOR, STYLE_BOLD, STYLE_BRACE, STYLE_BRACKET, STYLE_ITALIC, STYLE_UNDERLINE, TAG_BRANCH, TAG_DOC_MARGIN, TAG_GLOBAL_FORMATS, TAG_HIDDEN_DATA, TAG_ICON_LABEL, TAG_LABEL_MARGIN, TAG_LEAF_MARGIN, TAG_LEGEND, TAG_LEGEND_MARGIN, TAG_NODE, TAG_ROOT, TAG_SCALE_BAR, TAG_TEXT_LABEL, TAG_TREE
 
Constructor Summary
XTGWriter()
           
 
Method Summary
private  java.lang.String formatColor(java.awt.Color color)
           
private  java.lang.String formatColorByte(int value)
           
private  java.lang.String formatTextStyle(TextFormats f)
           
 void write(Document document, java.io.OutputStream stream)
           
 void write(Document document, java.io.OutputStream stream, NodeBranchDataAdapter internalAdapter, NodeBranchDataAdapter leafAdapter, NodeBranchDataAdapter branchLengthAdapter)
          A call of this method is identical with calling write(info.bioinfweb.treegraph.document.Document, java.io.OutputStream) becuase the tgx format supports writing any number of labels by default and there is no need to replace internal node names by label values.
private  void writeAnchor(LegendFormats f, int no)
           
private  void writeDistanceDimension(java.lang.String name, DistanceDimension d)
           
private  void writeGlobalFormats(GlobalFormats f)
           
private  void writeHiddenDataMap(HiddenDataMap m)
           
private  void writeLabelBlock(Labels labels, boolean above)
           
private  void writeLegends(Legends legends)
           
private  void writeLineAttr(LineFormats f)
           
private  void writeMargin(java.lang.String name, Margin m)
           
private  void writeScaleBar(ScaleBar sb)
           
private  void writeScaleValue(java.lang.String name, ScaleValue v)
           
private  void writeSubtree(Node root)
           
private  void writeTextElementData(TextElementData data)
           
private  void writeTextFormatsAttr(TextFormats f)
           
private  void writeTextFormatsAttr(TextFormats f, java.lang.String prefix)
           
 
Methods inherited from class info.bioinfweb.treegraph.document.io.AbstractDocumentWriter
write, write
 
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.document.io.DocumentWriter
write, write
 

Field Detail

STREAM_ENCODING

public static final java.lang.String STREAM_ENCODING
See Also:
Constant Field Values

XML_VERSION

public static java.lang.String XML_VERSION

XML_ENCODING

public static java.lang.String XML_ENCODING

writer

private javax.xml.stream.XMLStreamWriter writer
Constructor Detail

XTGWriter

public XTGWriter()
Method Detail

formatColorByte

private java.lang.String formatColorByte(int value)

formatColor

private java.lang.String formatColor(java.awt.Color color)

formatTextStyle

private java.lang.String formatTextStyle(TextFormats f)

writeTextElementData

private void writeTextElementData(TextElementData data)
                           throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

writeDistanceDimension

private void writeDistanceDimension(java.lang.String name,
                                    DistanceDimension d)
                             throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

writeMargin

private void writeMargin(java.lang.String name,
                         Margin m)
                  throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

writeGlobalFormats

private void writeGlobalFormats(GlobalFormats f)
                         throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

writeTextFormatsAttr

private void writeTextFormatsAttr(TextFormats f)
                           throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

writeTextFormatsAttr

private void writeTextFormatsAttr(TextFormats f,
                                  java.lang.String prefix)
                           throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

writeLineAttr

private void writeLineAttr(LineFormats f)
                    throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

writeLabelBlock

private void writeLabelBlock(Labels labels,
                             boolean above)
                      throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

writeHiddenDataMap

private void writeHiddenDataMap(HiddenDataMap m)
                         throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

writeSubtree

private void writeSubtree(Node root)
                   throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

writeScaleValue

private void writeScaleValue(java.lang.String name,
                             ScaleValue v)
                      throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

writeScaleBar

private void writeScaleBar(ScaleBar sb)
                    throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

writeAnchor

private void writeAnchor(LegendFormats f,
                         int no)
                  throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

writeLegends

private void writeLegends(Legends legends)
                   throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

write

public void write(Document document,
                  java.io.OutputStream stream)
           throws java.lang.Exception
Specified by:
write in interface DocumentWriter
Throws:
java.lang.Exception

write

public void write(Document document,
                  java.io.OutputStream stream,
                  NodeBranchDataAdapter internalAdapter,
                  NodeBranchDataAdapter leafAdapter,
                  NodeBranchDataAdapter branchLengthAdapter)
           throws java.lang.Exception
A call of this method is identical with calling write(info.bioinfweb.treegraph.document.Document, java.io.OutputStream) becuase the tgx format supports writing any number of labels by default and there is no need to replace internal node names by label values.

Specified by:
write in interface DocumentWriter
Throws:
java.lang.Exception
See Also:
info.bioinfweb.treegraph.document.io.DocumentWriter#write(info.bioinfweb.treegraph.document.Document, java.io.OutputStream, NodeBranchDataAdapter, NodeBranchDataAdapter)