Class WidthRepresentation

  • All Implemented Interfaces:
    java.io.Serializable

    @API(type=EXTENDABLE,
         src=PUBLIC)
    public class WidthRepresentation
    extends java.lang.Object
    implements java.io.Serializable
    Specifies the fixed and relative width determined from the value of width/colwidth attribute of the col.
    See Also:
    Serialized Form
    • Field Detail

      • DEFAULT_WIDTH_REPRESENTATION

        public static final WidthRepresentation DEFAULT_WIDTH_REPRESENTATION
        The default width representation. EXM-32772 KEEP THIS HERE, IMPORTANT FOR BACKWARD COMPATIBILITY.
    • Constructor Detail

      • WidthRepresentation

        public WidthRepresentation​(float fixedWidthValue,
                                   WidthRepresentation.Unit fixedWidthUnit,
                                   float relativeWidth,
                                   boolean isRelativeToParent)
        Constructor.
        Parameters:
        fixedWidthValue - The fixed width value. Ex: 2.5
        fixedWidthUnit - The unit of fixed width. Defaults to PIXEL.
        relativeWidth - The relative width part. Ex: 0.33
        isRelativeToParent - If true then the relative width represents a percentage of the parent table width, otherwise the relative value represent a proportional width which is evaluated taking into account the proportional values of the other columns.
        For example, if there are two columns with 70% and 30% relative widths then the table total width will be divided according with this values.
        If the relative widths for the two columns are specified in proportional units and, for example, have the values 1 for the first column and 2 for the second column then the second column will be twice as large as the first one.
      • WidthRepresentation

        public WidthRepresentation​(java.lang.String widthString,
                                   boolean acceptPercents)
        Constructor. Create a ColWidth corresponding to the given width representation.
        Parameters:
        widthString - The string representation of the Width. The representation format must be a sum of terms with the following format: n(*|%|units). If there are more that one terms with the same form (fixed or relative) then corresponding width (fixed or relative) will be reseted.
        acceptPercents - If true then percentage values are accepted
    • Method Detail

      • getFixedWidth

        public float getFixedWidth()
        Returns:
        Returns the fixed width part of the width representation. Ex: 2.5
      • getFixedWidthUnit

        public WidthRepresentation.Unit getFixedWidthUnit()
        Returns:
        Returns the fixed width unit. Ex: Unit.CENTIMETER
      • getRelativeWidth

        public float getRelativeWidth()
        Returns:
        Returns the relative width part of the width representation.
      • isRelativeToParent

        public boolean isRelativeToParent()
        Returns:
        Returns true if the relative part of the width is expressed relative to the parent width, false if is expressed relative to other siblings.
      • isApplicable

        public boolean isApplicable()
        Returns:
        true if the current width representation should be taken into account when building the layout.
      • isSpecified

        public boolean isSpecified()
        Check if this width is specified.
        Returns:
        true if the width representation is resulted from a width specified in the document or false if this a default width representation.
      • getAlign

        public java.lang.String getAlign()
        Get the text align specified on the colspec.
        Returns:
        Returns the text align.
      • setAlign

        public void setAlign​(java.lang.String align)
        Set the text align specified on the colspec.
        Parameters:
        align - The align value.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        See Also:
        Object.toString()
      • getWidthRepresentation

        public java.lang.String getWidthRepresentation()
        Returns:
        The string representation of the width. The format of the width is
        [fixed_width][fixed_width_unit] + [relative_width %|*]