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.RecordXMLWriter.java

License:Open Source License

static void writeShape(Element parentElement, Shape shape) {
    Element element = parentElement.addElement("shape");
    ShapeRecord[] records = shape.getShapeRecords();
    for (int i = 0; i < records.length; i++) {
        writeShapeRecord(element, records[i]);
    }//from   w  w w . j av  a 2  s.c o m
}

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

License:Open Source License

static void writeShapeWithStyle(Element parentElement, ShapeWithStyle shapeWithStyle) {
    Element element = parentElement.addElement("shapewithstyle");
    Element shapeElement = element.addElement("shape");
    ShapeRecord[] records = shapeWithStyle.getShapeRecords();
    for (int i = 0; i < records.length; i++) {
        writeShapeRecord(shapeElement, records[i]);
    }/*w  ww  . j ava2 s . co m*/
    writeLineStyles(element, shapeWithStyle.getLineStyles());
    writeFillStyles(element, shapeWithStyle.getFillStyles());
}

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

License:Open Source License

static void writeSoundInfo(Element parentElement, SoundInfo soundInfo) {
    Element element = parentElement.addElement("soundinfo");
    if (soundInfo.isSyncStop()) {
        element.addAttribute("syncstop", "true");
    }//from   www.  j  a v a 2  s .  c  o m
    if (soundInfo.isSyncNoMultiple()) {
        element.addAttribute("syncnomultiple", "true");
    }
    if (soundInfo.hasLoops()) {
        element.addAttribute("loopcount", Integer.toString(soundInfo.getLoopCount()));
    }
    if (soundInfo.hasInPoint()) {
        element.addAttribute("inpoint", Long.toString(soundInfo.getInPoint()));
    }
    if (soundInfo.hasOutPoint()) {
        element.addAttribute("outpoint", Long.toString(soundInfo.getOutPoint()));
    }
    if (soundInfo.hasEnvelope()) {
        Element recordsElement = element.addElement("enveloperecords");
        SoundEnvelope[] records = soundInfo.getEnvelopeRecords();
        for (int i = 0; i < records.length; i++) {
            RecordXMLWriter.writeSoundEnvelope(recordsElement, records[i]);
        }
    }
}

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

License:Open Source License

static void writeTextRecord(Element parentElement, TextRecord record) {
    Element element = parentElement.addElement("textrecord");
    if (record.hasFont()) {
        element.addAttribute("fontid", Integer.toString(record.getFontId()));
        element.addAttribute("height", Integer.toString(record.getTextHeight()));
    }/*w w  w  .j  av a  2  s  .c  om*/
    if (record.hasXOffset()) {
        element.addAttribute("xoffset", Short.toString(record.getXOffset()));
    }
    if (record.hasYOffset()) {
        element.addAttribute("yoffset", Short.toString(record.getYOffset()));
    }
    if (record.hasColor()) {
        writeColor(element, "color", record.getTextColor());
    }
    GlyphEntry[] glyphEntries = record.getGlyphEntries();
    Element glyphEntriesElement = element.addElement("glyphentries");
    for (int i = 0; i < glyphEntries.length; i++) {
        GlyphEntry glyphEntry = glyphEntries[i];
        Element glyphEntryElement = glyphEntriesElement.addElement("glyphentry");
        glyphEntryElement.addAttribute("index", Integer.toString(glyphEntry.getGlyphIndex()));
        glyphEntryElement.addAttribute("advance", Integer.toString(glyphEntry.getGlyphAdvance()));
    }
}

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

License:Open Source License

private static void writeAlphaBitmapData(Element parentElement, AlphaBitmapData data) {
    Element element = parentElement.addElement("alphabitmapdata");
    RGBA[] pixelData = data.getBitmapPixelData();
    writeRGBAArray(element, pixelData);/*from w  ww.ja v  a  2  s.  c  o m*/
}

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

License:Open Source License

