Class FontSizePropertyMaker

  • All Implemented Interfaces:
    java.lang.Cloneable, Constants

    public class FontSizePropertyMaker
    extends LengthProperty.Maker
    implements Constants
    This subclass of LengthProperty.Maker handles the special treatment of relative font sizes described in 7.8.4.
    • Field Detail

      • FONT_SIZE_NORMAL

        private static final int FONT_SIZE_NORMAL
        The default normal font size in mpt
        See Also:
        Constant Field Values
      • FONT_SIZE_GROWTH_FACTOR

        private static final double FONT_SIZE_GROWTH_FACTOR
        The factor to be applied when stepping font sizes upwards
        See Also:
        Constant Field Values
    • Constructor Detail

      • FontSizePropertyMaker

        public FontSizePropertyMaker​(int propId)
        Create a length property which can handle relative font sizes
        Parameters:
        propId - the font size property id.
    • Method Detail

      • make

        public Property make​(PropertyList propertyList,
                             java.lang.String value,
                             FObj fo)
                      throws PropertyException
        Create a Property object from an attribute specification. Contrary to basic lengths, percentages for font-size can be resolved here already: if the property evaluates to a PercentLength, it is immediately replaced by the resolved FixedLength.
        Overrides:
        make in class PropertyMaker
        Parameters:
        propertyList - The PropertyList object being built for this FO.
        value - The attribute value.
        fo - The parent FO for the FO whose property is being made.
        Returns:
        The initialized Property object.
        Throws:
        PropertyException - for invalid or inconsistent FO input
      • convertProperty

        public Property convertProperty​(Property p,
                                        PropertyList propertyList,
                                        FObj fo)
                                 throws PropertyException
        Return a Property object based on the passed Property object. This method is called if the Property object built by the parser isn't the right type for this property. It is overridden by subclasses. Implements the parts of 7.8.4 relevant to relative font sizes
        Overrides:
        convertProperty in class LengthProperty.Maker
        Parameters:
        p - The Property object return by the expression parser
        propertyList - The PropertyList object being built for this FO.
        fo - The parent FO for the FO whose property is being made.
        Returns:
        A Property of the correct type or null if the parsed value can't be converted to the correct type.
        Throws:
        PropertyException - for invalid or inconsistent FO input
      • computeClosestAbsoluteFontSize

        private int computeClosestAbsoluteFontSize​(int baseFontSize)
        Calculates the nearest absolute font size to the given font size.
        Parameters:
        baseFontSize - the font size in mpt of the parent fo
        Returns:
        the closest absolute font size