Example usage for org.jdom2 Element getText

List of usage examples for org.jdom2 Element getText

Introduction

In this page you can find the example usage for org.jdom2 Element getText.

Prototype

public String getText() 

Source Link

Document

Returns the textual content directly held under this element as a string.

Usage

From source file:com.ardor3d.extension.model.collada.jdom.ColladaNodeUtils.java

License:Open Source License

/**
 * Parse an asset element into an AssetData object.
 * //from w  ww  .j  a  v  a  2s .c o  m
 * @param asset
 * @return
 */
@SuppressWarnings("unchecked")
public AssetData parseAsset(final Element asset) {
    final AssetData assetData = new AssetData();

    for (final Element child : asset.getChildren()) {
        if ("contributor".equals(child.getName())) {
            parseContributor(assetData, child);
        } else if ("created".equals(child.getName())) {
            assetData.setCreated(child.getText());
        } else if ("keywords".equals(child.getName())) {
            assetData.setKeywords(child.getText());
        } else if ("modified".equals(child.getName())) {
            assetData.setModified(child.getText());
        } else if ("revision".equals(child.getName())) {
            assetData.setRevision(child.getText());
        } else if ("subject".equals(child.getName())) {
            assetData.setSubject(child.getText());
        } else if ("title".equals(child.getName())) {
            assetData.setTitle(child.getText());
        } else if ("unit".equals(child.getName())) {
            final String name = child.getAttributeValue("name");
            if (name != null) {
                assetData.setUnitName(name);
            }
            final String meter = child.getAttributeValue("meter");
            if (meter != null) {
                assetData.setUnitMeter(Float.parseFloat(meter.replace(",", ".")));
            }
        } else if ("up_axis".equals(child.getName())) {
            final String axis = child.getText();
            if ("X_UP".equals(axis)) {
                assetData.setUpAxis(new Vector3());
            } else if ("Y_UP".equals(axis)) {
                assetData.setUpAxis(Vector3.UNIT_Y);
            } else if ("Z_UP".equals(axis)) {
                assetData.setUpAxis(Vector3.UNIT_Z);
            }
        }
    }

    return assetData;
}

From source file:com.ardor3d.extension.model.collada.jdom.ColladaNodeUtils.java

License:Open Source License

@SuppressWarnings("unchecked")
private void parseContributor(final AssetData assetData, final Element contributor) {
    for (final Element child : contributor.getChildren()) {
        if ("author".equals(child.getName())) {
            assetData.setAuthor(child.getText());
        } else if ("authoringTool".equals(child.getName())) {
            assetData.setCreated(child.getText());
        } else if ("comments".equals(child.getName())) {
            assetData.setComments(child.getText());
        } else if ("copyright".equals(child.getName())) {
            assetData.setCopyright(child.getText());
        } else if ("source_data".equals(child.getName())) {
            assetData.setSourceData(child.getText());
        }/* ww  w . j  ava  2s. c om*/
    }
}

From source file:com.astronomy.project.Tag.java

/**
 * /*  w w w . j  ava2 s .  c o m*/
 * @param name Tag name
 * @param e XML element for tag
 */
public Tag(String name, Element e) {
    this.name = name;
    value = new SimpleStringProperty(e.getText());
}

From source file:com.athena.chameleon.engine.core.PDFDocGenerator.java

License:Apache License

/**
 * //from w w w . j a  v  a2  s. c  o m
 * ? ??  Chatper Data ? (data class : AnalyzeDefinition)
 * 
 * @param writer
 * @param chapterE
 * @param cNum
 * @param pdf
 * @param builder
 * @param data
 * @param upload
 * @throws Exception
 */
public static void addChapterForDynamic(PdfWriter writer, Element chapterE, int cNum, Document pdf,
        SAXBuilder builder, AnalyzeDefinition data, Upload upload) throws Exception {

    //chapter  xml 
    File chapterXml = new File(PDFDocGenerator.class.getResource(chapterE.getText()).getFile());
    org.jdom2.Document chapterDoc = builder.build(chapterXml);

    Element root = chapterDoc.getRootElement();

    //?? ? ??  setting
    setDynamicSection(root, data, upload);

    //chapter ?
    Chapter chapter = PDFWriterUtil.getChapter(root.getAttributeValue("title"), cNum);

    PDFWriterUtil.setElement(writer, chapter, root);

    pdf.add(chapter);
}

