Class ConstraintWidget

  • Direct Known Subclasses:
    Guideline, HelperWidget, WidgetContainer

    public class ConstraintWidget
    extends java.lang.Object
    Implements a constraint Widget model supporting constraints relations between other widgets.

    The widget has various anchors (i.e. Left, Top, Right, Bottom, representing their respective sides, as well as Baseline, Center_X and Center_Y). Connecting anchors from one widget to another represents a constraint relation between the two anchors; the LinearSystem will then be able to use this model to try to minimize the distances between connected anchors.

    If opposite anchors are connected (e.g. Left and Right anchors), if they have the same strength, the widget will be equally pulled toward their respective target anchor positions; if the widget has a fixed size, this means that the widget will be centered between the two target anchors. If the widget's size is allowed to adjust, the size of the widget will change to be as large as necessary so that the widget's anchors and the target anchors' distances are zero.

    Constraints are set by connecting a widget's anchor to another via the connect(androidx.constraintlayout.core.widgets.ConstraintAnchor, androidx.constraintlayout.core.widgets.ConstraintAnchor, int) function.
    • Field Detail

      • measured

        public boolean measured
      • horizontalChainRun

        public ChainRun horizontalChainRun
      • verticalChainRun

        public ChainRun verticalChainRun
      • isTerminalWidget

        public boolean[] isTerminalWidget
      • stringId

        public java.lang.String stringId
      • MATCH_CONSTRAINT_SPREAD

        public static final int MATCH_CONSTRAINT_SPREAD
        See Also:
        Constant Field Values
      • MATCH_CONSTRAINT_PERCENT

        public static final int MATCH_CONSTRAINT_PERCENT
        See Also:
        Constant Field Values
      • MATCH_CONSTRAINT_RATIO_RESOLVED

        public static final int MATCH_CONSTRAINT_RATIO_RESOLVED
        See Also:
        Constant Field Values
      • WRAP_BEHAVIOR_HORIZONTAL_ONLY

        public static final int WRAP_BEHAVIOR_HORIZONTAL_ONLY
        See Also:
        Constant Field Values
      • WRAP_BEHAVIOR_VERTICAL_ONLY

        public static final int WRAP_BEHAVIOR_VERTICAL_ONLY
        See Also:
        Constant Field Values
      • mHorizontalResolution

        public int mHorizontalResolution
      • mVerticalResolution

        public int mVerticalResolution
      • mMatchConstraintDefaultWidth

        public int mMatchConstraintDefaultWidth
      • mMatchConstraintDefaultHeight

        public int mMatchConstraintDefaultHeight
      • mResolvedMatchConstraintDefault

        public int[] mResolvedMatchConstraintDefault
      • mMatchConstraintMinWidth

        public int mMatchConstraintMinWidth
      • mMatchConstraintMaxWidth

        public int mMatchConstraintMaxWidth
      • mMatchConstraintPercentWidth

        public float mMatchConstraintPercentWidth
      • mMatchConstraintMinHeight

        public int mMatchConstraintMinHeight
      • mMatchConstraintMaxHeight

        public int mMatchConstraintMaxHeight
      • mMatchConstraintPercentHeight

        public float mMatchConstraintPercentHeight
      • mIsWidthWrapContent

        public boolean mIsWidthWrapContent
      • mIsHeightWrapContent

        public boolean mIsHeightWrapContent
      • mCircleConstraintAngle

        public float mCircleConstraintAngle
      • mDimensionRatio

        public float mDimensionRatio
      • mDimensionRatioSide

        protected int mDimensionRatioSide
      • mX

        protected int mX
      • mY

        protected int mY
      • mOffsetX

        protected int mOffsetX
      • mOffsetY

        protected int mOffsetY
      • mMinWidth

        protected int mMinWidth
      • mMinHeight

        protected int mMinHeight
      • DEFAULT_BIAS

        public static float DEFAULT_BIAS
      • mWeight

        public float[] mWeight
      • mListNextMatchConstraintsWidget

        protected ConstraintWidget[] mListNextMatchConstraintsWidget
      • horizontalGroup

        public int horizontalGroup
      • verticalGroup

        public int verticalGroup
    • Constructor Detail

      • ConstraintWidget

        public ConstraintWidget()
        Default constructor
      • ConstraintWidget

        public ConstraintWidget​(java.lang.String debugName)
      • ConstraintWidget

        public ConstraintWidget​(int x,
                                int y,
                                int width,
                                int height)
        Constructor
        Parameters:
        x - x position
        y - y position
        width - width of the layout
        height - height of the layout
      • ConstraintWidget

        public ConstraintWidget​(java.lang.String debugName,
                                int x,
                                int y,
                                int width,
                                int height)
      • ConstraintWidget

        public ConstraintWidget​(int width,
                                int height)
        Constructor
        Parameters:
        width - width of the layout
        height - height of the layout
      • ConstraintWidget

        public ConstraintWidget​(java.lang.String debugName,
                                int width,
                                int height)
    • Method Detail

      • getRun

        public WidgetRun getRun​(int orientation)
      • setFinalFrame

        public void setFinalFrame​(int left,
                                  int top,
                                  int right,
                                  int bottom,
                                  int baseline,
                                  int orientation)
      • setFinalLeft

        public void setFinalLeft​(int x1)
      • setFinalTop

        public void setFinalTop​(int y1)
      • resetSolvingPassFlag

        public void resetSolvingPassFlag()
      • isHorizontalSolvingPassDone

        public boolean isHorizontalSolvingPassDone()
      • isVerticalSolvingPassDone

        public boolean isVerticalSolvingPassDone()
      • markHorizontalSolvingPassDone

        public void markHorizontalSolvingPassDone()
      • markVerticalSolvingPassDone

        public void markVerticalSolvingPassDone()
      • setFinalHorizontal

        public void setFinalHorizontal​(int x1,
                                       int x2)
      • setFinalVertical

        public void setFinalVertical​(int y1,
                                     int y2)
      • setFinalBaseline

        public void setFinalBaseline​(int baselineValue)
      • isResolvedHorizontally

        public boolean isResolvedHorizontally()
      • isResolvedVertically

        public boolean isResolvedVertically()
      • resetFinalResolution

        public void resetFinalResolution()
      • ensureMeasureRequested

        public void ensureMeasureRequested()
      • hasDependencies

        public boolean hasDependencies()
      • hasDanglingDimension

        public boolean hasDanglingDimension​(int orientation)
      • hasResolvedTargets

        public boolean hasResolvedTargets​(int orientation,
                                          int size)
      • isInVirtualLayout

        public boolean isInVirtualLayout()
      • setInVirtualLayout

        public void setInVirtualLayout​(boolean inVirtualLayout)
      • getMaxHeight

        public int getMaxHeight()
      • getMaxWidth

        public int getMaxWidth()
      • setMaxWidth

        public void setMaxWidth​(int maxWidth)
      • setMaxHeight

        public void setMaxHeight​(int maxHeight)
      • isSpreadWidth

        public boolean isSpreadWidth()
      • isSpreadHeight

        public boolean isSpreadHeight()
      • setHasBaseline

        public void setHasBaseline​(boolean hasBaseline)
      • getHasBaseline

        public boolean getHasBaseline()
      • isInPlaceholder

        public boolean isInPlaceholder()
      • setInPlaceholder

        public void setInPlaceholder​(boolean inPlaceholder)
      • setInBarrier

        protected void setInBarrier​(int orientation,
                                    boolean value)
      • isInBarrier

        public boolean isInBarrier​(int orientation)
      • setMeasureRequested

        public void setMeasureRequested​(boolean measureRequested)
      • isMeasureRequested

        public boolean isMeasureRequested()
      • setWrapBehaviorInParent

        public void setWrapBehaviorInParent​(int behavior)
      • getWrapBehaviorInParent

        public int getWrapBehaviorInParent()
      • getLastHorizontalMeasureSpec

        public int getLastHorizontalMeasureSpec()
      • getLastVerticalMeasureSpec

        public int getLastVerticalMeasureSpec()
      • setLastMeasureSpec

        public void setLastMeasureSpec​(int horizontal,
                                       int vertical)
      • reset

        public void reset()
      • serialize

        public java.lang.StringBuilder serialize​(java.lang.StringBuilder ret)
        Serialize the anchors for JSON5 output
        Parameters:
        ret - StringBuilder to be populated
        Returns:
        the same string builder to alow chaining
      • oppositeDimensionDependsOn

        public boolean oppositeDimensionDependsOn​(int orientation)
      • oppositeDimensionsTied

        public boolean oppositeDimensionsTied()
      • hasDimensionOverride

        public boolean hasDimensionOverride()
      • ensureWidgetRuns

        public void ensureWidgetRuns()
      • resetSolverVariables

        public void resetSolverVariables​(Cache cache)
        Reset the solver variables of the anchors
      • isRoot

        public boolean isRoot()
        Returns true if the widget is the root widget
        Returns:
        true if root widget, false otherwise
      • getParent

        public ConstraintWidget getParent()
        Returns the parent of this widget if there is one
        Returns:
        parent
      • setParent

        public void setParent​(ConstraintWidget widget)
        Set the parent of this widget
        Parameters:
        widget - parent
      • setWidthWrapContent

        public void setWidthWrapContent​(boolean widthWrapContent)
        Keep track of wrap_content for width
      • isWidthWrapContent

        public boolean isWidthWrapContent()
        Returns true if width is set to wrap_content
      • setHeightWrapContent

        public void setHeightWrapContent​(boolean heightWrapContent)
        Keep track of wrap_content for height
      • isHeightWrapContent

        public boolean isHeightWrapContent()
        Returns true if height is set to wrap_content
      • connectCircularConstraint

        public void connectCircularConstraint​(ConstraintWidget target,
                                              float angle,
                                              int radius)
        Set a circular constraint
        Parameters:
        target - the target widget we will use as the center of the circle
        angle - the angle (from 0 to 360)
        radius - the radius used
      • getType

        public java.lang.String getType()
        Returns the type string if set
        Returns:
        type (null if not set)
      • setType

        public void setType​(java.lang.String type)
        Set the type of the widget (as a String)
        Parameters:
        type - type of the widget
      • setVisibility

        public void setVisibility​(int visibility)
        Set the visibility for this widget
        Parameters:
        visibility - either VISIBLE, INVISIBLE, or GONE
      • getVisibility

        public int getVisibility()
        Returns the current visibility value for this widget
        Returns:
        the visibility (VISIBLE, INVISIBLE, or GONE)
      • setAnimated

        public void setAnimated​(boolean animated)
        Set if this widget is animated. Currently only affects gone behaviour
        Parameters:
        animated - if true the widget must be positioned correctly when not visible
      • isAnimated

        public boolean isAnimated()
        Returns if this widget is animated. Currently only affects gone behaviour
        Returns:
        true if ConstraintWidget is used in Animation
      • getDebugName

        public java.lang.String getDebugName()
        Returns the name of this widget (used for debug purposes)
        Returns:
        the debug name
      • setDebugName

        public void setDebugName​(java.lang.String name)
        Set the debug name of this widget
      • setDebugSolverName

        public void setDebugSolverName​(LinearSystem system,
                                       java.lang.String name)
        Utility debug function. Sets the names of the anchors in the solver given a widget's name. The given name is used as a prefix, resulting in anchors' names of the form:

        • {name}.left
        • {name}.top
        • {name}.right
        • {name}.bottom
        • {name}.baseline
        Parameters:
        system - solver used
        name - name of the widget
      • createObjectVariables

        public void createObjectVariables​(LinearSystem system)
        Create all the system variables for this widget
      • toString

        public java.lang.String toString()
        Returns a string representation of the ConstraintWidget
        Overrides:
        toString in class java.lang.Object
        Returns:
        string representation of the widget
      • getX

        public int getX()
        Return the x position of the widget, relative to its container
        Returns:
        x position
      • getY

        public int getY()
        Return the y position of the widget, relative to its container
        Returns:
        y position
      • getWidth

        public int getWidth()
        Return the width of the widget
        Returns:
        width width
      • getOptimizerWrapWidth

        public int getOptimizerWrapWidth()
      • getOptimizerWrapHeight

        public int getOptimizerWrapHeight()
      • getHeight

        public int getHeight()
        Return the height of the widget
        Returns:
        height height
      • getLength

        public int getLength​(int orientation)
        Get a dimension of the widget in a particular orientation.
        Returns:
        The dimension of the specified orientation.
      • getRootX

        protected int getRootX()
        Return the x position of the widget, relative to the root (without animation)
        Returns:
        x position
      • getRootY

        protected int getRootY()
        Return the y position of the widget, relative to the root (without animation)
      • getMinWidth

        public int getMinWidth()
        Return the minimum width of the widget
        Returns:
        minimum width
      • getMinHeight

        public int getMinHeight()
        Return the minimum height of the widget
        Returns:
        minimum height
      • getLeft

        public int getLeft()
        Return the left position of the widget (similar to getX())
        Returns:
        left position of the widget
      • getTop

        public int getTop()
        Return the top position of the widget (similar to getY())
        Returns:
        top position of the widget
      • getRight

        public int getRight()
        Return the right position of the widget
        Returns:
        right position of the widget
      • getBottom

        public int getBottom()
        Return the bottom position of the widget
        Returns:
        bottom position of the widget
      • getHorizontalMargin

        public int getHorizontalMargin()
        Returns all the horizontal margin of the widget.
      • getVerticalMargin

        public int getVerticalMargin()
        Returns all the vertical margin of the widget
      • getHorizontalBiasPercent

        public float getHorizontalBiasPercent()
        Return the horizontal percentage bias that is used when two opposite connections exist of the same strength.
        Returns:
        horizontal percentage bias
      • getVerticalBiasPercent

        public float getVerticalBiasPercent()
        Return the vertical percentage bias that is used when two opposite connections exist of the same strength.
        Returns:
        vertical percentage bias
      • getBiasPercent

        public float getBiasPercent​(int orientation)
        Return the percentage bias that is used when two opposite connections exist of the same strength in a particular orientation.
        Parameters:
        orientation - Orientation HORIZONTAL/VERTICAL.
        Returns:
        Respective percentage bias.
      • hasBaseline

        public boolean hasBaseline()
        Return true if this widget has a baseline
        Returns:
        true if the widget has a baseline, false otherwise
      • getBaselineDistance

        public int getBaselineDistance()
        Return the baseline distance relative to the top of the widget
        Returns:
        baseline
      • getCompanionWidget

        public java.lang.Object getCompanionWidget()
        Return the companion widget. Typically, this would be the real widget we represent with this instance of ConstraintWidget.
        Returns:
        the companion widget, if set.
      • getAnchors

        public java.util.ArrayList<ConstraintAnchor> getAnchors()
        Return the array of anchors of this widget
        Returns:
        array of anchors
      • setX

        public void setX​(int x)
        Set the x position of the widget, relative to its container
        Parameters:
        x - x position
      • setY

        public void setY​(int y)
        Set the y position of the widget, relative to its container
        Parameters:
        y - y position
      • setOrigin

        public void setOrigin​(int x,
                              int y)
        Set both the origin in (x, y) of the widget, relative to its container
        Parameters:
        x - x position
        y - y position
      • setOffset

        public void setOffset​(int x,
                              int y)
        Set the offset of this widget relative to the root widget
        Parameters:
        x - horizontal offset
        y - vertical offset
      • setGoneMargin

        public void setGoneMargin​(ConstraintAnchor.Type type,
                                  int goneMargin)
        Set the margin to be used when connected to a widget with a visibility of GONE
        Parameters:
        type - the anchor to set the margin on
        goneMargin - the margin value to use
      • setWidth

        public void setWidth​(int w)
        Set the width of the widget
        Parameters:
        w - width
      • setHeight

        public void setHeight​(int h)
        Set the height of the widget
        Parameters:
        h - height
      • setLength

        public void setLength​(int length,
                              int orientation)
        Set the dimension of a widget in a particular orientation.
        Parameters:
        length - Size of the dimension.
        orientation - HORIZONTAL or VERTICAL
      • setHorizontalMatchStyle

        public void setHorizontalMatchStyle​(int horizontalMatchStyle,
                                            int min,
                                            int max,
                                            float percent)
        Set the horizontal style when MATCH_CONSTRAINT is set
        Parameters:
        horizontalMatchStyle - MATCH_CONSTRAINT_SPREAD or MATCH_CONSTRAINT_WRAP
        min - minimum value
        max - maximum value
        percent - Percent width
      • setVerticalMatchStyle

        public void setVerticalMatchStyle​(int verticalMatchStyle,
                                          int min,
                                          int max,
                                          float percent)
        Set the vertical style when MATCH_CONSTRAINT is set
        Parameters:
        verticalMatchStyle - MATCH_CONSTRAINT_SPREAD or MATCH_CONSTRAINT_WRAP
        min - minimum value
        max - maximum value
        percent - Percent height
      • setDimensionRatio

        public void setDimensionRatio​(java.lang.String ratio)
        Set the ratio of the widget
        Parameters:
        ratio - given string of format [H|V],[float|x:y] or [float|x:y]
      • setDimensionRatio

        public void setDimensionRatio​(float ratio,
                                      int dimensionRatioSide)
        Set the ratio of the widget The ratio will be applied if at least one of the dimension (width or height) is set to a behaviour of DimensionBehaviour.MATCH_CONSTRAINT -- the dimension's value will be set to the other dimension * ratio.
        Parameters:
        ratio - A float value that describes W/H or H/W depending on the provided dimensionRatioSide
        dimensionRatioSide - The side the ratio should be calculated on, HORIZONTAL, VERTICAL, or UNKNOWN
      • getDimensionRatio

        public float getDimensionRatio()
        Return the current ratio of this widget
        Returns:
        the dimension ratio (HORIZONTAL, VERTICAL, or UNKNOWN)
      • getDimensionRatioSide

        public int getDimensionRatioSide()
        Return the current side on which ratio will be applied
        Returns:
        HORIZONTAL, VERTICAL, or UNKNOWN
      • setHorizontalBiasPercent

        public void setHorizontalBiasPercent​(float horizontalBiasPercent)
        Set the horizontal bias percent to apply when we have two opposite constraints of equal strength
        Parameters:
        horizontalBiasPercent - the percentage used
      • setVerticalBiasPercent

        public void setVerticalBiasPercent​(float verticalBiasPercent)
        Set the vertical bias percent to apply when we have two opposite constraints of equal strength
        Parameters:
        verticalBiasPercent - the percentage used
      • setMinWidth

        public void setMinWidth​(int w)
        Set the minimum width of the widget
        Parameters:
        w - minimum width
      • setMinHeight

        public void setMinHeight​(int h)
        Set the minimum height of the widget
        Parameters:
        h - minimum height
      • setDimension

        public void setDimension​(int w,
                                 int h)
        Set both width and height of the widget
        Parameters:
        w - width
        h - height
      • setFrame

        public void setFrame​(int left,
                             int top,
                             int right,
                             int bottom)
        Set the position+dimension of the widget given left/top/right/bottom
        Parameters:
        left - left side position of the widget
        top - top side position of the widget
        right - right side position of the widget
        bottom - bottom side position of the widget
      • setFrame

        public void setFrame​(int start,
                             int end,
                             int orientation)
        Set the position+dimension of the widget based on starting/ending positions on one dimension.
        Parameters:
        start - Left/Top side position of the widget.
        end - Right/Bottom side position of the widget.
        orientation - Orientation being set (HORIZONTAL/VERTICAL).
      • setHorizontalDimension

        public void setHorizontalDimension​(int left,
                                           int right)
        Set the positions for the horizontal dimension only
        Parameters:
        left - left side position of the widget
        right - right side position of the widget
      • setVerticalDimension

        public void setVerticalDimension​(int top,
                                         int bottom)
        Set the positions for the vertical dimension only
        Parameters:
        top - top side position of the widget
        bottom - bottom side position of the widget
      • setBaselineDistance

        public void setBaselineDistance​(int baseline)
        Set the baseline distance relative to the top of the widget
        Parameters:
        baseline - the distance of the baseline relative to the widget's top
      • setCompanionWidget

        public void setCompanionWidget​(java.lang.Object companion)
        Set the companion widget. Typically, this would be the real widget we represent with this instance of ConstraintWidget.
      • setContainerItemSkip

        public void setContainerItemSkip​(int skip)
        Set the skip value for this widget. This can be used when a widget is in a container, so that container can position the widget as if it was positioned further in the list of widgets. For example, with Table, this is used to skip empty cells (the widget after an empty cell will have a skip value of one)
      • getContainerItemSkip

        public int getContainerItemSkip()
        Accessor for the skip value
        Returns:
        skip value
      • setHorizontalWeight

        public void setHorizontalWeight​(float horizontalWeight)
        Set the horizontal weight (only used in chains)
        Parameters:
        horizontalWeight - Floating point value weight
      • setVerticalWeight

        public void setVerticalWeight​(float verticalWeight)
        Set the vertical weight (only used in chains)
        Parameters:
        verticalWeight - Floating point value weight
      • setHorizontalChainStyle

        public void setHorizontalChainStyle​(int horizontalChainStyle)
        Set the chain starting from this widget to be packed. The horizontal bias will control how elements of the chain are positioned.
        Parameters:
        horizontalChainStyle - (CHAIN_SPREAD, CHAIN_SPREAD_INSIDE, CHAIN_PACKED)
      • getHorizontalChainStyle

        public int getHorizontalChainStyle()
        get the chain starting from this widget to be packed. The horizontal bias will control how elements of the chain are positioned.
        Returns:
        Horizontal Chain Style
      • setVerticalChainStyle

        public void setVerticalChainStyle​(int verticalChainStyle)
        Set the chain starting from this widget to be packed. The vertical bias will control how elements of the chain are positioned.
        Parameters:
        verticalChainStyle - (CHAIN_SPREAD, CHAIN_SPREAD_INSIDE, CHAIN_PACKED)
      • getVerticalChainStyle

        public int getVerticalChainStyle()
        Set the chain starting from this widget to be packed. The vertical bias will control how elements of the chain are positioned.
      • allowedInBarrier

        public boolean allowedInBarrier()
        Returns true if this widget should be used in a barrier
      • immediateConnect

        public void immediateConnect​(ConstraintAnchor.Type startType,
                                     ConstraintWidget target,
                                     ConstraintAnchor.Type endType,
                                     int margin,
                                     int goneMargin)
        Immediate connection to an anchor without any checks.
        Parameters:
        startType - The type of anchor on this widget
        target - The target widget
        endType - The type of anchor on the target widget
        margin - How much margin we want to keep as a minimum distance between the two anchors
        goneMargin - How much margin we want to keep if the target is set to View.GONE
      • connect

        public void connect​(ConstraintAnchor from,
                            ConstraintAnchor to,
                            int margin)
        Connect the given anchors together (the from anchor should be owned by this widget)
        Parameters:
        from - the anchor we are connecting from (of this widget)
        to - the anchor we are connecting to
        margin - how much margin we want to have
      • connect

        public void connect​(ConstraintAnchor.Type constraintFrom,
                            ConstraintWidget target,
                            ConstraintAnchor.Type constraintTo)
        Connect a given anchor of this widget to another anchor of a target widget
        Parameters:
        constraintFrom - which anchor of this widget to connect from
        target - the target widget
        constraintTo - the target anchor on the target widget
      • connect

        public void connect​(ConstraintAnchor.Type constraintFrom,
                            ConstraintWidget target,
                            ConstraintAnchor.Type constraintTo,
                            int margin)
        Connect a given anchor of this widget to another anchor of a target widget
        Parameters:
        constraintFrom - which anchor of this widget to connect from
        target - the target widget
        constraintTo - the target anchor on the target widget
        margin - how much margin we want to keep as a minimum distance between the two anchors
      • resetAllConstraints

        public void resetAllConstraints()
        Reset all the constraints set on this widget
      • resetAnchor

        public void resetAnchor​(ConstraintAnchor anchor)
        Reset the given anchor
        Parameters:
        anchor - the anchor we want to reset
      • resetAnchors

        public void resetAnchors()
        Reset all connections
      • getAnchor

        public ConstraintAnchor getAnchor​(ConstraintAnchor.Type anchorType)
        Given a type of anchor, returns the corresponding anchor.
        Parameters:
        anchorType - type of the anchor (LEFT, TOP, RIGHT, BOTTOM, BASELINE, CENTER_X, CENTER_Y)
        Returns:
        the matching anchor
      • getHorizontalDimensionBehaviour

        public ConstraintWidget.DimensionBehaviour getHorizontalDimensionBehaviour()
        Accessor for the horizontal dimension behaviour
        Returns:
        dimension behaviour
      • getVerticalDimensionBehaviour

        public ConstraintWidget.DimensionBehaviour getVerticalDimensionBehaviour()
        Accessor for the vertical dimension behaviour
        Returns:
        dimension behaviour
      • setHorizontalDimensionBehaviour

        public void setHorizontalDimensionBehaviour​(ConstraintWidget.DimensionBehaviour behaviour)
        Set the widget's behaviour for the horizontal dimension
        Parameters:
        behaviour - the horizontal dimension's behaviour
      • setVerticalDimensionBehaviour

        public void setVerticalDimensionBehaviour​(ConstraintWidget.DimensionBehaviour behaviour)
        Set the widget's behaviour for the vertical dimension
        Parameters:
        behaviour - the vertical dimension's behaviour
      • isInHorizontalChain

        public boolean isInHorizontalChain()
        Test if you are in a Horizontal chain
        Returns:
        true if in a horizontal chain
      • getPreviousChainMember

        public ConstraintWidget getPreviousChainMember​(int orientation)
        Return the previous chain member if one exists
        Parameters:
        orientation - HORIZONTAL or VERTICAL
        Returns:
        the previous chain member or null if we are the first chain element
      • getNextChainMember

        public ConstraintWidget getNextChainMember​(int orientation)
        Return the next chain member if one exists
        Parameters:
        orientation - HORIZONTAL or VERTICAL
        Returns:
        the next chain member or null if we are the last chain element
      • getHorizontalChainControlWidget

        public ConstraintWidget getHorizontalChainControlWidget()
        if in a horizontal chain return the left most widget in the chain.
        Returns:
        left most widget in chain or null
      • isInVerticalChain

        public boolean isInVerticalChain()
        Test if you are in a vertical chain
        Returns:
        true if in a vertical chain
      • getVerticalChainControlWidget

        public ConstraintWidget getVerticalChainControlWidget()
        if in a vertical chain return the top most widget in the chain.
        Returns:
        top most widget in chain or null
      • addToSolver

        public void addToSolver​(LinearSystem system,
                                boolean optimize)
        Add this widget to the solver
        Parameters:
        system - the solver we want to add the widget to
        optimize - true if Optimizer.OPTIMIZATION_GRAPH is on
      • setupDimensionRatio

        public void setupDimensionRatio​(boolean hParentWrapContent,
                                        boolean vParentWrapContent,
                                        boolean horizontalDimensionFixed,
                                        boolean verticalDimensionFixed)
        Resolves the dimension ratio parameters (mResolvedDimensionRatioSide & mDimensionRatio)
        Parameters:
        hParentWrapContent - true if parent is in wrap content horizontally
        vParentWrapContent - true if parent is in wrap content vertically
        horizontalDimensionFixed - true if this widget horizontal dimension is fixed
        verticalDimensionFixed - true if this widget vertical dimension is fixed
      • updateFromSolver

        public void updateFromSolver​(LinearSystem system,
                                     boolean optimize)
        Update the widget from the values generated by the solver
        Parameters:
        system - the solver we get the values from.
        optimize - true if Optimizer.OPTIMIZATION_GRAPH is on
      • updateFromRuns

        public void updateFromRuns​(boolean updateHorizontal,
                                   boolean updateVertical)
      • getSceneString

        public void getSceneString​(java.lang.StringBuilder ret)