Class Length

  • All Implemented Interfaces:
    LengthValue

    public final class Length
    extends java.lang.Object
    implements LengthValue
    • Field Detail

      • UNSPECIFIED

        @NotNull
        public static final @NotNull Length UNSPECIFIED
      • ZERO

        @NotNull
        public static final @NotNull Length ZERO
      • ONE

        @NotNull
        public static final @NotNull Length ONE
      • INHERITED

        @NotNull
        public static final @NotNull Length INHERITED
      • unit

        @NotNull
        private final @NotNull Unit unit
      • value

        private final float value
    • Constructor Detail

      • Length

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

        public Length​(@NotNull
                      @NotNull Length ry)
    • Method Detail

      • isUnspecified

        public static boolean isUnspecified​(float value)
      • isSpecified

        public static boolean isSpecified​(float value)
      • resolveNonPercentage

        private static float resolveNonPercentage​(@NotNull
                                                  @NotNull MeasureContext context,
                                                  Unit unit,
                                                  float value)
      • resolve

        public float resolve​(@NotNull
                             @NotNull MeasureContext context)
        Description copied from interface: LengthValue
        Resolve the length to its effective value.
        Specified by:
        resolve in interface LengthValue
        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

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

        public boolean isZero()
      • isAbsolute

        public boolean isAbsolute()
      • 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,
                                                             @NotNull
                                                             @NotNull PercentageDimension dimension)
      • orElseIfUnspecified

        @NotNull
        public @NotNull Length orElseIfUnspecified​(float value)
      • multiply

        @NotNull
        public @NotNull 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