LinearSystem
public class LinearSystem
Represents and solves a system of linear equations.
Summary
Constants |
|
|---|---|
static final boolean |
DEBUG = false |
static final boolean |
FULL_DEBUG = false |
Public fields |
|
|---|---|
static long |
|
static long |
|
static boolean |
|
static boolean |
|
static boolean |
|
static boolean |
|
static boolean |
|
static boolean |
|
boolean |
|
boolean |
|
boolean |
|
static Metrics |
Public constructors |
|---|
Public methods |
|
|---|---|
void |
addCenterPoint(Add the equations constraining a widget center to another widget center, positioned on a circle, following an angle and radius |
void |
addCentering(Add an equation of the form (1 - bias) * (a - b) = bias * (c - d) |
void |
addConstraint(ArrayRow row)Add the equation to the system |
void |
addEquality(SolverVariable a, int value)Add an equation of the form a = value |
ArrayRow |
addEquality(SolverVariable a, SolverVariable b, int margin, int strength)Add an equation of the form a = b + margin |
void |
addGreaterBarrier( |
void |
addGreaterThan(Add an equation of the form a >= b + margin |
void |
addLowerBarrier( |
void |
addLowerThan(Add an equation of the form a <= b + margin |
void |
addRatio( |
void |
addSynonym(SolverVariable a, SolverVariable b, int margin) |
SolverVariable |
createErrorVariable(int strength, String prefix) |
SolverVariable |
|
SolverVariable |
createObjectVariable(Object anchor) |
ArrayRow |
|
static ArrayRow |
createRowDimensionPercent(Create a constraint to express A = C * percent |
SolverVariable |
|
void |
|
void |
|
void |
fillMetrics(Metrics metrics) |
Cache |
getCache() |
int |
|
static Metrics |
|
int |
|
int |
|
int |
getObjectVariableValue(Object object) |
void |
minimize()Minimize the current goal of the system. |
void |
|
void |
reset()Reset the LinearSystem object so that it can be reused. |
Constants
Public fields
Public constructors
Public methods
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 | |
|---|---|
float angle |
from 0 to 360 |
int radius |
the distance between the two centers |
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 | |
|---|---|
SolverVariable a |
variable a |
SolverVariable b |
variable b |
int m1 |
margin 1 |
float bias |
bias between ab - cd |
SolverVariable c |
variable c |
SolverVariable d |
variable d |
int m2 |
margin 2 |
int strength |
strength used |
addConstraint
public void addConstraint(ArrayRow row)
Add the equation to the system
| Parameters | |
|---|---|
ArrayRow row |
the equation we want to add expressed as a system row. |
addEquality
public void addEquality(SolverVariable a, int value)
Add an equation of the form a = value
| Parameters | |
|---|---|
SolverVariable a |
variable a |
int value |
the value we set |
addEquality
public ArrayRow addEquality(SolverVariable a, SolverVariable b, int margin, int strength)
Add an equation of the form a = b + margin
| Parameters | |
|---|---|
SolverVariable a |
variable a |
SolverVariable b |
variable b |
int margin |
margin used |
int strength |
strength used |
addGreaterBarrier
public void addGreaterBarrier(
SolverVariable a,
SolverVariable b,
int margin,
boolean hasMatchConstraintWidgets
)
addGreaterThan
public void addGreaterThan(
SolverVariable a,
SolverVariable b,
int margin,
int strength
)
Add an equation of the form a >= b + margin
| Parameters | |
|---|---|
SolverVariable a |
variable a |
SolverVariable b |
variable b |
int margin |
margin |
int strength |
strength used |
addLowerBarrier
public void addLowerBarrier(
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 | |
|---|---|
SolverVariable a |
variable a |
SolverVariable b |
variable b |
int margin |
margin |
int strength |
strength used |
addRatio
public void addRatio(
SolverVariable a,
SolverVariable b,
SolverVariable c,
SolverVariable d,
float ratio,
int strength
)
createErrorVariable
public SolverVariable createErrorVariable(int strength, String prefix)
createRowDimensionPercent
public static ArrayRow createRowDimensionPercent(
LinearSystem linearSystem,
SolverVariable variableA,
SolverVariable variableC,
float percent
)
Create a constraint to express A = C * percent
| Parameters | |
|---|---|
LinearSystem linearSystem |
the system we create the row on |
SolverVariable variableA |
variable a |
SolverVariable variableC |
variable c |
float percent |
the percent used |
| Returns | |
|---|---|
ArrayRow |
the created row |
minimize
public void minimize()
Minimize the current goal of the system.
| Throws | |
|---|---|
java.lang.Exception |