Example usage for org.dom4j Element addElement

List of usage examples for org.dom4j Element addElement

Introduction

In this page you can find the example usage for org.dom4j Element addElement.

Prototype

Element addElement(String name);

Source Link

Document

Adds a new Element node with the given name to this branch and returns a reference to the new node.

Usage

From source file:com.jswiff.xml.TagXMLWriter.java

License:Open Source License

private static void writeDefineMorphShape(Element parentElement, DefineMorphShape tag) {
    Element element = parentElement.addElement("definemorphshape");
    element.addAttribute("charid", Integer.toString(tag.getCharacterId()));
    Shape startShape = tag.getStartShape();
    Shape endShape = tag.getEndShape();
    MorphLineStyles morphLineStyles = tag.getMorphLineStyles();
    MorphFillStyles morphFillStyles = tag.getMorphFillStyles();
    boolean zeroOffset = ((startShape == null) || (endShape == null) || (morphLineStyles == null)
            || (morphFillStyles == null));
    Element startElement = element.addElement("start");
    RecordXMLWriter.writeRect(startElement, "bounds", tag.getStartBounds());
    Element endElement = element.addElement("end");
    RecordXMLWriter.writeRect(endElement, "bounds", tag.getEndBounds());
    if (!zeroOffset) {
        RecordXMLWriter.writeShape(startElement, startShape);
        RecordXMLWriter.writeShape(endElement, endShape);
        RecordXMLWriter.writeMorphLineStyles(element, morphLineStyles);
        RecordXMLWriter.writeMorphFillStyles(element, morphFillStyles);
    }/*w ww . jav  a2s . com*/
}

From source file:com.jswiff.xml.TagXMLWriter.java

License:Open Source License

private static void writeDefineMorphShape2(Element parentElement, DefineMorphShape2 tag) {
    Element element = parentElement.addElement("definemorphshape2");
    element.addAttribute("charid", Integer.toString(tag.getCharacterId()));
    Shape startShape = tag.getStartShape();
    Shape endShape = tag.getEndShape();
    MorphLineStyles morphLineStyles = tag.getMorphLineStyles();
    MorphFillStyles morphFillStyles = tag.getMorphFillStyles();
    boolean zeroOffset = ((startShape == null) || (endShape == null) || (morphLineStyles == null)
            || (morphFillStyles == null));
    Element startElement = element.addElement("start");
    RecordXMLWriter.writeRect(startElement, "shapebounds", tag.getStartShapeBounds());
    RecordXMLWriter.writeRect(startElement, "edgebounds", tag.getStartEdgeBounds());
    Element endElement = element.addElement("end");
    RecordXMLWriter.writeRect(endElement, "shapebounds", tag.getEndShapeBounds());
    RecordXMLWriter.writeRect(endElement, "edgebounds", tag.getEndEdgeBounds());
    if (!zeroOffset) {
        RecordXMLWriter.writeShape(startElement, startShape);
        RecordXMLWriter.writeShape(endElement, endShape);
        RecordXMLWriter.writeMorphLineStyles(element, morphLineStyles);
        RecordXMLWriter.writeMorphFillStyles(element, morphFillStyles);
    }//from  www.  j a  v a  2  s  .c  o m
}

From source file:com.jswiff.xml.TagXMLWriter.java

License:Open Source License

private static void writeDefineShape(Element parentElement, DefineShape tag) {
    Element element = parentElement.addElement("defineshape");
    element.addAttribute("charid", Integer.toString(tag.getCharacterId()));
    RecordXMLWriter.writeRect(element, "bounds", tag.getShapeBounds());
    RecordXMLWriter.writeShapeWithStyle(element, tag.getShapes());
}

From source file:com.jswiff.xml.TagXMLWriter.java

License:Open Source License

private static void writeDefineShape2(Element parentElement, DefineShape2 tag) {
    Element element = parentElement.addElement("defineshape2");
    element.addAttribute("charid", Integer.toString(tag.getCharacterId()));
    RecordXMLWriter.writeRect(element, "bounds", tag.getShapeBounds());
    RecordXMLWriter.writeShapeWithStyle(element, tag.getShapes());
}

