public BinaryConstraint() { } // this has to be here because of // Java's constructor idiocy. public BinaryConstraint(Variable var1, Variable var2, Strength strength) : base(strength) { v1 = var1; v2 = var2; direction = nodirection; addConstraint(); }
public EditConstraint(Variable v, Strength str) : base(v, str) { }
// Install a stay constraint with the given strength on the given variable. public StayConstraint(Variable v, Strength str) : base(v, str) { }
// Decide if I can be satisfied and record that decision. public override void chooseMethod(int mark) { satisfied = myOutput.mark != mark && Strength.stronger(strength, myOutput.walkStrength); }
public Boolean satisfied; // true if I am currently satisfied public UnaryConstraint(Variable v, Strength strength) : base(strength) { myOutput = v; satisfied = false; addConstraint(); }
// Install a constraint with the given strength equating the given variables. public EqualityConstraint(Variable var1, Variable var2, Strength strength) : base(var1, var2, strength) { }
public static Strength weakestOf(Strength s1, Strength s2) { return weaker(s1, s2) ? s1 : s2; }
public static Strength strongest(Strength s1, Strength s2) { return(stronger(s1, s2) ? s1 : s2); }
public static Boolean weaker(Strength s1, Strength s2) { return(s1._strengthValue > s2._strengthValue); }
public static Strength weakestOf(Strength s1, Strength s2) { return(weaker(s1, s2) ? s1 : s2); }
public static Boolean stronger(Strength s1, Strength s2) { return(s1._strengthValue < s2._strengthValue); }
public static Boolean stronger(Strength s1, Strength s2) { return s1._strengthValue < s2._strengthValue; }
public String name; // a symbolic name for reporting purposes private Variable(String name, int initialValue, Strength walkStrength, int nconstraints) { value = initialValue; constraints = new ArrayList(nconstraints); determinedBy = null; mark = 0; this.walkStrength = walkStrength; stay = true; this.name = name; }
public static Boolean weaker(Strength s1, Strength s2) { return s1._strengthValue > s2._strengthValue; }
// Attempt to assign the given value to me using the given strength. public void setValue(int value, Strength strength) { EditConstraint e = new EditConstraint(this, strength); if (e.isSatisfied()) { this.value = value; deltablue.planner.propagateFrom(this); } e.destroyConstraint(); }
public Variable offset; // offset input variable // Install a scale constraint with the given strength on the given variables. public ScaleConstraint(Variable src, Variable scale, Variable offset, Variable dest, Strength strength) { // Curse this wretched language for insisting that constructor invocation // must be the first thing in a method... // ..because of that, we must copy the code from the inherited // constructors. this.strength = strength; v1 = src; v2 = dest; direction = nodirection; this.scale = scale; this.offset = offset; addConstraint(); }
public Constraint() { } // this has to be here because of // Java's constructor idiocy. public Constraint(Strength strength) { this.strength = strength; }
public static Strength strongest(Strength s1, Strength s2) { return stronger(s1, s2) ? s1 : s2; }
} // this has to be here because of // Java's constructor idiocy. public Constraint(Strength strength) { this.strength = strength; }