Class ReferenceLayout


public class ReferenceLayout extends StyledElement<ReferenceLayout>
A layout for API/class reference documentation with method listing and detail panels.

ReferenceLayout is designed for displaying API documentation, class references, or any structured reference material. It provides a summary/index sidebar with a scrollable detail area.

Structure:

 ┌────────────────────────────────────────────────────┐
 │                    Header                          │
 │                (Class/API name)                    │
 ├─────────┬──────────────────────────────────────────┤
 │  Index  │                                          │
 │         │           Detail Content                 │
 │ Method1 │                                          │
 │ Method2 │     (method signatures, params,          │
 │ Method3 │      descriptions, examples)             │
 │  ...    │                                          │
 └─────────┴──────────────────────────────────────────┘
 

Use Cases:

  • API documentation (class/method reference)
  • Component documentation
  • Configuration reference
  • Glossary or dictionary layouts

Usage:


 // API class documentation
 ReferenceLayout classRef = new ReferenceLayout();
 classRef.setHeader(new H1("MyClass"));
 classRef.setDescription(classDescription);

 // Add methods to index
 classRef.addEntry("constructor", "MyClass()", constructorDetails);
 classRef.addEntry("getValue", "getValue()", getValueDetails);
 classRef.addEntry("setValue", "setValue(String value)", setValueDetails);

 // With custom widths
 ReferenceLayout api = new ReferenceLayout();
 api.setIndexWidth(180);
 
Since:
2025
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • ReferenceLayout

      public ReferenceLayout()
      Constructs a ReferenceLayout with default settings.
  • Method Details

    • initialize

      protected void initialize()
      Builds the element tree for the layout.
      Overrides:
      initialize in class StyledElement<ReferenceLayout>
    • setHeader

      public ReferenceLayout setHeader(Element<?> header)
      Sets the header content (class/API name, etc.).
      Parameters:
      header - the header element
      Returns:
      this ReferenceLayout for method chaining
    • setDescription

      public ReferenceLayout setDescription(Element<?> description)
      Sets the description content (class description, overview, etc.).
      Parameters:
      description - the description element
      Returns:
      this ReferenceLayout for method chaining
    • addEntry

      public ReferenceLayout addEntry(String id, String label, Element<?> detail)
      Adds an entry to the reference (method, property, etc.).
      Parameters:
      id - the unique identifier for this entry (used as anchor)
      label - the display label in the index
      detail - the detail content for this entry
      Returns:
      this ReferenceLayout for method chaining
    • addEntry

      public ReferenceLayout addEntry(String id, Element<?> detail)
      Adds an entry with just an ID (label defaults to ID).
      Parameters:
      id - the unique identifier (also used as label)
      detail - the detail content for this entry
      Returns:
      this ReferenceLayout for method chaining
    • setIndexWidth

      public ReferenceLayout setIndexWidth(int width)
      Sets the index pane width.
      Parameters:
      width - the width in pixels
      Returns:
      this ReferenceLayout for method chaining
    • setIndexWidth

      public ReferenceLayout setIndexWidth(String width)
      Sets the index pane width.
      Parameters:
      width - the width value (e.g., "200px", "15rem")
      Returns:
      this ReferenceLayout for method chaining
    • noStickyIndex

      public ReferenceLayout noStickyIndex()
      Disables sticky positioning for the index.
      Returns:
      this ReferenceLayout for method chaining
    • setHeaderBackground

      public ReferenceLayout setHeaderBackground(String color)
      Sets the header background color.
      Parameters:
      color - the background color
      Returns:
      this ReferenceLayout for method chaining
    • setIndexBackground

      public ReferenceLayout setIndexBackground(String color)
      Sets the index background color.
      Parameters:
      color - the background color
      Returns:
      this ReferenceLayout for method chaining
    • setDetailBackground

      public ReferenceLayout setDetailBackground(String color)
      Sets the detail background color.
      Parameters:
      color - the background color
      Returns:
      this ReferenceLayout for method chaining
    • setHeaderPadding

      public ReferenceLayout setHeaderPadding(int padding)
      Sets padding for the header.
      Parameters:
      padding - the padding in pixels
      Returns:
      this ReferenceLayout for method chaining
    • setHeaderPadding

      public ReferenceLayout setHeaderPadding(String padding)
      Sets padding for the header.
      Parameters:
      padding - the padding value (e.g., "1rem", "16px")
      Returns:
      this ReferenceLayout for method chaining
    • setIndexPadding

      public ReferenceLayout setIndexPadding(int padding)
      Sets padding for the index.
      Parameters:
      padding - the padding in pixels
      Returns:
      this ReferenceLayout for method chaining
    • setIndexPadding

      public ReferenceLayout setIndexPadding(String padding)
      Sets padding for the index.
      Parameters:
      padding - the padding value (e.g., "1rem", "16px")
      Returns:
      this ReferenceLayout for method chaining
    • setDetailPadding

      public ReferenceLayout setDetailPadding(int padding)
      Sets padding for the detail area.
      Parameters:
      padding - the padding in pixels
      Returns:
      this ReferenceLayout for method chaining
    • setDetailPadding

      public ReferenceLayout setDetailPadding(String padding)
      Sets padding for the detail area.
      Parameters:
      padding - the padding value (e.g., "1rem", "16px")
      Returns:
      this ReferenceLayout for method chaining
    • setIndexItemGap

      public ReferenceLayout setIndexItemGap(int gap)
      Sets the gap between index items.
      Parameters:
      gap - the gap in pixels
      Returns:
      this ReferenceLayout for method chaining
    • setDetailItemGap

      public ReferenceLayout setDetailItemGap(String gap)
      Sets the gap between detail items.
      Parameters:
      gap - the gap value (e.g., "2rem", "24px")
      Returns:
      this ReferenceLayout for method chaining
    • getHeaderPane

      public Div getHeaderPane()
      Returns the header pane for customization.
      Returns:
      the header pane
    • getDescriptionPane

      public Div getDescriptionPane()
      Returns the description pane for customization.
      Returns:
      the description pane
    • getIndexPane

      public Div getIndexPane()
      Returns the index pane for customization.
      Returns:
      the index pane
    • getDetailPane

      public Div getDetailPane()
      Returns the detail pane for customization.
      Returns:
      the detail pane
    • getIndexItems

      public VStack getIndexItems()
      Returns the index items container.
      Returns:
      the index items VStack
    • getDetailItems

      public VStack getDetailItems()
      Returns the detail items container.
      Returns:
      the detail items VStack