Class CSSGridTracks.Track

java.lang.Object
com.iizix.prop.ui.CSSGridTracks.Track
Enclosing class:
CSSGridTracks

public static final class CSSGridTracks.Track extends Object
One track, track function or repetition. Immutable.
Author:
Christopher Mindus
  • Method Details

    • length

      public static CSSGridTracks.Track length(String number, String unit)
      Creates a length track.
      Parameters:
      number - The non-negative number, e.g. "200" or "1.5".
      unit - One of CSSGridTracks.LENGTH_UNITS, or "" when the number is zero.
      Returns:
      The track.
      Throws:
      IllegalArgumentException - For a negative or malformed number or an unknown unit.
    • flex

      public static CSSGridTracks.Track flex(String number)
      Creates a flexible track.
      Parameters:
      number - The non-negative number of fr.
      Returns:
      The track.
      Throws:
      IllegalArgumentException - For a negative or malformed number.
    • keyword

      public static CSSGridTracks.Track keyword(CSSGridTracks.Kind kind)
      Creates a keyword track.
      Parameters:
      kind - CSSGridTracks.Kind.AUTO, CSSGridTracks.Kind.MIN_CONTENT or CSSGridTracks.Kind.MAX_CONTENT.
      Returns:
      The track.
      Throws:
      IllegalArgumentException - For another kind.
    • minmax

      Creates a minmax(min,max) track.
      Parameters:
      min - The minimum: a length or a keyword, never a flexible length.
      max - The maximum: a length, a flexible length or a keyword.
      Returns:
      The track.
      Throws:
      IllegalArgumentException - When an argument is not allowed in its position.
    • fitContent

      public static CSSGridTracks.Track fitContent(CSSGridTracks.Track limit)
      Creates a fit-content(length) track.
      Parameters:
      limit - The length limit.
      Returns:
      The track.
      Throws:
      IllegalArgumentException - When the limit is not a length.
    • repeat

      public static CSSGridTracks.Track repeat(int count, List<CSSGridTracks.Track> repeated)
      Creates a repeat(count,tracks).
      Parameters:
      count - A positive count up to CSSGridTracks.MAX_REPEAT, CSSGridTracks.AUTO_FILL or CSSGridTracks.AUTO_FIT.
      repeated - The repeated tracks, at least one, none of them a repeat; with auto-fill or auto-fit every one of them must have a fixed size.
      Returns:
      The track.
      Throws:
      IllegalArgumentException - When the count or a track is not allowed.
    • getKind

      public CSSGridTracks.Kind getKind()
      Returns the kind.
      Returns:
      The kind, never null.
    • getNumber

      public String getNumber()
      Returns the canonical number text of a length or flexible length.
      Returns:
      The number text, e.g. "1.5", or null for other kinds.
    • getValue

      public double getValue()
      Returns the number of a length or flexible length.
      Returns:
      The number, or Double.NaN for other kinds.
    • getUnit

      public String getUnit()
      Returns the unit of a length ("" for a unitless 0) or "fr" for a flexible length.
      Returns:
      The lower-case unit, or null for other kinds.
    • getMin

      public CSSGridTracks.Track getMin()
      Returns the minimum of minmax() or the limit of fit-content().
      Returns:
      The track, or null for other kinds.
    • getMax

      public CSSGridTracks.Track getMax()
      Returns the maximum of minmax().
      Returns:
      The track, or null for other kinds.
    • getCount

      public int getCount()
      Returns the repeat count of repeat().
      Returns:
      A positive count, CSSGridTracks.AUTO_FILL, CSSGridTracks.AUTO_FIT, or 0 for other kinds.
    • getRepeated

      public List<CSSGridTracks.Track> getRepeated()
      Returns the repeated tracks of repeat().
      Returns:
      The unmodifiable list, empty for other kinds.
    • isBreadth

      public boolean isBreadth()
      Returns if this is a simple breadth: a length, a flexible length or a keyword.
      Returns:
      true for a breadth.
    • isFixedSize

      public boolean isFixedSize()
      Returns if this track has a fixed size in the CSS sense (<fixed-size>): a length, or a minmax() with a length as either its minimum or (with an inflexible minimum) its maximum. Only fixed sizes may be repeated by auto-fill or auto-fit.
      Returns:
      true for a fixed size.
    • isFlexible

      public boolean isFlexible()
      Returns if this track (or one inside it) grows with a flexible length fr.
      Returns:
      true when flexible.
    • getTrackCount

      public int getTrackCount()
      Returns the number of tracks this entry produces.
      Returns:
      The count, -1 when it depends on the container size (auto-fill, auto-fit).
    • toString

      public String toString()
      Returns the CSS text of the track, in canonical form.
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object obj)
      Two tracks are equal when their canonical CSS texts are equal.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Hash code of the canonical CSS text.
      Overrides:
      hashCode in class Object