List of usage examples for org.dom4j Element addElement
Element addElement(String name);
Element
node with the given name to this branch and returns a reference to the new node. From source file:com.jswiff.xml.RecordXMLWriter.java
License:Open Source License
private static void writeRGBArray(Element parentElement, RGB[] data) { Element element = parentElement.addElement("rgbarray"); short[] buffer = new short[data.length * 3]; for (int i = 0; i < data.length; i++) { RGB rgb = data[i];/*from w w w .ja v a 2 s. c om*/ buffer[i * 3] = rgb.getRed(); buffer[(i * 3) + 1] = rgb.getGreen(); buffer[(i * 3) + 2] = rgb.getBlue(); } element.addText(Base64.encodeUnsigned(buffer)); }
From source file:com.jswiff.xml.RecordXMLWriter.java
License:Open Source License
private static void writeSoundEnvelope(Element parentElement, SoundEnvelope soundEnvelope) { Element element = parentElement.addElement("soundenvelope"); element.addAttribute("pos44", Long.toString(soundEnvelope.getPos44())); element.addAttribute("leftlevel", Integer.toString(soundEnvelope.getLeftLevel())); element.addAttribute("rightlevel", Integer.toString(soundEnvelope.getRightLevel())); }
From source file:com.jswiff.xml.RecordXMLWriter.java
License:Open Source License
private static void writeStraightEdgeRecord(Element parentElement, StraightEdgeRecord straightEdgeRecord) { Element element = parentElement.addElement("straightedgerecord"); element.addAttribute("dx", Integer.toString(straightEdgeRecord.getDeltaX())); element.addAttribute("dy", Integer.toString(straightEdgeRecord.getDeltaY())); }
From source file:com.jswiff.xml.RecordXMLWriter.java
License:Open Source License
private static void writeStyleChangeRecord(Element parentElement, StyleChangeRecord styleChangeRecord) { Element element = parentElement.addElement("stylechangerecord"); if (styleChangeRecord.hasMoveTo()) { Element moveTo = element.addElement("moveto"); moveTo.addAttribute("x", Integer.toString(styleChangeRecord.getMoveToX())); moveTo.addAttribute("y", Integer.toString(styleChangeRecord.getMoveToY())); }/*from ww w . java 2 s. c o m*/ if (styleChangeRecord.hasLineStyle() || styleChangeRecord.hasFillStyle0() || styleChangeRecord.hasFillStyle1() || styleChangeRecord.hasNewStyles()) { Element styles = element.addElement("styles"); if (styleChangeRecord.hasLineStyle()) { styles.addAttribute("line", Integer.toString(styleChangeRecord.getLineStyle())); } if (styleChangeRecord.hasFillStyle0()) { styles.addAttribute("fill0", Integer.toString(styleChangeRecord.getFillStyle0())); } if (styleChangeRecord.hasFillStyle1()) { styles.addAttribute("fill1", Integer.toString(styleChangeRecord.getFillStyle1())); } if (styleChangeRecord.hasNewStyles()) { writeLineStyles(styles, styleChangeRecord.getNewLineStyles()); writeFillStyles(styles, styleChangeRecord.getNewFillStyles()); } } }
From source file:com.jswiff.xml.TagXMLWriter.java
License:Open Source License
private static void writeDefineBits(Element parentElement, DefineBits tag) { Element element = parentElement.addElement("definebits"); element.addAttribute("charid", Integer.toString(tag.getCharacterId())); element.addElement("jpegdata").addText(Base64.encode(tag.getJpegData())); }
From source file:com.jswiff.xml.TagXMLWriter.java
License:Open Source License
private static void writeDefineBitsJPEG2(Element parentElement, DefineBitsJPEG2 tag) { Element element = parentElement.addElement("definebitsjpeg2"); element.addAttribute("charid", Integer.toString(tag.getCharacterId())); element.addElement("jpegdata").addText(Base64.encode(tag.getJpegData())); }
From source file:com.jswiff.xml.TagXMLWriter.java
License:Open Source License
private static void writeDefineBitsJPEG3(Element parentElement, DefineBitsJPEG3 tag) { Element element = parentElement.addElement("definebitsjpeg3"); element.addAttribute("charid", Integer.toString(tag.getCharacterId())); element.addElement("jpegdata").addText(Base64.encode(tag.getJpegData())); element.addElement("alphadata").addText(Base64.encode(tag.getBitmapAlphaData())); }
From source file:com.jswiff.xml.TagXMLWriter.java
License:Open Source License
private static void writeDefineBitsLossless(Element parentElement, DefineBitsLossless tag) { Element element = parentElement.addElement("definebitslossless"); element.addAttribute("charid", Integer.toString(tag.getCharacterId())); String format;/*from w ww. j a v a2 s .c o m*/ switch (tag.getFormat()) { case DefineBitsLossless.FORMAT_8_BIT_COLORMAPPED: format = "8bit"; break; case DefineBitsLossless.FORMAT_15_BIT_RGB: format = "15bit"; break; case DefineBitsLossless.FORMAT_24_BIT_RGB: format = "24bit"; break; default: throw new IllegalArgumentException("Illegal lossless bitmap format: " + tag.getFormat()); } element.addAttribute("format", format); element.addAttribute("width", Integer.toString(tag.getWidth())); element.addAttribute("height", Integer.toString(tag.getHeight())); RecordXMLWriter.writeZlibBitmapData(element, tag.getZlibBitmapData()); }
From source file:com.jswiff.xml.TagXMLWriter.java
License:Open Source License
private static void writeDefineBitsLossless2(Element parentElement, DefineBitsLossless2 tag) { Element element = parentElement.addElement("definebitslossless2"); element.addAttribute("charid", Integer.toString(tag.getCharacterId())); String format;/*from w ww . j av a 2 s . com*/ switch (tag.getFormat()) { case DefineBitsLossless2.FORMAT_8_BIT_COLORMAPPED: format = "8bit"; break; case DefineBitsLossless2.FORMAT_32_BIT_RGBA: format = "32bit"; break; default: throw new IllegalArgumentException("Illegal lossless bitmap format: " + tag.getFormat()); } element.addAttribute("format", format); element.addAttribute("width", Integer.toString(tag.getWidth())); element.addAttribute("height", Integer.toString(tag.getHeight())); RecordXMLWriter.writeZlibBitmapData(element, tag.getZlibBitmapData()); }
From source file:com.jswiff.xml.TagXMLWriter.java
License:Open Source License
private static void writeDefineButton(Element parentElement, DefineButton tag) { Element element = parentElement.addElement("definebutton"); element.addAttribute("charid", Integer.toString(tag.getCharacterId())); Element charsElement = element.addElement("chars"); ButtonRecord[] characters = tag.getCharacters(); for (int i = 0; i < characters.length; i++) { RecordXMLWriter.writeButtonRecord(charsElement, characters[i]); }/* w w w.j a v a 2s . c o m*/ RecordXMLWriter.writeActionBlock(element, tag.getActions()); }