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.

  • 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 panel
      orientation - the direction each line fills in
  • Method Details

    • orientation

      public org.inspirenxe.strata.api.layout.Orientation orientation()
      Specified by:
      orientation in interface org.inspirenxe.strata.api.layout.WrapPanel
    • setOrientation

      public org.inspirenxe.strata.api.layout.WrapPanel setOrientation(org.inspirenxe.strata.api.layout.Orientation orientation)
      Specified by:
      setOrientation in interface org.inspirenxe.strata.api.layout.WrapPanel
    • spacing

      public float spacing()
      Specified by:
      spacing in interface org.inspirenxe.strata.api.layout.WrapPanel
    • lineSpacing

      public float lineSpacing()
      Specified by:
      lineSpacing in interface org.inspirenxe.strata.api.layout.WrapPanel
    • setSpacing

      public org.inspirenxe.strata.api.layout.WrapPanel setSpacing(float spacing, float lineSpacing)
      Specified by:
      setSpacing in interface org.inspirenxe.strata.api.layout.WrapPanel
    • lineAlignment

      public org.inspirenxe.strata.api.layout.HorizontalAlignment lineAlignment()
      Specified by:
      lineAlignment in interface org.inspirenxe.strata.api.layout.WrapPanel
    • setLineAlignment

      public org.inspirenxe.strata.api.layout.WrapPanel setLineAlignment(org.inspirenxe.strata.api.layout.HorizontalAlignment alignment)
      Specified by:
      setLineAlignment in interface org.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: BuiltInComponent
      Returns the size the content needs within the given space, as CustomComponent.measure does.
      Specified by:
      measure in class BuiltInComponent<org.inspirenxe.strata.api.layout.WrapPanel>
      Parameters:
      context - text measurement and child measuring
      availableWidth - the width offered, margin removed; may be Float.POSITIVE_INFINITY
      availableHeight - the height offered, margin removed; may be Float.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: BuiltInComponent
      Returns the smallest size the content can work in, as CustomComponent.measureMinimum does. The default returns Size.ZERO.
      Overrides:
      measureMinimum in class BuiltInComponent<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: BuiltInComposite
      Gives every child its slot. Called after BuiltInComponent.measure(MeasureContext, float, float), with the component's final bounds, and again with the same bounds after BuiltInComposite.invalidateArrangement().
      Specified by:
      arrange in class BuiltInComposite<org.inspirenxe.strata.api.layout.WrapPanel>
      Parameters:
      context - child sizes and slot assignment
      bounds - the component's bounds
    • snapshotState

      protected Object snapshotState()
      Description copied from class: BuiltInComponent
      Returns 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:
      snapshotState in class BuiltInComponent<org.inspirenxe.strata.api.layout.WrapPanel>
      Returns:
      the state, or null for none