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