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
static void writeSoundInfo(Element parentElement, SoundInfo soundInfo) { Element element = parentElement.addElement("soundinfo"); if (soundInfo.isSyncStop()) { element.addAttribute("syncstop", "true"); }//from w w w .ja v a2 s. co 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 ww . j a v a 2 s .co m*/ 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 writeClipEventFlags(Element parentElement, ClipEventFlags flags) { Element element = parentElement.addElement("clipeventflags"); if (flags.isKeyUp()) { element.addAttribute("keyup", "true"); }/*w w w. j a v a 2 s . co 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 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())); }
From source file:com.jswiff.xml.RecordXMLWriter.java
License:Open Source License
private static void writeEnhancedStrokeStyles(Element parentElement, byte jointStyle, byte startCapStyle, byte endCapStyle, double miterLimit, byte scaleStroke) { switch (jointStyle) { case EnhancedStrokeStyle.JOINT_ROUND: parentElement.addAttribute("joint", "round"); break;/*from ww w . j a va2 s . com*/ case EnhancedStrokeStyle.JOINT_MITER: parentElement.addAttribute("joint", "miter"); parentElement.addAttribute("miterlimit", StringUtilities.doubleToString(miterLimit)); break; case EnhancedStrokeStyle.JOINT_BEVEL: parentElement.addAttribute("joint", "bevel"); break; } Element capStyleElement = parentElement.addElement("capstyle"); switch (startCapStyle) { case EnhancedStrokeStyle.CAPS_NONE: capStyleElement.addAttribute("start", "none"); break; case EnhancedStrokeStyle.CAPS_ROUND: capStyleElement.addAttribute("start", "round"); break; case EnhancedStrokeStyle.CAPS_SQUARE: capStyleElement.addAttribute("start", "square"); break; } switch (endCapStyle) { case EnhancedStrokeStyle.CAPS_NONE: capStyleElement.addAttribute("end", "none"); break; case EnhancedStrokeStyle.CAPS_ROUND: capStyleElement.addAttribute("end", "round"); break; case EnhancedStrokeStyle.CAPS_SQUARE: capStyleElement.addAttribute("end", "square"); break; } switch (scaleStroke) { case EnhancedStrokeStyle.SCALE_NONE: parentElement.addAttribute("scalestroke", "none"); break; case EnhancedStrokeStyle.SCALE_HORIZONTAL: parentElement.addAttribute("scalestroke", "horizontal"); break; case EnhancedStrokeStyle.SCALE_VERTICAL: parentElement.addAttribute("scalestroke", "vertical"); break; case EnhancedStrokeStyle.SCALE_BOTH: parentElement.addAttribute("scalestroke", "both"); break; } }
From source file:com.jswiff.xml.RecordXMLWriter.java
License:Open Source License
private static void writeFillStyle(Element parentElement, FillStyle fillStyle) { Element fillStyleElement = parentElement.addElement("fillstyle"); boolean isGradient = false; boolean isFocal = false; boolean isBitmap = false; switch (fillStyle.getType()) { case FillStyle.TYPE_SOLID: fillStyleElement.addAttribute("type", "solid"); writeColor(fillStyleElement, "color", fillStyle.getColor()); break;//from ww w.jav a 2 s .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 fill type: " + fillStyle.getType()); } if (isGradient) { if (isFocal) { writeFocalGradient(fillStyleElement.addElement("focalgradient"), (FocalGradient) fillStyle.getGradient()); } else { writeGradient(fillStyleElement.addElement("gradient"), fillStyle.getGradient()); } writeMatrix(fillStyleElement, "gradientmatrix", fillStyle.getGradientMatrix()); } else if (isBitmap) { fillStyleElement.addAttribute("bitmapid", Integer.toString(fillStyle.getBitmapId())); writeMatrix(fillStyleElement, "bitmapmatrix", fillStyle.getBitmapMatrix()); } }
From source file:com.jswiff.xml.RecordXMLWriter.java
License:Open Source License
private static void writeFocalGradient(Element gradientElement, FocalGradient gradient) { writeGradient(gradientElement, gradient); gradientElement.addAttribute("focalpointratio", StringUtilities.doubleToString(gradient.getFocalPointRatio())); }
From source file:com.jswiff.xml.RecordXMLWriter.java
License:Open Source License
private static void writeFocalMorphGradient(Element gradientElement, FocalMorphGradient gradient) { writeMorphGradient(gradientElement, gradient); gradientElement.addAttribute("startfocalpointratio", StringUtilities.doubleToString(gradient.getStartFocalPointRatio())); gradientElement.addAttribute("endfocalpointratio", StringUtilities.doubleToString(gradient.getEndFocalPointRatio())); }
From source file:com.jswiff.xml.RecordXMLWriter.java
License:Open Source License
private static void writeGradient(Element gradientElement, Gradient gradient) { switch (gradient.getInterpolationMethod()) { case Gradient.INTERPOLATION_LINEAR_RGB: gradientElement.addAttribute("interpolation", "linear-rgb"); break;/* w w w. j a v a2 s . c om*/ 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; } GradRecord[] records = gradient.getGradientRecords(); for (int i = 0; i < records.length; i++) { GradRecord record = records[i]; Element recordElement = gradientElement.addElement("gradrecord"); recordElement.addAttribute("ratio", Short.toString(record.getRatio())); writeColor(recordElement, "color", record.getColor()); } }
From source file:com.jswiff.xml.RecordXMLWriter.java
License:Open Source License
private static void writeLineStyles(Element parentElement, LineStyleArray lineStyles) { int size = lineStyles.getSize(); Element lineStylesElement = parentElement.addElement("linestyles"); for (int i = 1; i <= size; i++) { Object style = lineStyles.getStyle(i); if (style instanceof LineStyle) { LineStyle lineStyle = (LineStyle) style; Element lineStyleElement = lineStylesElement.addElement("linestyle"); lineStyleElement.addAttribute("width", Integer.toString(lineStyle.getWidth())); writeColor(lineStyleElement, "color", lineStyle.getColor()); } else {//from w w w . j a v a 2s . co m LineStyle2 lineStyle2 = (LineStyle2) style; Element lineStyle2Element = lineStylesElement.addElement("linestyle2"); lineStyle2Element.addAttribute("width", Integer.toString(lineStyle2.getWidth())); writeEnhancedStrokeStyles(lineStyle2Element, lineStyle2.getJointStyle(), lineStyle2.getStartCapStyle(), lineStyle2.getEndCapStyle(), lineStyle2.getMiterLimit(), lineStyle2.getScaleStroke()); if (lineStyle2.isClose()) { parentElement.addAttribute("close", "true"); } if (lineStyle2.isPixelHinting()) { parentElement.addAttribute("pixelhinting", "true"); } FillStyle fillStyle = lineStyle2.getFillStyle(); if (fillStyle == null) { writeColor(lineStyle2Element, "color", lineStyle2.getColor()); } else { writeFillStyle(lineStyle2Element, fillStyle); } } } }