Class UnitValue

    • Constructor Detail

      • UnitValue

        public UnitValue​(float value)
      • UnitValue

        public UnitValue​(float value,
                         int unit,
                         String createString)
      • UnitValue

        public UnitValue​(float value,
                         String unitStr,
                         boolean isHor,
                         int oper,
                         String createString)
    • Method Detail

      • getPixels

        public final int getPixels​(float refValue,
                                   ContainerWrapper parent,
                                   ComponentWrapper comp)
        Returns the size in pixels rounded.
        Parameters:
        refValue - The reference value. Normally the size of the parent. For unit ALIGN the current size of the component should be sent in.
        parent - The parent. May be null for testing the validity of the value, but should normally not and are not required to return any usable value if null.
        comp - The component, if any, that the value is for. Might be null if the value is not connected to any component.
        Returns:
        The size in pixels.
      • getPixelsExact

        public final float getPixelsExact​(float refValue,
                                          ContainerWrapper parent,
                                          ComponentWrapper comp)
        Returns the size in pixels.
        Parameters:
        refValue - The reference value. Normally the size of the parent. For unit ALIGN the current size of the component should be sent in.
        parent - The parent. May be null for testing the validity of the value, but should normally not and are not required to return any usable value if null.
        comp - The component, if any, that the value is for. Might be null if the value is not connected to any component.
        Returns:
        The size in pixels.
      • getSubUnits

        public final UnitValue[] getSubUnits()
      • getUnit

        public final int getUnit()
      • getUnitString

        public final String getUnitString()
      • getOperation

        public final int getOperation()
      • getValue

        public final float getValue()
      • isHorizontal

        public final boolean isHorizontal()
      • getConstraintString

        public final String getConstraintString()
        Returns the creation string for this object. Note that LayoutUtil.setDesignTime(ContainerWrapper, boolean) must be set to true for the creation strings to be stored.
        Returns:
        The constraint string or null if none is registered.
      • hashCode

        public final int hashCode()
        Overrides:
        hashCode in class Object
      • addGlobalUnitConverter

        public static void addGlobalUnitConverter​(UnitConverter conv)
        Adds a global unit converter that can convert from some unit to pixels.

        This converter will be asked before the platform converter so the values for it (e.g. "related" and "unrelated") can be overridden. It is however not possible to override the built in ones (e.g. "mm", "pixel" or "lp").

        Parameters:
        conv - The converter. Not null.
      • removeGlobalUnitConverter

        public static boolean removeGlobalUnitConverter​(UnitConverter unit)
        Removed the converter.
        Parameters:
        unit - The converter.
        Returns:
        If there was a converter found and thus removed.
      • getGlobalUnitConverters

        public static UnitConverter[] getGlobalUnitConverters()
        Returns the global converters currently registered. The platform converter will not be in this list.
        Returns:
        The converters. Never null.