Class DimConstraint

  • All Implemented Interfaces:
    java.io.Externalizable, java.io.Serializable

    public final class DimConstraint
    extends java.lang.Object
    implements java.io.Externalizable
    A simple value holder for a constraint for one dimension.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      DimConstraint()
      Empty constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      UnitValue getAlign()
      Returns the alignment used either as a default value for sub-entities or for this entity.
      UnitValue getAlignOrDefault​(boolean isCols)  
      (package private) int[] getComponentGaps​(ContainerWrapper parent, ComponentWrapper comp, BoundSize adjGap, ComponentWrapper adjacentComp, java.lang.String tag, int refSize, int adjacentSide, boolean isLTR)
      Returns the gaps as pixel values.
      java.lang.String getEndGroup()
      Returns the end group that this entity should be in for the dimension that this object is describing.
      BoundSize getGapAfter()
      Returns the gap after this entity.
      BoundSize getGapBefore()
      Returns the gap before this entity.
      java.lang.Float getGrow()
      Returns the grow weight.
      int getGrowPriority()
      Returns the grow priority.
      (package private) int[] getRowGaps​(ContainerWrapper parent, BoundSize defGap, int refSize, boolean before)
      Returns the gaps as pixel values.
      java.lang.Float getShrink()
      Returns the shrink priority.
      int getShrinkPriority()
      Returns the shrink priority.
      BoundSize getSize()
      Returns the min/preferred/max size for the entity in the dimension that this object describes.
      java.lang.String getSizeGroup()
      Returns the size group that this entity should be in for the dimension that this object is describing.
      (package private) boolean hasGapAfter()  
      (package private) boolean hasGapBefore()  
      boolean isFill()
      Returns if the component in the row/column that this constraint should default be grown in the same dimension that this constraint represents (width for column and height for a row).
      (package private) boolean isGapAfterPush()  
      (package private) boolean isGapBeforePush()  
      boolean isNoGrid()
      Returns if the row/column should default to flow and not to grid behaviour.
      void readExternal​(java.io.ObjectInput in)  
      private java.lang.Object readResolve()  
      void setAlign​(UnitValue uv)
      Sets the alignment used wither as a default value for sub-entities or for this entity.
      void setEndGroup​(java.lang.String s)
      Sets the end group that this entity should be in for the dimension that this object is describing.
      void setFill​(boolean b)
      Sets if the component in the row/column that this constraint should default be grown in the same dimension that this constraint represents (width for column and height for a row).
      void setGapAfter​(BoundSize size)
      Sets the gap after this entity.
      void setGapBefore​(BoundSize size)
      Sets the gap before this entity.
      void setGrow​(java.lang.Float weight)
      Sets the grow weight.
      void setGrowPriority​(int p)
      Sets the grow priority.
      void setNoGrid​(boolean b)
      Sets if the row/column should default to flow and not to grid behaviour.
      void setShrink​(java.lang.Float weight)
      Sets the shrink priority.
      void setShrinkPriority​(int p)
      Sets the shrink priority.
      void setSize​(BoundSize size)
      Sets the min/preferred/max size for the entity in the dimension that this object describes.
      void setSizeGroup​(java.lang.String s)
      Sets the size group that this entity should be in for the dimension that this object is describing.
      void writeExternal​(java.io.ObjectOutput out)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • resize

        final ResizeConstraint resize
        How this entity can be resized in the dimension that this constraint represents.
      • sizeGroup

        private java.lang.String sizeGroup
      • endGroup

        private java.lang.String endGroup
      • fill

        private boolean fill
      • noGrid

        private boolean noGrid
    • Constructor Detail

      • DimConstraint

        public DimConstraint()
        Empty constructor.
    • Method Detail

      • getGrowPriority

        public int getGrowPriority()
        Returns the grow priority. Relative priority is used for determining which entities gets the extra space first.

        For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

        Returns:
        The grow priority.
      • setGrowPriority

        public void setGrowPriority​(int p)
        Sets the grow priority. Relative priority is used for determining which entities gets the extra space first.

        For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

        Parameters:
        p - The new grow priority.
      • getGrow

        public java.lang.Float getGrow()
        Returns the grow weight.

        Grow weight is how flexible the entity should be, relative to other entities, when it comes to growing. null or zero mean it will never grow. An entity that has twice the grow weight compared to another entity will get twice as much of available space.

        GrowWeight are only compared within the same GrowPrio.

        For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

        Returns:
        The current grow weight.
      • setGrow

        public void setGrow​(java.lang.Float weight)
        Sets the grow weight.

        Grow weight is how flexible the entity should be, relative to other entities, when it comes to growing. null or zero mean it will never grow. An entity that has twice the grow weight compared to another entity will get twice as much of available space.

        GrowWeight are only compared within the same GrowPrio.

        For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

        Parameters:
        weight - The new grow weight.
      • getShrinkPriority

        public int getShrinkPriority()
        Returns the shrink priority. Relative priority is used for determining which entities gets smaller first when space is scarce.

        For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

        Returns:
        The shrink priority.
      • setShrinkPriority

        public void setShrinkPriority​(int p)
        Sets the shrink priority. Relative priority is used for determining which entities gets smaller first when space is scarce.

        For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

        Parameters:
        p - The new shrink priority.
      • getShrink

        public java.lang.Float getShrink()
        Returns the shrink priority. Relative priority is used for determining which entities gets smaller first when space is scarce. Shrink weight is how flexible the entity should be, relative to other entities, when it comes to shrinking. null or zero mean it will never shrink (default). An entity that has twice the shrink weight compared to another entity will get twice as much of available space.

        Shrink(Weight) are only compared within the same ShrinkPrio.

        For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

        Returns:
        The current shrink weight.
      • setShrink

        public void setShrink​(java.lang.Float weight)
        Sets the shrink priority. Relative priority is used for determining which entities gets smaller first when space is scarce. Shrink weight is how flexible the entity should be, relative to other entities, when it comes to shrinking. null or zero mean it will never shrink (default). An entity that has twice the shrink weight compared to another entity will get twice as much of available space.

        Shrink(Weight) are only compared within the same ShrinkPrio.

        For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

        Parameters:
        weight - The new shrink weight.
      • getAlignOrDefault

        public UnitValue getAlignOrDefault​(boolean isCols)
      • getAlign

        public UnitValue getAlign()
        Returns the alignment used either as a default value for sub-entities or for this entity.

        For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

        Returns:
        The alignment.
      • setAlign

        public void setAlign​(UnitValue uv)
        Sets the alignment used wither as a default value for sub-entities or for this entity.

        For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

        Parameters:
        uv - The new shrink priority. E.g. UnitValue.CENTER or UnitValue.LEADING.
      • getGapAfter

        public BoundSize getGapAfter()
        Returns the gap after this entity. The gap is an empty space and can have a min/preferred/maximum size so that it can shrink and grow depending on available space. Gaps are against other entities' edges and not against other entities' gaps.

        For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

        Returns:
        The gap after this entity
      • setGapAfter

        public void setGapAfter​(BoundSize size)
        Sets the gap after this entity. The gap is an empty space and can have a min/preferred/maximum size so that it can shrink and grow depending on available space. Gaps are against other entities' edges and not against other entities' gaps.

        For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

        Parameters:
        size - The new gap.
        See Also:
        ConstraintParser.parseBoundSize(String, boolean, boolean)
      • hasGapAfter

        boolean hasGapAfter()
      • isGapAfterPush

        boolean isGapAfterPush()
      • getGapBefore

        public BoundSize getGapBefore()
        Returns the gap before this entity. The gap is an empty space and can have a min/preferred/maximum size so that it can shrink and grow depending on available space. Gaps are against other entities' edges and not against other entities' gaps.

        For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

        Returns:
        The gap before this entity
      • setGapBefore

        public void setGapBefore​(BoundSize size)
        Sets the gap before this entity. The gap is an empty space and can have a min/preferred/maximum size so that it can shrink and grow depending on available space. Gaps are against other entities' edges and not against other entities' gaps.

        See also ConstraintParser.parseBoundSize(String, boolean, boolean). For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

        Parameters:
        size - The new gap.
      • hasGapBefore

        boolean hasGapBefore()
      • isGapBeforePush

        boolean isGapBeforePush()
      • getSize

        public BoundSize getSize()
        Returns the min/preferred/max size for the entity in the dimension that this object describes.

        See also ConstraintParser.parseBoundSize(String, boolean, boolean). For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

        Returns:
        The current size. Never null since v3.5.
      • setSize

        public void setSize​(BoundSize size)
        Sets the min/preferred/max size for the entity in the dimension that this object describes.

        For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

        Parameters:
        size - The new size. May be null.
      • getSizeGroup

        public java.lang.String getSizeGroup()
        Returns the size group that this entity should be in for the dimension that this object is describing. If this constraint is in a size group that is specified here. null means no size group and all other values are legal. Comparison with .equals(). Components/columns/rows in the same size group will have the same min/preferred/max size; that of the largest in the group for the first two and the smallest for max.

        For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

        Returns:
        The current size group. May be null.
      • setSizeGroup

        public void setSizeGroup​(java.lang.String s)
        Sets the size group that this entity should be in for the dimension that this object is describing. If this constraint is in a size group that is specified here. null means no size group and all other values are legal. Comparison with .equals(). Components/columns/rows in the same size group will have the same min/preferred/max size; that of the largest in the group for the first two and the smallest for max.

        For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

        Parameters:
        s - The new size group. null disables size grouping.
      • getEndGroup

        public java.lang.String getEndGroup()
        Returns the end group that this entity should be in for the dimension that this object is describing. If this constraint is in an end group that is specified here. null means no end group and all other values are legal. Comparison with .equals(). Components in the same end group will have the same end coordinate.

        For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

        Returns:
        The current end group. null may be returned.
      • setEndGroup

        public void setEndGroup​(java.lang.String s)
        Sets the end group that this entity should be in for the dimension that this object is describing. If this constraint is in an end group that is specified here. null means no end group and all other values are legal. Comparison with .equals(). Components in the same end group will have the same end coordinate.

        For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

        Parameters:
        s - The new end group. null disables end grouping.
      • isFill

        public boolean isFill()
        Returns if the component in the row/column that this constraint should default be grown in the same dimension that this constraint represents (width for column and height for a row).

        For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

        Returns:
        true means that components should grow.
      • setFill

        public void setFill​(boolean b)
        Sets if the component in the row/column that this constraint should default be grown in the same dimension that this constraint represents (width for column and height for a row).

        For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

        Parameters:
        b - true means that components should grow.
      • isNoGrid

        public boolean isNoGrid()
        Returns if the row/column should default to flow and not to grid behaviour. This means that the whole row/column will be one cell and all components will end up in that cell.

        For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

        Returns:
        true means that the whole row/column should be one cell.
      • setNoGrid

        public void setNoGrid​(boolean b)
        Sets if the row/column should default to flow and not to grid behaviour. This means that the whole row/column will be one cell and all components will end up in that cell.

        For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.

        Parameters:
        b - true means that the whole row/column should be one cell.
      • getRowGaps

        int[] getRowGaps​(ContainerWrapper parent,
                         BoundSize defGap,
                         int refSize,
                         boolean before)
        Returns the gaps as pixel values.
        Parameters:
        parent - The parent. Used to get the pixel values.
        defGap - The default gap to use if there is no gap set on this object (i.e. it is null).
        refSize - The reference size used to get the pixel sizes.
        before - IF it is the gap before rather than the gap after to return.
        Returns:
        The [min,preferred,max] sizes for the specified gap. Uses LayoutUtil.NOT_SET for gap sizes that are null. Returns null if there was no gap specified. A new and free to use array.
      • getComponentGaps

        int[] getComponentGaps​(ContainerWrapper parent,
                               ComponentWrapper comp,
                               BoundSize adjGap,
                               ComponentWrapper adjacentComp,
                               java.lang.String tag,
                               int refSize,
                               int adjacentSide,
                               boolean isLTR)
        Returns the gaps as pixel values.
        Parameters:
        parent - The parent. Used to get the pixel values.
        comp - The component that the gap is for. If not for a component it is null.
        adjGap - The gap that the adjacent component, if any, has towards comp.
        adjacentComp - The adjacent component if any. May be null.
        refSize - The reference size used to get the pixel sizes.
        adjacentSide - What side the adjacentComp is on. 0 = top, 1 = left, 2 = bottom, 3 = right.
        tag - The tag string that the component might be tagged with in the component constraints. May be null.
        isLTR - If it is left-to-right.
        Returns:
        The [min,preferred,max] sizes for the specified gap. Uses LayoutUtil.NOT_SET for gap sizes that are null. Returns null if there was no gap specified. A new and free to use array.
      • readResolve

        private java.lang.Object readResolve()
                                      throws java.io.ObjectStreamException
        Throws:
        java.io.ObjectStreamException
      • readExternal

        public void readExternal​(java.io.ObjectInput in)
                          throws java.io.IOException,
                                 java.lang.ClassNotFoundException
        Specified by:
        readExternal in interface java.io.Externalizable
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • writeExternal

        public void writeExternal​(java.io.ObjectOutput out)
                           throws java.io.IOException
        Specified by:
        writeExternal in interface java.io.Externalizable
        Throws:
        java.io.IOException