From source file:com.athena.chameleon.engine.core.PDFDocGenerator.java

License:Apache License

/**
 * ? ??  Chatper Data ? (data class : PDFMetadataDefinition)
 * //w w w  .  j  av  a 2s. c  om
 * @param writer
 * @param chapterE
 * @param cNum
 * @param pdf
 * @param builder
 * @param data
 * @param upload
 * @throws Exception
 */
public static void addChapterForDynamic(PdfWriter writer, Element chapterE, int cNum, Document pdf,
        SAXBuilder builder, PDFMetadataDefinition data, Upload upload) throws Exception {

    //chapter  xml 
    File chapterXml = new File(PDFDocGenerator.class.getResource(chapterE.getText()).getFile());
    org.jdom2.Document chapterDoc = builder.build(chapterXml);

    Element root = chapterDoc.getRootElement();

    //?? ? ??  setting
    setDynamicSection(root, data, upload);

    //chapter ?
    Chapter chapter = PDFWriterUtil.getChapter(root.getAttributeValue("title"), cNum);

    PDFWriterUtil.setElement(writer, chapter, root);

    pdf.add(chapter);
}

From source file:com.athena.chameleon.engine.core.PDFDocGenerator.java

License:Apache License

/**
 * // www. j  av a2s  .c om
 *  ?
 * 
 * @param writer
 * @param chapterE
 * @param cNum
 * @param pdf
 * @param builder
 * @throws Exception
 */
public static void addChapter(PdfWriter writer, Element chapterE, int cNum, Document pdf, SAXBuilder builder)
        throws Exception {

    //chapter  xml 
    File chapterXml = new File(PDFDocGenerator.class.getResource(chapterE.getText()).getFile());
    org.jdom2.Document chapterDoc = builder.build(chapterXml);

    //chapter ?
    Element root = chapterDoc.getRootElement();
    Chapter chapter = PDFWriterUtil.getChapter(root.getAttributeValue("title"), cNum);

    PDFWriterUtil.setElement(writer, chapter, root);

    pdf.add(chapter);
}

From source file:com.athena.chameleon.engine.utils.PDFWriterUtil.java

License:Apache License

/**
 * Element Mapping/*w ww. j a v  a2  s  .co m*/
 * 
 * @param section section ?
 * @param e element 
 * @return Section
 * @throws Exception
 */
public static Section setElement(PdfWriter writer, Section section, Element e) throws Exception {

    for (org.jdom2.Element e1 : e.getChildren()) {

        if (e1.getName().equals("section")) {
            //  section?   
            setSectionElement(writer, section, e1);

        } else if (e1.getName().equals("text")) {

            /* ? text ?
               attribute : padding -  padding  */
            if (e1.getAttributeValue("padding") != null) {
                Paragraph text = getDefault(e1.getText());
                text.setIndentationLeft(
                        text.getIndentationLeft() + Float.parseFloat(e1.getAttributeValue("padding")));

                section.add(text);
            } else {
                section.add(getDefault(e1.getText()));
            }

        } else if (e1.getName().equals("table")) {
            // ?
            setTable(section, e1);

        } else if (e1.getName().equals("textR")) {
            //?? ? text ?
            section.add(getDefaultRed(e1.getText(), Font.ITALIC));

        } else if (e1.getName().equals("textP")) {
            //? ? text ?
            section.add(getDefaultPoint(e1.getText()));

        } else if (e1.getName().equals("box")) {
            //text box ?
            setBox(section, e1);

        } else if (e1.getName().equals("boxB")) {
            //? ? text box ?
            setBoxB(section, e1);

        } else if (e1.getName().equals("boxW")) {
            //text box ?
            setBoxW(section, e1);

        } else if (e1.getName().equals("list")) {
            //? ?
            setList(section, e1);

        } else if (e1.getName().equals("img")) {
            //? ?
            setImage(section, e1);
        } else if (e1.getName().equals("chart")) {
            // ?
            setChart(writer, section, e1);
        }
    }

    return section;

}

From source file:com.athena.chameleon.engine.utils.PDFWriterUtil.java

License:Apache License