private static void writeAlphaColorMapData(Element parentElement, AlphaColorMapData data) {
    Element element = parentElement.addElement("alphacolormapdata");
    Element colorTableElement = element.addElement("colortable");
    RGBA[] colorTable = data.getColorTableRGBA();
    writeRGBAArray(colorTableElement, colorTable);
    Element pixelDataElement = element.addElement("pixeldata");
    short[] pixelData = data.getColorMapPixelData();
    pixelDataElement.addText(Base64.encodeUnsigned(pixelData));
}

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

License:Open Source License

private static void writeBitmapData(Element parentElement, BitmapData data) {
    Element element = parentElement.addElement("bitmapdata");
    BitmapPixelData[] pixelData = data.getBitmapPixelData();
    if (pixelData[0] instanceof Pix15) { // array is homogeneous
        writePix15Array(element, (Pix15[]) pixelData);
    } else {/*from  ww  w  .  j av a 2  s.  co  m*/
        writePix24Array(element, (Pix24[]) pixelData);
    }
}

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

License:Open Source License

private static void writeClipEventFlags(Element parentElement, ClipEventFlags flags) {
    Element element = parentElement.addElement("clipeventflags");
    if (flags.isKeyUp()) {
        element.addAttribute("keyup", "true");
    }/*from w  w  w.j av  a2 s .c o m*/
    if (flags.isKeyDown()) {
        element.addAttribute("keydown", "true");
    }
    if (flags.isKeyPress()) {
        element.addAttribute("keypress", "true");
    }
    if (flags.isMouseUp()) {
        element.addAttribute("mouseup", "true");
    }
    if (flags.isMouseDown()) {
        element.addAttribute("mousedown", "true");
    }
    if (flags.isMouseMove()) {
        element.addAttribute("mousemove", "true");
    }
    if (flags.isLoad()) {
        element.addAttribute("load", "true");
    }
    if (flags.isUnload()) {
        element.addAttribute("unload", "true");
    }
    if (flags.isEnterFrame()) {
        element.addAttribute("enterframe", "true");
    }
    if (flags.isDragOver()) {
        element.addAttribute("dragover", "true");
    }
    if (flags.isDragOut()) {
        element.addAttribute("dragout", "true");
    }
    if (flags.isRollOver()) {
        element.addAttribute("rollover", "true");
    }
    if (flags.isRollOut()) {
        element.addAttribute("rollout", "true");
    }
    if (flags.isReleaseOutside()) {
        element.addAttribute("releaseoutside", "true");
    }
    if (flags.isRelease()) {
        element.addAttribute("release", "true");
    }
    if (flags.isPress()) {
        element.addAttribute("press", "true");
    }
    if (flags.isInitialize()) {
        element.addAttribute("initialize", "true");
    }
    if (flags.isData()) {
        element.addAttribute("data", "true");
    }
    if (flags.isConstruct()) {
        element.addAttribute("construct", "true");
    }
}

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

License:Open Source License

private static void writeColorMapData(Element parentElement, ColorMapData data) {
    Element element = parentElement.addElement("colormapdata");
    Element colorTableElement = element.addElement("colortable");
    RGB[] colorTable = data.getColorTableRGB();
    writeRGBArray(colorTableElement, colorTable);
    Element pixelDataElement = element.addElement("pixeldata");
    short[] pixelData = data.getColorMapPixelData();
    pixelDataElement.addText(Base64.encodeUnsigned(pixelData));
}

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

License:Open Source License

private static void writeCurvedEdgeRecord(Element parentElement, CurvedEdgeRecord curvedEdgeRecord) {
    Element element = parentElement.addElement("curvededgerecord");
    element.addAttribute("anchordx", Integer.toString(curvedEdgeRecord.getAnchorDeltaX()));
    element.addAttribute("anchordy", Integer.toString(curvedEdgeRecord.getAnchorDeltaY()));
    element.addAttribute("controldx", Integer.toString(curvedEdgeRecord.getControlDeltaX()));
    element.addAttribute("controldy", Integer.toString(curvedEdgeRecord.getControlDeltaY()));
}