Class Figure<T extends Figure<T>>


public class Figure<T extends Figure<T>> extends StyledContainerElement<T>
Represents an HTML <figure> element.

The <figure> element specifies self-contained content, such as illustrations, diagrams, photos, code listings, or other content that is referenced from the main content but could be moved to another location without affecting the flow of the document. It is typically used in conjunction with a <figcaption> element to provide a caption or legend for the content.

Features:

  • Semantic container for self-contained content
  • Commonly used with images, diagrams, and code snippets
  • Supports optional <figcaption> child element
  • Enhances document structure and accessibility

Usage:


 // Create a figure with image and caption
 Figure figure = new Figure();
 Image img = new Image("photo.jpg", "Beach sunset");
 FigCaption caption = new FigCaption("Sunset at the beach");

 figure.addElement(img);
 figure.addElement(caption);

 // Create a figure with code listing
 Figure codeFigure = new Figure();
 Pre codeBlock = new Pre();
 codeBlock.addText("function hello() { return 'world'; }");
 FigCaption codeCaption = new FigCaption("Listing 1: Hello World Function");

 codeFigure.addElement(codeBlock);
 codeFigure.addElement(codeCaption);
 
Since:
2007
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • Figure

      public Figure()
      Constructs an empty <figure> element.

      Creates a figure element without initial content. Child elements such as images, videos, code blocks, and optional captions should be added using the addElement() method.