Package androidx.constraintlayout.core
Class LinearSystem
- java.lang.Object
-
- androidx.constraintlayout.core.LinearSystem
-
public class LinearSystem extends java.lang.ObjectRepresents and solves a system of linear equations.
-
-
Field Summary
Fields Modifier and Type Field Description static longARRAY_ROW_CREATIONstatic booleanDEBUGstatic booleanFULL_DEBUGbooleangraphOptimizerbooleanhasSimpleDefinitionbooleannewgraphOptimizerstatic longOPTIMIZED_ARRAY_ROW_CREATIONstatic booleanOPTIMIZED_ENGINEstatic booleanSIMPLIFY_SYNONYMSstatic booleanSKIP_COLUMNSstatic MetricssMetricsstatic booleanUSE_BASIC_SYNONYMSstatic booleanUSE_DEPENDENCY_ORDERINGstatic booleanUSE_SYNONYMS
-
Constructor Summary
Constructors Constructor Description LinearSystem()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCentering(SolverVariable a, SolverVariable b, int m1, float bias, SolverVariable c, SolverVariable d, int m2, int strength)Add an equation of the form (1 - bias) * (a - b) = bias * (c - d)voidaddCenterPoint(ConstraintWidget widget, ConstraintWidget target, float angle, int radius)Add the equations constraining a widget center to another widget center, positioned on a circle, following an angle and radiusvoidaddConstraint(ArrayRow row)Add the equation to the systemvoidaddEquality(SolverVariable a, int value)Add an equation of the form a = valueArrayRowaddEquality(SolverVariable a, SolverVariable b, int margin, int strength)Add an equation of the form a = b + marginvoidaddGreaterBarrier(SolverVariable a, SolverVariable b, int margin, boolean hasMatchConstraintWidgets)voidaddGreaterThan(SolverVariable a, SolverVariable b, int margin, int strength)Add an equation of the form a >= b + marginvoidaddLowerBarrier(SolverVariable a, SolverVariable b, int margin, boolean hasMatchConstraintWidgets)voidaddLowerThan(SolverVariable a, SolverVariable b, int margin, int strength)Add an equation of the form a <= b + marginvoidaddRatio(SolverVariable a, SolverVariable b, SolverVariable c, SolverVariable d, float ratio, int strength)voidaddSynonym(SolverVariable a, SolverVariable b, int margin)SolverVariablecreateErrorVariable(int strength, java.lang.String prefix)SolverVariablecreateExtraVariable()SolverVariablecreateObjectVariable(java.lang.Object anchor)ArrayRowcreateRow()static ArrayRowcreateRowDimensionPercent(LinearSystem linearSystem, SolverVariable variableA, SolverVariable variableC, float percent)Create a constraint to express A = C * percentSolverVariablecreateSlackVariable()voiddisplayReadableRows()voiddisplayVariablesReadableRows()voidfillMetrics(Metrics metrics)CachegetCache()intgetMemoryUsed()static MetricsgetMetrics()intgetNumEquations()intgetNumVariables()intgetObjectVariableValue(java.lang.Object object)voidminimize()Minimize the current goal of the system.voidremoveRow(ArrayRow row)voidreset()Reset the LinearSystem object so that it can be reused.
-
-
-
Field Detail
-
FULL_DEBUG
public static final boolean FULL_DEBUG
- See Also:
- Constant Field Values
-
DEBUG
public static final boolean DEBUG
- See Also:
- Constant Field Values
-
USE_DEPENDENCY_ORDERING
public static boolean USE_DEPENDENCY_ORDERING
-
USE_BASIC_SYNONYMS
public static boolean USE_BASIC_SYNONYMS
-
SIMPLIFY_SYNONYMS
public static boolean SIMPLIFY_SYNONYMS
-
USE_SYNONYMS
public static boolean USE_SYNONYMS
-
SKIP_COLUMNS
public static boolean SKIP_COLUMNS
-
OPTIMIZED_ENGINE
public static boolean OPTIMIZED_ENGINE
-
hasSimpleDefinition
public boolean hasSimpleDefinition
-
graphOptimizer
public boolean graphOptimizer
-
newgraphOptimizer
public boolean newgraphOptimizer
-
sMetrics
public static Metrics sMetrics
-
ARRAY_ROW_CREATION
public static long ARRAY_ROW_CREATION
-
OPTIMIZED_ARRAY_ROW_CREATION
public static long OPTIMIZED_ARRAY_ROW_CREATION
-
-
Method Detail
-
fillMetrics
public void fillMetrics(Metrics metrics)
-
getMetrics
public static Metrics getMetrics()
-
reset
public void reset()
Reset the LinearSystem object so that it can be reused.
-
createObjectVariable
public SolverVariable createObjectVariable(java.lang.Object anchor)
-
createRow
public ArrayRow createRow()
-
createSlackVariable
public SolverVariable createSlackVariable()
-
createExtraVariable
public SolverVariable createExtraVariable()
-
createErrorVariable
public SolverVariable createErrorVariable(int strength, java.lang.String prefix)
-
getObjectVariableValue
public int getObjectVariableValue(java.lang.Object object)
-
minimize
public void minimize() throws java.lang.ExceptionMinimize the current goal of the system.- Throws:
java.lang.Exception
-
addConstraint
public void addConstraint(ArrayRow row)
Add the equation to the system- Parameters:
row- the equation we want to add expressed as a system row.
-
removeRow
public void removeRow(ArrayRow row)
-
displayReadableRows
public void displayReadableRows()
-
displayVariablesReadableRows
public void displayVariablesReadableRows()
-
getMemoryUsed
public int getMemoryUsed()
-
getNumEquations
public int getNumEquations()
-
getNumVariables
public int getNumVariables()
-
getCache
public Cache getCache()
-
addGreaterThan
public void addGreaterThan(SolverVariable a, SolverVariable b, int margin, int strength)
Add an equation of the form a >= b + margin- Parameters:
a- variable ab- variable bmargin- marginstrength- strength used
-
addGreaterBarrier
public void addGreaterBarrier(SolverVariable a, SolverVariable b, int margin, boolean hasMatchConstraintWidgets)
-
addLowerThan
public void addLowerThan(SolverVariable a, SolverVariable b, int margin, int strength)
Add an equation of the form a <= b + margin- Parameters:
a- variable ab- variable bmargin- marginstrength- strength used
-
addLowerBarrier
public void addLowerBarrier(SolverVariable a, SolverVariable b, int margin, boolean hasMatchConstraintWidgets)
-
addCentering
public void addCentering(SolverVariable a, SolverVariable b, int m1, float bias, SolverVariable c, SolverVariable d, int m2, int strength)
Add an equation of the form (1 - bias) * (a - b) = bias * (c - d)- Parameters:
a- variable ab- variable bm1- margin 1bias- bias between ab - cdc- variable cd- variable dm2- margin 2strength- strength used
-
addRatio
public void addRatio(SolverVariable a, SolverVariable b, SolverVariable c, SolverVariable d, float ratio, int strength)
-
addSynonym
public void addSynonym(SolverVariable a, SolverVariable b, int margin)
-
addEquality
public ArrayRow addEquality(SolverVariable a, SolverVariable b, int margin, int strength)
Add an equation of the form a = b + margin- Parameters:
a- variable ab- variable bmargin- margin usedstrength- strength used
-
addEquality
public void addEquality(SolverVariable a, int value)
Add an equation of the form a = value- Parameters:
a- variable avalue- the value we set
-
createRowDimensionPercent
public static ArrayRow createRowDimensionPercent(LinearSystem linearSystem, SolverVariable variableA, SolverVariable variableC, float percent)
Create a constraint to express A = C * percent- Parameters:
linearSystem- the system we create the row onvariableA- variable avariableC- variable cpercent- the percent used- Returns:
- the created row
-
addCenterPoint
public void addCenterPoint(ConstraintWidget widget, ConstraintWidget target, float angle, int radius)
Add the equations constraining a widget center to another widget center, positioned on a circle, following an angle and radius- Parameters:
angle- from 0 to 360radius- the distance between the two centers
-
-