Class SpringGridLayout

java.lang.Object
com.simsilica.lemur.component.AbstractGuiComponent
com.simsilica.lemur.component.SpringGridLayout
All Implemented Interfaces:
GuiComponent, GuiLayout, Cloneable

public class SpringGridLayout extends AbstractGuiComponent implements GuiLayout, Cloneable
A layout that manages children on a grid that automatically resizes to fit the components along the major or minor axes (row and column be default). Each row and column is sized large enough to fit the largest child within that row or column.
  • Constructor Details

    • SpringGridLayout

      public SpringGridLayout()
    • SpringGridLayout

      public SpringGridLayout(Axis mainAxis, Axis minorAxis)
    • SpringGridLayout

      public SpringGridLayout(Axis mainAxis, Axis minorAxis, FillMode mainFill, FillMode minorFill)
  • Method Details

    • clone

      public SpringGridLayout clone()
      Specified by:
      clone in interface GuiComponent
      Specified by:
      clone in interface GuiLayout
      Overrides:
      clone in class AbstractGuiComponent
    • invalidate

      protected void invalidate()
      Overrides:
      invalidate in class AbstractGuiComponent
    • getMajor

      protected final float getMajor(Vector3f v)
    • getMinor

      protected final float getMinor(Vector3f v)
    • getAlternate

      protected final float getAlternate(Vector3f v)
    • setMajor

      protected final void setMajor(Vector3f v, float f)
    • setMinor

      protected final void setMinor(Vector3f v, float f)
    • setAlternate

      protected final void setAlternate(Vector3f v, float f)
    • addMajor

      protected final void addMajor(Vector3f v, float f)
    • addMinor

      protected final void addMinor(Vector3f v, float f)
    • addAlternate

      protected final void addAlternate(Vector3f v, float f)
    • refreshRowColPrefs

      protected float refreshRowColPrefs()
      Recalculates the internal arrays that keep track of the preferred sizes for each row and collumn. The preferred sizes are based on the maximum preferred size of every component in the row or column. This returns the "alternate axis" max size for all contained components. In a standard row, column setup where rows are vertical and columns are horizontal, the alternate axis is depth.
    • calculatePreferredSize

      public void calculatePreferredSize(Vector3f size)
      Specified by:
      calculatePreferredSize in interface GuiComponent
    • weighted

      protected float weighted(int index, float pref, float totalSize, float totalPref, int count, FillMode fill, Axis axis)
    • distribute

      protected void distribute(float[] sizes, float[] prefs, float totalSize, float totalPref, FillMode fill, Axis axis)
    • reshape

      public void reshape(Vector3f pos, Vector3f size)
      Specified by:
      reshape in interface GuiComponent
    • getRow

      protected Map<Integer,SpringGridLayout.Entry> getRow(int row, boolean create)
    • addChild

      public <T extends Node> T addChild(int row, int column, T n)
    • addChild

      public <T extends Node> T addChild(T n, Object... constraints)
      Specified by:
      addChild in interface GuiLayout
    • getChild

      public Node getChild(int row, int column)
    • removeChild

      public void removeChild(Node n)
      Specified by:
      removeChild in interface GuiLayout
    • getChildren

      public Collection<Node> getChildren()
      Specified by:
      getChildren in interface GuiLayout
    • clearChildren

      public void clearChildren()
      Specified by:
      clearChildren in interface GuiLayout
    • remove

      protected void remove(SpringGridLayout.Entry e)
    • attach

      public void attach(GuiControl parent)
      Specified by:
      attach in interface GuiComponent
      Overrides:
      attach in class AbstractGuiComponent
    • detach

      public void detach(GuiControl parent)
      Specified by:
      detach in interface GuiComponent
      Overrides:
      detach in class AbstractGuiComponent
    • toString

      public String toString()
      Overrides:
      toString in class Object