sub_arctic.constraints
Interface constraint_impl

All Known Implementing Classes:
std_constraint_impl

public abstract interface constraint_impl

Interface for objects that provide an implementation for constraints. These object understand how to encode and decode an integer encoding of a constraint (or maintain such a coding inside themselves), and use that to perform operations such as evaluate the constraint, determine if it depends upon a particular value, produce a human readable rendition of the constraint, etc.

For constraint implementations that do not encode the constraints inside the object, there is typically only one instance of each constraint implementation which is shared by all constraints encoded in the same form (this is true for example of std_constraint_impl).

See Also:
constraints.std_constraint_impl

Method Summary
 java.util.Vector depend_list(int enc, interactor constr_obj, int orient)
          Extract the set of objects/parts that a constraint depends on.
 boolean depends_on(int enc, interactor constr_obj, int which_obj, int which_part, int nth_child, int orient)
          Test whether the given encoded constraint depends on the indicated neighboring object and part.
 int eval(int enc, interactor constr_obj, int constr_part, int orient)
          Evaluate an encoded constraint (under a given orientation).
 java.util.Vector implicit_depend_list(int enc, interactor constr_obj, int orient)
          Extract the dependencies that are implicit in the particular operation encoded in the given standard constraint encoding.
 boolean is_external(int enc)
          Determine if a given constraint encoding represents an external (aka heavyweight) constraint.
 boolean is_none(int enc)
          Determine if a given constraint encoding represents "none" (i.e., that no constraint is to be applied).
 java.lang.String str_for(int enc, int orient)
          Create a human readable string corresponding to the given constraint encoding.
 java.lang.String tag_for(int enc, int orient)
          Create a terse human readable string corresponding to the given constraint encoding.
 

Method Detail

str_for

public java.lang.String str_for(int enc,
                                int orient)
Create a human readable string corresponding to the given constraint encoding.
Parameters:
int - enc the constraint encoding
int - orient the orientation of the constraint
Returns:
String a human readable string for the constraint

tag_for

public java.lang.String tag_for(int enc,
                                int orient)
Create a terse human readable string corresponding to the given constraint encoding.
Parameters:
int - enc the constraint encoding
int - orient the orientation of the constraint
Returns:
String a human readable string for the constraint

is_none

public boolean is_none(int enc)
Determine if a given constraint encoding represents "none" (i.e., that no constraint is to be applied).

Parameters:
int - enc the encoding for the constraint.
Returns:
boolean true if the encoding represents "none"

is_external

public boolean is_external(int enc)
Determine if a given constraint encoding represents an external (aka heavyweight) constraint.

Parameters:
int - enc the encoding for the constraint.
Returns:
boolean true if the encoding indicates an external constraint

eval

public int eval(int enc,
                interactor constr_obj,
                int constr_part,
                int orient)
Evaluate an encoded constraint (under a given orientation). The constraint is being applied to the given part of the given object (i.e. the constr_part part of the constr_obj object). The encoding typically will designate parameter values relative to that object (i.e. the width of the parent of the object).

Parameters:
int - enc the encoding of the constraint
interactor - constr_obj the object being constrained
int - constr_part the part being constrained
int - orient the orientation of the constraint
Returns:
int the result of the evaluation

depends_on

public boolean depends_on(int enc,
                          interactor constr_obj,
                          int which_obj,
                          int which_part,
                          int nth_child,
                          int orient)
Test whether the given encoded constraint depends on the indicated neighboring object and part. The constraint is attached to the constr_obj object and this test is expressed relative to that object. The object and part that we determine dependency upon is encoded in test_which_obj and test_which_part. For tests of child objects, an indication of the index of that child is also given.

If this is an "external" constraint that maintains its own dependency edges and works through the external notification system, then this method may safely return false in all cases.

Parameters:
int - enc The encoding for the constraint.
interactor - constr_obj The object the constraint is attached to
int - test_which_obj The neighboring object we are asking about. This can be one of the values OBJCODE_SELF, OBJCODE_PARENT, OBJCODE_SOME_CHILD, OBJCODE_PREV_SIBLING, or OBJCODE_NEXT_SIBLING.
int - test_which_part The part we are asking about.
int - nth_child for SOME_CHILD, this provides the index of the child (and is ignored otherwise).
int - orient Orientation of the constraint. This should be HORIZONTAL or VERTICAL.
Returns:
boolean whether the given constraint depends upon the given value

depend_list

public java.util.Vector depend_list(int enc,
                                    interactor constr_obj,
                                    int orient)
Extract the set of objects/parts that a constraint depends on. This produces a Vector with pairs of entries, the first being an interactor, and the second being an Integer which is the part number of that interactor that is depended upon.

Parameters:
int - enc encoding value for the constraint in question.
interactor - constr_obj the object the constraint is attached to (hence its referents are relative to).
int - orient Orientation of the constraint. This should be HORIZONTAL or VERTICAL.
Returns:
Vector containing pairs of objects, the first being an interactor which is depended upon, and the second being an Integer giving the part number of the part depended upon.

implicit_depend_list

public java.util.Vector implicit_depend_list(int enc,
                                             interactor constr_obj,
                                             int orient)
Extract the dependencies that are implicit in the particular operation encoded in the given standard constraint encoding.

Parameters:
int - enc encoding value for the constraint in question.
interactor - constr_obj the object the constraint is attached to (hence its referents are relative to).
int - orient Orientation of the constraint. This should be HORIZONTAL or VERTICAL.
Returns:
Vector containing pairs of objects, the first being an interactor which is depended upon, and the second being an Integer giving the part number of the part depended upon.