List of usage examples for org.dom4j Element addAttribute
Element addAttribute(QName qName, String value);
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 ww . ja v a 2 s . c om*/ RecordXMLWriter.writeActionBlock(element, tag.getActions()); }
From source file:com.jswiff.xml.TagXMLWriter.java
License:Open Source License
private static void writeDefineButton2(Element parentElement, DefineButton2 tag) { Element element = parentElement.addElement("definebutton2"); element.addAttribute("charid", Integer.toString(tag.getCharacterId())); if (tag.isTrackAsMenu()) { element.addAttribute("trackasmenu", "true"); }/*from w w w. j av a 2 s . c o m*/ Element charsElement = element.addElement("chars"); ButtonRecord[] characters = tag.getCharacters(); for (int i = 0; i < characters.length; i++) { RecordXMLWriter.writeButtonRecord(charsElement, characters[i]); } Element actionsElement = element.addElement("actions"); ButtonCondAction[] actions = tag.getActions(); if (actions != null) { for (int i = 0; i < actions.length; i++) { RecordXMLWriter.writeButtonCondAction(actionsElement, actions[i]); } } }
From source file:com.jswiff.xml.TagXMLWriter.java
License:Open Source License
private static void writeDefineButtonCXform(Element parentElement, DefineButtonCXform tag) { Element element = parentElement.addElement("definebuttoncxform"); element.addAttribute("charid", Integer.toString(tag.getCharacterId())); RecordXMLWriter.writeCXForm(element, tag.getColorTransform()); }
From source file:com.jswiff.xml.TagXMLWriter.java
License:Open Source License
private static void writeDefineButtonSound(Element parentElement, DefineButtonSound tag) { Element element = parentElement.addElement("definebuttonsound"); element.addAttribute("buttonid", Integer.toString(tag.getButtonId())); if (tag.getOverUpToIdleSoundId() != 0) { Element overUpToIdle = element.addElement("overuptoidle"); overUpToIdle.addAttribute("soundid", Integer.toString(tag.getOverUpToIdleSoundId())); RecordXMLWriter.writeSoundInfo(overUpToIdle, tag.getOverUpToIdleSoundInfo()); }//from w w w . j a v a2 s. c o m if (tag.getIdleToOverUpSoundId() != 0) { Element idleToOverUp = element.addElement("idletooverup"); idleToOverUp.addAttribute("soundid", Integer.toString(tag.getIdleToOverUpSoundId())); RecordXMLWriter.writeSoundInfo(idleToOverUp, tag.getIdleToOverUpSoundInfo()); } if (tag.getOverUpToOverDownSoundId() != 0) { Element overUpToOverDown = element.addElement("overuptooverdown"); overUpToOverDown.addAttribute("soundid", Integer.toString(tag.getOverUpToOverDownSoundId())); RecordXMLWriter.writeSoundInfo(overUpToOverDown, tag.getOverUpToOverDownSoundInfo()); } if (tag.getOverDownToOverUpSoundId() != 0) { Element overDownToOverUp = element.addElement("overdowntooverup"); overDownToOverUp.addAttribute("soundid", Integer.toString(tag.getOverDownToOverUpSoundId())); RecordXMLWriter.writeSoundInfo(overDownToOverUp, tag.getOverDownToOverUpSoundInfo()); } }
From source file:com.jswiff.xml.TagXMLWriter.java
License:Open Source License
private static void writeDefineEditText(Element parentElement, DefineEditText tag) { Element element = parentElement.addElement("defineedittext"); element.addAttribute("charid", Integer.toString(tag.getCharacterId())); if (tag.isWordWrap()) { element.addAttribute("wordwrap", "true"); }/*from ww w . j a va 2s . c om*/ if (tag.isMultiline()) { element.addAttribute("multiline", "true"); } if (tag.isPassword()) { element.addAttribute("password", "true"); } if (tag.isReadOnly()) { element.addAttribute("readonly", "true"); } if (tag.isAutoSize()) { element.addAttribute("autosize", "true"); } if (tag.isNoSelect()) { element.addAttribute("noselect", "true"); } if (tag.isBorder()) { element.addAttribute("border", "true"); } if (tag.isHtml()) { element.addAttribute("html", "true"); } if (tag.isUseOutlines()) { element.addAttribute("useoutlines", "true"); } if (tag.hasMaxLength()) { element.addAttribute("maxlength", Integer.toString(tag.getMaxLength())); } String var = tag.getVariableName(); if ((var != null) && (var.length() > 0)) { element.addAttribute("variable", var); } RecordXMLWriter.writeRect(element, "bounds", tag.getBounds()); if (tag.hasText()) { element.addElement("initialtext").addText(tag.getInitialText()); } if (tag.hasTextColor()) { RecordXMLWriter.writeRGBA(element, "color", tag.getTextColor()); } if (tag.hasFont()) { Element font = element.addElement("font"); font.addAttribute("fontid", Integer.toString(tag.getFontId())); font.addAttribute("height", Integer.toString(tag.getFontHeight())); } if (tag.hasLayout()) { Element layout = element.addElement("layout"); String align; switch (tag.getAlign()) { case DefineEditText.ALIGN_LEFT: align = "left"; break; case DefineEditText.ALIGN_CENTER: align = "center"; break; case DefineEditText.ALIGN_JUSTIFY: align = "justify"; break; case DefineEditText.ALIGN_RIGHT: align = "right"; break; default: throw new IllegalArgumentException("Illegal text alignment: " + tag.getAlign()); } layout.addAttribute("align", align); layout.addAttribute("leftmargin", Integer.toString(tag.getLeftMargin())); layout.addAttribute("rightmargin", Integer.toString(tag.getRightMargin())); layout.addAttribute("indent", Integer.toString(tag.getIndent())); layout.addAttribute("leading", Integer.toString(tag.getLeading())); } }
From source file:com.jswiff.xml.TagXMLWriter.java
License:Open Source License
private static void writeDefineFont(Element parentElement, DefineFont tag) { Element element = parentElement.addElement("definefont"); element.addAttribute("charid", Integer.toString(tag.getCharacterId())); Element glyphShapeTableElement = element.addElement("glyphshapetable"); Shape[] glyphShapeTable = tag.getGlyphShapeTable(); for (int i = 0; i < glyphShapeTable.length; i++) { RecordXMLWriter.writeShape(glyphShapeTableElement, glyphShapeTable[i]); }//www .j a va 2s. c o m }
From source file:com.jswiff.xml.TagXMLWriter.java
License:Open Source License
private static void writeDefineFont2(Element parentElement, DefineFont2 tag) { Element element = parentElement.addElement("definefont2"); element.addAttribute("charid", Integer.toString(tag.getCharacterId())); element.addAttribute("fontname", tag.getFontName()); if (tag.isANSI()) { element.addAttribute("ansi", "true"); } else if (tag.isShiftJIS()) { element.addAttribute("shiftjis", "true"); }//from w w w . j av a2 s .co m if (tag.isBold()) { element.addAttribute("bold", "true"); } if (tag.isItalic()) { element.addAttribute("italic", "true"); } if (tag.isSmallText()) { element.addAttribute("smalltext", "true"); } writeLanguage(element, tag.getLanguageCode()); Shape[] table = tag.getGlyphShapeTable(); if (table != null) { Element glyphShapeTableElement = element.addElement("glyphshapetable"); char[] codeTable = tag.getCodeTable(); for (int i = 0; i < table.length; i++) { Element glyphElement = glyphShapeTableElement.addElement("glyph"); glyphElement.addAttribute("char", Character.toString(codeTable[i])); RecordXMLWriter.writeShape(glyphElement, table[i]); if (tag.hasLayout()) { glyphElement.addAttribute("advance", Short.toString(tag.getAdvanceTable()[i])); RecordXMLWriter.writeRect(glyphElement, "bounds", tag.getBoundsTable()[i]); } } } if (tag.hasLayout()) { Element layout = element.addElement("layout"); layout.addAttribute("ascent", Integer.toString(tag.getAscent())); layout.addAttribute("descent", Integer.toString(tag.getDescent())); layout.addAttribute("leading", Integer.toString(tag.getLeading())); KerningRecord[] kerningTable = tag.getKerningTable(); if ((kerningTable != null) && (kerningTable.length > 0)) { Element kerningTableElement = layout.addElement("kerningtable"); for (int i = 0; i < kerningTable.length; i++) { KerningRecord record = kerningTable[i]; Element recordElement = kerningTableElement.addElement("kerningrecord"); recordElement.addAttribute("left", Character.toString(record.getLeft())); recordElement.addAttribute("right", Character.toString(record.getRight())); recordElement.addAttribute("adjust", Short.toString(record.getAdjustment())); } } } }
From source file:com.jswiff.xml.TagXMLWriter.java
License:Open Source License
private static void writeDefineFont3(Element parentElement, DefineFont3 tag) { Element element = parentElement.addElement("definefont3"); element.addAttribute("charid", Integer.toString(tag.getCharacterId())); element.addAttribute("fontname", tag.getFontName()); if (tag.isBold()) { element.addAttribute("bold", "true"); }/*w w w . j a v a2 s . c o m*/ if (tag.isItalic()) { element.addAttribute("italic", "true"); } if (tag.isSmallText()) { element.addAttribute("smalltext", "true"); } writeLanguage(element, tag.getLanguageCode()); Shape[] table = tag.getGlyphShapeTable(); if (table != null) { Element glyphShapeTableElement = element.addElement("glyphshapetable"); char[] codeTable = tag.getCodeTable(); for (int i = 0; i < table.length; i++) { Element glyphElement = glyphShapeTableElement.addElement("glyph"); glyphElement.addAttribute("char", Character.toString(codeTable[i])); RecordXMLWriter.writeShape(glyphElement, table[i]); if (tag.hasLayout()) { glyphElement.addAttribute("advance", Short.toString(tag.getAdvanceTable()[i])); RecordXMLWriter.writeRect(glyphElement, "bounds", tag.getBoundsTable()[i]); } } } if (tag.hasLayout()) { Element layout = element.addElement("layout"); layout.addAttribute("ascent", Integer.toString(tag.getAscent())); layout.addAttribute("descent", Integer.toString(tag.getDescent())); layout.addAttribute("leading", Integer.toString(tag.getLeading())); KerningRecord[] kerningTable = tag.getKerningTable(); if ((kerningTable != null) && (kerningTable.length > 0)) { Element kerningTableElement = layout.addElement("kerningtable"); for (int i = 0; i < kerningTable.length; i++) { KerningRecord record = kerningTable[i]; Element recordElement = kerningTableElement.addElement("kerningrecord"); recordElement.addAttribute("left", Character.toString(record.getLeft())); recordElement.addAttribute("right", Character.toString(record.getRight())); recordElement.addAttribute("adjust", Short.toString(record.getAdjustment())); } } } }
From source file:com.jswiff.xml.TagXMLWriter.java
License:Open Source License
private static void writeDefineFontAlignment(Element parentElement, DefineFontAlignment tag) { Element element = parentElement.addElement("definefontalignment"); element.addAttribute("fontid", Integer.toString(tag.getFontId())); switch (tag.getThickness()) { case DefineFontAlignment.THIN: element.addAttribute("thickness", "thin"); break;/*from w w w .j a v a 2 s. c om*/ case DefineFontAlignment.MEDIUM: element.addAttribute("thickness", "medium"); break; case DefineFontAlignment.THICK: element.addAttribute("thickness", "thick"); break; } RecordXMLWriter.writeAlignmentZones(element, tag.getAlignmentZones()); }
From source file:com.jswiff.xml.TagXMLWriter.java
License:Open Source License
private static void writeDefineFontInfo(Element parentElement, DefineFontInfo tag) { Element element = parentElement.addElement("definefontinfo"); element.addAttribute("fontid", Integer.toString(tag.getFontId())); element.addAttribute("fontname", tag.getFontName()); if (tag.isANSI()) { element.addAttribute("ansi", "true"); } else if (tag.isShiftJIS()) { element.addAttribute("shiftjis", "true"); }/*from w w w .j av a2 s . co m*/ if (tag.isBold()) { element.addAttribute("bold", "true"); } if (tag.isItalic()) { element.addAttribute("italic", "true"); } if (tag.isSmallText()) { element.addAttribute("smalltext", "true"); } char[] codeTable = tag.getCodeTable(); for (int i = 0; i < codeTable.length; i++) { element.addElement("char").addText(Character.toString(codeTable[i])); } }