Class Length
- java.lang.Object
-
- com.github.weisj.jsvg.geometry.size.Length
-
@Immutable public final class Length extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private static float
inchesPerCm
private static float
pixelsPerInch
private @NotNull Unit
unit
static @NotNull Length
UNSPECIFIED
static float
UNSPECIFIED_RAW
private float
value
static @NotNull Length
ZERO
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull Length
coerceNonNegative()
@NotNull Length
coercePercentageToCorrectUnit(@NotNull UnitType unitType)
boolean
equals(java.lang.Object o)
int
hashCode()
boolean
isSpecified()
static boolean
isSpecified(float value)
boolean
isUnspecified()
static boolean
isUnspecified(float value)
boolean
isZero()
Length
multiply(float scalingFactor)
Length
orElseIfUnspecified(float value)
float
raw()
float
resolveFontSize(@NotNull MeasureContext context)
Used for resolving font sizes.float
resolveHeight(@NotNull MeasureContext context)
Used for resolving lengths which are used as y-coordinates or height values.float
resolveLength(@NotNull MeasureContext context)
Used for resolving lengths which are neither used as y/x-coordinates nor width/height values.private float
resolveNonPercentage(@NotNull MeasureContext context)
float
resolveWidth(@NotNull MeasureContext context)
Used for resolving lengths which are used as x-coordinates or width values.java.lang.String
toString()
@NotNull Unit
unit()
-
-
-
Field Detail
-
UNSPECIFIED_RAW
public static final float UNSPECIFIED_RAW
- See Also:
- Constant Field Values
-
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
-
pixelsPerInch
private static final float pixelsPerInch
- See Also:
- Constant Field Values
-
inchesPerCm
private static final float inchesPerCm
- See Also:
- Constant Field Values
-
-
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 theViewBox.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 classjava.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 classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-