class ConstraintAnchor


Model a constraint relation. Widgets contains anchors, and a constraint relation between two widgets is made by connecting one anchor to another. The anchor will contains a pointer to the target anchor if it is connected.

Summary

Nested types

Define the type of anchor

Public constructors

Constructor

Public functions

Boolean
connect(toAnchor: ConstraintAnchor!, margin: Int)

Connects this anchor to another one.

Boolean
connect(
    toAnchor: ConstraintAnchor!,
    margin: Int,
    goneMargin: Int,
    forceConnection: Boolean
)

Connects this anchor to another one.

Unit
copyFrom(
    source: ConstraintAnchor!,
    map: HashMap<ConstraintWidget!, ConstraintWidget!>!
)
Unit
findDependents(
    orientation: Int,
    list: ArrayList<WidgetGroup!>!,
    group: WidgetGroup!
)
HashSet<ConstraintAnchor!>!
Int
Int

Return the connection's margin from this anchor to its target.

ConstraintAnchor!

Returns the opposite anchor to this one

ConstraintWidget!

Return the anchor's owner

SolverVariable!

Return the solver variable for this anchor

ConstraintAnchor!

Return the connection's target (null if not connected)

ConstraintAnchor.Type!

Return the type of the anchor

Boolean
Boolean
Boolean
Boolean

Returns the connection status of this anchor

Boolean

Return true if we can connect this anchor to this target.

Boolean

Return true if we can connect this anchor to this target.

Boolean

Return true if this anchor is a side anchor

Boolean

Return true if the connection to the given anchor is in the same dimension (horizontal or vertical)

Boolean

Checks if the connection to a given anchor is valid.

Boolean

Utility function returning true if this anchor is a vertical one.

Unit

Resets the anchor's connection.

Unit
Unit

Reset the solver variable

Unit
setFinalValue(finalValue: Int)
Unit
setGoneMargin(margin: Int)