From source file:com.jswiff.xml.TagXMLWriter.java

License:Open Source License

private static void writeDefineShape3(Element parentElement, DefineShape3 tag) {
    Element element = parentElement.addElement("defineshape3");
    element.addAttribute("charid", Integer.toString(tag.getCharacterId()));
    RecordXMLWriter.writeRect(element, "bounds", tag.getShapeBounds());
    RecordXMLWriter.writeShapeWithStyle(element, tag.getShapes());
}

From source file:com.jswiff.xml.TagXMLWriter.java

License:Open Source License

private static void writeDefineShape4(Element parentElement, DefineShape4 tag) {
    Element element = parentElement.addElement("defineshape4");
    element.addAttribute("charid", Integer.toString(tag.getCharacterId()));
    RecordXMLWriter.writeRect(element, "shapebounds", tag.getShapeBounds());
    RecordXMLWriter.writeRect(element, "edgebounds", tag.getEdgeBounds());
    RecordXMLWriter.writeShapeWithStyle(element, tag.getShapes());
}

From source file:com.jswiff.xml.TagXMLWriter.java

License:Open Source License

private static void writeDefineSound(Element parentElement, DefineSound tag) {
    Element element = parentElement.addElement("definesound");
    element.addAttribute("charid", Integer.toString(tag.getCharacterId()));
    element.addAttribute("format", getSoundFormatString(tag.getFormat()));
    element.addAttribute("rate", getSoundRateString(tag.getRate()));
    if (tag.is16BitSample()) {
        element.addAttribute("sample16bit", "true");
    }//from   w w w  .  j a v  a2  s .  c o  m
    if (tag.isStereo()) {
        element.addAttribute("stereo", "true");
    }
    element.addAttribute("samplecount", Long.toString(tag.getSampleCount()));
    element.addText(Base64.encode(tag.getSoundData()));
}

From source file:com.jswiff.xml.TagXMLWriter.java

License:Open Source License

private static void writeDefineSprite(Element parentElement, DefineSprite tag) {
    Element element = parentElement.addElement("definesprite");
    element.addAttribute("charid", Integer.toString(tag.getCharacterId()));
    for (Iterator it = tag.getControlTags().iterator(); it.hasNext();) {
        Tag controlTag = (Tag) it.next();
        writeTag(element, controlTag);/*from  ww  w.  ja  v a 2 s.  c  o  m*/
    }
}

From source file:com.jswiff.xml.TagXMLWriter.java

License:Open Source License

private static void writeDefineText(Element parentElement, DefineText tag) {
    Element element = parentElement.addElement("definetext");
    element.addAttribute("charid", Integer.toString(tag.getCharacterId()));
    RecordXMLWriter.writeRect(element, "bounds", tag.getTextBounds());
    RecordXMLWriter.writeMatrix(element, "matrix", tag.getTextMatrix());
    Element textRecordsElement = element.addElement("textrecords");
    TextRecord[] textRecords = tag.getTextRecords();
    for (int i = 0; i < textRecords.length; i++) {
        RecordXMLWriter.writeTextRecord(textRecordsElement, textRecords[i]);
    }/*w  w w  .  j  a v  a  2 s.co m*/
}

From source file:com.jswiff.xml.TagXMLWriter.java

License:Open Source License

private static void writeDefineText2(Element parentElement, DefineText2 tag) {
    Element element = parentElement.addElement("definetext2");
    element.addAttribute("charid", Integer.toString(tag.getCharacterId()));
    RecordXMLWriter.writeRect(element, "bounds", tag.getTextBounds());
    RecordXMLWriter.writeMatrix(element, "matrix", tag.getTextMatrix());
    Element textRecordsElement = element.addElement("textrecords");
    TextRecord[] textRecords = tag.getTextRecords();
    for (int i = 0; i < textRecords.length; i++) {
        RecordXMLWriter.writeTextRecord(textRecordsElement, textRecords[i]);
    }/*from w w w  .j  a v  a2s. co m*/
}