Class UnitValue

java.lang.Object
com.itextpdf.layout.properties.UnitValue

public class UnitValue extends Object
A specialized class that holds a value and the unit it is measured in.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
    protected int
     
    protected float
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    UnitValue(int unitType, float value)
    Creates a UnitValue object with a specified type and value.
    UnitValue(UnitValue unitValue)
    Creates a copy of UnitValue object.
  • Method Summary

    Modifier and Type
    Method
    Description
    static UnitValue[]
    createPercentArray(float[] values)
    Creates an array of UnitValue PERCENT objects with specified values.
    static UnitValue[]
    createPercentArray(int size)
    Creates an array of UnitValue PERCENT objects with equal values.
    static UnitValue
    createPercentValue(float value)
    Creates a UnitValue PERCENT object with a specified value.
    static UnitValue[]
    createPointArray(float[] values)
    Creates an array of UnitValue POINT objects with specified values.
    static UnitValue
    createPointValue(float value)
    Creates a UnitValue POINT object with a specified value.
    boolean
    equals(Object obj)
     
    int
    Returns the unit this value is stored in, either points (pt) or percent(%)
    float
    Gets the measured value stored in this object
    int
     
    boolean
    Returns whether or not the value is stored in percent (%)
    boolean
    Returns whether or not the value is stored in points (pt)
    void
    setUnitType(int unitType)
    Sets the unit this value is stored in, either points (pt) or percent(%)
    void
    setValue(float value)
    Sets the measured value stored in this object
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • UnitValue

      public UnitValue (int unitType, float value)
      Creates a UnitValue object with a specified type and value.
      Parameters:
      unitType - either POINT or a PERCENT
      value - the value to be stored.
    • UnitValue

      public UnitValue (UnitValue unitValue)
      Creates a copy of UnitValue object.
      Parameters:
      unitValue - the value to be stored
  • Method Details

    • createPointValue

      public static UnitValue createPointValue (float value)
      Creates a UnitValue POINT object with a specified value.
      Parameters:
      value - the value to be stored.
      Returns:
      a new POINT UnitValue
    • createPercentValue

      public static UnitValue createPercentValue (float value)
      Creates a UnitValue PERCENT object with a specified value.
      Parameters:
      value - the value to be stored.
      Returns:
      a new PERCENT UnitValue
    • createPercentArray

      public static UnitValue[] createPercentArray (float[] values)
      Creates an array of UnitValue PERCENT objects with specified values.
      Parameters:
      values - the values to be stored.
      Returns:
      a new normalized (Σ=100%) array of PERCENT UnitValue.
    • createPercentArray

      public static UnitValue[] createPercentArray (int size)
      Creates an array of UnitValue PERCENT objects with equal values.
      Parameters:
      size - of the resulted array.
      Returns:
      a array of equal PERCENT UnitValue.
    • createPointArray

      public static UnitValue[] createPointArray (float[] values)
      Creates an array of UnitValue POINT objects with specified values.
      Parameters:
      values - the values to be stored.
      Returns:
      a new array of POINT UnitValue
    • getUnitType

      public int getUnitType()
      Returns the unit this value is stored in, either points (pt) or percent(%)
      Returns:
      either 1 for POINT or 2 for PERCENT
    • setUnitType

      public void setUnitType (int unitType)
      Sets the unit this value is stored in, either points (pt) or percent(%)
      Parameters:
      unitType - either POINT or PERCENT
    • getValue

      public float getValue()
      Gets the measured value stored in this object
      Returns:
      the value, as a float
    • setValue

      public void setValue (float value)
      Sets the measured value stored in this object
      Parameters:
      value - a float
    • isPointValue

      public boolean isPointValue()
      Returns whether or not the value is stored in points (pt)
      Returns:
      true if stored in points
    • isPercentValue

      public boolean isPercentValue()
      Returns whether or not the value is stored in percent (%)
      Returns:
      true if stored in percent
    • equals

      public boolean equals (Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object