If you think the Android project android-cassowary-layout listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package no.agens.cassowarylayout;
/*fromwww.java2s.com*/import org.pybee.cassowary.SimplexSolver;
import org.pybee.cassowary.Constraint;
import org.pybee.cassowary.Expression;
import org.pybee.cassowary.Strength;
import org.pybee.cassowary.Variable;
/**
* Created by alex on 02/11/14.
*/publicclass ChildNode extends Node {
public ChildNode(SimplexSolver solver) {
super(solver);
}
@Override
protectedvoid createImplicitConstraints(String variableName, Variable variable) {
if (RIGHT.equals(variableName)) {
solver.addConstraint(new Constraint(variable, Constraint.Operator.EQ, new Expression(getLeft()).plus(getWidth()), Strength.REQUIRED));
} elseif (BOTTOM.equals(variableName)) {
solver.addConstraint(new Constraint(variable, Constraint.Operator.EQ, new Expression(getTop()).plus(getHeight()), Strength.REQUIRED));
} elseif (CENTERX.equals(variableName)) {
solver.addConstraint(new Constraint(variable, Constraint.Operator.EQ, new Expression(getWidth()).divide(2).plus(getLeft()), Strength.REQUIRED));
} elseif (CENTERY.equals(variableName)) {
solver.addConstraint(new Constraint(variable, Constraint.Operator.EQ, new Expression(getHeight()).divide(2).plus(getTop()), Strength.REQUIRED));
}
}
}