Set the gone margin of the connection (if there's one)

Unit
setMargin(margin: Int)

Set the margin of the connection (if there's one)

String!

Return a string representation of this anchor

Public constructors

ConstraintAnchor

Added in 1.1.0-alpha13
ConstraintAnchor(owner: ConstraintWidget!, type: ConstraintAnchor.Type!)

Constructor

Parameters
owner: ConstraintWidget!

the widget owner of this anchor.

type: ConstraintAnchor.Type!

the anchor type.

Public functions

connect

Added in 1.1.0-alpha13
fun connect(toAnchor: ConstraintAnchor!, margin: Int): Boolean

Connects this anchor to another one.

Returns
Boolean

true if the connection succeeds.

connect

Added in 1.1.0-alpha13
fun connect(
    toAnchor: ConstraintAnchor!,
    margin: Int,
    goneMargin: Int,
    forceConnection: Boolean
): Boolean

Connects this anchor to another one.

Returns
Boolean

true if the connection succeeds.

copyFrom

Added in 1.1.0-alpha13
fun copyFrom(
    source: ConstraintAnchor!,
    map: HashMap<ConstraintWidget!, ConstraintWidget!>!
): Unit

findDependents

Added in 1.1.0-alpha13
fun findDependents(
    orientation: Int,
    list: ArrayList<WidgetGroup!>!,
    group: WidgetGroup!
): Unit

getDependents

Added in 1.1.0-alpha13
fun getDependents(): HashSet<ConstraintAnchor!>!

getFinalValue

Added in 1.1.0-alpha13
fun getFinalValue(): Int

getMargin

Added in 1.1.0-alpha13
fun getMargin(): Int

Return the connection's margin from this anchor to its target.

Returns
Int

the margin value. 0 if not connected.

getOpposite

Added in 1.1.0-alpha13
fun getOpposite(): ConstraintAnchor!

Returns the opposite anchor to this one

Returns
ConstraintAnchor!

opposite anchor

getOwner

Added in 1.1.0-alpha13
fun getOwner(): ConstraintWidget!

Return the anchor's owner

Returns
ConstraintWidget!

the Widget owning the anchor

getSolverVariable

Added in 1.1.0-alpha13
fun getSolverVariable(): SolverVariable!

Return the solver variable for this anchor

getTarget

Added in 1.1.0-alpha13
fun getTarget(): ConstraintAnchor!

Return the connection's target (null if not connected)

Returns
ConstraintAnchor!

the ConstraintAnchor target

getType

Added in 1.1.0-alpha13
fun getType(): ConstraintAnchor.Type!

Return the type of the anchor

Returns
ConstraintAnchor.Type!

type of the anchor.

hasCenteredDependents

Added in 1.1.0-alpha13
fun hasCenteredDependents(): Boolean

hasDependents

Added in 1.1.0-alpha13
fun hasDependents(): Boolean

hasFinalValue

Added in 1.1.0-alpha13
fun hasFinalValue(): Boolean

isConnected

Added in 1.1.0-alpha13
fun isConnected(): Boolean

Returns the connection status of this anchor

Returns
Boolean

true if the anchor is connected to another one.

isConnectionAllowed

Added in 1.1.0-alpha13
fun isConnectionAllowed(target: ConstraintWidget!): Boolean

Return true if we can connect this anchor to this target. We recursively follow connections in order to detect eventual cycles; if we do we disallow the connection. We also only allow connections to direct parent, siblings, and descendants.

Parameters
target: ConstraintWidget!

the ConstraintWidget we are trying to connect to

Returns
Boolean

true if the connection is allowed, false otherwise

isConnectionAllowed

Added in 1.1.0-alpha13
fun isConnectionAllowed(target: ConstraintWidget!, anchor: ConstraintAnchor!): Boolean

Return true if we can connect this anchor to this target. We recursively follow connections in order to detect eventual cycles; if we do we disallow the connection. We also only allow connections to direct parent, siblings, and descendants.

Parameters
target: ConstraintWidget!

the ConstraintWidget we are trying to connect to

anchor: ConstraintAnchor!

Allow anchor if it loops back to me directly

Returns
Boolean

if the connection is allowed, false otherwise

isSideAnchor

Added in 1.1.0-alpha13
fun isSideAnchor(): Boolean

Return true if this anchor is a side anchor

Returns
Boolean

true if side anchor

isSimilarDimensionConnection

Added in 1.1.0-alpha13
fun isSimilarDimensionConnection(anchor: ConstraintAnchor!): Boolean

Return true if the connection to the given anchor is in the same dimension (horizontal or vertical)

Parameters
anchor: ConstraintAnchor!

the anchor we want to connect to

Returns
Boolean

true if it's an anchor on the same dimension

isValidConnection

Added in 1.1.0-alpha13
fun isValidConnection(anchor: ConstraintAnchor!): Boolean

Checks if the connection to a given anchor is valid.

Parameters
anchor: ConstraintAnchor!

the anchor we want to connect to

Returns
Boolean

true if it's a compatible anchor

isVerticalAnchor

Added in 1.1.0-alpha13
fun isVerticalAnchor(): Boolean

Utility function returning true if this anchor is a vertical one.

Returns
Boolean

true if vertical anchor, false otherwise

reset

Added in 1.1.0-alpha13
fun reset(): Unit

Resets the anchor's connection.

resetFinalResolution

Added in 1.1.0-alpha13
fun resetFinalResolution(): Unit

resetSolverVariable

Added in 1.1.0-alpha13
fun resetSolverVariable(cache: Cache!): Unit

Reset the solver variable

setFinalValue

Added in 1.1.0-alpha13
fun setFinalValue(finalValue: Int): Unit

setGoneMargin

Added in 1.1.0-alpha13
fun setGoneMargin(margin: Int): Unit

Set the gone margin of the connection (if there's one)

Parameters
margin: Int

the new margin of the connection

setMargin

Added in 1.1.0-alpha13
fun setMargin(margin: Int): Unit

Set the margin of the connection (if there's one)

Parameters
margin: Int

the new margin of the connection

toString

fun toString(): String!

Return a string representation of this anchor

Returns
String!

string representation of the anchor

Public properties

mMargin

Added in 1.1.0-alpha13
val mMarginInt

mOwner

Added in 1.1.0-alpha13
val mOwnerConstraintWidget!

mTarget

Added in 1.1.0-alpha13
val mTargetConstraintAnchor!

mType

Added in 1.1.0-alpha13
val mTypeConstraintAnchor.Type!