Package com.helger.pdflayout.spec
Class HeightSpec
- java.lang.Object
-
- com.helger.pdflayout.spec.HeightSpec
-
- All Implemented Interfaces:
Serializable
@Immutable @MustImplementEqualsAndHashcode public class HeightSpec extends Object implements Serializable
This class defines a dependent height of an elements:- absolute - element has a fixed height
- percentage - element height is a certain percentage of the surrounding element
- star - element height is a relative part of the unused height of the surrounding element. All star elements evenly share the available height.
- auto - elements takes the height it needs
- Author:
- Philip Helger
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description HeightSpec(EValueUOMType eType, float fValue)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static HeightSpecabs(float fValue)Create a height element with an absolute value.static HeightSpecauto()Create a new auto height element.booleanequals(Object o)floatgetEffectiveValue(float fAvailableHeight)Get the effective height based on the passed available height.EValueUOMTypegetType()StringgetTypeID()floatgetValue()inthashCode()booleanisAbsolute()booleanisAuto()booleanisStar()static HeightSpecperc(float fPerc)Create a height element with an percentage value.static HeightSpecstar()Create a new star height element.StringtoString()
-
-
-
Constructor Detail
-
HeightSpec
public HeightSpec(@Nonnull EValueUOMType eType, float fValue)
-
-
Method Detail
-
getType
@Nonnull public final EValueUOMType getType()
- Returns:
- The height type. Never
null.
-
getTypeID
@Nonnull @Nonempty public final String getTypeID()
- Returns:
- The ID of the height type. Never
null.
-
isAbsolute
public final boolean isAbsolute()
- Returns:
trueif type is 'absolute' or 'percentage'- Only absolute entries need to provide a value!
-
isStar
public final boolean isStar()
- Returns:
trueif type is 'star'.
-
isAuto
public final boolean isAuto()
- Returns:
trueif type is 'auto'.
-
getValue
@Nonnegative public final float getValue()
- Returns:
- The height value - is either an absolute value or a percentage
value - depending on
getType(). For star height elements this is 0.
-
getEffectiveValue
@Nonnegative public float getEffectiveValue(float fAvailableHeight)
Get the effective height based on the passed available height. This may not be called for star or auto height elements.- Parameters:
fAvailableHeight- The available height.- Returns:
- The effective height to use.
-
abs
@Nonnull public static HeightSpec abs(@Nonnegative float fValue)
Create a height element with an absolute value.- Parameters:
fValue- The height to use. Must be > 0.- Returns:
- Never
null.
-
perc
@Nonnull public static HeightSpec perc(@Nonnegative float fPerc)
Create a height element with an percentage value.- Parameters:
fPerc- The height percentage to use. Must be > 0.- Returns:
- Never
null.
-
star
@Nonnull public static HeightSpec star()
Create a new star height element.- Returns:
- Never
null.
-
auto
@Nonnull public static HeightSpec auto()
Create a new auto height element.- Returns:
- Never
null.
-
-