/**
 * /* w  w  w. ja va2s.  c  o m*/
 *  box 
 *
 * @param section box  section ?
 * @param e box   element
 * @throws Exception
 */
public static void setBox(Section section, Element e) throws Exception {

    PdfPTable t = new PdfPTable(1);
    t.setSpacingBefore(1);
    t.setSpacingAfter(12);

    if (e.getAttributeValue("width") != null)
        t.setTotalWidth(Float.parseFloat(e.getAttributeValue("width")));

    PdfPCell cell = new PdfPCell();
    if (e.getAttributeValue("option") != null) {

        ColumnText col = new ColumnText(null);
        for (Element e1 : e.getChildren()) {
            if (e1.getAttributeValue("type").equals("red"))
                col.addText(new Phrase(e1.getText(), fnBoxRed));
            else
                col.addText(new Phrase(e1.getText(), fnBox));
        }
        cell.setColumn(col);

    } else {
        cell.setPhrase(new Phrase(e.getText(), fnBox));
    }

    cell.setPaddingLeft(10);
    cell.setLeading(0.0F, 1.8F);
    cell.setVerticalAlignment(com.itextpdf.text.Element.ALIGN_MIDDLE);
    cell.setBackgroundColor(new BaseColor(238, 236, 225));

    t.addCell(cell);

    section.add(t);

}

From source file:com.athena.chameleon.engine.utils.PDFWriterUtil.java

License:Apache License

/**
 * //from ww w  . j av  a2  s  .com
 * box (Backgroud : Black)
 *
 * @param section box  section ?
 * @param e box   element
 * @throws Exception
 */
public static void setBoxB(Section section, Element e) throws Exception {

    PdfPTable t = new PdfPTable(1);
    t.setSpacingBefore(1);
    t.setSpacingAfter(12);

    if (e.getAttributeValue("width") != null)
        t.setTotalWidth(Float.parseFloat(e.getAttributeValue("width")));

    PdfPCell cell = new PdfPCell();
    if (e.getAttributeValue("option") != null) {

        ColumnText col = new ColumnText(null);
        for (Element e1 : e.getChildren()) {
            if (e1.getAttributeValue("type").equals("red"))
                col.addText(new Phrase(e1.getText(), fnBoxRed));
            else
                col.addText(new Phrase(e1.getText(), fnBoxWhite));
        }
        cell.setColumn(col);

    } else {
        cell.setPhrase(new Phrase(e.getText(), fnBoxWhite));
    }

    cell.setPaddingLeft(10);
    cell.setLeading(0.0F, 1.8F);
    cell.setVerticalAlignment(com.itextpdf.text.Element.ALIGN_MIDDLE);
    cell.setBackgroundColor(new BaseColor(0, 0, 0));

    t.addCell(cell);

    section.add(t);

}

From source file:com.athena.chameleon.engine.utils.PDFWriterUtil.java

License:Apache License

/**
 * /* ww  w . j  av a  2s  .  c o m*/
 * box (Backgroud : White)
 *
 * @param section box  section ?
 * @param e box   element
 * @throws Exception
 */
public static void setBoxW(Section section, Element e) throws Exception {

    PdfPTable t = new PdfPTable(1);
    t.setSpacingBefore(1);
    t.setSpacingAfter(12);

    if (e.getAttributeValue("width") != null)
        t.setTotalWidth(Float.parseFloat(e.getAttributeValue("width")));

    PdfPCell cell = new PdfPCell();
    if (e.getAttributeValue("option") != null) {

        ColumnText col = new ColumnText(null);
        for (Element e1 : e.getChildren()) {
            if (e1.getAttributeValue("type").equals("red"))
                col.addText(new Phrase(e1.getText(), fnBoxRed));
            else
                col.addText(new Phrase(e1.getText(), fnBoxBlack));
        }
        cell.setColumn(col);

    } else {
        cell.setPhrase(new Phrase(e.getText(), fnBoxBlack));
    }

    cell.setPaddingLeft(10);
    cell.setLeading(0.0F, 1.8F);
    cell.setVerticalAlignment(com.itextpdf.text.Element.ALIGN_MIDDLE);
    cell.setBackgroundColor(new BaseColor(255, 255, 255));

    t.addCell(cell);

    section.add(t);

}