Class WrapPanelImpl
java.lang.Object
org.inspirenxe.strata.core.node.BuiltInComponent<org.inspirenxe.strata.api.layout.WrapPanel>
org.inspirenxe.strata.core.node.BuiltInComposite<org.inspirenxe.strata.api.layout.WrapPanel>
org.inspirenxe.strata.core.node.BuiltInContainer<org.inspirenxe.strata.api.layout.WrapPanel>
org.inspirenxe.strata.core.layout.WrapPanelImpl
- All Implemented Interfaces:
org.inspirenxe.strata.api.component.Component<org.inspirenxe.strata.api.layout.WrapPanel>, org.inspirenxe.strata.api.component.Container<org.inspirenxe.strata.api.layout.WrapPanel>, org.inspirenxe.strata.api.component.Enableable<org.inspirenxe.strata.api.layout.WrapPanel>, org.inspirenxe.strata.api.component.HasContextMenu<org.inspirenxe.strata.api.layout.WrapPanel>, org.inspirenxe.strata.api.component.HasCursor<org.inspirenxe.strata.api.layout.WrapPanel>, org.inspirenxe.strata.api.component.HasTooltip<org.inspirenxe.strata.api.layout.WrapPanel>, org.inspirenxe.strata.api.event.EventTarget<org.inspirenxe.strata.api.layout.WrapPanel>, org.inspirenxe.strata.api.layout.WrapPanel
public final class WrapPanelImpl
extends BuiltInContainer<org.inspirenxe.strata.api.layout.WrapPanel>
implements org.inspirenxe.strata.api.layout.WrapPanel
The core
WrapPanel. Measuring offers each child the content length along the lines and unlimited space
across them, then breaks the children into lines where the next child would pass the content length; the panel
asks for its longest line and the sum of its line thicknesses and gaps. Arranging breaks the lines again at the
content box's length, from the sizes the children asked for, and gives each child a slot as long as it asked for
and as thick as its line, placed along the line by the line alignment. Neither pass allocates beyond the slots.
In rows, the children of each row aligned VerticalAlignment.BASELINE
are lined up as BaselineRow describes: the row is at least as tall as they need lined up, and each one's
slot starts where its baseline meets theirs, as tall as the child asked for. Columns place them at the top.
The panel's content minimum is the largest outer minimum of its visible children on each axis, plus the padding.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.inspirenxe.strata.api.layout.WrapPanel
org.inspirenxe.strata.api.layout.WrapPanel.State -
Field Summary
Fields inherited from interface org.inspirenxe.strata.api.component.Component
ATTACHED, DETACHED, ENABLED, MEASURED, OPACITY, PAINT, PAINTED, VISIBLEFields inherited from interface org.inspirenxe.strata.api.component.HasContextMenu
SHOW_CONTEXT_MENUFields inherited from interface org.inspirenxe.strata.api.component.HasTooltip
TOOLTIP -
Constructor Summary
ConstructorsConstructorDescriptionWrapPanelImpl(ComponentFactoryImpl ui, org.inspirenxe.strata.api.layout.Orientation orientation) Creates an empty panel with no spacing and lines aligned to their start. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidarrange(org.inspirenxe.strata.api.extension.ArrangeContext context, org.inspirenxe.strata.api.geometry.Rect bounds) Gives every child its slot.org.inspirenxe.strata.api.layout.HorizontalAlignmentfloatprotected org.inspirenxe.strata.api.geometry.Sizemeasure(org.inspirenxe.strata.api.extension.MeasureContext context, float availableWidth, float availableHeight) Returns the size the content needs within the given space, asCustomComponent.measuredoes.protected org.inspirenxe.strata.api.geometry.SizemeasureMinimum(org.inspirenxe.strata.api.extension.MeasureContext context) Returns the smallest size the content can work in, asCustomComponent.measureMinimumdoes.org.inspirenxe.strata.api.layout.Orientationorg.inspirenxe.strata.api.layout.WrapPanelsetLineAlignment(org.inspirenxe.strata.api.layout.HorizontalAlignment alignment) org.inspirenxe.strata.api.layout.WrapPanelsetOrientation(org.inspirenxe.strata.api.layout.Orientation orientation) org.inspirenxe.strata.api.layout.WrapPanelsetSpacing(float spacing, float lineSpacing) protected ObjectReturns this component's own state for a snapshot, an immutable value without its children's state.floatspacing()Methods inherited from class BuiltInContainer
add, background, border, children, clear, clearPadding, clipsChildren, contentBox, indexOf, insert, lower, move, padding, paintOrder, raise, remove, setBackground, setBorder, setClipChildren, setPadding, setTextStyle, textStyleMethods inherited from class BuiltInComposite
addChild, addContent, childClip, childList, clearChildren, insertChild, insertContent, invalidateArrangement, lowerChild, moveChild, node, onChildRemoved, onDescendantFocused, paintOverChildren, raiseChild, removeChild, setChildClippingMethods inherited from class BuiltInComponent
acceptsTextInput, activatesOnPress, ancestor, baseline, bind, bounds, clearTooltip, contextMenu, cursor, desiredHeight, desiredWidth, environment, flow, flowDirection, hasStyleState, horizontalAlignment, hostRoot, id, invalidateLayout, isAttached, isEnabled, isFocusable, isFocused, isFocusFromPress, isFocusVisible, isFocusWithin, isHandled, isHitTestVisible, isHovered, isHoverWithin, isPressed, isRightToLeft, isTabbable, isVisible, margin, maxHeight, maxWidth, minHeight, minWidth, motionAnimator, nodeOf, offsetX, offsetY, onApplyTheme, onAttached, onChar, onClick, onDetached, onDisabled, onDrag, onDragEnd, onDragEnter, onDragExit, onDragOver, onDragStart, onDrop, onEdgeScroll, onEnabledChanged, onEvent, onFocusGained, onFocusLost, onKey, onOtherEvent, onPointerEnter, onPointerExit, onPointerMove, onPointerPress, onPointerRelease, onPressWithin, onReleased, onScroll, onTransferDone, opacity, paint, parent, parent, repaint, repaintAfter, repaintNextFrame, report, report, request, request, requestFocus, requiredStyleKeys, self, setAlignment, setContextMenu, setCursor, setEnabled, setFlowDirection, setFocusable, setFocusDelegate, setHeight, setHitTestVisible, setId, setMargin, setMaxSize, setMinSize, setOffset, setOpacity, setStyleState, setTabbable, setTabIndex, setTooltip, setVisible, setWidth, setZIndex, stylePaint, styleText, subscribe, tabIndex, textInputKind, theme, tooltip, toString, unbind, verticalAlignment, whileAttached, zIndexMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.inspirenxe.strata.api.component.Component
ancestor, bind, bounds, desiredHeight, desiredWidth, flowDirection, horizontalAlignment, id, isAttached, isEffectivelyEnabled, isEffectivelyVisible, isEnabled, isFocusWithin, isHitTestVisible, isVisible, margin, maxHeight, maxWidth, minHeight, minWidth, opacity, parent, parent, setAlignment, setAnchor, setEnabled, setFlowDirection, setHeight, setHitTestVisible, setId, setMargin, setMargin, setMargin, setMargin, setMaxSize, setMinSize, setOpacity, setSize, setVisible, setWidth, setZIndex, unbind, verticalAlignment, whileAttached, zIndexMethods inherited from interface org.inspirenxe.strata.api.component.Container
add, background, border, children, clear, clearPadding, clipsChildren, indexOf, insert, lower, move, padding, paintOrder, raise, remove, setBackground, setBorder, setClipChildren, setPadding, setPadding, setPadding, setPadding, setTextStyle, textStyleMethods inherited from interface org.inspirenxe.strata.api.event.EventTarget
onEvent, onEvent, subscribeMethods inherited from interface org.inspirenxe.strata.api.component.HasContextMenu
contextMenu, setContextMenuMethods inherited from interface org.inspirenxe.strata.api.component.HasCursor
cursor, setCursorMethods inherited from interface org.inspirenxe.strata.api.component.HasTooltip
clearTooltip, setTooltip, setTooltip, setTooltip, tooltip
-
Constructor Details
-
WrapPanelImpl
public WrapPanelImpl(ComponentFactoryImpl ui, org.inspirenxe.strata.api.layout.Orientation orientation) Creates an empty panel with no spacing and lines aligned to their start.- Parameters:
ui- the factory that owns the panelorientation- the direction each line fills in
-
-
Method Details
-
orientation
public org.inspirenxe.strata.api.layout.Orientation orientation()- Specified by:
orientationin interfaceorg.inspirenxe.strata.api.layout.WrapPanel
-
setOrientation
public org.inspirenxe.strata.api.layout.WrapPanel setOrientation(org.inspirenxe.strata.api.layout.Orientation orientation) - Specified by:
setOrientationin interfaceorg.inspirenxe.strata.api.layout.WrapPanel
-
spacing
public float spacing()- Specified by:
spacingin interfaceorg.inspirenxe.strata.api.layout.WrapPanel
-
lineSpacing
public float lineSpacing()- Specified by:
lineSpacingin interfaceorg.inspirenxe.strata.api.layout.WrapPanel
-
setSpacing
public org.inspirenxe.strata.api.layout.WrapPanel setSpacing(float spacing, float lineSpacing) - Specified by:
setSpacingin interfaceorg.inspirenxe.strata.api.layout.WrapPanel
-
lineAlignment
public org.inspirenxe.strata.api.layout.HorizontalAlignment lineAlignment()- Specified by:
lineAlignmentin interfaceorg.inspirenxe.strata.api.layout.WrapPanel
-
setLineAlignment
public org.inspirenxe.strata.api.layout.WrapPanel setLineAlignment(org.inspirenxe.strata.api.layout.HorizontalAlignment alignment) - Specified by:
setLineAlignmentin interfaceorg.inspirenxe.strata.api.layout.WrapPanel
-
measure
protected org.inspirenxe.strata.api.geometry.Size measure(org.inspirenxe.strata.api.extension.MeasureContext context, float availableWidth, float availableHeight) Description copied from class:BuiltInComponentReturns the size the content needs within the given space, asCustomComponent.measuredoes.- Specified by:
measurein classBuiltInComponent<org.inspirenxe.strata.api.layout.WrapPanel>- Parameters:
context- text measurement and child measuringavailableWidth- the width offered, margin removed; may beFloat.POSITIVE_INFINITYavailableHeight- the height offered, margin removed; may beFloat.POSITIVE_INFINITY- Returns:
- the natural size of the content
-
measureMinimum
protected org.inspirenxe.strata.api.geometry.Size measureMinimum(org.inspirenxe.strata.api.extension.MeasureContext context) Description copied from class:BuiltInComponentReturns the smallest size the content can work in, asCustomComponent.measureMinimumdoes. The default returnsSize.ZERO.- Overrides:
measureMinimumin classBuiltInComponent<org.inspirenxe.strata.api.layout.WrapPanel>- Parameters:
context- text measurement and the children's minimums- Returns:
- the smallest size of the content
-
arrange
protected void arrange(org.inspirenxe.strata.api.extension.ArrangeContext context, org.inspirenxe.strata.api.geometry.Rect bounds) Description copied from class:BuiltInCompositeGives every child its slot. Called afterBuiltInComponent.measure(MeasureContext, float, float), with the component's final bounds, and again with the same bounds afterBuiltInComposite.invalidateArrangement().- Specified by:
arrangein classBuiltInComposite<org.inspirenxe.strata.api.layout.WrapPanel>- Parameters:
context- child sizes and slot assignmentbounds- the component's bounds
-
snapshotState
Description copied from class:BuiltInComponentReturns this component's own state for a snapshot, an immutable value without its children's state. Called only when an event with snapshots captures this component. The default returns null.- Overrides:
snapshotStatein classBuiltInComponent<org.inspirenxe.strata.api.layout.WrapPanel>- Returns:
- the state, or null for none
-