Example usage for org.jdom2 Element setAttribute

List of usage examples for org.jdom2 Element setAttribute

Introduction

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

Prototype

public Element setAttribute(final String name, final String value) 

Source Link

Document

This sets an attribute value for this element.

Usage

From source file:at.ac.tuwien.ims.latex2mobiformulaconv.converter.mathml2html.elements.layout.Mroot.java

License:Open Source License

@Override
public Element render(FormulaElement parent, List<FormulaElement> siblings) {

    Element mrootSpan = new Element("span");
    mrootSpan.setAttribute("class", "mroot");

    if (degree != null) {
        Element indexSpan = new Element("span");
        indexSpan.setAttribute("class", "mroot-degree");

        indexSpan.addContent(degree.render(null, null));

        mrootSpan.addContent(indexSpan);
    }//  w ww  .  j  a  v a  2s. c  o  m

    // Root symbol
    Element mrootSymbol = new Element("span");
    mrootSymbol.setAttribute("class", "mroot-symbol");
    Mtext sqrtSymbol = new Mtext();
    sqrtSymbol.setValue(ROOT_SYMBOL);
    mrootSymbol.addContent(sqrtSymbol.render(null, null));
    mrootSpan.addContent(mrootSymbol);

    Element mrootTopbar = new Element("span");
    mrootTopbar.setAttribute("class", "mroot-topbar");

    // base
    Element baseSpan = new Element("span");
    baseSpan.setAttribute("class", "mroot-base");
    baseSpan.addContent(base.render(null, null));
    mrootTopbar.addContent(baseSpan);

    mrootSpan.addContent(mrootTopbar);

    return mrootSpan;
}

From source file:at.ac.tuwien.ims.latex2mobiformulaconv.converter.mathml2html.elements.layout.Mrow.java

License:Open Source License

@Override
public Element render(FormulaElement parent, List<FormulaElement> siblings) {
    if (list.isEmpty()) {
        Element nothing = new Element("span");
        nothing.setAttribute("class", "nothing");
        nothing.setText(" ");
        return nothing;
    }/*  w ww . j a va2s.  c om*/

    if (list.size() == 1) {
        // MathML2 3.3.1.2.1 mrow of one argument
        // http://www.w3.org/TR/MathML2/chapter3.html#presm.mrow
        // MathML renderers are required to treat an mrow element containing exactly one argument as equivalent
        // in all ways to the single argument occurring alone,
        // provided there are no attributes on the mrow element's start tag.
        return list.get(0).render(parent, siblings);
    }

    Element span = new Element("span");
    span.setAttribute("class", "mrow");

    Iterator<FormulaElement> iterator = list.iterator();
    while (iterator.hasNext()) {
        FormulaElement cur = iterator.next();
        Element html = cur.render(this, list);
        if (html != null) {
            span.addContent(html);
        } else {
            logger.debug("HTML is NULL: " + cur.getClass().toString());
        }
    }
    return span;
}

From source file:at.ac.tuwien.ims.latex2mobiformulaconv.converter.mathml2html.elements.layout.Mstyle.java

License:Open Source License

@Override
public Element render(FormulaElement parent, List<FormulaElement> siblings) {
    Element span = new Element("span");

    // set style classes
    String cssClass = "mstyle";
    if (style != null && style.isEmpty() == false) {
        cssClass += " mathvariant-" + style;
    }//from   www  .j a v a  2  s. c o  m

    span.setAttribute("class", cssClass);

    if (base.isEmpty() == false) {
        for (FormulaElement e : base) {
            span.addContent(e.render(null, null));
        }
    }
    return span;
}

From source file:at.ac.tuwien.ims.latex2mobiformulaconv.converter.mathml2html.elements.scriptlimit.Mover.java

License:Open Source License

@Override
public Element render(FormulaElement parent, List<FormulaElement> siblings) {
    Element mainDiv = new Element("div");
    mainDiv.setAttribute("class", "mover");

    // Siblings/*from w ww  . ja  va 2 s. c o m*/
    List<FormulaElement> content = new ArrayList<>();
    content.add(base);
    content.add(overscript);

    Element baseDiv = new Element("div");
    baseDiv.addContent(base.render(this, content));
    baseDiv.setAttribute("class", "base");

    Element overscriptDiv = new Element("div");
    overscriptDiv.setAttribute("class", "overscript");
    overscriptDiv.addContent(overscript.render(this, content));

    mainDiv.addContent(overscriptDiv);
    mainDiv.addContent(baseDiv);

    return mainDiv;
}

From source file:at.ac.tuwien.ims.latex2mobiformulaconv.converter.mathml2html.elements.scriptlimit.Msub.java

License:Open Source License

