Class Sub<T extends Sub<T>>

Direct Known Subclasses:
Subscript

public class Sub<T extends Sub<T>> extends PhrasingContentElement<T>
Represents an HTML <sub> element for displaying subscript text.

This class provides functionality to create subscript text, which appears half a character below the normal line and is often rendered in a smaller font. Subscripts are commonly used in mathematical formulas, chemical formulas, and other technical notations where characters need to appear below the baseline.

Features:

  • Renders text below the normal baseline
  • Typically displayed in a smaller font size
  • Supports text initialization through constructor
  • Commonly used for mathematical and chemical formulas
  • Extends
    invalid reference
    TextElement
    for text content management

Usage:


 // Create subscript for chemical formula
 Span formula = new Span();
 formula.addElement(new Text("H"));
 formula.addElement(new Sub("2"));
 formula.addElement(new Text("O"));
 // Renders as: H₂O

 // Create subscript for mathematical notation
 Span math = new Span();
 math.addElement(new Text("x"));
 math.addElement(new Sub("1"));
 // Renders as: x₁

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

    • Sub

      public Sub()
      Constructs an empty Sub element.

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

      invalid reference
      TextElement
      .

    • Sub

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

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

      Parameters:
      text - the text content to display as subscript