List of usage examples for org.dom4j Element elements
List<Element> elements();
From source file:com.jswiff.xml.RecordXMLReader.java
License:Open Source License
static Shape readShape(Element element) { List shapeRecordElements = element.elements(); int arrayLength = shapeRecordElements.size(); ShapeRecord[] shapeRecords = new ShapeRecord[arrayLength]; for (int i = 0; i < arrayLength; i++) { Element shapeRecordElement = (Element) shapeRecordElements.get(i); if (shapeRecordElement.getName().equals("straightedgerecord")) { shapeRecords[i] = readStraightEdgeRecord(shapeRecordElement); } else if (shapeRecordElement.getName().equals("curvededgerecord")) { shapeRecords[i] = readCurvedEdgeRecord(shapeRecordElement); } else if (shapeRecordElement.getName().equals("stylechangerecord")) { shapeRecords[i] = readStyleChangeRecord(shapeRecordElement); }//from w w w. ja va2 s . co m } return new Shape(shapeRecords); }
From source file:com.jswiff.xml.RecordXMLReader.java
License:Open Source License
static ShapeWithStyle readShapeWithStyle(Element parentElement) { Element element = getElement("shapewithstyle", parentElement); Element shape = getElement("shape", element); List shapeRecordElements = shape.elements(); int arrayLength = shapeRecordElements.size(); ShapeRecord[] shapeRecords = new ShapeRecord[arrayLength]; for (int i = 0; i < arrayLength; i++) { Element shapeRecordElement = (Element) shapeRecordElements.get(i); if (shapeRecordElement.getName().equals("straightedgerecord")) { shapeRecords[i] = readStraightEdgeRecord(shapeRecordElement); } else if (shapeRecordElement.getName().equals("curvededgerecord")) { shapeRecords[i] = readCurvedEdgeRecord(shapeRecordElement); } else if (shapeRecordElement.getName().equals("stylechangerecord")) { shapeRecords[i] = readStyleChangeRecord(shapeRecordElement); }// www . j a va 2s.co m } Element lineStyles = element.element("linestyles"); Element fillStyles = element.element("fillstyles"); return new ShapeWithStyle(readFillStyles(fillStyles), readLineStyles(lineStyles), shapeRecords); }
From source file:com.jswiff.xml.RecordXMLReader.java
License:Open Source License
static TextRecord[] readTextRecords(Element parentElement) { Element element = getElement("textrecords", parentElement); List recordElements = element.elements(); int arrayLength = recordElements.size(); TextRecord[] records = new TextRecord[arrayLength]; for (int i = 0; i < arrayLength; i++) { Element recordElement = (Element) recordElements.get(i); GlyphEntry[] glyphEntries = readGlyphEntries(recordElement); TextRecord record = new TextRecord(glyphEntries); Attribute fontId = recordElement.attribute("fontid"); if (fontId != null) { record.setFont(Integer.parseInt(fontId.getValue()), getIntAttribute("height", recordElement)); }/* w w w.j a va 2 s . co m*/ Attribute xOffset = recordElement.attribute("xoffset"); if (xOffset != null) { record.setXOffset(Short.parseShort(xOffset.getValue())); } Attribute yOffset = recordElement.attribute("yoffset"); if (yOffset != null) { record.setYOffset(Short.parseShort(yOffset.getValue())); } Element color = recordElement.element("color"); if (color != null) { record.setTextColor(RecordXMLReader.readColor(color)); } records[i] = record; } return records; }
From source file:com.jswiff.xml.RecordXMLReader.java
License:Open Source License
private static FillStyleArray readFillStyles(Element element) { List styleElements = element.elements(); FillStyleArray styleArray = new FillStyleArray(); for (Iterator it = styleElements.iterator(); it.hasNext();) { Element styleElement = (Element) it.next(); styleArray.addStyle(readFillStyle(styleElement)); }/* w ww .j av a 2 s .c o m*/ return styleArray; }
From source file:com.jswiff.xml.RecordXMLReader.java
License:Open Source License
private static GlyphEntry[] readGlyphEntries(Element parentElement) { Element element = getElement("glyphentries", parentElement); List entryElements = element.elements(); int arrayLength = entryElements.size(); GlyphEntry[] entries = new GlyphEntry[arrayLength]; for (int i = 0; i < arrayLength; i++) { Element entryElement = (Element) entryElements.get(i); entries[i] = new GlyphEntry(getIntAttribute("index", entryElement), getIntAttribute("advance", entryElement)); }//ww w . ja v a 2 s .c o m return entries; }
From source file:com.jswiff.xml.RecordXMLReader.java
License:Open Source License
private static LineStyleArray readLineStyles(Element element) { LineStyleArray styleArray = new LineStyleArray(); List styleElements = element.elements(); for (Iterator it = styleElements.iterator(); it.hasNext();) { Element styleElement = (Element) it.next(); if (styleElement.getName().equals("linestyle")) { styleArray.addStyle(readLineStyle(styleElement)); } else if (styleElement.getName().equals("linestyle2")) { styleArray.addStyle(readLineStyle2(styleElement)); }//from ww w.j a v a2s .c o m } return styleArray; }
From source file:com.jswiff.xml.RecordXMLReader.java
License:Open Source License
private static SoundEnvelope[] readSoundEnvelopeRecords(Element parentElement) { List recordElements = parentElement.elements(); int arrayLength = recordElements.size(); SoundEnvelope[] records = new SoundEnvelope[arrayLength]; for (int i = 0; i < arrayLength; i++) { Element recordElement = (Element) recordElements.get(i); long pos44 = getLongAttribute("pos44", recordElement); int leftLevel = getIntAttribute("leftlevel", recordElement); int rightLevel = getIntAttribute("rightlevel", recordElement); SoundEnvelope record = new SoundEnvelope(pos44, leftLevel, rightLevel); records[i] = record;//w w w .ja v a 2 s .co m } return records; }
From source file:com.jswiff.xml.TagXMLReader.java
License:Open Source License
private static Tag readDefineFont2(Element tagElement) { int characterId = RecordXMLReader.getCharacterId(tagElement); String fontName = getStringAttribute("fontname", tagElement); Shape[] glyphShapes = null;/*from www. ja va 2s . com*/ char[] codeTable = null; short[] advanceTable = null; Rect[] boundsTable = null; boolean hasLayout = false; Element glyphShapeTableElement = tagElement.element("glyphshapetable"); if (glyphShapeTableElement != null) { List glyphElements = glyphShapeTableElement.elements(); int numGlyphs = glyphElements.size(); advanceTable = new short[numGlyphs]; boundsTable = new Rect[numGlyphs]; glyphShapes = new Shape[numGlyphs]; codeTable = new char[numGlyphs]; for (int i = 0; i < numGlyphs; i++) { Element glyphElement = (Element) glyphElements.get(i); codeTable[i] = getStringAttribute("char", glyphElement).charAt(0); glyphShapes[i] = RecordXMLReader.readShape(RecordXMLReader.getElement("shape", glyphElement)); Attribute advance = glyphElement.attribute("advance"); if (advance != null) { hasLayout = true; advanceTable[i] = Short.parseShort(advance.getValue()); boundsTable[i] = RecordXMLReader.readRect(RecordXMLReader.getElement("bounds", glyphElement)); } } } DefineFont2 defineFont2 = new DefineFont2(characterId, fontName, glyphShapes, codeTable); if (hasLayout) { Element layout = RecordXMLReader.getElement("layout", tagElement); short ascent = RecordXMLReader.getShortAttribute("ascent", layout); short descent = RecordXMLReader.getShortAttribute("descent", layout); short leading = RecordXMLReader.getShortAttribute("leading", layout); KerningRecord[] kerningTable = null; Element kerningTableElement = layout.element("kerningtable"); if (kerningTableElement != null) { List recordElements = kerningTableElement.elements(); int arrayLength = recordElements.size(); kerningTable = new KerningRecord[arrayLength]; for (int i = 0; i < arrayLength; i++) { Element recordElement = (Element) recordElements.get(i); char left = getStringAttribute("left", recordElement).charAt(0); char right = getStringAttribute("right", recordElement).charAt(0); short adjustment = RecordXMLReader.getShortAttribute("adjust", recordElement); kerningTable[i] = new KerningRecord(left, right, adjustment); } } defineFont2.setLayout(ascent, descent, leading, advanceTable, boundsTable, kerningTable); } if (RecordXMLReader.getBooleanAttribute("ansi", tagElement)) { defineFont2.setANSI(true); } if (RecordXMLReader.getBooleanAttribute("shiftjis", tagElement)) { defineFont2.setShiftJIS(true); } if (RecordXMLReader.getBooleanAttribute("bold", tagElement)) { defineFont2.setBold(true); } if (RecordXMLReader.getBooleanAttribute("italic", tagElement)) { defineFont2.setItalic(true); } if (RecordXMLReader.getBooleanAttribute("smalltext", tagElement)) { defineFont2.setSmallText(true); } defineFont2.setLanguageCode(readLangCode(tagElement)); return defineFont2; }
From source file:com.jswiff.xml.TagXMLReader.java
License:Open Source License
private static Tag readDefineFont3(Element tagElement) { int characterId = RecordXMLReader.getCharacterId(tagElement); String fontName = getStringAttribute("fontname", tagElement); Shape[] glyphShapes = null;//from w w w . j a va 2s.c o m char[] codeTable = null; short[] advanceTable = null; Rect[] boundsTable = null; boolean hasLayout = false; Element glyphShapeTableElement = tagElement.element("glyphshapetable"); if (glyphShapeTableElement != null) { List glyphElements = glyphShapeTableElement.elements(); int numGlyphs = glyphElements.size(); advanceTable = new short[numGlyphs]; boundsTable = new Rect[numGlyphs]; glyphShapes = new Shape[numGlyphs]; codeTable = new char[numGlyphs]; for (int i = 0; i < numGlyphs; i++) { Element glyphElement = (Element) glyphElements.get(i); codeTable[i] = getStringAttribute("char", glyphElement).charAt(0); glyphShapes[i] = RecordXMLReader.readShape(RecordXMLReader.getElement("shape", glyphElement)); Attribute advance = glyphElement.attribute("advance"); if (advance != null) { hasLayout = true; advanceTable[i] = Short.parseShort(advance.getValue()); boundsTable[i] = RecordXMLReader.readRect(RecordXMLReader.getElement("bounds", glyphElement)); } } } DefineFont3 defineFont3 = new DefineFont3(characterId, fontName, glyphShapes, codeTable); if (hasLayout) { Element layout = RecordXMLReader.getElement("layout", tagElement); short ascent = RecordXMLReader.getShortAttribute("ascent", layout); short descent = RecordXMLReader.getShortAttribute("descent", layout); short leading = RecordXMLReader.getShortAttribute("leading", layout); KerningRecord[] kerningTable = null; Element kerningTableElement = layout.element("kerningtable"); if (kerningTableElement != null) { List recordElements = kerningTableElement.elements(); int arrayLength = recordElements.size(); kerningTable = new KerningRecord[arrayLength]; for (int i = 0; i < arrayLength; i++) { Element recordElement = (Element) recordElements.get(i); char left = getStringAttribute("left", recordElement).charAt(0); char right = getStringAttribute("right", recordElement).charAt(0); short adjustment = RecordXMLReader.getShortAttribute("adjust", recordElement); kerningTable[i] = new KerningRecord(left, right, adjustment); } } defineFont3.setLayout(ascent, descent, leading, advanceTable, boundsTable, kerningTable); } if (RecordXMLReader.getBooleanAttribute("bold", tagElement)) { defineFont3.setBold(true); } if (RecordXMLReader.getBooleanAttribute("italic", tagElement)) { defineFont3.setItalic(true); } if (RecordXMLReader.getBooleanAttribute("smalltext", tagElement)) { defineFont3.setSmallText(true); } defineFont3.setLanguageCode(readLangCode(tagElement)); return defineFont3; }
From source file:com.jswiff.xml.TagXMLReader.java
License:Open Source License
private static Tag readDefineFontInfo(Element tagElement) { int fontId = RecordXMLReader.getIntAttribute("fontid", tagElement); String fontName = getStringAttribute("fontname", tagElement); List charElements = tagElement.elements(); int arrayLength = charElements.size(); char[] codeTable = new char[arrayLength]; for (int i = 0; i < arrayLength; i++) { Element charElement = (Element) charElements.get(i); codeTable[i] = charElement.getText().charAt(0); }/*from w ww. j av a 2 s. c o m*/ DefineFontInfo defineFontInfo = new DefineFontInfo(fontId, fontName, codeTable); if (RecordXMLReader.getBooleanAttribute("ansi", tagElement)) { defineFontInfo.setANSI(true); } if (RecordXMLReader.getBooleanAttribute("shiftjis", tagElement)) { defineFontInfo.setShiftJIS(true); } if (RecordXMLReader.getBooleanAttribute("bold", tagElement)) { defineFontInfo.setBold(true); } if (RecordXMLReader.getBooleanAttribute("italic", tagElement)) { defineFontInfo.setItalic(true); } if (RecordXMLReader.getBooleanAttribute("smalltext", tagElement)) { defineFontInfo.setSmallText(true); } return defineFontInfo; }