@Override
public Element render(FormulaElement parent, List<FormulaElement> siblings) {
    Element msubSpan = new Element("span");
    msubSpan.setAttribute("class", "msub");

    // Add base content
    msubSpan.addContent(base.render(null, null));

    // Add subscript content
    Element sub = new Element("sub");
    sub.addContent(subscript.render(null, null));
    msubSpan.addContent(sub);// ww  w .  jav a  2  s.  co m

    return msubSpan;
}

From source file:at.ac.tuwien.ims.latex2mobiformulaconv.converter.mathml2html.elements.scriptlimit.Msubsup.java

License:Open Source License

@Override
public Element render(FormulaElement parent, List<FormulaElement> siblings) {
    Element msubsupSpan = new Element("span");
    msubsupSpan.setAttribute("class", "msubsup");

    // Add base content
    msubsupSpan.addContent(base.render(null, null));

    // Add subscript content
    Element sup = new Element("sup");
    sup.addContent(superscript.render(null, null));
    msubsupSpan.addContent(sup);//from  w  ww . j a  v a 2 s  . c  om

    // Add superscript content
    Element sub = new Element("sub");
    sub.addContent(subscript.render(null, null));
    msubsupSpan.addContent(sub);

    return msubsupSpan;
}

From source file:at.ac.tuwien.ims.latex2mobiformulaconv.converter.mathml2html.elements.scriptlimit.Msup.java

License:Open Source License

@Override
public Element render(FormulaElement parent, List<FormulaElement> siblings) {
    Element msuperSpan = new Element("span");
    msuperSpan.setAttribute("class", "msup");

    // Add base content
    if (base != null) {
        Element baseElement = base.render(null, null);
        msuperSpan.addContent(baseElement);
    }//w w  w. ja va2  s . com

    // Add superscript content
    Element sub = new Element("sup");
    sub.addContent(superscript.render(null, null));
    msuperSpan.addContent(sub);

    return msuperSpan;
}

From source file:at.ac.tuwien.ims.latex2mobiformulaconv.converter.mathml2html.elements.scriptlimit.Munder.java

License:Open Source License

@Override
public Element render(FormulaElement parent, List<FormulaElement> siblings) {
    Element mainDiv = new Element("div");
    mainDiv.setAttribute("class", "munder");

    // Siblings//from  ww  w . j  a  v  a 2  s. co  m
    List<FormulaElement> content = new ArrayList<>();
    content.add(base);
    content.add(underscript);

    Element baseDiv = new Element("div");
    baseDiv.addContent(base.render(this, content));
    baseDiv.setAttribute("class", "base");
    mainDiv.addContent(baseDiv);

    Element underscriptDiv = new Element("div");
    underscriptDiv.setAttribute("class", "underscript");
    underscriptDiv.addContent(underscript.render(this, content));
    mainDiv.addContent(underscriptDiv);

    return mainDiv;
}

From source file:at.ac.tuwien.ims.latex2mobiformulaconv.converter.mathml2html.elements.tablesmatrices.Mtable.java

License:Open Source License

@Override
public Element render(FormulaElement parent, List<FormulaElement> siblings) {
    Element mtableDiv = new Element("div");
    mtableDiv.setAttribute("class", "mtable");

    // create Table
    Element table = new Element("table");

    // Matrix / Table parenthesis
    if (parent != null && parent instanceof Mfenced) {
        Mfenced mfenced = (Mfenced) parent;
        if (mfenced.getOpened().equals("(") && mfenced.getClosed().equals(")")) {
            table.setAttribute("class", "pmatrix");
        }//from  w ww  . jav  a2 s.c  o  m
        if (mfenced.getOpened().equals("[") && mfenced.getClosed().equals("]")) {
            table.setAttribute("class", "bmatrix");
        }
        if (mfenced.getOpened().equals("{") && mfenced.getClosed().equals("}")) {
            table.setAttribute("class", "pmatrix"); // intentionally pmatrix for curved border corners
            mtableDiv.setAttribute("class", mtableDiv.getAttributeValue("class") + " mtable-Bmatrix");
        }
        if (mfenced.getOpened().equals("|") && mfenced.getClosed().equals("|")) {
            table.setAttribute("class", "vmatrix");
        }
        if (mfenced.getOpened().equals("") && mfenced.getClosed().equals("")) {
            table.setAttribute("class", "Vmatrix");
        }

    }

    // evaluate Rows
    for (int i = 0; i < rows.size(); i++) {
        table.addContent(rows.get(i).render(null, null));
    }

    mtableDiv.addContent(table);

    return mtableDiv;
}

From source file:at.ac.tuwien.ims.latex2mobiformulaconv.converter.mathml2html.elements.token.Mspace.java

License:Open Source License

@Override
public Element render(FormulaElement parent, List<FormulaElement> siblings) {
    Element span = new Element("span");
    span.setAttribute("class", "mspace");

    String style = "width: " + width.toString() + "; height: " + height.toString() + ";";
    span.setAttribute("style", style);

    span.setText(" ");
    return span;//from  w w  w  .  j a v  a  2  s.c  o  m
}