Class Sup<T extends Sup<T>>

Direct Known Subclasses:
Superscript

public class Sup<T extends Sup<T>> extends PhrasingContentElement<T>
Represents an HTML <sup> element for displaying superscript text.

This class provides functionality to create superscript text, which appears half a character above the normal line and is often rendered in a smaller font. Superscripts are commonly used in mathematical formulas, scientific notation, ordinal numbers, footnote references, and exponents where characters need to appear above the baseline.

Features:

  • Renders text above the normal baseline
  • Typically displayed in a smaller font size
  • Supports text initialization through constructor
  • Commonly used for exponents, footnotes, and ordinal indicators
  • Extends
    invalid reference
    TextElement
    for text content management

Usage:


 // Create superscript for mathematical exponent
 Span math = new Span();
 math.addElement(new Text("x"));
 math.addElement(new Sup("2"));
 // Renders as: x²

 // Create superscript for ordinal number
 Span ordinal = new Span();
 ordinal.addElement(new Text("1"));
 ordinal.addElement(new Sup("st"));
 // Renders as: 1ˢᵗ

 // Create superscript for footnote reference
 Span footnote = new Span();
 footnote.addElement(new Text("See reference"));
 footnote.addElement(new Sup("1"));
 // Renders as: See reference¹

 // Empty superscript for dynamic content
 Sup sup = new Sup();
 sup.setText("TM");
 
Since:
2007
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • Sup

      public Sup()
      Constructs an empty Sup element.

      Creates a new <sup> element with no initial text content. Text can be added later using methods inherited from

      invalid reference
      TextElement
      .

    • Sup

      public Sup(String text)
      Constructs a Sup element with the specified text content.

      Creates a new <sup> element containing the provided text, which will be rendered above the normal baseline.

      Parameters:
      text - the text content to display as superscript