Class Length


  • @Immutable
    public final class Length
    extends java.lang.Object
    • Field Detail

      • UNSPECIFIED

        @NotNull
        public static final @NotNull Length UNSPECIFIED
      • ZERO

        @NotNull
        public static final @NotNull Length ZERO
      • unit

        @NotNull
        private final @NotNull Unit unit
      • value

        private final float value
    • Constructor Detail

      • Length

        public Length​(@NotNull
                      @NotNull Unit unit,
                      float value)
    • Method Detail

      • isUnspecified

        public static boolean isUnspecified​(float value)
      • isSpecified

        public static boolean isSpecified​(float value)
      • resolveNonPercentage

        private float resolveNonPercentage​(@NotNull
                                           @NotNull MeasureContext context)
      • resolveWidth

        public float resolveWidth​(@NotNull
                                  @NotNull MeasureContext context)
        Used for resolving lengths which are used as x-coordinates or width values.
        Parameters:
        context - the measuring context.
        Returns:
        the resolved size.
      • resolveHeight

        public float resolveHeight​(@NotNull
                                   @NotNull MeasureContext context)
        Used for resolving lengths which are used as y-coordinates or height values.
        Parameters:
        context - the measuring context.
        Returns:
        the resolved size.
      • resolveLength

        public float resolveLength​(@NotNull
                                   @NotNull MeasureContext context)
        Used for resolving lengths which are neither used as y/x-coordinates nor width/height values. Relative sizes are relative to the ViewBox.normedDiagonalLength().
        Parameters:
        context - the measuring context.
        Returns:
        the resolved size.
      • resolveFontSize

        public float resolveFontSize​(@NotNull
                                     @NotNull MeasureContext context)
        Used for resolving font sizes. Relative values will be resolves with respect to the current font size. This isn't dependent on the current viewBox.
        Parameters:
        context - the measuring context.
        Returns:
        the resolved size.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • isZero

        public boolean isZero()
      • raw

        public float raw()
      • unit

        @NotNull
        public @NotNull Unit unit()
      • isUnspecified

        public boolean isUnspecified()
      • isSpecified

        public boolean isSpecified()
      • coerceNonNegative

        @NotNull
        public @NotNull Length coerceNonNegative()
      • coercePercentageToCorrectUnit

        @NotNull
        public @NotNull Length coercePercentageToCorrectUnit​(@NotNull
                                                             @NotNull UnitType unitType)
      • orElseIfUnspecified

        public Length orElseIfUnspecified​(float value)
      • multiply

        public Length multiply​(float scalingFactor)
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object