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 writeButtonRecord(Element parentElement, ButtonRecord buttonRecord) { Element element = parentElement.addElement("buttonrecord"); element.addAttribute("charid", Integer.toString(buttonRecord.getCharacterId())); element.addAttribute("depth", Integer.toString(buttonRecord.getPlaceDepth())); if (buttonRecord.hasBlendMode()) { element.addAttribute("blendmode", BlendMode.getDescription(buttonRecord.getBlendMode())); }//w w w. j a v a 2s. co m Element state = element.addElement("state"); if (buttonRecord.isUpState()) { state.addAttribute("up", "true"); } if (buttonRecord.isDownState()) { state.addAttribute("down", "true"); } if (buttonRecord.isOverState()) { state.addAttribute("over", "true"); } if (buttonRecord.isHitState()) { state.addAttribute("hit", "true"); } writeMatrix(element, buttonRecord.getPlaceMatrix()); CXformWithAlpha colorTransform = buttonRecord.getColorTransform(); if (colorTransform != null) { writeCXFormWithAlpha(element, colorTransform); } if (buttonRecord.hasFilters()) { RecordXMLWriter.writeFilters(element, buttonRecord.getFilters()); } }
From source file:com.jswiff.xml.RecordXMLWriter.java
License:Open Source License
static void writeCXForm(Element parentElement, CXform cXform) { Element element = parentElement.addElement("cxform"); if (cXform.hasAddTerms()) { Element add = element.addElement("add"); add.addAttribute("r", Integer.toString(cXform.getRedAddTerm())); add.addAttribute("g", Integer.toString(cXform.getGreenAddTerm())); add.addAttribute("b", Integer.toString(cXform.getBlueAddTerm())); }/*ww w .j ava2 s. com*/ if (cXform.hasMultTerms()) { Element mult = element.addElement("mult"); mult.addAttribute("r", Integer.toString(cXform.getRedMultTerm())); mult.addAttribute("g", Integer.toString(cXform.getGreenMultTerm())); mult.addAttribute("b", Integer.toString(cXform.getBlueMultTerm())); } }
From source file:com.jswiff.xml.RecordXMLWriter.java
License:Open Source License
static void writeCXFormWithAlpha(Element parentElement, CXformWithAlpha cXformWithAlpha) { Element element = parentElement.addElement("cxformwithalpha"); if (cXformWithAlpha.hasAddTerms()) { Element add = element.addElement("add"); add.addAttribute("r", Integer.toString(cXformWithAlpha.getRedAddTerm())); add.addAttribute("g", Integer.toString(cXformWithAlpha.getGreenAddTerm())); add.addAttribute("b", Integer.toString(cXformWithAlpha.getBlueAddTerm())); add.addAttribute("a", Integer.toString(cXformWithAlpha.getAlphaAddTerm())); }//from w ww.j a v a2 s .c o m if (cXformWithAlpha.hasMultTerms()) { Element mult = element.addElement("mult"); mult.addAttribute("r", Integer.toString(cXformWithAlpha.getRedMultTerm())); mult.addAttribute("g", Integer.toString(cXformWithAlpha.getGreenMultTerm())); mult.addAttribute("b", Integer.toString(cXformWithAlpha.getBlueMultTerm())); mult.addAttribute("a", Integer.toString(cXformWithAlpha.getAlphaMultTerm())); } }
From source file:com.jswiff.xml.RecordXMLWriter.java
License:Open Source License
static void writeClipActions(Element parentElement, ClipActions clipActions) { Element element = parentElement.addElement("clipactions"); writeClipEventFlags(element, clipActions.getEventFlags()); List records = clipActions.getClipActionRecords(); for (Iterator it = records.iterator(); it.hasNext();) { ClipActionRecord record = (ClipActionRecord) it.next(); Element recordElement = element.addElement("clipactionrecord"); ClipEventFlags eventFlags = record.getEventFlags(); writeClipEventFlags(recordElement, eventFlags); if (eventFlags.isKeyPress()) { recordElement.addAttribute("keycode", Short.toString(record.getKeyCode())); }/*from w w w . j av a2 s.c om*/ writeActionBlock(recordElement, record.getActions()); } }
From source file:com.jswiff.xml.RecordXMLWriter.java
License:Open Source License
static void writeFilters(Element parentElement, List filters) { Element element = parentElement.addElement("filters"); for (int j = 0; j < filters.size(); j++) { Object filter = filters.get(j); if (filter instanceof ColorMatrixFilter) { ColorMatrixFilter colorMatrixFilter = (ColorMatrixFilter) filter; Element filterElement = element.addElement("colormatrix"); float[] matrix = colorMatrixFilter.getMatrix(); for (int i = 0; i < matrix.length; i++) { filterElement.addElement("val").addText(StringUtilities.doubleToString(matrix[i])); }// w w w . j av a 2s. c o m } else if (filter instanceof ConvolutionFilter) { ConvolutionFilter convolutionFilter = (ConvolutionFilter) filter; Element filterElement = element.addElement("convolution"); Element matrixElement = filterElement.addElement("matrix"); matrixElement.addAttribute("rows", Integer.toString(convolutionFilter.getMatrixRows())); float[] matrix = convolutionFilter.getMatrix(); for (int i = 0; i < matrix.length; i++) { matrixElement.addElement("val").addText(StringUtilities.doubleToString(matrix[i])); } writeRGBA(filterElement, "color", convolutionFilter.getColor()); filterElement.addAttribute("divisor", StringUtilities.doubleToString(convolutionFilter.getDivisor())); filterElement.addAttribute("bias", StringUtilities.doubleToString(convolutionFilter.getBias())); if (convolutionFilter.isClamp()) { filterElement.addAttribute("clamp", "true"); } if (convolutionFilter.isPreserveAlpha()) { filterElement.addAttribute("preservealpha", "true"); } } else if (filter instanceof BlurFilter) { BlurFilter blurFilter = (BlurFilter) filter; Element filterElement = element.addElement("blur"); filterElement.addAttribute("x", StringUtilities.doubleToString(blurFilter.getX())); filterElement.addAttribute("y", StringUtilities.doubleToString(blurFilter.getY())); filterElement.addAttribute("quality", Integer.toString(blurFilter.getQuality())); } else if (filter instanceof DropShadowFilter) { DropShadowFilter dropShadowFilter = (DropShadowFilter) filter; Element filterElement = element.addElement("dropshadow"); writeRGBA(filterElement, "color", dropShadowFilter.getColor()); filterElement.addAttribute("x", StringUtilities.doubleToString(dropShadowFilter.getX())); filterElement.addAttribute("y", StringUtilities.doubleToString(dropShadowFilter.getY())); filterElement.addAttribute("angle", StringUtilities.doubleToString(dropShadowFilter.getAngle())); filterElement.addAttribute("distance", StringUtilities.doubleToString(dropShadowFilter.getDistance())); filterElement.addAttribute("strength", StringUtilities.doubleToString(dropShadowFilter.getStrength())); filterElement.addAttribute("quality", Integer.toString(dropShadowFilter.getQuality())); if (dropShadowFilter.isInner()) { filterElement.addAttribute("inner", "true"); } if (dropShadowFilter.isKnockout()) { filterElement.addAttribute("knockout", "true"); } if (dropShadowFilter.isHideObject()) { filterElement.addAttribute("hideobject", "true"); } } else if (filter instanceof GlowFilter) { GlowFilter glowFilter = (GlowFilter) filter; Element filterElement = element.addElement("glow"); writeRGBA(filterElement, "color", glowFilter.getColor()); filterElement.addAttribute("x", StringUtilities.doubleToString(glowFilter.getX())); filterElement.addAttribute("y", StringUtilities.doubleToString(glowFilter.getY())); filterElement.addAttribute("strength", StringUtilities.doubleToString(glowFilter.getStrength())); filterElement.addAttribute("quality", Integer.toString(glowFilter.getQuality())); if (glowFilter.isInner()) { filterElement.addAttribute("inner", "true"); } if (glowFilter.isKnockout()) { filterElement.addAttribute("knockout", "true"); } } else if (filter instanceof BevelFilter) { BevelFilter bevelFilter = (BevelFilter) filter; Element filterElement = element.addElement("bevel"); writeRGBA(filterElement, "highlightcolor", bevelFilter.getHighlightColor()); writeRGBA(filterElement, "shadowcolor", bevelFilter.getShadowColor()); filterElement.addAttribute("x", StringUtilities.doubleToString(bevelFilter.getX())); filterElement.addAttribute("y", StringUtilities.doubleToString(bevelFilter.getY())); filterElement.addAttribute("angle", StringUtilities.doubleToString(bevelFilter.getAngle())); filterElement.addAttribute("distance", StringUtilities.doubleToString(bevelFilter.getDistance())); filterElement.addAttribute("strength", StringUtilities.doubleToString(bevelFilter.getStrength())); filterElement.addAttribute("quality", Integer.toString(bevelFilter.getQuality())); if (bevelFilter.isInner()) { filterElement.addAttribute("inner", "true"); } if (bevelFilter.isKnockout()) { filterElement.addAttribute("knockout", "true"); } if (bevelFilter.isOnTop()) { filterElement.addAttribute("ontop", "true"); } } else if (filter instanceof GradientGlowFilter) { GradientGlowFilter gradientGlowFilter = (GradientGlowFilter) filter; Element filterElement = element.addElement("gradientglow"); RGBA[] colors = gradientGlowFilter.getColors(); short[] ratios = gradientGlowFilter.getRatios(); int controlPointsCount = colors.length; Element pointsElement = filterElement.addElement("controlpoints"); for (int i = 0; i < controlPointsCount; i++) { Element pointElement = pointsElement.addElement("controlpoint"); pointElement.addAttribute("ratio", Short.toString(ratios[i])); writeRGBA(pointElement, "color", colors[i]); } filterElement.addAttribute("x", StringUtilities.doubleToString(gradientGlowFilter.getX())); filterElement.addAttribute("y", StringUtilities.doubleToString(gradientGlowFilter.getY())); filterElement.addAttribute("angle", StringUtilities.doubleToString(gradientGlowFilter.getAngle())); filterElement.addAttribute("distance", StringUtilities.doubleToString(gradientGlowFilter.getDistance())); filterElement.addAttribute("strength", StringUtilities.doubleToString(gradientGlowFilter.getStrength())); filterElement.addAttribute("quality", Integer.toString(gradientGlowFilter.getQuality())); if (gradientGlowFilter.isInner()) { filterElement.addAttribute("inner", "true"); } if (gradientGlowFilter.isKnockout()) { filterElement.addAttribute("knockout", "true"); } if (gradientGlowFilter.isOnTop()) { filterElement.addAttribute("ontop", "true"); } } else if (filter instanceof GradientBevelFilter) { GradientBevelFilter gradientBevelFilter = (GradientBevelFilter) filter; Element filterElement = element.addElement("gradientbevel"); RGBA[] colors = gradientBevelFilter.getColors(); short[] ratios = gradientBevelFilter.getRatios(); int controlPointsCount = colors.length; Element pointsElement = filterElement.addElement("controlpoints"); for (int i = 0; i < controlPointsCount; i++) { Element pointElement = pointsElement.addElement("controlpoint"); pointElement.addAttribute("ratio", Short.toString(ratios[i])); writeRGBA(pointElement, "color", colors[i]); } filterElement.addAttribute("x", StringUtilities.doubleToString(gradientBevelFilter.getX())); filterElement.addAttribute("y", StringUtilities.doubleToString(gradientBevelFilter.getY())); filterElement.addAttribute("angle", StringUtilities.doubleToString(gradientBevelFilter.getAngle())); filterElement.addAttribute("distance", StringUtilities.doubleToString(gradientBevelFilter.getDistance())); filterElement.addAttribute("strength", StringUtilities.doubleToString(gradientBevelFilter.getStrength())); filterElement.addAttribute("quality", Integer.toString(gradientBevelFilter.getQuality())); if (gradientBevelFilter.isInner()) { filterElement.addAttribute("inner", "true"); } if (gradientBevelFilter.isKnockout()) { filterElement.addAttribute("knockout", "true"); } if (gradientBevelFilter.isOnTop()) { filterElement.addAttribute("ontop", "true"); } } } }
From source file:com.jswiff.xml.RecordXMLWriter.java
License:Open Source License
static void writeMatrix(Element parentElement, String elementName, Matrix matrix) { Element element = parentElement.addElement(elementName); Element translate = element.addElement("translate"); translate.addAttribute("x", Integer.toString(matrix.getTranslateX())); translate.addAttribute("y", Integer.toString(matrix.getTranslateY())); if (matrix.hasRotateSkew()) { Element rotateSkew = element.addElement("rotateskew"); rotateSkew.addAttribute("rs0", StringUtilities.doubleToString(matrix.getRotateSkew0())); rotateSkew.addAttribute("rs1", StringUtilities.doubleToString(matrix.getRotateSkew1())); }//www .j a va 2 s . co m if (matrix.hasScale()) { Element scale = element.addElement("scale"); scale.addAttribute("x", StringUtilities.doubleToString(matrix.getScaleX())); scale.addAttribute("y", StringUtilities.doubleToString(matrix.getScaleY())); } }
From source file:com.jswiff.xml.RecordXMLWriter.java
License:Open Source License
static void writeMorphLineStyles(Element parentElement, MorphLineStyles lineStyles) { int size = lineStyles.getSize(); Element lineStylesElement = parentElement.addElement("morphlinestyles"); for (int i = 1; i <= size; i++) { Object style = lineStyles.getStyle(i); if (style instanceof MorphLineStyle) { MorphLineStyle lineStyle = (MorphLineStyle) style; Element lineStyleElement = lineStylesElement.addElement("morphlinestyle"); Element startElement = lineStyleElement.addElement("start"); startElement.addAttribute("width", Integer.toString(lineStyle.getStartWidth())); writeRGBA(startElement, "color", lineStyle.getStartColor()); Element endElement = lineStyleElement.addElement("end"); endElement.addAttribute("width", Integer.toString(lineStyle.getEndWidth())); writeRGBA(endElement, "color", lineStyle.getEndColor()); } else {//w w w. j av a2 s. co m MorphLineStyle2 lineStyle2 = (MorphLineStyle2) style; Element lineStyle2Element = lineStylesElement.addElement("morphlinestyle2"); Element startElement = lineStyle2Element.addElement("start"); Element end = lineStyle2Element.addElement("end"); startElement.addAttribute("width", Integer.toString(lineStyle2.getStartWidth())); end.addAttribute("width", Integer.toString(lineStyle2.getEndWidth())); 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"); } MorphFillStyle fillStyle = lineStyle2.getFillStyle(); if (fillStyle == null) { writeColor(startElement, "color", lineStyle2.getStartColor()); writeColor(end, "color", lineStyle2.getEndColor()); } else { writeMorphFillStyle(lineStyle2Element, fillStyle); } } } }
From source file:com.jswiff.xml.RecordXMLWriter.java
License:Open Source License
static void writeRGB(Element parentElement, String elementName, RGB rgbColor) { Element element = parentElement.addElement(elementName); element.addAttribute("r", Integer.toString(rgbColor.getRed())); element.addAttribute("g", Integer.toString(rgbColor.getGreen())); element.addAttribute("b", Integer.toString(rgbColor.getBlue())); }
From source file:com.jswiff.xml.RecordXMLWriter.java
License:Open Source License
static void writeRGBA(Element parentElement, String elementName, RGBA rgbaColor) { Element element = parentElement.addElement(elementName); element.addAttribute("r", Integer.toString(rgbaColor.getRed())); element.addAttribute("g", Integer.toString(rgbaColor.getGreen())); element.addAttribute("b", Integer.toString(rgbaColor.getBlue())); element.addAttribute("a", Integer.toString(rgbaColor.getAlpha())); }
From source file:com.jswiff.xml.RecordXMLWriter.java
License:Open Source License
static void writeRect(Element parentElement, String elementName, Rect rect) { Element element = parentElement.addElement(elementName); element.addAttribute("xmin", Long.toString(rect.getXMin())); element.addAttribute("xmax", Long.toString(rect.getXMax())); element.addAttribute("ymin", Long.toString(rect.getYMin())); element.addAttribute("ymax", Long.toString(rect.getYMax())); }