List of usage examples for org.dom4j Element addAttribute
Element addAttribute(QName qName, String value);
From source file:com.jswiff.xml.RecordXMLWriter.java
License:Open Source License
private static void writeMorphFillStyle(Element parentElement, MorphFillStyle fillStyle) { Element fillStyleElement = parentElement.addElement("morphfillstyle"); Element start = fillStyleElement.addElement("start"); Element end = fillStyleElement.addElement("end"); boolean isGradient = false; boolean isFocal = false; boolean isBitmap = false; switch (fillStyle.getType()) { case FillStyle.TYPE_SOLID: fillStyleElement.addAttribute("type", "solid"); writeRGBA(start, "color", fillStyle.getStartColor()); writeRGBA(end, "color", fillStyle.getEndColor()); break;/*from w ww .j a v a2s. c o m*/ case FillStyle.TYPE_LINEAR_GRADIENT: fillStyleElement.addAttribute("type", "lineargradient"); isGradient = true; break; case FillStyle.TYPE_FOCAL_RADIAL_GRADIENT: fillStyleElement.addAttribute("type", "focalradialgradient"); isGradient = true; isFocal = true; break; case FillStyle.TYPE_RADIAL_GRADIENT: fillStyleElement.addAttribute("type", "radialgradient"); isGradient = true; break; case FillStyle.TYPE_TILED_BITMAP: fillStyleElement.addAttribute("type", "tiledbitmap"); isBitmap = true; break; case FillStyle.TYPE_CLIPPED_BITMAP: fillStyleElement.addAttribute("type", "clippedbitmap"); isBitmap = true; break; case FillStyle.TYPE_NONSMOOTHED_TILED_BITMAP: fillStyleElement.addAttribute("type", "nonsmoothedtiledbitmap"); isBitmap = true; break; case FillStyle.TYPE_NONSMOOTHED_CLIPPED_BITMAP: fillStyleElement.addAttribute("type", "nonsmoothedclippedbitmap"); isBitmap = true; break; default: throw new IllegalArgumentException("Illegal morph fill type: " + fillStyle.getType()); } if (isGradient) { if (isFocal) { writeFocalMorphGradient(fillStyleElement.addElement("focalmorphgradient"), (FocalMorphGradient) fillStyle.getGradient()); } else { writeMorphGradient(fillStyleElement.addElement("morphgradient"), fillStyle.getGradient()); } writeMatrix(start, "gradientmatrix", fillStyle.getStartGradientMatrix()); writeMatrix(end, "gradientmatrix", fillStyle.getEndGradientMatrix()); } else if (isBitmap) { fillStyleElement.addAttribute("bitmapid", Integer.toString(fillStyle.getBitmapId())); writeMatrix(start, "bitmapmatrix", fillStyle.getStartBitmapMatrix()); writeMatrix(end, "bitmapmatrix", fillStyle.getEndBitmapMatrix()); } }
From source file:com.jswiff.xml.RecordXMLWriter.java
License:Open Source License
private static void writeMorphGradient(Element gradientElement, MorphGradient gradient) { switch (gradient.getInterpolationMethod()) { case Gradient.INTERPOLATION_LINEAR_RGB: gradientElement.addAttribute("interpolation", "linear-rgb"); break;/*from w ww .j ava 2 s. c o m*/ case Gradient.INTERPOLATION_RGB: gradientElement.addAttribute("interpolation", "rgb"); break; } switch (gradient.getSpreadMethod()) { case Gradient.SPREAD_PAD: gradientElement.addAttribute("spread", "pad"); break; case Gradient.SPREAD_REFLECT: gradientElement.addAttribute("spread", "reflect"); break; case Gradient.SPREAD_REPEAT: gradientElement.addAttribute("spread", "repeat"); break; } MorphGradRecord[] records = gradient.getGradientRecords(); for (int i = 0; i < records.length; i++) { MorphGradRecord record = records[i]; Element recordElement = gradientElement.addElement("morphgradrecord"); Element start = recordElement.addElement("start"); start.addAttribute("ratio", Short.toString(record.getStartRatio())); writeRGBA(start, "color", record.getStartColor()); Element end = recordElement.addElement("end"); end.addAttribute("ratio", Short.toString(record.getEndRatio())); writeRGBA(end, "color", record.getEndColor()); } }
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())); }// ww w . j a va 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;/* ww w . j a va 2 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;/* w ww . j a v 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()); }