Package com.oorian.html.layout
Class ComposableLayout
java.lang.Object
A flexible slot-based layout system for user-defined layouts.
ComposableLayout allows creating custom layouts by defining named slots and assigning content to them. It uses CSS Grid for flexible positioning of slots.
Use Cases:
- Custom page layouts with multiple regions
- Dashboard layouts with configurable panels
- Template-based layouts
- Complex layouts that don't fit standard patterns
Usage:
// Define a custom layout with named slots
ComposableLayout layout = new ComposableLayout();
layout.setGridTemplate("'header header' auto 'sidebar main' 1fr 'footer footer' auto / 250px 1fr");
// Assign content to slots
layout.slot("header", headerContent);
layout.slot("sidebar", sidebarContent);
layout.slot("main", mainContent);
layout.slot("footer", footerContent);
// Simple two-column layout
ComposableLayout twoCol = ComposableLayout.columns(2);
twoCol.slot("col1", leftContent);
twoCol.slot("col2", rightContent);
// Dashboard with custom areas
ComposableLayout dashboard = new ComposableLayout();
dashboard.defineArea("stats", 1, 1, 1, 4); // Row 1, spans 4 columns
dashboard.defineArea("chart", 2, 1, 1, 2); // Row 2, spans 2 columns
dashboard.defineArea("list", 2, 3, 1, 2); // Row 2, columns 3-4
- Since:
- 2025
- Version:
- 1.0
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs an empty ComposableLayout.ComposableLayout(int columns) Constructs a ComposableLayout with the specified number of equal columns. -
Method Summary
Modifier and TypeMethodDescriptionfinal ComposableLayoutSets auto-fill columns with a minimum width (responsive grid).final ComposableLayoutSets auto-fit columns with a minimum width (responsive grid).static ComposableLayoutcolumns(int columns) Creates a ComposableLayout with the specified number of equal columns.defineArea(String name, int row, int column) Defines a named area at the specified grid position.defineArea(String name, int row, int column, int rowSpan, int colSpan) Defines a named area at the specified grid position with span.Returns the slot container for the given name.booleanChecks if a slot with the given name exists.removeSlot(String name) Removes a slot and its content.static ComposableLayoutrows(int rows) Creates a ComposableLayout with the specified number of rows.final ComposableLayoutsetColumns(int columns) Sets the number of equal-width columns.final ComposableLayoutsetGap(int gap) Sets the gap between grid cells.final ComposableLayoutsetGap(int rowGap, int columnGap) Sets separate row and column gaps.final ComposableLayoutSets the gap between grid cells.final ComposableLayoutsetGridAreas(String areas) Sets grid-template-areas for named area placement.final ComposableLayoutsetGridColumns(String columns) Sets grid-template-columns for column sizing.final ComposableLayoutsetGridRows(String rows) Sets grid-template-rows for row sizing.final ComposableLayoutsetGridTemplate(String template) Sets the full CSS grid-template property for complex layouts.final ComposableLayoutsetRows(int rows) Sets the number of equal-height rows.Sets content into a named slot.Methods inherited from class com.oorian.html.StyledElement
addClass, addStyle, addStyle, addStyleAttribute, addTransition, animate, clearTransitions, getActiveStyle, getCssClass, getDisabledStyle, getFocusStyle, getFocusVisibleStyle, getHoverStyle, getHtml, getStyle, getStyleAttribute, hidden, hide, initialize, isDisplayed, isTransitionForwardActive, onHide, onRemovedFromPage, onShow, removeClass, setActiveStyle, setAlignContent, setAlignContent, setAlignItems, setAlignItems, setAlignSelf, setAlignSelf, setAnimation, setAnimationDelay, setAnimationDelay, setAnimationDelay, setAnimationDirection, setAnimationDirection, setAnimationDuration, setAnimationDuration, setAnimationDuration, setAnimationFillMode, setAnimationFillMode, setAnimationIterationCount, setAnimationIterationCount, setAnimationIterationCount, setAnimationName, setAnimationPlayState, setAnimationPlayState, setAnimationTimingFunction, setAnimationTimingFunction, setAnimationTimingFunction, setAnimationTimingFunction, setBackdropFilter, setBackdropFilter, setBackfaceVisibility, setBackfaceVisibility, setBackground, setBackground, setBackgroundAttachment, setBackgroundAttachment, setBackgroundBlendMode, setBackgroundBlendMode, setBackgroundClip, setBackgroundClip, setBackgroundColor, setBackgroundColor, setBackgroundColor, setBackgroundImage, setBackgroundImage, setBackgroundOrigin, setBackgroundOrigin, setBackgroundPosition, setBackgroundPosition, setBackgroundPosition, setBackgroundPosition, setBackgroundPosition, setBackgroundRepeat, setBackgroundRepeat, setBackgroundSize, setBackgroundSize, setBackgroundSize, setBackgroundSize, setBackgroundSize, setBlur, setBorder, setBorder, setBorder, setBorder, setBorder, setBorder, setBorder, setBorder, setBorder, setBorderBottom, setBorderBottom, setBorderBottom, setBorderBottom, setBorderBottom, setBorderBottom, setBorderBottom, setBorderBottom, setBorderBottomColor, setBorderBottomColor, setBorderBottomLeftRadius, setBorderBottomLeftRadius, setBorderBottomLeftRadius, setBorderBottomRightRadius, setBorderBottomRightRadius, setBorderBottomRightRadius, setBorderBottomStyle, setBorderBottomStyle, setBorderBottomWidth, setBorderBottomWidth, setBorderBottomWidth, setBorderBottomWidth, setBorderColor, setBorderColor, setBorderColor, setBorderColor, setBorderImage, setBorderImage, setBorderImageOutset, setBorderImageRepeat, setBorderImageSlice, setBorderImageSource, setBorderImageWidth, setBorderLeft, setBorderLeft, setBorderLeft, setBorderLeft, setBorderLeft, setBorderLeft, setBorderLeft, setBorderLeft, setBorderLeftColor, setBorderLeftColor, setBorderLeftStyle, setBorderLeftStyle, setBorderLeftWidth, setBorderLeftWidth, setBorderLeftWidth, setBorderLeftWidth, setBorderRadius, setBorderRadius, setBorderRadius, setBorderRadius, setBorderRadius, setBorderRadius, setBorderRight, setBorderRight, setBorderRight, setBorderRight, setBorderRight, setBorderRight, setBorderRight, setBorderRight, setBorderRightColor, setBorderRightColor, setBorderRightStyle, setBorderRightStyle, setBorderRightWidth, setBorderRightWidth, setBorderRightWidth, setBorderRightWidth, setBorderStyle, setBorderStyle, setBorderTop, setBorderTop, setBorderTop, setBorderTop, setBorderTop, setBorderTop, setBorderTop, setBorderTop, setBorderTopColor, setBorderTopColor, setBorderTopLeftRadius, setBorderTopLeftRadius, setBorderTopLeftRadius, setBorderTopRightRadius, setBorderTopRightRadius, setBorderTopRightRadius, setBorderTopStyle, setBorderTopStyle, setBorderTopWidth, setBorderTopWidth, setBorderTopWidth, setBorderTopWidth, setBorderWidth, setBorderWidth, setBorderWidth, setBorderWidth, setBorderWidth, setBorderWidth, setBorderWidth, setBottom, setBottom, setBottom, setBoxShadow, setBoxShadow, setBoxShadow, setBoxShadow, setBoxShadow, setBoxSizing, setBoxSizing, setBreakAfter, setBreakBefore, setBreakInside, setBrightness, setClass, setClear, setClear, setClip, setClipPath, setClipPath, setColGap, setColGap, setColor, setColor, setColumnCount, setColumnCount, setColumnFill, setColumnFill, setColumnGap, setColumnRule, setColumnRuleColor, setColumnRuleColor, setColumnRuleStyle, setColumnRuleStyle, setColumnRuleWidth, setColumnRuleWidth, setColumns, setColumns, setColumns, setColumnSpan, setColumnWidth, setColumnWidth, setColumnWidth, setContrast, setCounterIncrement, setCounterReset, setCursor, setCursor, setDirection, setDirection, setDisabledStyle, setDisplay, setDisplay, setFilter, setFilter, setFilterOpacity, setFlex, setFlexBasis, setFlexDirection, setFlexDirection, setFlexFlow, setFlexGrow, setFlexGrow, setFlexShrink, setFlexShrink, setFlexWrap, setFlexWrap, setFloat, setFloat, setFocusStyle, setFocusVisibleStyle, setFont, setFont, setFont, setFont, setFont, setFont, setFont, setFont, setFont, setFont, setFont, setFont, setFontFace, setFontFamily, setFontFamily, setFontFeatureSettings, setFontKerning, setFontLanguageOverride, setFontSize, setFontSize, setFontSize, setFontSizeAdjust, setFontStretch, setFontStretch, setFontStyle, setFontStyle, setFontSynthesis, setFontVariant, setFontVariant, setFontVariantAlternates, setFontVariantCaps, setFontVariantEastAsian, setFontVariantLigatures, setFontVariantNumeric, setFontVariantPosition, setFontWeight, setFontWeight, setGap, setGrayscale, setHangingPunctuation, setHangingPunctuation, setHeight, setHeight, setHeight, setHoverStyle, setHueRotate, setHyphens, setImageOrientation, setImageRendering, setImageResolution, setImeMode, setInvert, setJustifyContent, setJustifyContent, setKeyFrames, setLeft, setLeft, setLeft, setLetterSpacing, setLetterSpacing, setLetterSpacing, setLetterSpacing, setLineBreak, setLineHeight, setLineHeight, setLineHeight, setLineHeight, setMargin, setMargin, setMargin, setMargin, setMargin, setMarginBottom, setMarginBottom, setMarginBottom, setMarginLeft, setMarginLeft, setMarginLeft, setMarginRight, setMarginRight, setMarginRight, setMarginTop, setMarginTop, setMarginTop, setMark, setMarkAfter, setMarkBefore, setMarks, setMarqueeDirection, setMarqueePlayCount, setMarqueeSpeed, setMarqueeStyle, setMask, setMaskType, setMaxHeight, setMaxHeight, setMaxHeight, setMaxHeightToWindowHeight, setMaxWidth, setMaxWidth, setMaxWidth, setMaxWidthToWindowWidth, setMinHeight, setMinHeight, setMinHeight, setMinHeightToWindowHeight, setMinWidth, setMinWidth, setMinWidth, setMinWidthToWindowWidth, setNavDown, setNavIndex, setNavIndex, setNavLeft, setNavRight, setNavUp, setObjectFit, setObjectPosition, setOnClickNavigateBack, setOnClickNavigateBack, setOnClickNavigateBack, setOnClickNavigateForward, setOnClickNavigateForward, setOnClickNavigateForward, setOnClickNavigateTo, setOnDblClick, setOnDblClickChange, setOpacity, setOpacity, setOrder, setOrder, setOrphans, setOutline, setOutline, setOutline, setOutline, setOutlineColor, setOutlineColor, setOutlineOffset, setOutlineOffset, setOutlineOffset, setOutlineStyle, setOutlineStyle, setOutlineWidth, setOutlineWidth, setOutlineWidth, setOutlineWidth, setOverflow, setOverflow, setOverflow, setOverflowWrap, setOverflowX, setOverflowX, setOverflowY, setOverflowY, setPadding, setPadding, setPadding, setPadding, setPadding, setPadding, setPadding, setPadding, setPaddingBottom, setPaddingBottom, setPaddingBottom, setPaddingLeft, setPaddingLeft, setPaddingLeft, setPaddingRight, setPaddingRight, setPaddingRight, setPaddingTop, setPaddingTop, setPaddingTop, setPageBreakAfter, setPageBreakAfter, setPageBreakBefore, setPageBreakBefore, setPageBreakInside, setPageBreakInside, setPerspective, setPerspective, setPerspective, setPerspectiveOrigin, setPerspectiveOrigin, setPerspectiveOrigin, setPerspectiveOrigin, setPhonemes, setPosition, setPosition, setPosition, setPosition, setPosition, setQuotes, setResize, setResize, setResizeToWindowHeight, setResizeToWindowHeight, setResizeToWindowWidth, setRest, setRestAfter, setRestBefore, setRight, setRight, setRight, setRotate, setRotate, setRowGap, setRowGap, setSaturate, setScale, setScale, setSepia, setShow, setSize, setSize, setSize, setSkewX, setSkewY, setStyle, setStyle, setTabSize, setTabSize, setTabSize, setTabSize, setTextAlign, setTextAlign, setTextAlignLast, setTextAlignLast, setTextCombineUpright, setTextCombineWeight, setTextDecoration, setTextDecoration, setTextDecorationColor, setTextDecorationColor, setTextDecorationLine, setTextDecorationLine, setTextDecorationStyle, setTextDecorationStyle, setTextIndent, setTextIndent, setTextIndent, setTextIndent, setTextJustify, setTextJustify, setTextOrientation, setTextOverflow, setTextOverflow, setTextSelectDisabled, setTextShadow, setTextShadow, setTextShadow, setTextShadow, setTextShadow, setTextTransform, setTextTransform, setTextUnderlinePosition, setTop, setTop, setTop, setTransform, setTransform, setTransformOrigin, setTransformOrigin, setTransformOrigin, setTransformOrigin, setTransformOrigin, setTransformStyle, setTransformStyle, setTransition, setTransitionDelay, setTransitionDelay, setTransitionDelay, setTransitionDuration, setTransitionDuration, setTransitionDuration, setTransitionProperty, setTransitionTimingFunction, setTransitionTimingFunction, setTransitionTimingFunction, setTransitionTimingFunction, setTranslateX, setTranslateY, setTranslateZ, setUnicodeBidi, setUnicodeBidi, setVerticalAlign, setVerticalAlign, setVisibility, setVisibility, setVoiceBalance, setVoiceDuration, setVoicePitch, setVoicePitchRange, setVoiceRate, setVoiceStress, setVoiceVolume, setWhiteSpace, setWhiteSpace, setWidows, setWidth, setWidth, setWidth, setWordBreak, setWordBreak, setWordSpacing, setWordSpacing, setWordSpacing, setWordSpacing, setWordWrap, setWordWrap, setWritingMode, setZIndex, setZIndex, show, shown, stopAnimation, transitionForward, transitionForward, transitionReverse, transitionReverse, updateStyle, updateStyle, updateStyleIfChangedMethods inherited from class com.oorian.html.VisualElement
clearOnClick, click, disable, enable, getAccessKey, getAutoCapitalize, getEnterKeyHint, getInputMode, getPopover, getRole, getTabIndex, getTitle, isAutoFocus, isContentEditable, isDisabled, isDraggable, isHidden, isInert, isSpellCheck, onDisabled, onEnabled, setAccessKey, setAriaAtomic, setAriaBusy, setAriaChecked, setAriaCheckedMixed, setAriaControls, setAriaCurrent, setAriaDescribedBy, setAriaDisabled, setAriaErrorMessage, setAriaExpanded, setAriaHasPopup, setAriaHasPopup, setAriaHidden, setAriaInvalid, setAriaLabel, setAriaLabelledBy, setAriaLevel, setAriaLive, setAriaModal, setAriaOwns, setAriaPressed, setAriaRequired, setAriaSelected, setAriaValueRange, setAriaValueText, setAutoCapitalize, setAutoFocus, setConsumeEvent, setContentEditable, setDisabled, setDraggable, setDropAllowed, setEnterKeyHint, setFocus, setHidden, setInert, setInputMode, setOnAnimationCancel, setOnAnimationEnd, setOnAnimationIteration, setOnAnimationStart, setOnAuxClick, setOnBeforeInput, setOnBeforeToggle, setOnBlur, setOnChange, setOnClick, setOnClickChange, setOnCompositionEnd, setOnCompositionStart, setOnCompositionUpdate, setOnContextMenu, setOnCopy, setOnCut, setOnDocumentResize, setOnFocus, setOnFocusIn, setOnFocusOut, setOnFormData, setOnGotPointerCapture, setOnInput, setOnInvalid, setOnKeyDown, setOnKeyPressed, setOnKeyUp, setOnLostPointerCapture, setOnMouseDown, setOnMouseEnter, setOnMouseLeave, setOnMouseMove, setOnMouseOut, setOnMouseOutChangeClass, setOnMouseOutChangeStyle, setOnMouseOutChangeStyle, setOnMouseOver, setOnMouseOverChangeClass, setOnMouseOverChangeStyle, setOnMouseOverChangeStyle, setOnMouseOverShow, setOnMouseUp, setOnPageLoad, setOnPaste, setOnPointerCancel, setOnPointerDown, setOnPointerEnter, setOnPointerLeave, setOnPointerMove, setOnPointerOut, setOnPointerOver, setOnPointerUp, setOnResize, setOnScroll, setOnScrollEnd, setOnSelect, setOnSelectionChange, setOnSelectStart, setOnToggle, setOnTouchCancel, setOnTouchEnd, setOnTouchMove, setOnTouchStart, setOnTransitionCancel, setOnTransitionEnd, setOnTransitionRun, setOnTransitionStart, setOnWheel, setOnWindowResize, setPopover, setRole, setRole, setSpellCheck, setTabIndex, setTitle, setTooltipMethods inherited from class com.oorian.html.Element
addAttribute, addAttribute, addAttribute, addAttribute, addElement, addLineBreak, addLineOfText, addLineOfText, addLineOfText, addParagraph, addParagraph, addSpacer, addText, addText, addText, addText, assignId, containsElement, containsElement, create, dispatchEvent, dispatchEvent, dispatchEvent, dispatchEvent, equals, excludeId, executeJs, executeJs, executeJs, getAccept, getAllElements, getAncestor, getAttribute, getAttributes, getComponent, getDir, getElement, getElementById, getElementCount, getElementCount, getElements, getElements, getElementsByComponentName, getElementsByTagName, getHtml, getId, getInnerHtml, getInnerHtml, getIs, getItemId, getItemProp, getItemRef, getItemType, getLang, getNextSibling, getPage, getParent, getPart, getPrevSibling, getSlot, getTagName, getTextContent, getUrl, hasAttribute, hasElements, insertElement, isChildOf, isClosedTag, isCreated, isDescendantOf, isDescendantOf, isInitialized, isItemScope, isTranslate, onCallback, onCreated, onElementAdded, onElementRemoved, onHashChange, onHidden, onInitialized, onJsReturn, onPageLoaded, onPageUnloaded, onRefresh, onShown, onUpdated, onUserEvent, prewrite, recreate, refresh, refresh, registerAddition, registerListener, registerListener, registerListener, registerListener, registerListener, registerListener, registerListener, registerSubtraction, registerUpdate, removeAllElements, removeAttribute, removeAttribute, removeElement, removeElement, removeFromParent, requestCallback, requestCallback, requestCallback, requestCallback, resetId, scrollTo, scrollToBottom, scrollToTop, self, sendCommand, sendUpdate, setAccept, setComponent, setDir, setDir, setElement, setId, setIs, setItemId, setItemProp, setItemRef, setItemScope, setItemType, setLang, setOnError, setOnLoad, setPage, setParent, setPart, setSlot, setTagName, setText, setText, setText, setText, setTranslate, toString, unregisterListener, update, updateAttributes
-
Constructor Details
-
ComposableLayout
public ComposableLayout()Constructs an empty ComposableLayout. -
ComposableLayout
public ComposableLayout(int columns) Constructs a ComposableLayout with the specified number of equal columns.- Parameters:
columns- the number of columns
-
-
Method Details
-
columns
Creates a ComposableLayout with the specified number of equal columns.- Parameters:
columns- the number of columns- Returns:
- a new ComposableLayout with equal columns
-
rows
Creates a ComposableLayout with the specified number of rows.- Parameters:
rows- the number of rows- Returns:
- a new ComposableLayout with equal rows
-
setColumns
Sets the number of equal-width columns.- Parameters:
columns- the number of columns- Returns:
- this ComposableLayout for method chaining
-
setRows
Sets the number of equal-height rows.- Parameters:
rows- the number of rows- Returns:
- this ComposableLayout for method chaining
-
setGridTemplate
Sets the full CSS grid-template property for complex layouts.Example: "'header header' auto 'sidebar main' 1fr 'footer footer' auto / 250px 1fr"
- Parameters:
template- the CSS grid-template value- Returns:
- this ComposableLayout for method chaining
-
setGridAreas
Sets grid-template-areas for named area placement.Example: "'header header' 'sidebar main' 'footer footer'"
- Parameters:
areas- the CSS grid-template-areas value- Returns:
- this ComposableLayout for method chaining
-
setGridColumns
Sets grid-template-columns for column sizing.- Parameters:
columns- the CSS grid-template-columns value- Returns:
- this ComposableLayout for method chaining
-
setGridRows
Sets grid-template-rows for row sizing.- Parameters:
rows- the CSS grid-template-rows value- Returns:
- this ComposableLayout for method chaining
-
slot
Sets content into a named slot.If grid-template-areas is defined, the slot name corresponds to an area name. Otherwise, the slot is positioned using CSS Grid placement properties.
- Parameters:
name- the slot name (corresponds to grid-area name)content- the content to place in the slot- Returns:
- this ComposableLayout for method chaining
-
defineArea
Defines a named area at the specified grid position.- Parameters:
name- the area namerow- the starting row (1-based)column- the starting column (1-based)- Returns:
- this ComposableLayout for method chaining
-
defineArea
Defines a named area at the specified grid position with span.- Parameters:
name- the area namerow- the starting row (1-based)column- the starting column (1-based)rowSpan- the number of rows to spancolSpan- the number of columns to span- Returns:
- this ComposableLayout for method chaining
-
getSlot
Returns the slot container for the given name.- Parameters:
name- the slot name- Returns:
- the slot container, or null if not found
-
hasSlot
Checks if a slot with the given name exists.- Parameters:
name- the slot name- Returns:
- true if the slot exists
-
removeSlot
Removes a slot and its content.- Parameters:
name- the slot name- Returns:
- this ComposableLayout for method chaining
-
setGap
Sets the gap between grid cells.- Overrides:
setGapin classStyledElement<ComposableLayout>- Parameters:
gap- the gap in pixels- Returns:
- this ComposableLayout for method chaining
-
setGap
Sets the gap between grid cells.- Overrides:
setGapin classStyledElement<ComposableLayout>- Parameters:
gap- the gap value (e.g., "1rem", "16px")- Returns:
- this ComposableLayout for method chaining
-
setGap
Sets separate row and column gaps.- Overrides:
setGapin classStyledElement<ComposableLayout>- Parameters:
rowGap- the vertical gap between rows in pixelscolumnGap- the horizontal gap between columns in pixels- Returns:
- this ComposableLayout for method chaining
-
autoFit
Sets auto-fit columns with a minimum width (responsive grid).- Parameters:
minWidth- the minimum column width- Returns:
- this ComposableLayout for method chaining
-
autoFill
Sets auto-fill columns with a minimum width (responsive grid).- Parameters:
minWidth- the minimum column width- Returns:
- this ComposableLayout for method chaining
-